babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994
  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. /** Offline (baking) quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  828. /** High quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  830. /** Medium quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  832. /** Low quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  834. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  835. static readonly SCALEMODE_FLOOR: number;
  836. /** Defines that texture rescaling will look for the nearest power of 2 size */
  837. static readonly SCALEMODE_NEAREST: number;
  838. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  839. static readonly SCALEMODE_CEILING: number;
  840. /**
  841. * The dirty texture flag value
  842. */
  843. static readonly MATERIAL_TextureDirtyFlag: number;
  844. /**
  845. * The dirty light flag value
  846. */
  847. static readonly MATERIAL_LightDirtyFlag: number;
  848. /**
  849. * The dirty fresnel flag value
  850. */
  851. static readonly MATERIAL_FresnelDirtyFlag: number;
  852. /**
  853. * The dirty attribute flag value
  854. */
  855. static readonly MATERIAL_AttributesDirtyFlag: number;
  856. /**
  857. * The dirty misc flag value
  858. */
  859. static readonly MATERIAL_MiscDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * 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.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * 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.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. }
  1057. }
  1058. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1059. import { Nullable } from "babylonjs/types";
  1060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1061. /**
  1062. * This represents the required contract to create a new type of texture loader.
  1063. */
  1064. export interface IInternalTextureLoader {
  1065. /**
  1066. * Defines wether the loader supports cascade loading the different faces.
  1067. */
  1068. supportCascades: boolean;
  1069. /**
  1070. * This returns if the loader support the current file information.
  1071. * @param extension defines the file extension of the file being loaded
  1072. * @returns true if the loader can load the specified file
  1073. */
  1074. canLoad(extension: string): boolean;
  1075. /**
  1076. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1077. * @param data contains the texture data
  1078. * @param texture defines the BabylonJS internal texture
  1079. * @param createPolynomials will be true if polynomials have been requested
  1080. * @param onLoad defines the callback to trigger once the texture is ready
  1081. * @param onError defines the callback to trigger in case of error
  1082. */
  1083. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1084. /**
  1085. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1086. * @param data contains the texture data
  1087. * @param texture defines the BabylonJS internal texture
  1088. * @param callback defines the method to call once ready to upload
  1089. */
  1090. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1091. }
  1092. }
  1093. declare module "babylonjs/Engines/IPipelineContext" {
  1094. /**
  1095. * Class used to store and describe the pipeline context associated with an effect
  1096. */
  1097. export interface IPipelineContext {
  1098. /**
  1099. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1100. */
  1101. isAsync: boolean;
  1102. /**
  1103. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1104. */
  1105. isReady: boolean;
  1106. /** @hidden */
  1107. _getVertexShaderCode(): string | null;
  1108. /** @hidden */
  1109. _getFragmentShaderCode(): string | null;
  1110. /** @hidden */
  1111. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1112. }
  1113. }
  1114. declare module "babylonjs/Meshes/dataBuffer" {
  1115. /**
  1116. * Class used to store gfx data (like WebGLBuffer)
  1117. */
  1118. export class DataBuffer {
  1119. /**
  1120. * Gets or sets the number of objects referencing this buffer
  1121. */
  1122. references: number;
  1123. /** Gets or sets the size of the underlying buffer */
  1124. capacity: number;
  1125. /**
  1126. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1127. */
  1128. is32Bits: boolean;
  1129. /**
  1130. * Gets the underlying buffer
  1131. */
  1132. get underlyingResource(): any;
  1133. }
  1134. }
  1135. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1136. /** @hidden */
  1137. export interface IShaderProcessor {
  1138. attributeProcessor?: (attribute: string) => string;
  1139. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1140. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1141. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1142. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1143. lineProcessor?: (line: string, isFragment: boolean) => string;
  1144. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1145. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1146. }
  1147. }
  1148. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1149. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1150. /** @hidden */
  1151. export interface ProcessingOptions {
  1152. defines: string[];
  1153. indexParameters: any;
  1154. isFragment: boolean;
  1155. shouldUseHighPrecisionShader: boolean;
  1156. supportsUniformBuffers: boolean;
  1157. shadersRepository: string;
  1158. includesShadersStore: {
  1159. [key: string]: string;
  1160. };
  1161. processor?: IShaderProcessor;
  1162. version: string;
  1163. platformName: string;
  1164. lookForClosingBracketForUniformBuffer?: boolean;
  1165. }
  1166. }
  1167. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1168. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1169. /** @hidden */
  1170. export class ShaderCodeNode {
  1171. line: string;
  1172. children: ShaderCodeNode[];
  1173. additionalDefineKey?: string;
  1174. additionalDefineValue?: string;
  1175. isValid(preprocessors: {
  1176. [key: string]: string;
  1177. }): boolean;
  1178. process(preprocessors: {
  1179. [key: string]: string;
  1180. }, options: ProcessingOptions): string;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1184. /** @hidden */
  1185. export class ShaderCodeCursor {
  1186. private _lines;
  1187. lineIndex: number;
  1188. get currentLine(): string;
  1189. get canRead(): boolean;
  1190. set lines(value: string[]);
  1191. }
  1192. }
  1193. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1194. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1195. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1196. /** @hidden */
  1197. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1198. process(preprocessors: {
  1199. [key: string]: string;
  1200. }, options: ProcessingOptions): string;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1204. /** @hidden */
  1205. export class ShaderDefineExpression {
  1206. isTrue(preprocessors: {
  1207. [key: string]: string;
  1208. }): boolean;
  1209. private static _OperatorPriority;
  1210. private static _Stack;
  1211. static postfixToInfix(postfix: string[]): string;
  1212. static infixToPostfix(infix: string): string[];
  1213. }
  1214. }
  1215. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1216. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderCodeTestNode extends ShaderCodeNode {
  1220. testExpression: ShaderDefineExpression;
  1221. isValid(preprocessors: {
  1222. [key: string]: string;
  1223. }): boolean;
  1224. }
  1225. }
  1226. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1227. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1228. /** @hidden */
  1229. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1230. define: string;
  1231. not: boolean;
  1232. constructor(define: string, not?: boolean);
  1233. isTrue(preprocessors: {
  1234. [key: string]: string;
  1235. }): boolean;
  1236. }
  1237. }
  1238. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1239. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1240. /** @hidden */
  1241. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1242. leftOperand: ShaderDefineExpression;
  1243. rightOperand: ShaderDefineExpression;
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1250. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1251. /** @hidden */
  1252. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1253. leftOperand: ShaderDefineExpression;
  1254. rightOperand: ShaderDefineExpression;
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1261. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1262. /** @hidden */
  1263. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1264. define: string;
  1265. operand: string;
  1266. testValue: string;
  1267. constructor(define: string, operand: string, testValue: string);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module "babylonjs/Offline/IOfflineProvider" {
  1274. /**
  1275. * Class used to enable access to offline support
  1276. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1277. */
  1278. export interface IOfflineProvider {
  1279. /**
  1280. * Gets a boolean indicating if scene must be saved in the database
  1281. */
  1282. enableSceneOffline: boolean;
  1283. /**
  1284. * Gets a boolean indicating if textures must be saved in the database
  1285. */
  1286. enableTexturesOffline: boolean;
  1287. /**
  1288. * Open the offline support and make it available
  1289. * @param successCallback defines the callback to call on success
  1290. * @param errorCallback defines the callback to call on error
  1291. */
  1292. open(successCallback: () => void, errorCallback: () => void): void;
  1293. /**
  1294. * Loads an image from the offline support
  1295. * @param url defines the url to load from
  1296. * @param image defines the target DOM image
  1297. */
  1298. loadImage(url: string, image: HTMLImageElement): void;
  1299. /**
  1300. * Loads a file from offline support
  1301. * @param url defines the URL to load from
  1302. * @param sceneLoaded defines a callback to call on success
  1303. * @param progressCallBack defines a callback to call when progress changed
  1304. * @param errorCallback defines a callback to call on error
  1305. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1306. */
  1307. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1308. }
  1309. }
  1310. declare module "babylonjs/Misc/filesInputStore" {
  1311. /**
  1312. * Class used to help managing file picking and drag'n'drop
  1313. * File Storage
  1314. */
  1315. export class FilesInputStore {
  1316. /**
  1317. * List of files ready to be loaded
  1318. */
  1319. static FilesToLoad: {
  1320. [key: string]: File;
  1321. };
  1322. }
  1323. }
  1324. declare module "babylonjs/Misc/retryStrategy" {
  1325. import { WebRequest } from "babylonjs/Misc/webRequest";
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module "babylonjs/Misc/baseError" {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module "babylonjs/Misc/fileTools" {
  1349. import { WebRequest } from "babylonjs/Misc/webRequest";
  1350. import { Nullable } from "babylonjs/types";
  1351. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1352. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1353. import { BaseError } from "babylonjs/Misc/baseError";
  1354. /** @ignore */
  1355. export class LoadFileError extends BaseError {
  1356. request?: WebRequest;
  1357. file?: File;
  1358. /**
  1359. * Creates a new LoadFileError
  1360. * @param message defines the message of the error
  1361. * @param request defines the optional web request
  1362. * @param file defines the optional file
  1363. */
  1364. constructor(message: string, object?: WebRequest | File);
  1365. }
  1366. /** @ignore */
  1367. export class RequestFileError extends BaseError {
  1368. request: WebRequest;
  1369. /**
  1370. * Creates a new LoadFileError
  1371. * @param message defines the message of the error
  1372. * @param request defines the optional web request
  1373. */
  1374. constructor(message: string, request: WebRequest);
  1375. }
  1376. /** @ignore */
  1377. export class ReadFileError extends BaseError {
  1378. file: File;
  1379. /**
  1380. * Creates a new ReadFileError
  1381. * @param message defines the message of the error
  1382. * @param file defines the optional file
  1383. */
  1384. constructor(message: string, file: File);
  1385. }
  1386. /**
  1387. * @hidden
  1388. */
  1389. export class FileTools {
  1390. /**
  1391. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1392. */
  1393. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1394. /**
  1395. * Gets or sets the base URL to use to load assets
  1396. */
  1397. static BaseUrl: string;
  1398. /**
  1399. * Default behaviour for cors in the application.
  1400. * It can be a string if the expected behavior is identical in the entire app.
  1401. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1402. */
  1403. static CorsBehavior: string | ((url: string | string[]) => string);
  1404. /**
  1405. * Gets or sets a function used to pre-process url before using them to load assets
  1406. */
  1407. static PreprocessUrl: (url: string) => string;
  1408. /**
  1409. * Removes unwanted characters from an url
  1410. * @param url defines the url to clean
  1411. * @returns the cleaned url
  1412. */
  1413. private static _CleanUrl;
  1414. /**
  1415. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1416. * @param url define the url we are trying
  1417. * @param element define the dom element where to configure the cors policy
  1418. */
  1419. static SetCorsBehavior(url: string | string[], element: {
  1420. crossOrigin: string | null;
  1421. }): void;
  1422. /**
  1423. * Loads an image as an HTMLImageElement.
  1424. * @param input url string, ArrayBuffer, or Blob to load
  1425. * @param onLoad callback called when the image successfully loads
  1426. * @param onError callback called when the image fails to load
  1427. * @param offlineProvider offline provider for caching
  1428. * @param mimeType optional mime type
  1429. * @returns the HTMLImageElement of the loaded image
  1430. */
  1431. 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>;
  1432. /**
  1433. * Reads a file from a File object
  1434. * @param file defines the file to load
  1435. * @param onSuccess defines the callback to call when data is loaded
  1436. * @param onProgress defines the callback to call during loading process
  1437. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1438. * @param onError defines the callback to call when an error occurs
  1439. * @returns a file request object
  1440. */
  1441. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1442. /**
  1443. * Loads a file from a url
  1444. * @param url url to load
  1445. * @param onSuccess callback called when the file successfully loads
  1446. * @param onProgress callback called while file is loading (if the server supports this mode)
  1447. * @param offlineProvider defines the offline provider for caching
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @returns a file request object
  1451. */
  1452. 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;
  1453. /**
  1454. * Loads a file
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1459. * @param onError callback called when the file fails to load
  1460. * @param onOpened callback called when the web request is opened
  1461. * @returns a file request object
  1462. */
  1463. 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;
  1464. /**
  1465. * Checks if the loaded document was accessed via `file:`-Protocol.
  1466. * @returns boolean
  1467. */
  1468. static IsFileURL(): boolean;
  1469. }
  1470. }
  1471. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1472. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1473. import { WebRequest } from "babylonjs/Misc/webRequest";
  1474. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1475. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1476. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1477. /** @hidden */
  1478. export class ShaderProcessor {
  1479. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1480. private static _ProcessPrecision;
  1481. private static _ExtractOperation;
  1482. private static _BuildSubExpression;
  1483. private static _BuildExpression;
  1484. private static _MoveCursorWithinIf;
  1485. private static _MoveCursor;
  1486. private static _EvaluatePreProcessors;
  1487. private static _PreparePreProcessors;
  1488. private static _ProcessShaderConversion;
  1489. private static _ProcessIncludes;
  1490. /**
  1491. * Loads a file from a url
  1492. * @param url url to load
  1493. * @param onSuccess callback called when the file successfully loads
  1494. * @param onProgress callback called while file is loading (if the server supports this mode)
  1495. * @param offlineProvider defines the offline provider for caching
  1496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1497. * @param onError callback called when the file fails to load
  1498. * @returns a file request object
  1499. * @hidden
  1500. */
  1501. 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;
  1502. }
  1503. }
  1504. declare module "babylonjs/Maths/math.like" {
  1505. import { float, int, DeepImmutable } from "babylonjs/types";
  1506. /**
  1507. * @hidden
  1508. */
  1509. export interface IColor4Like {
  1510. r: float;
  1511. g: float;
  1512. b: float;
  1513. a: float;
  1514. }
  1515. /**
  1516. * @hidden
  1517. */
  1518. export interface IColor3Like {
  1519. r: float;
  1520. g: float;
  1521. b: float;
  1522. }
  1523. /**
  1524. * @hidden
  1525. */
  1526. export interface IVector4Like {
  1527. x: float;
  1528. y: float;
  1529. z: float;
  1530. w: float;
  1531. }
  1532. /**
  1533. * @hidden
  1534. */
  1535. export interface IVector3Like {
  1536. x: float;
  1537. y: float;
  1538. z: float;
  1539. }
  1540. /**
  1541. * @hidden
  1542. */
  1543. export interface IVector2Like {
  1544. x: float;
  1545. y: float;
  1546. }
  1547. /**
  1548. * @hidden
  1549. */
  1550. export interface IMatrixLike {
  1551. toArray(): DeepImmutable<Float32Array>;
  1552. updateFlag: int;
  1553. }
  1554. /**
  1555. * @hidden
  1556. */
  1557. export interface IViewportLike {
  1558. x: float;
  1559. y: float;
  1560. width: float;
  1561. height: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IPlaneLike {
  1567. normal: IVector3Like;
  1568. d: float;
  1569. normalize(): void;
  1570. }
  1571. }
  1572. declare module "babylonjs/Materials/iEffectFallbacks" {
  1573. import { Effect } from "babylonjs/Materials/effect";
  1574. /**
  1575. * Interface used to define common properties for effect fallbacks
  1576. */
  1577. export interface IEffectFallbacks {
  1578. /**
  1579. * Removes the defines that should be removed when falling back.
  1580. * @param currentDefines defines the current define statements for the shader.
  1581. * @param effect defines the current effect we try to compile
  1582. * @returns The resulting defines with defines of the current rank removed.
  1583. */
  1584. reduce(currentDefines: string, effect: Effect): string;
  1585. /**
  1586. * Removes the fallback from the bound mesh.
  1587. */
  1588. unBindMesh(): void;
  1589. /**
  1590. * Checks to see if more fallbacks are still availible.
  1591. */
  1592. hasMoreFallbacks: boolean;
  1593. }
  1594. }
  1595. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1596. /**
  1597. * Class used to evalaute queries containing `and` and `or` operators
  1598. */
  1599. export class AndOrNotEvaluator {
  1600. /**
  1601. * Evaluate a query
  1602. * @param query defines the query to evaluate
  1603. * @param evaluateCallback defines the callback used to filter result
  1604. * @returns true if the query matches
  1605. */
  1606. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1607. private static _HandleParenthesisContent;
  1608. private static _SimplifyNegation;
  1609. }
  1610. }
  1611. declare module "babylonjs/Misc/tags" {
  1612. /**
  1613. * Class used to store custom tags
  1614. */
  1615. export class Tags {
  1616. /**
  1617. * Adds support for tags on the given object
  1618. * @param obj defines the object to use
  1619. */
  1620. static EnableFor(obj: any): void;
  1621. /**
  1622. * Removes tags support
  1623. * @param obj defines the object to use
  1624. */
  1625. static DisableFor(obj: any): void;
  1626. /**
  1627. * Gets a boolean indicating if the given object has tags
  1628. * @param obj defines the object to use
  1629. * @returns a boolean
  1630. */
  1631. static HasTags(obj: any): boolean;
  1632. /**
  1633. * Gets the tags available on a given object
  1634. * @param obj defines the object to use
  1635. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1636. * @returns the tags
  1637. */
  1638. static GetTags(obj: any, asString?: boolean): any;
  1639. /**
  1640. * Adds tags to an object
  1641. * @param obj defines the object to use
  1642. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1643. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1644. */
  1645. static AddTagsTo(obj: any, tagsString: string): void;
  1646. /**
  1647. * @hidden
  1648. */
  1649. static _AddTagTo(obj: any, tag: string): void;
  1650. /**
  1651. * Removes specific tags from a specific object
  1652. * @param obj defines the object to use
  1653. * @param tagsString defines the tags to remove
  1654. */
  1655. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1656. /**
  1657. * @hidden
  1658. */
  1659. static _RemoveTagFrom(obj: any, tag: string): void;
  1660. /**
  1661. * Defines if tags hosted on an object match a given query
  1662. * @param obj defines the object to use
  1663. * @param tagsQuery defines the tag query
  1664. * @returns a boolean
  1665. */
  1666. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1667. }
  1668. }
  1669. declare module "babylonjs/Maths/math.scalar" {
  1670. /**
  1671. * Scalar computation library
  1672. */
  1673. export class Scalar {
  1674. /**
  1675. * Two pi constants convenient for computation.
  1676. */
  1677. static TwoPi: number;
  1678. /**
  1679. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1680. * @param a number
  1681. * @param b number
  1682. * @param epsilon (default = 1.401298E-45)
  1683. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1684. */
  1685. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1686. /**
  1687. * Returns a string : the upper case translation of the number i to hexadecimal.
  1688. * @param i number
  1689. * @returns the upper case translation of the number i to hexadecimal.
  1690. */
  1691. static ToHex(i: number): string;
  1692. /**
  1693. * Returns -1 if value is negative and +1 is value is positive.
  1694. * @param value the value
  1695. * @returns the value itself if it's equal to zero.
  1696. */
  1697. static Sign(value: number): number;
  1698. /**
  1699. * Returns the value itself if it's between min and max.
  1700. * Returns min if the value is lower than min.
  1701. * Returns max if the value is greater than max.
  1702. * @param value the value to clmap
  1703. * @param min the min value to clamp to (default: 0)
  1704. * @param max the max value to clamp to (default: 1)
  1705. * @returns the clamped value
  1706. */
  1707. static Clamp(value: number, min?: number, max?: number): number;
  1708. /**
  1709. * the log2 of value.
  1710. * @param value the value to compute log2 of
  1711. * @returns the log2 of value.
  1712. */
  1713. static Log2(value: number): number;
  1714. /**
  1715. * Loops the value, so that it is never larger than length and never smaller than 0.
  1716. *
  1717. * This is similar to the modulo operator but it works with floating point numbers.
  1718. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1719. * With t = 5 and length = 2.5, the result would be 0.0.
  1720. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1721. * @param value the value
  1722. * @param length the length
  1723. * @returns the looped value
  1724. */
  1725. static Repeat(value: number, length: number): number;
  1726. /**
  1727. * Normalize the value between 0.0 and 1.0 using min and max values
  1728. * @param value value to normalize
  1729. * @param min max to normalize between
  1730. * @param max min to normalize between
  1731. * @returns the normalized value
  1732. */
  1733. static Normalize(value: number, min: number, max: number): number;
  1734. /**
  1735. * Denormalize the value from 0.0 and 1.0 using min and max values
  1736. * @param normalized value to denormalize
  1737. * @param min max to denormalize between
  1738. * @param max min to denormalize between
  1739. * @returns the denormalized value
  1740. */
  1741. static Denormalize(normalized: number, min: number, max: number): number;
  1742. /**
  1743. * Calculates the shortest difference between two given angles given in degrees.
  1744. * @param current current angle in degrees
  1745. * @param target target angle in degrees
  1746. * @returns the delta
  1747. */
  1748. static DeltaAngle(current: number, target: number): number;
  1749. /**
  1750. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1751. * @param tx value
  1752. * @param length length
  1753. * @returns The returned value will move back and forth between 0 and length
  1754. */
  1755. static PingPong(tx: number, length: number): number;
  1756. /**
  1757. * Interpolates between min and max with smoothing at the limits.
  1758. *
  1759. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1760. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1761. * @param from from
  1762. * @param to to
  1763. * @param tx value
  1764. * @returns the smooth stepped value
  1765. */
  1766. static SmoothStep(from: number, to: number, tx: number): number;
  1767. /**
  1768. * Moves a value current towards target.
  1769. *
  1770. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1771. * Negative values of maxDelta pushes the value away from target.
  1772. * @param current current value
  1773. * @param target target value
  1774. * @param maxDelta max distance to move
  1775. * @returns resulting value
  1776. */
  1777. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1778. /**
  1779. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1780. *
  1781. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1782. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1783. * @param current current value
  1784. * @param target target value
  1785. * @param maxDelta max distance to move
  1786. * @returns resulting angle
  1787. */
  1788. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1789. /**
  1790. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1791. * @param start start value
  1792. * @param end target value
  1793. * @param amount amount to lerp between
  1794. * @returns the lerped value
  1795. */
  1796. static Lerp(start: number, end: number, amount: number): number;
  1797. /**
  1798. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1799. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1800. * @param start start value
  1801. * @param end target value
  1802. * @param amount amount to lerp between
  1803. * @returns the lerped value
  1804. */
  1805. static LerpAngle(start: number, end: number, amount: number): number;
  1806. /**
  1807. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1808. * @param a start value
  1809. * @param b target value
  1810. * @param value value between a and b
  1811. * @returns the inverseLerp value
  1812. */
  1813. static InverseLerp(a: number, b: number, value: number): number;
  1814. /**
  1815. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1816. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1817. * @param value1 spline value
  1818. * @param tangent1 spline value
  1819. * @param value2 spline value
  1820. * @param tangent2 spline value
  1821. * @param amount input value
  1822. * @returns hermite result
  1823. */
  1824. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1825. /**
  1826. * Returns a random float number between and min and max values
  1827. * @param min min value of random
  1828. * @param max max value of random
  1829. * @returns random value
  1830. */
  1831. static RandomRange(min: number, max: number): number;
  1832. /**
  1833. * This function returns percentage of a number in a given range.
  1834. *
  1835. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1836. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1837. * @param number to convert to percentage
  1838. * @param min min range
  1839. * @param max max range
  1840. * @returns the percentage
  1841. */
  1842. static RangeToPercent(number: number, min: number, max: number): number;
  1843. /**
  1844. * This function returns number that corresponds to the percentage in a given range.
  1845. *
  1846. * PercentToRange(0.34,0,100) will return 34.
  1847. * @param percent to convert to number
  1848. * @param min min range
  1849. * @param max max range
  1850. * @returns the number
  1851. */
  1852. static PercentToRange(percent: number, min: number, max: number): number;
  1853. /**
  1854. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1855. * @param angle The angle to normalize in radian.
  1856. * @return The converted angle.
  1857. */
  1858. static NormalizeRadians(angle: number): number;
  1859. }
  1860. }
  1861. declare module "babylonjs/Maths/math.constants" {
  1862. /**
  1863. * Constant used to convert a value to gamma space
  1864. * @ignorenaming
  1865. */
  1866. export const ToGammaSpace: number;
  1867. /**
  1868. * Constant used to convert a value to linear space
  1869. * @ignorenaming
  1870. */
  1871. export const ToLinearSpace = 2.2;
  1872. /**
  1873. * Constant used to define the minimal number value in Babylon.js
  1874. * @ignorenaming
  1875. */
  1876. let Epsilon: number;
  1877. export { Epsilon };
  1878. }
  1879. declare module "babylonjs/Maths/math.viewport" {
  1880. /**
  1881. * Class used to represent a viewport on screen
  1882. */
  1883. export class Viewport {
  1884. /** viewport left coordinate */
  1885. x: number;
  1886. /** viewport top coordinate */
  1887. y: number;
  1888. /**viewport width */
  1889. width: number;
  1890. /** viewport height */
  1891. height: number;
  1892. /**
  1893. * Creates a Viewport object located at (x, y) and sized (width, height)
  1894. * @param x defines viewport left coordinate
  1895. * @param y defines viewport top coordinate
  1896. * @param width defines the viewport width
  1897. * @param height defines the viewport height
  1898. */
  1899. constructor(
  1900. /** viewport left coordinate */
  1901. x: number,
  1902. /** viewport top coordinate */
  1903. y: number,
  1904. /**viewport width */
  1905. width: number,
  1906. /** viewport height */
  1907. height: number);
  1908. /**
  1909. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1910. * @param renderWidth defines the rendering width
  1911. * @param renderHeight defines the rendering height
  1912. * @returns a new Viewport
  1913. */
  1914. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1915. /**
  1916. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1917. * @param renderWidth defines the rendering width
  1918. * @param renderHeight defines the rendering height
  1919. * @param ref defines the target viewport
  1920. * @returns the current viewport
  1921. */
  1922. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1923. /**
  1924. * Returns a new Viewport copied from the current one
  1925. * @returns a new Viewport
  1926. */
  1927. clone(): Viewport;
  1928. }
  1929. }
  1930. declare module "babylonjs/Misc/arrayTools" {
  1931. /**
  1932. * Class containing a set of static utilities functions for arrays.
  1933. */
  1934. export class ArrayTools {
  1935. /**
  1936. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1937. * @param size the number of element to construct and put in the array
  1938. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1939. * @returns a new array filled with new objects
  1940. */
  1941. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1942. }
  1943. }
  1944. declare module "babylonjs/Maths/math.plane" {
  1945. import { DeepImmutable } from "babylonjs/types";
  1946. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1947. /**
  1948. * Represents a plane by the equation ax + by + cz + d = 0
  1949. */
  1950. export class Plane {
  1951. private static _TmpMatrix;
  1952. /**
  1953. * Normal of the plane (a,b,c)
  1954. */
  1955. normal: Vector3;
  1956. /**
  1957. * d component of the plane
  1958. */
  1959. d: number;
  1960. /**
  1961. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1962. * @param a a component of the plane
  1963. * @param b b component of the plane
  1964. * @param c c component of the plane
  1965. * @param d d component of the plane
  1966. */
  1967. constructor(a: number, b: number, c: number, d: number);
  1968. /**
  1969. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * @returns a new plane copied from the current Plane.
  1974. */
  1975. clone(): Plane;
  1976. /**
  1977. * @returns the string "Plane".
  1978. */
  1979. getClassName(): string;
  1980. /**
  1981. * @returns the Plane hash code.
  1982. */
  1983. getHashCode(): number;
  1984. /**
  1985. * Normalize the current Plane in place.
  1986. * @returns the updated Plane.
  1987. */
  1988. normalize(): Plane;
  1989. /**
  1990. * Applies a transformation the plane and returns the result
  1991. * @param transformation the transformation matrix to be applied to the plane
  1992. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1993. */
  1994. transform(transformation: DeepImmutable<Matrix>): Plane;
  1995. /**
  1996. * Compute the dot product between the point and the plane normal
  1997. * @param point point to calculate the dot product with
  1998. * @returns the dot product (float) of the point coordinates and the plane normal.
  1999. */
  2000. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2001. /**
  2002. * Updates the current Plane from the plane defined by the three given points.
  2003. * @param point1 one of the points used to contruct the plane
  2004. * @param point2 one of the points used to contruct the plane
  2005. * @param point3 one of the points used to contruct the plane
  2006. * @returns the updated Plane.
  2007. */
  2008. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2009. /**
  2010. * Checks if the plane is facing a given direction
  2011. * @param direction the direction to check if the plane is facing
  2012. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2013. * @returns True is the vector "direction" is the same side than the plane normal.
  2014. */
  2015. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2016. /**
  2017. * Calculates the distance to a point
  2018. * @param point point to calculate distance to
  2019. * @returns the signed distance (float) from the given point to the Plane.
  2020. */
  2021. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2022. /**
  2023. * Creates a plane from an array
  2024. * @param array the array to create a plane from
  2025. * @returns a new Plane from the given array.
  2026. */
  2027. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2028. /**
  2029. * Creates a plane from three points
  2030. * @param point1 point used to create the plane
  2031. * @param point2 point used to create the plane
  2032. * @param point3 point used to create the plane
  2033. * @returns a new Plane defined by the three given points.
  2034. */
  2035. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2036. /**
  2037. * Creates a plane from an origin point and a normal
  2038. * @param origin origin of the plane to be constructed
  2039. * @param normal normal of the plane to be constructed
  2040. * @returns a new Plane the normal vector to this plane at the given origin point.
  2041. * Note : the vector "normal" is updated because normalized.
  2042. */
  2043. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2044. /**
  2045. * Calculates the distance from a plane and a point
  2046. * @param origin origin of the plane to be constructed
  2047. * @param normal normal of the plane to be constructed
  2048. * @param point point to calculate distance to
  2049. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2050. */
  2051. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2052. }
  2053. }
  2054. declare module "babylonjs/Maths/math.vector" {
  2055. import { Viewport } from "babylonjs/Maths/math.viewport";
  2056. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2057. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2058. import { Plane } from "babylonjs/Maths/math.plane";
  2059. /**
  2060. * Class representing a vector containing 2 coordinates
  2061. */
  2062. export class Vector2 {
  2063. /** defines the first coordinate */
  2064. x: number;
  2065. /** defines the second coordinate */
  2066. y: number;
  2067. /**
  2068. * Creates a new Vector2 from the given x and y coordinates
  2069. * @param x defines the first coordinate
  2070. * @param y defines the second coordinate
  2071. */
  2072. constructor(
  2073. /** defines the first coordinate */
  2074. x?: number,
  2075. /** defines the second coordinate */
  2076. y?: number);
  2077. /**
  2078. * Gets a string with the Vector2 coordinates
  2079. * @returns a string with the Vector2 coordinates
  2080. */
  2081. toString(): string;
  2082. /**
  2083. * Gets class name
  2084. * @returns the string "Vector2"
  2085. */
  2086. getClassName(): string;
  2087. /**
  2088. * Gets current vector hash code
  2089. * @returns the Vector2 hash code as a number
  2090. */
  2091. getHashCode(): number;
  2092. /**
  2093. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2094. * @param array defines the source array
  2095. * @param index defines the offset in source array
  2096. * @returns the current Vector2
  2097. */
  2098. toArray(array: FloatArray, index?: number): Vector2;
  2099. /**
  2100. * Copy the current vector to an array
  2101. * @returns a new array with 2 elements: the Vector2 coordinates.
  2102. */
  2103. asArray(): number[];
  2104. /**
  2105. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2106. * @param source defines the source Vector2
  2107. * @returns the current updated Vector2
  2108. */
  2109. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2110. /**
  2111. * Sets the Vector2 coordinates with the given floats
  2112. * @param x defines the first coordinate
  2113. * @param y defines the second coordinate
  2114. * @returns the current updated Vector2
  2115. */
  2116. copyFromFloats(x: number, y: number): Vector2;
  2117. /**
  2118. * Sets the Vector2 coordinates with the given floats
  2119. * @param x defines the first coordinate
  2120. * @param y defines the second coordinate
  2121. * @returns the current updated Vector2
  2122. */
  2123. set(x: number, y: number): Vector2;
  2124. /**
  2125. * Add another vector with the current one
  2126. * @param otherVector defines the other vector
  2127. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2128. */
  2129. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2130. /**
  2131. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2132. * @param otherVector defines the other vector
  2133. * @param result defines the target vector
  2134. * @returns the unmodified current Vector2
  2135. */
  2136. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2137. /**
  2138. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2139. * @param otherVector defines the other vector
  2140. * @returns the current updated Vector2
  2141. */
  2142. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2143. /**
  2144. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2145. * @param otherVector defines the other vector
  2146. * @returns a new Vector2
  2147. */
  2148. addVector3(otherVector: Vector3): Vector2;
  2149. /**
  2150. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2151. * @param otherVector defines the other vector
  2152. * @returns a new Vector2
  2153. */
  2154. subtract(otherVector: Vector2): Vector2;
  2155. /**
  2156. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2157. * @param otherVector defines the other vector
  2158. * @param result defines the target vector
  2159. * @returns the unmodified current Vector2
  2160. */
  2161. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2162. /**
  2163. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @returns the current updated Vector2
  2166. */
  2167. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Multiplies in place the current Vector2 coordinates by the given ones
  2170. * @param otherVector defines the other vector
  2171. * @returns the current updated Vector2
  2172. */
  2173. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2176. * @param otherVector defines the other vector
  2177. * @returns a new Vector2
  2178. */
  2179. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2180. /**
  2181. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2182. * @param otherVector defines the other vector
  2183. * @param result defines the target vector
  2184. * @returns the unmodified current Vector2
  2185. */
  2186. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2187. /**
  2188. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2189. * @param x defines the first coordinate
  2190. * @param y defines the second coordinate
  2191. * @returns a new Vector2
  2192. */
  2193. multiplyByFloats(x: number, y: number): Vector2;
  2194. /**
  2195. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns a new Vector2
  2198. */
  2199. divide(otherVector: Vector2): Vector2;
  2200. /**
  2201. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2202. * @param otherVector defines the other vector
  2203. * @param result defines the target vector
  2204. * @returns the unmodified current Vector2
  2205. */
  2206. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2207. /**
  2208. * Divides the current Vector2 coordinates by the given ones
  2209. * @param otherVector defines the other vector
  2210. * @returns the current updated Vector2
  2211. */
  2212. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2213. /**
  2214. * Gets a new Vector2 with current Vector2 negated coordinates
  2215. * @returns a new Vector2
  2216. */
  2217. negate(): Vector2;
  2218. /**
  2219. * Negate this vector in place
  2220. * @returns this
  2221. */
  2222. negateInPlace(): Vector2;
  2223. /**
  2224. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2225. * @param result defines the Vector3 object where to store the result
  2226. * @returns the current Vector2
  2227. */
  2228. negateToRef(result: Vector2): Vector2;
  2229. /**
  2230. * Multiply the Vector2 coordinates by scale
  2231. * @param scale defines the scaling factor
  2232. * @returns the current updated Vector2
  2233. */
  2234. scaleInPlace(scale: number): Vector2;
  2235. /**
  2236. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2237. * @param scale defines the scaling factor
  2238. * @returns a new Vector2
  2239. */
  2240. scale(scale: number): Vector2;
  2241. /**
  2242. * Scale the current Vector2 values by a factor to a given Vector2
  2243. * @param scale defines the scale factor
  2244. * @param result defines the Vector2 object where to store the result
  2245. * @returns the unmodified current Vector2
  2246. */
  2247. scaleToRef(scale: number, result: Vector2): Vector2;
  2248. /**
  2249. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2250. * @param scale defines the scale factor
  2251. * @param result defines the Vector2 object where to store the result
  2252. * @returns the unmodified current Vector2
  2253. */
  2254. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2255. /**
  2256. * Gets a boolean if two vectors are equals
  2257. * @param otherVector defines the other vector
  2258. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2259. */
  2260. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2261. /**
  2262. * Gets a boolean if two vectors are equals (using an epsilon value)
  2263. * @param otherVector defines the other vector
  2264. * @param epsilon defines the minimal distance to consider equality
  2265. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2266. */
  2267. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2268. /**
  2269. * Gets a new Vector2 from current Vector2 floored values
  2270. * @returns a new Vector2
  2271. */
  2272. floor(): Vector2;
  2273. /**
  2274. * Gets a new Vector2 from current Vector2 floored values
  2275. * @returns a new Vector2
  2276. */
  2277. fract(): Vector2;
  2278. /**
  2279. * Gets the length of the vector
  2280. * @returns the vector length (float)
  2281. */
  2282. length(): number;
  2283. /**
  2284. * Gets the vector squared length
  2285. * @returns the vector squared length (float)
  2286. */
  2287. lengthSquared(): number;
  2288. /**
  2289. * Normalize the vector
  2290. * @returns the current updated Vector2
  2291. */
  2292. normalize(): Vector2;
  2293. /**
  2294. * Gets a new Vector2 copied from the Vector2
  2295. * @returns a new Vector2
  2296. */
  2297. clone(): Vector2;
  2298. /**
  2299. * Gets a new Vector2(0, 0)
  2300. * @returns a new Vector2
  2301. */
  2302. static Zero(): Vector2;
  2303. /**
  2304. * Gets a new Vector2(1, 1)
  2305. * @returns a new Vector2
  2306. */
  2307. static One(): Vector2;
  2308. /**
  2309. * Gets a new Vector2 set from the given index element of the given array
  2310. * @param array defines the data source
  2311. * @param offset defines the offset in the data source
  2312. * @returns a new Vector2
  2313. */
  2314. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2315. /**
  2316. * Sets "result" from the given index element of the given array
  2317. * @param array defines the data source
  2318. * @param offset defines the offset in the data source
  2319. * @param result defines the target vector
  2320. */
  2321. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2322. /**
  2323. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2324. * @param value1 defines 1st point of control
  2325. * @param value2 defines 2nd point of control
  2326. * @param value3 defines 3rd point of control
  2327. * @param value4 defines 4th point of control
  2328. * @param amount defines the interpolation factor
  2329. * @returns a new Vector2
  2330. */
  2331. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2332. /**
  2333. * 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".
  2334. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2335. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2336. * @param value defines the value to clamp
  2337. * @param min defines the lower limit
  2338. * @param max defines the upper limit
  2339. * @returns a new Vector2
  2340. */
  2341. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2342. /**
  2343. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2344. * @param value1 defines the 1st control point
  2345. * @param tangent1 defines the outgoing tangent
  2346. * @param value2 defines the 2nd control point
  2347. * @param tangent2 defines the incoming tangent
  2348. * @param amount defines the interpolation factor
  2349. * @returns a new Vector2
  2350. */
  2351. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2352. /**
  2353. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2354. * @param start defines the start vector
  2355. * @param end defines the end vector
  2356. * @param amount defines the interpolation factor
  2357. * @returns a new Vector2
  2358. */
  2359. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2360. /**
  2361. * Gets the dot product of the vector "left" and the vector "right"
  2362. * @param left defines first vector
  2363. * @param right defines second vector
  2364. * @returns the dot product (float)
  2365. */
  2366. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2367. /**
  2368. * Returns a new Vector2 equal to the normalized given vector
  2369. * @param vector defines the vector to normalize
  2370. * @returns a new Vector2
  2371. */
  2372. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2373. /**
  2374. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2375. * @param left defines 1st vector
  2376. * @param right defines 2nd vector
  2377. * @returns a new Vector2
  2378. */
  2379. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2380. /**
  2381. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2382. * @param left defines 1st vector
  2383. * @param right defines 2nd vector
  2384. * @returns a new Vector2
  2385. */
  2386. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2387. /**
  2388. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2389. * @param vector defines the vector to transform
  2390. * @param transformation defines the matrix to apply
  2391. * @returns a new Vector2
  2392. */
  2393. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2394. /**
  2395. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2396. * @param vector defines the vector to transform
  2397. * @param transformation defines the matrix to apply
  2398. * @param result defines the target vector
  2399. */
  2400. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2401. /**
  2402. * Determines if a given vector is included in a triangle
  2403. * @param p defines the vector to test
  2404. * @param p0 defines 1st triangle point
  2405. * @param p1 defines 2nd triangle point
  2406. * @param p2 defines 3rd triangle point
  2407. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2408. */
  2409. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2410. /**
  2411. * Gets the distance between the vectors "value1" and "value2"
  2412. * @param value1 defines first vector
  2413. * @param value2 defines second vector
  2414. * @returns the distance between vectors
  2415. */
  2416. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2417. /**
  2418. * Returns the squared distance between the vectors "value1" and "value2"
  2419. * @param value1 defines first vector
  2420. * @param value2 defines second vector
  2421. * @returns the squared distance between vectors
  2422. */
  2423. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2424. /**
  2425. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2426. * @param value1 defines first vector
  2427. * @param value2 defines second vector
  2428. * @returns a new Vector2
  2429. */
  2430. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2433. * @param p defines the middle point
  2434. * @param segA defines one point of the segment
  2435. * @param segB defines the other point of the segment
  2436. * @returns the shortest distance
  2437. */
  2438. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2439. }
  2440. /**
  2441. * Class used to store (x,y,z) vector representation
  2442. * A Vector3 is the main object used in 3D geometry
  2443. * It can represent etiher the coordinates of a point the space, either a direction
  2444. * Reminder: js uses a left handed forward facing system
  2445. */
  2446. export class Vector3 {
  2447. private static _UpReadOnly;
  2448. private static _ZeroReadOnly;
  2449. /** @hidden */
  2450. _x: number;
  2451. /** @hidden */
  2452. _y: number;
  2453. /** @hidden */
  2454. _z: number;
  2455. /** @hidden */
  2456. _isDirty: boolean;
  2457. /** Gets or sets the x coordinate */
  2458. get x(): number;
  2459. set x(value: number);
  2460. /** Gets or sets the y coordinate */
  2461. get y(): number;
  2462. set y(value: number);
  2463. /** Gets or sets the z coordinate */
  2464. get z(): number;
  2465. set z(value: number);
  2466. /**
  2467. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2468. * @param x defines the first coordinates (on X axis)
  2469. * @param y defines the second coordinates (on Y axis)
  2470. * @param z defines the third coordinates (on Z axis)
  2471. */
  2472. constructor(x?: number, y?: number, z?: number);
  2473. /**
  2474. * Creates a string representation of the Vector3
  2475. * @returns a string with the Vector3 coordinates.
  2476. */
  2477. toString(): string;
  2478. /**
  2479. * Gets the class name
  2480. * @returns the string "Vector3"
  2481. */
  2482. getClassName(): string;
  2483. /**
  2484. * Creates the Vector3 hash code
  2485. * @returns a number which tends to be unique between Vector3 instances
  2486. */
  2487. getHashCode(): number;
  2488. /**
  2489. * Creates an array containing three elements : the coordinates of the Vector3
  2490. * @returns a new array of numbers
  2491. */
  2492. asArray(): number[];
  2493. /**
  2494. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2495. * @param array defines the destination array
  2496. * @param index defines the offset in the destination array
  2497. * @returns the current Vector3
  2498. */
  2499. toArray(array: FloatArray, index?: number): Vector3;
  2500. /**
  2501. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2502. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2503. */
  2504. toQuaternion(): Quaternion;
  2505. /**
  2506. * Adds the given vector to the current Vector3
  2507. * @param otherVector defines the second operand
  2508. * @returns the current updated Vector3
  2509. */
  2510. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Adds the given coordinates to the current Vector3
  2513. * @param x defines the x coordinate of the operand
  2514. * @param y defines the y coordinate of the operand
  2515. * @param z defines the z coordinate of the operand
  2516. * @returns the current updated Vector3
  2517. */
  2518. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2519. /**
  2520. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2521. * @param otherVector defines the second operand
  2522. * @returns the resulting Vector3
  2523. */
  2524. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2525. /**
  2526. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2527. * @param otherVector defines the second operand
  2528. * @param result defines the Vector3 object where to store the result
  2529. * @returns the current Vector3
  2530. */
  2531. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2532. /**
  2533. * Subtract the given vector from the current Vector3
  2534. * @param otherVector defines the second operand
  2535. * @returns the current updated Vector3
  2536. */
  2537. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2538. /**
  2539. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2540. * @param otherVector defines the second operand
  2541. * @returns the resulting Vector3
  2542. */
  2543. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2546. * @param otherVector defines the second operand
  2547. * @param result defines the Vector3 object where to store the result
  2548. * @returns the current Vector3
  2549. */
  2550. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2551. /**
  2552. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2553. * @param x defines the x coordinate of the operand
  2554. * @param y defines the y coordinate of the operand
  2555. * @param z defines the z coordinate of the operand
  2556. * @returns the resulting Vector3
  2557. */
  2558. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2559. /**
  2560. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2561. * @param x defines the x coordinate of the operand
  2562. * @param y defines the y coordinate of the operand
  2563. * @param z defines the z coordinate of the operand
  2564. * @param result defines the Vector3 object where to store the result
  2565. * @returns the current Vector3
  2566. */
  2567. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2568. /**
  2569. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2570. * @returns a new Vector3
  2571. */
  2572. negate(): Vector3;
  2573. /**
  2574. * Negate this vector in place
  2575. * @returns this
  2576. */
  2577. negateInPlace(): Vector3;
  2578. /**
  2579. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2580. * @param result defines the Vector3 object where to store the result
  2581. * @returns the current Vector3
  2582. */
  2583. negateToRef(result: Vector3): Vector3;
  2584. /**
  2585. * Multiplies the Vector3 coordinates by the float "scale"
  2586. * @param scale defines the multiplier factor
  2587. * @returns the current updated Vector3
  2588. */
  2589. scaleInPlace(scale: number): Vector3;
  2590. /**
  2591. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2592. * @param scale defines the multiplier factor
  2593. * @returns a new Vector3
  2594. */
  2595. scale(scale: number): Vector3;
  2596. /**
  2597. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2598. * @param scale defines the multiplier factor
  2599. * @param result defines the Vector3 object where to store the result
  2600. * @returns the current Vector3
  2601. */
  2602. scaleToRef(scale: number, result: Vector3): Vector3;
  2603. /**
  2604. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2605. * @param scale defines the scale factor
  2606. * @param result defines the Vector3 object where to store the result
  2607. * @returns the unmodified current Vector3
  2608. */
  2609. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2610. /**
  2611. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2612. * @param origin defines the origin of the projection ray
  2613. * @param plane defines the plane to project to
  2614. * @returns the projected vector3
  2615. */
  2616. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2617. /**
  2618. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2619. * @param origin defines the origin of the projection ray
  2620. * @param plane defines the plane to project to
  2621. * @param result defines the Vector3 where to store the result
  2622. */
  2623. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2624. /**
  2625. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2626. * @param otherVector defines the second operand
  2627. * @returns true if both vectors are equals
  2628. */
  2629. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2630. /**
  2631. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2632. * @param otherVector defines the second operand
  2633. * @param epsilon defines the minimal distance to define values as equals
  2634. * @returns true if both vectors are distant less than epsilon
  2635. */
  2636. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2637. /**
  2638. * Returns true if the current Vector3 coordinates equals the given floats
  2639. * @param x defines the x coordinate of the operand
  2640. * @param y defines the y coordinate of the operand
  2641. * @param z defines the z coordinate of the operand
  2642. * @returns true if both vectors are equals
  2643. */
  2644. equalsToFloats(x: number, y: number, z: number): boolean;
  2645. /**
  2646. * Multiplies the current Vector3 coordinates by the given ones
  2647. * @param otherVector defines the second operand
  2648. * @returns the current updated Vector3
  2649. */
  2650. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2651. /**
  2652. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2653. * @param otherVector defines the second operand
  2654. * @returns the new Vector3
  2655. */
  2656. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2657. /**
  2658. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2659. * @param otherVector defines the second operand
  2660. * @param result defines the Vector3 object where to store the result
  2661. * @returns the current Vector3
  2662. */
  2663. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2664. /**
  2665. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2666. * @param x defines the x coordinate of the operand
  2667. * @param y defines the y coordinate of the operand
  2668. * @param z defines the z coordinate of the operand
  2669. * @returns the new Vector3
  2670. */
  2671. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2672. /**
  2673. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2674. * @param otherVector defines the second operand
  2675. * @returns the new Vector3
  2676. */
  2677. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2678. /**
  2679. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2680. * @param otherVector defines the second operand
  2681. * @param result defines the Vector3 object where to store the result
  2682. * @returns the current Vector3
  2683. */
  2684. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2685. /**
  2686. * Divides the current Vector3 coordinates by the given ones.
  2687. * @param otherVector defines the second operand
  2688. * @returns the current updated Vector3
  2689. */
  2690. divideInPlace(otherVector: Vector3): Vector3;
  2691. /**
  2692. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2693. * @param other defines the second operand
  2694. * @returns the current updated Vector3
  2695. */
  2696. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2697. /**
  2698. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2699. * @param other defines the second operand
  2700. * @returns the current updated Vector3
  2701. */
  2702. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2703. /**
  2704. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2705. * @param x defines the x coordinate of the operand
  2706. * @param y defines the y coordinate of the operand
  2707. * @param z defines the z coordinate of the operand
  2708. * @returns the current updated Vector3
  2709. */
  2710. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2711. /**
  2712. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2713. * @param x defines the x coordinate of the operand
  2714. * @param y defines the y coordinate of the operand
  2715. * @param z defines the z coordinate of the operand
  2716. * @returns the current updated Vector3
  2717. */
  2718. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2719. /**
  2720. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2721. * Check if is non uniform within a certain amount of decimal places to account for this
  2722. * @param epsilon the amount the values can differ
  2723. * @returns if the the vector is non uniform to a certain number of decimal places
  2724. */
  2725. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2726. /**
  2727. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2728. */
  2729. get isNonUniform(): boolean;
  2730. /**
  2731. * Gets a new Vector3 from current Vector3 floored values
  2732. * @returns a new Vector3
  2733. */
  2734. floor(): Vector3;
  2735. /**
  2736. * Gets a new Vector3 from current Vector3 floored values
  2737. * @returns a new Vector3
  2738. */
  2739. fract(): Vector3;
  2740. /**
  2741. * Gets the length of the Vector3
  2742. * @returns the length of the Vector3
  2743. */
  2744. length(): number;
  2745. /**
  2746. * Gets the squared length of the Vector3
  2747. * @returns squared length of the Vector3
  2748. */
  2749. lengthSquared(): number;
  2750. /**
  2751. * Normalize the current Vector3.
  2752. * Please note that this is an in place operation.
  2753. * @returns the current updated Vector3
  2754. */
  2755. normalize(): Vector3;
  2756. /**
  2757. * Reorders the x y z properties of the vector in place
  2758. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2759. * @returns the current updated vector
  2760. */
  2761. reorderInPlace(order: string): this;
  2762. /**
  2763. * Rotates the vector around 0,0,0 by a quaternion
  2764. * @param quaternion the rotation quaternion
  2765. * @param result vector to store the result
  2766. * @returns the resulting vector
  2767. */
  2768. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2769. /**
  2770. * Rotates a vector around a given point
  2771. * @param quaternion the rotation quaternion
  2772. * @param point the point to rotate around
  2773. * @param result vector to store the result
  2774. * @returns the resulting vector
  2775. */
  2776. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2777. /**
  2778. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2779. * The cross product is then orthogonal to both current and "other"
  2780. * @param other defines the right operand
  2781. * @returns the cross product
  2782. */
  2783. cross(other: Vector3): Vector3;
  2784. /**
  2785. * Normalize the current Vector3 with the given input length.
  2786. * Please note that this is an in place operation.
  2787. * @param len the length of the vector
  2788. * @returns the current updated Vector3
  2789. */
  2790. normalizeFromLength(len: number): Vector3;
  2791. /**
  2792. * Normalize the current Vector3 to a new vector
  2793. * @returns the new Vector3
  2794. */
  2795. normalizeToNew(): Vector3;
  2796. /**
  2797. * Normalize the current Vector3 to the reference
  2798. * @param reference define the Vector3 to update
  2799. * @returns the updated Vector3
  2800. */
  2801. normalizeToRef(reference: Vector3): Vector3;
  2802. /**
  2803. * Creates a new Vector3 copied from the current Vector3
  2804. * @returns the new Vector3
  2805. */
  2806. clone(): Vector3;
  2807. /**
  2808. * Copies the given vector coordinates to the current Vector3 ones
  2809. * @param source defines the source Vector3
  2810. * @returns the current updated Vector3
  2811. */
  2812. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2813. /**
  2814. * Copies the given floats to the current Vector3 coordinates
  2815. * @param x defines the x coordinate of the operand
  2816. * @param y defines the y coordinate of the operand
  2817. * @param z defines the z coordinate of the operand
  2818. * @returns the current updated Vector3
  2819. */
  2820. copyFromFloats(x: number, y: number, z: number): Vector3;
  2821. /**
  2822. * Copies the given floats to the current Vector3 coordinates
  2823. * @param x defines the x coordinate of the operand
  2824. * @param y defines the y coordinate of the operand
  2825. * @param z defines the z coordinate of the operand
  2826. * @returns the current updated Vector3
  2827. */
  2828. set(x: number, y: number, z: number): Vector3;
  2829. /**
  2830. * Copies the given float to the current Vector3 coordinates
  2831. * @param v defines the x, y and z coordinates of the operand
  2832. * @returns the current updated Vector3
  2833. */
  2834. setAll(v: number): Vector3;
  2835. /**
  2836. * Get the clip factor between two vectors
  2837. * @param vector0 defines the first operand
  2838. * @param vector1 defines the second operand
  2839. * @param axis defines the axis to use
  2840. * @param size defines the size along the axis
  2841. * @returns the clip factor
  2842. */
  2843. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2844. /**
  2845. * Get angle between two vectors
  2846. * @param vector0 angle between vector0 and vector1
  2847. * @param vector1 angle between vector0 and vector1
  2848. * @param normal direction of the normal
  2849. * @return the angle between vector0 and vector1
  2850. */
  2851. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2852. /**
  2853. * Returns a new Vector3 set from the index "offset" of the given array
  2854. * @param array defines the source array
  2855. * @param offset defines the offset in the source array
  2856. * @returns the new Vector3
  2857. */
  2858. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2859. /**
  2860. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2861. * @param array defines the source array
  2862. * @param offset defines the offset in the source array
  2863. * @returns the new Vector3
  2864. * @deprecated Please use FromArray instead.
  2865. */
  2866. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2867. /**
  2868. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2869. * @param array defines the source array
  2870. * @param offset defines the offset in the source array
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2874. /**
  2875. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2876. * @param array defines the source array
  2877. * @param offset defines the offset in the source array
  2878. * @param result defines the Vector3 where to store the result
  2879. * @deprecated Please use FromArrayToRef instead.
  2880. */
  2881. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2882. /**
  2883. * Sets the given vector "result" with the given floats.
  2884. * @param x defines the x coordinate of the source
  2885. * @param y defines the y coordinate of the source
  2886. * @param z defines the z coordinate of the source
  2887. * @param result defines the Vector3 where to store the result
  2888. */
  2889. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2890. /**
  2891. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2892. * @returns a new empty Vector3
  2893. */
  2894. static Zero(): Vector3;
  2895. /**
  2896. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2897. * @returns a new unit Vector3
  2898. */
  2899. static One(): Vector3;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2902. * @returns a new up Vector3
  2903. */
  2904. static Up(): Vector3;
  2905. /**
  2906. * Gets a up Vector3 that must not be updated
  2907. */
  2908. static get UpReadOnly(): DeepImmutable<Vector3>;
  2909. /**
  2910. * Gets a zero Vector3 that must not be updated
  2911. */
  2912. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2913. /**
  2914. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2915. * @returns a new down Vector3
  2916. */
  2917. static Down(): Vector3;
  2918. /**
  2919. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2920. * @param rightHandedSystem is the scene right-handed (negative z)
  2921. * @returns a new forward Vector3
  2922. */
  2923. static Forward(rightHandedSystem?: boolean): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2926. * @param rightHandedSystem is the scene right-handed (negative-z)
  2927. * @returns a new forward Vector3
  2928. */
  2929. static Backward(rightHandedSystem?: boolean): Vector3;
  2930. /**
  2931. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2932. * @returns a new right Vector3
  2933. */
  2934. static Right(): Vector3;
  2935. /**
  2936. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2937. * @returns a new left Vector3
  2938. */
  2939. static Left(): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2942. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2943. * @param vector defines the Vector3 to transform
  2944. * @param transformation defines the transformation matrix
  2945. * @returns the transformed Vector3
  2946. */
  2947. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2950. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2951. * @param vector defines the Vector3 to transform
  2952. * @param transformation defines the transformation matrix
  2953. * @param result defines the Vector3 where to store the result
  2954. */
  2955. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2956. /**
  2957. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2958. * This method computes tranformed coordinates only, not transformed direction vectors
  2959. * @param x define the x coordinate of the source vector
  2960. * @param y define the y coordinate of the source vector
  2961. * @param z define the z coordinate of the source vector
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2968. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2969. * @param vector defines the Vector3 to transform
  2970. * @param transformation defines the transformation matrix
  2971. * @returns the new Vector3
  2972. */
  2973. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2976. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2977. * @param vector defines the Vector3 to transform
  2978. * @param transformation defines the transformation matrix
  2979. * @param result defines the Vector3 where to store the result
  2980. */
  2981. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2982. /**
  2983. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2984. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2985. * @param x define the x coordinate of the source vector
  2986. * @param y define the y coordinate of the source vector
  2987. * @param z define the z coordinate of the source vector
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2994. * @param value1 defines the first control point
  2995. * @param value2 defines the second control point
  2996. * @param value3 defines the third control point
  2997. * @param value4 defines the fourth control point
  2998. * @param amount defines the amount on the spline to use
  2999. * @returns the new Vector3
  3000. */
  3001. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3002. /**
  3003. * 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"
  3004. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3005. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3006. * @param value defines the current value
  3007. * @param min defines the lower range value
  3008. * @param max defines the upper range value
  3009. * @returns the new Vector3
  3010. */
  3011. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * 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"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @param result defines the Vector3 where to store the result
  3020. */
  3021. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3022. /**
  3023. * Checks if a given vector is inside a specific range
  3024. * @param v defines the vector to test
  3025. * @param min defines the minimum range
  3026. * @param max defines the maximum range
  3027. */
  3028. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3029. /**
  3030. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3031. * @param value1 defines the first control point
  3032. * @param tangent1 defines the first tangent vector
  3033. * @param value2 defines the second control point
  3034. * @param tangent2 defines the second tangent vector
  3035. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3036. * @returns the new Vector3
  3037. */
  3038. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3041. * @param start defines the start value
  3042. * @param end defines the end value
  3043. * @param amount max defines amount between both (between 0 and 1)
  3044. * @returns the new Vector3
  3045. */
  3046. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3047. /**
  3048. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3049. * @param start defines the start value
  3050. * @param end defines the end value
  3051. * @param amount max defines amount between both (between 0 and 1)
  3052. * @param result defines the Vector3 where to store the result
  3053. */
  3054. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3055. /**
  3056. * Returns the dot product (float) between the vectors "left" and "right"
  3057. * @param left defines the left operand
  3058. * @param right defines the right operand
  3059. * @returns the dot product
  3060. */
  3061. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3062. /**
  3063. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3064. * The cross product is then orthogonal to both "left" and "right"
  3065. * @param left defines the left operand
  3066. * @param right defines the right operand
  3067. * @returns the cross product
  3068. */
  3069. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3070. /**
  3071. * Sets the given vector "result" with the cross product of "left" and "right"
  3072. * The cross product is then orthogonal to both "left" and "right"
  3073. * @param left defines the left operand
  3074. * @param right defines the right operand
  3075. * @param result defines the Vector3 where to store the result
  3076. */
  3077. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3078. /**
  3079. * Returns a new Vector3 as the normalization of the given vector
  3080. * @param vector defines the Vector3 to normalize
  3081. * @returns the new Vector3
  3082. */
  3083. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3084. /**
  3085. * Sets the given vector "result" with the normalization of the given first vector
  3086. * @param vector defines the Vector3 to normalize
  3087. * @param result defines the Vector3 where to store the result
  3088. */
  3089. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3090. /**
  3091. * Project a Vector3 onto screen space
  3092. * @param vector defines the Vector3 to project
  3093. * @param world defines the world matrix to use
  3094. * @param transform defines the transform (view x projection) matrix to use
  3095. * @param viewport defines the screen viewport to use
  3096. * @returns the new Vector3
  3097. */
  3098. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3099. /** @hidden */
  3100. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3101. /**
  3102. * Unproject from screen space to object space
  3103. * @param source defines the screen space Vector3 to use
  3104. * @param viewportWidth defines the current width of the viewport
  3105. * @param viewportHeight defines the current height of the viewport
  3106. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3107. * @param transform defines the transform (view x projection) matrix to use
  3108. * @returns the new Vector3
  3109. */
  3110. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param view defines the view matrix to use
  3118. * @param projection defines the projection matrix to use
  3119. * @returns the new Vector3
  3120. */
  3121. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3122. /**
  3123. * Unproject from screen space to object space
  3124. * @param source defines the screen space Vector3 to use
  3125. * @param viewportWidth defines the current width of the viewport
  3126. * @param viewportHeight defines the current height of the viewport
  3127. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3128. * @param view defines the view matrix to use
  3129. * @param projection defines the projection matrix to use
  3130. * @param result defines the Vector3 where to store the result
  3131. */
  3132. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3133. /**
  3134. * Unproject from screen space to object space
  3135. * @param sourceX defines the screen space x coordinate to use
  3136. * @param sourceY defines the screen space y coordinate to use
  3137. * @param sourceZ defines the screen space z coordinate to use
  3138. * @param viewportWidth defines the current width of the viewport
  3139. * @param viewportHeight defines the current height of the viewport
  3140. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3141. * @param view defines the view matrix to use
  3142. * @param projection defines the projection matrix to use
  3143. * @param result defines the Vector3 where to store the result
  3144. */
  3145. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3146. /**
  3147. * Gets the minimal coordinate values between two Vector3
  3148. * @param left defines the first operand
  3149. * @param right defines the second operand
  3150. * @returns the new Vector3
  3151. */
  3152. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3153. /**
  3154. * Gets the maximal coordinate values between two Vector3
  3155. * @param left defines the first operand
  3156. * @param right defines the second operand
  3157. * @returns the new Vector3
  3158. */
  3159. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3160. /**
  3161. * Returns the distance between the vectors "value1" and "value2"
  3162. * @param value1 defines the first operand
  3163. * @param value2 defines the second operand
  3164. * @returns the distance
  3165. */
  3166. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3167. /**
  3168. * Returns the squared distance between the vectors "value1" and "value2"
  3169. * @param value1 defines the first operand
  3170. * @param value2 defines the second operand
  3171. * @returns the squared distance
  3172. */
  3173. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3174. /**
  3175. * Returns a new Vector3 located at the center between "value1" and "value2"
  3176. * @param value1 defines the first operand
  3177. * @param value2 defines the second operand
  3178. * @returns the new Vector3
  3179. */
  3180. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3181. /**
  3182. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3183. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3184. * to something in order to rotate it from its local system to the given target system
  3185. * Note: axis1, axis2 and axis3 are normalized during this operation
  3186. * @param axis1 defines the first axis
  3187. * @param axis2 defines the second axis
  3188. * @param axis3 defines the third axis
  3189. * @returns a new Vector3
  3190. */
  3191. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3192. /**
  3193. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3194. * @param axis1 defines the first axis
  3195. * @param axis2 defines the second axis
  3196. * @param axis3 defines the third axis
  3197. * @param ref defines the Vector3 where to store the result
  3198. */
  3199. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3200. }
  3201. /**
  3202. * Vector4 class created for EulerAngle class conversion to Quaternion
  3203. */
  3204. export class Vector4 {
  3205. /** x value of the vector */
  3206. x: number;
  3207. /** y value of the vector */
  3208. y: number;
  3209. /** z value of the vector */
  3210. z: number;
  3211. /** w value of the vector */
  3212. w: number;
  3213. /**
  3214. * Creates a Vector4 object from the given floats.
  3215. * @param x x value of the vector
  3216. * @param y y value of the vector
  3217. * @param z z value of the vector
  3218. * @param w w value of the vector
  3219. */
  3220. constructor(
  3221. /** x value of the vector */
  3222. x: number,
  3223. /** y value of the vector */
  3224. y: number,
  3225. /** z value of the vector */
  3226. z: number,
  3227. /** w value of the vector */
  3228. w: number);
  3229. /**
  3230. * Returns the string with the Vector4 coordinates.
  3231. * @returns a string containing all the vector values
  3232. */
  3233. toString(): string;
  3234. /**
  3235. * Returns the string "Vector4".
  3236. * @returns "Vector4"
  3237. */
  3238. getClassName(): string;
  3239. /**
  3240. * Returns the Vector4 hash code.
  3241. * @returns a unique hash code
  3242. */
  3243. getHashCode(): number;
  3244. /**
  3245. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3246. * @returns the resulting array
  3247. */
  3248. asArray(): number[];
  3249. /**
  3250. * Populates the given array from the given index with the Vector4 coordinates.
  3251. * @param array array to populate
  3252. * @param index index of the array to start at (default: 0)
  3253. * @returns the Vector4.
  3254. */
  3255. toArray(array: FloatArray, index?: number): Vector4;
  3256. /**
  3257. * Adds the given vector to the current Vector4.
  3258. * @param otherVector the vector to add
  3259. * @returns the updated Vector4.
  3260. */
  3261. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3264. * @param otherVector the vector to add
  3265. * @returns the resulting vector
  3266. */
  3267. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3270. * @param otherVector the vector to add
  3271. * @param result the vector to store the result
  3272. * @returns the current Vector4.
  3273. */
  3274. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3275. /**
  3276. * Subtract in place the given vector from the current Vector4.
  3277. * @param otherVector the vector to subtract
  3278. * @returns the updated Vector4.
  3279. */
  3280. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3283. * @param otherVector the vector to add
  3284. * @returns the new vector with the result
  3285. */
  3286. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3287. /**
  3288. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3289. * @param otherVector the vector to subtract
  3290. * @param result the vector to store the result
  3291. * @returns the current Vector4.
  3292. */
  3293. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3294. /**
  3295. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3296. */
  3297. /**
  3298. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3299. * @param x value to subtract
  3300. * @param y value to subtract
  3301. * @param z value to subtract
  3302. * @param w value to subtract
  3303. * @returns new vector containing the result
  3304. */
  3305. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3306. /**
  3307. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3308. * @param x value to subtract
  3309. * @param y value to subtract
  3310. * @param z value to subtract
  3311. * @param w value to subtract
  3312. * @param result the vector to store the result in
  3313. * @returns the current Vector4.
  3314. */
  3315. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3316. /**
  3317. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3318. * @returns a new vector with the negated values
  3319. */
  3320. negate(): Vector4;
  3321. /**
  3322. * Negate this vector in place
  3323. * @returns this
  3324. */
  3325. negateInPlace(): Vector4;
  3326. /**
  3327. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3328. * @param result defines the Vector3 object where to store the result
  3329. * @returns the current Vector4
  3330. */
  3331. negateToRef(result: Vector4): Vector4;
  3332. /**
  3333. * Multiplies the current Vector4 coordinates by scale (float).
  3334. * @param scale the number to scale with
  3335. * @returns the updated Vector4.
  3336. */
  3337. scaleInPlace(scale: number): Vector4;
  3338. /**
  3339. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3340. * @param scale the number to scale with
  3341. * @returns a new vector with the result
  3342. */
  3343. scale(scale: number): Vector4;
  3344. /**
  3345. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3346. * @param scale the number to scale with
  3347. * @param result a vector to store the result in
  3348. * @returns the current Vector4.
  3349. */
  3350. scaleToRef(scale: number, result: Vector4): Vector4;
  3351. /**
  3352. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3353. * @param scale defines the scale factor
  3354. * @param result defines the Vector4 object where to store the result
  3355. * @returns the unmodified current Vector4
  3356. */
  3357. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3358. /**
  3359. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3360. * @param otherVector the vector to compare against
  3361. * @returns true if they are equal
  3362. */
  3363. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3364. /**
  3365. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3366. * @param otherVector vector to compare against
  3367. * @param epsilon (Default: very small number)
  3368. * @returns true if they are equal
  3369. */
  3370. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3371. /**
  3372. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3373. * @param x x value to compare against
  3374. * @param y y value to compare against
  3375. * @param z z value to compare against
  3376. * @param w w value to compare against
  3377. * @returns true if equal
  3378. */
  3379. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3380. /**
  3381. * Multiplies in place the current Vector4 by the given one.
  3382. * @param otherVector vector to multiple with
  3383. * @returns the updated Vector4.
  3384. */
  3385. multiplyInPlace(otherVector: Vector4): Vector4;
  3386. /**
  3387. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3388. * @param otherVector vector to multiple with
  3389. * @returns resulting new vector
  3390. */
  3391. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3392. /**
  3393. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3394. * @param otherVector vector to multiple with
  3395. * @param result vector to store the result
  3396. * @returns the current Vector4.
  3397. */
  3398. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3399. /**
  3400. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3401. * @param x x value multiply with
  3402. * @param y y value multiply with
  3403. * @param z z value multiply with
  3404. * @param w w value multiply with
  3405. * @returns resulting new vector
  3406. */
  3407. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3408. /**
  3409. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3410. * @param otherVector vector to devide with
  3411. * @returns resulting new vector
  3412. */
  3413. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3414. /**
  3415. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3416. * @param otherVector vector to devide with
  3417. * @param result vector to store the result
  3418. * @returns the current Vector4.
  3419. */
  3420. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3421. /**
  3422. * Divides the current Vector3 coordinates by the given ones.
  3423. * @param otherVector vector to devide with
  3424. * @returns the updated Vector3.
  3425. */
  3426. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3427. /**
  3428. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3429. * @param other defines the second operand
  3430. * @returns the current updated Vector4
  3431. */
  3432. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3435. * @param other defines the second operand
  3436. * @returns the current updated Vector4
  3437. */
  3438. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3439. /**
  3440. * Gets a new Vector4 from current Vector4 floored values
  3441. * @returns a new Vector4
  3442. */
  3443. floor(): Vector4;
  3444. /**
  3445. * Gets a new Vector4 from current Vector3 floored values
  3446. * @returns a new Vector4
  3447. */
  3448. fract(): Vector4;
  3449. /**
  3450. * Returns the Vector4 length (float).
  3451. * @returns the length
  3452. */
  3453. length(): number;
  3454. /**
  3455. * Returns the Vector4 squared length (float).
  3456. * @returns the length squared
  3457. */
  3458. lengthSquared(): number;
  3459. /**
  3460. * Normalizes in place the Vector4.
  3461. * @returns the updated Vector4.
  3462. */
  3463. normalize(): Vector4;
  3464. /**
  3465. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3466. * @returns this converted to a new vector3
  3467. */
  3468. toVector3(): Vector3;
  3469. /**
  3470. * Returns a new Vector4 copied from the current one.
  3471. * @returns the new cloned vector
  3472. */
  3473. clone(): Vector4;
  3474. /**
  3475. * Updates the current Vector4 with the given one coordinates.
  3476. * @param source the source vector to copy from
  3477. * @returns the updated Vector4.
  3478. */
  3479. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3480. /**
  3481. * Updates the current Vector4 coordinates with the given floats.
  3482. * @param x float to copy from
  3483. * @param y float to copy from
  3484. * @param z float to copy from
  3485. * @param w float to copy from
  3486. * @returns the updated Vector4.
  3487. */
  3488. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3489. /**
  3490. * Updates the current Vector4 coordinates with the given floats.
  3491. * @param x float to set from
  3492. * @param y float to set from
  3493. * @param z float to set from
  3494. * @param w float to set from
  3495. * @returns the updated Vector4.
  3496. */
  3497. set(x: number, y: number, z: number, w: number): Vector4;
  3498. /**
  3499. * Copies the given float to the current Vector3 coordinates
  3500. * @param v defines the x, y, z and w coordinates of the operand
  3501. * @returns the current updated Vector3
  3502. */
  3503. setAll(v: number): Vector4;
  3504. /**
  3505. * Returns a new Vector4 set from the starting index of the given array.
  3506. * @param array the array to pull values from
  3507. * @param offset the offset into the array to start at
  3508. * @returns the new vector
  3509. */
  3510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3511. /**
  3512. * Updates the given vector "result" from the starting index of the given array.
  3513. * @param array the array to pull values from
  3514. * @param offset the offset into the array to start at
  3515. * @param result the vector to store the result in
  3516. */
  3517. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3518. /**
  3519. * Updates the given vector "result" from the starting index of the given Float32Array.
  3520. * @param array the array to pull values from
  3521. * @param offset the offset into the array to start at
  3522. * @param result the vector to store the result in
  3523. */
  3524. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3525. /**
  3526. * Updates the given vector "result" coordinates from the given floats.
  3527. * @param x float to set from
  3528. * @param y float to set from
  3529. * @param z float to set from
  3530. * @param w float to set from
  3531. * @param result the vector to the floats in
  3532. */
  3533. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3534. /**
  3535. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3536. * @returns the new vector
  3537. */
  3538. static Zero(): Vector4;
  3539. /**
  3540. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3541. * @returns the new vector
  3542. */
  3543. static One(): Vector4;
  3544. /**
  3545. * Returns a new normalized Vector4 from the given one.
  3546. * @param vector the vector to normalize
  3547. * @returns the vector
  3548. */
  3549. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3550. /**
  3551. * Updates the given vector "result" from the normalization of the given one.
  3552. * @param vector the vector to normalize
  3553. * @param result the vector to store the result in
  3554. */
  3555. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3556. /**
  3557. * Returns a vector with the minimum values from the left and right vectors
  3558. * @param left left vector to minimize
  3559. * @param right right vector to minimize
  3560. * @returns a new vector with the minimum of the left and right vector values
  3561. */
  3562. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3563. /**
  3564. * Returns a vector with the maximum values from the left and right vectors
  3565. * @param left left vector to maximize
  3566. * @param right right vector to maximize
  3567. * @returns a new vector with the maximum of the left and right vector values
  3568. */
  3569. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3570. /**
  3571. * Returns the distance (float) between the vectors "value1" and "value2".
  3572. * @param value1 value to calulate the distance between
  3573. * @param value2 value to calulate the distance between
  3574. * @return the distance between the two vectors
  3575. */
  3576. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3577. /**
  3578. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3579. * @param value1 value to calulate the distance between
  3580. * @param value2 value to calulate the distance between
  3581. * @return the distance between the two vectors squared
  3582. */
  3583. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3584. /**
  3585. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3586. * @param value1 value to calulate the center between
  3587. * @param value2 value to calulate the center between
  3588. * @return the center between the two vectors
  3589. */
  3590. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3591. /**
  3592. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3593. * This methods computes transformed normalized direction vectors only.
  3594. * @param vector the vector to transform
  3595. * @param transformation the transformation matrix to apply
  3596. * @returns the new vector
  3597. */
  3598. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3599. /**
  3600. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3601. * This methods computes transformed normalized direction vectors only.
  3602. * @param vector the vector to transform
  3603. * @param transformation the transformation matrix to apply
  3604. * @param result the vector to store the result in
  3605. */
  3606. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3607. /**
  3608. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3609. * This methods computes transformed normalized direction vectors only.
  3610. * @param x value to transform
  3611. * @param y value to transform
  3612. * @param z value to transform
  3613. * @param w value to transform
  3614. * @param transformation the transformation matrix to apply
  3615. * @param result the vector to store the results in
  3616. */
  3617. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3618. /**
  3619. * Creates a new Vector4 from a Vector3
  3620. * @param source defines the source data
  3621. * @param w defines the 4th component (default is 0)
  3622. * @returns a new Vector4
  3623. */
  3624. static FromVector3(source: Vector3, w?: number): Vector4;
  3625. }
  3626. /**
  3627. * Class used to store quaternion data
  3628. * @see https://en.wikipedia.org/wiki/Quaternion
  3629. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3630. */
  3631. export class Quaternion {
  3632. /** @hidden */
  3633. _x: number;
  3634. /** @hidden */
  3635. _y: number;
  3636. /** @hidden */
  3637. _z: number;
  3638. /** @hidden */
  3639. _w: number;
  3640. /** @hidden */
  3641. _isDirty: boolean;
  3642. /** Gets or sets the x coordinate */
  3643. get x(): number;
  3644. set x(value: number);
  3645. /** Gets or sets the y coordinate */
  3646. get y(): number;
  3647. set y(value: number);
  3648. /** Gets or sets the z coordinate */
  3649. get z(): number;
  3650. set z(value: number);
  3651. /** Gets or sets the w coordinate */
  3652. get w(): number;
  3653. set w(value: number);
  3654. /**
  3655. * Creates a new Quaternion from the given floats
  3656. * @param x defines the first component (0 by default)
  3657. * @param y defines the second component (0 by default)
  3658. * @param z defines the third component (0 by default)
  3659. * @param w defines the fourth component (1.0 by default)
  3660. */
  3661. constructor(x?: number, y?: number, z?: number, w?: number);
  3662. /**
  3663. * Gets a string representation for the current quaternion
  3664. * @returns a string with the Quaternion coordinates
  3665. */
  3666. toString(): string;
  3667. /**
  3668. * Gets the class name of the quaternion
  3669. * @returns the string "Quaternion"
  3670. */
  3671. getClassName(): string;
  3672. /**
  3673. * Gets a hash code for this quaternion
  3674. * @returns the quaternion hash code
  3675. */
  3676. getHashCode(): number;
  3677. /**
  3678. * Copy the quaternion to an array
  3679. * @returns a new array populated with 4 elements from the quaternion coordinates
  3680. */
  3681. asArray(): number[];
  3682. /**
  3683. * Check if two quaternions are equals
  3684. * @param otherQuaternion defines the second operand
  3685. * @return true if the current quaternion and the given one coordinates are strictly equals
  3686. */
  3687. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3688. /**
  3689. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3690. * @param otherQuaternion defines the other quaternion
  3691. * @param epsilon defines the minimal distance to consider equality
  3692. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3693. */
  3694. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3695. /**
  3696. * Clone the current quaternion
  3697. * @returns a new quaternion copied from the current one
  3698. */
  3699. clone(): Quaternion;
  3700. /**
  3701. * Copy a quaternion to the current one
  3702. * @param other defines the other quaternion
  3703. * @returns the updated current quaternion
  3704. */
  3705. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3706. /**
  3707. * Updates the current quaternion with the given float coordinates
  3708. * @param x defines the x coordinate
  3709. * @param y defines the y coordinate
  3710. * @param z defines the z coordinate
  3711. * @param w defines the w coordinate
  3712. * @returns the updated current quaternion
  3713. */
  3714. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3715. /**
  3716. * Updates the current quaternion from the given float coordinates
  3717. * @param x defines the x coordinate
  3718. * @param y defines the y coordinate
  3719. * @param z defines the z coordinate
  3720. * @param w defines the w coordinate
  3721. * @returns the updated current quaternion
  3722. */
  3723. set(x: number, y: number, z: number, w: number): Quaternion;
  3724. /**
  3725. * Adds two quaternions
  3726. * @param other defines the second operand
  3727. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3728. */
  3729. add(other: DeepImmutable<Quaternion>): Quaternion;
  3730. /**
  3731. * Add a quaternion to the current one
  3732. * @param other defines the quaternion to add
  3733. * @returns the current quaternion
  3734. */
  3735. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3736. /**
  3737. * Subtract two quaternions
  3738. * @param other defines the second operand
  3739. * @returns a new quaternion as the subtraction result of the given one from the current one
  3740. */
  3741. subtract(other: Quaternion): Quaternion;
  3742. /**
  3743. * Multiplies the current quaternion by a scale factor
  3744. * @param value defines the scale factor
  3745. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3746. */
  3747. scale(value: number): Quaternion;
  3748. /**
  3749. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3750. * @param scale defines the scale factor
  3751. * @param result defines the Quaternion object where to store the result
  3752. * @returns the unmodified current quaternion
  3753. */
  3754. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3755. /**
  3756. * Multiplies in place the current quaternion by a scale factor
  3757. * @param value defines the scale factor
  3758. * @returns the current modified quaternion
  3759. */
  3760. scaleInPlace(value: number): Quaternion;
  3761. /**
  3762. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3763. * @param scale defines the scale factor
  3764. * @param result defines the Quaternion object where to store the result
  3765. * @returns the unmodified current quaternion
  3766. */
  3767. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3768. /**
  3769. * Multiplies two quaternions
  3770. * @param q1 defines the second operand
  3771. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3772. */
  3773. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3774. /**
  3775. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3776. * @param q1 defines the second operand
  3777. * @param result defines the target quaternion
  3778. * @returns the current quaternion
  3779. */
  3780. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3781. /**
  3782. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3783. * @param q1 defines the second operand
  3784. * @returns the currentupdated quaternion
  3785. */
  3786. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3787. /**
  3788. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3789. * @param ref defines the target quaternion
  3790. * @returns the current quaternion
  3791. */
  3792. conjugateToRef(ref: Quaternion): Quaternion;
  3793. /**
  3794. * Conjugates in place (1-q) the current quaternion
  3795. * @returns the current updated quaternion
  3796. */
  3797. conjugateInPlace(): Quaternion;
  3798. /**
  3799. * Conjugates in place (1-q) the current quaternion
  3800. * @returns a new quaternion
  3801. */
  3802. conjugate(): Quaternion;
  3803. /**
  3804. * Gets length of current quaternion
  3805. * @returns the quaternion length (float)
  3806. */
  3807. length(): number;
  3808. /**
  3809. * Normalize in place the current quaternion
  3810. * @returns the current updated quaternion
  3811. */
  3812. normalize(): Quaternion;
  3813. /**
  3814. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3815. * @param order is a reserved parameter and is ignore for now
  3816. * @returns a new Vector3 containing the Euler angles
  3817. */
  3818. toEulerAngles(order?: string): Vector3;
  3819. /**
  3820. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3821. * @param result defines the vector which will be filled with the Euler angles
  3822. * @param order is a reserved parameter and is ignore for now
  3823. * @returns the current unchanged quaternion
  3824. */
  3825. toEulerAnglesToRef(result: Vector3): Quaternion;
  3826. /**
  3827. * Updates the given rotation matrix with the current quaternion values
  3828. * @param result defines the target matrix
  3829. * @returns the current unchanged quaternion
  3830. */
  3831. toRotationMatrix(result: Matrix): Quaternion;
  3832. /**
  3833. * Updates the current quaternion from the given rotation matrix values
  3834. * @param matrix defines the source matrix
  3835. * @returns the current updated quaternion
  3836. */
  3837. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3838. /**
  3839. * Creates a new quaternion from a rotation matrix
  3840. * @param matrix defines the source matrix
  3841. * @returns a new quaternion created from the given rotation matrix values
  3842. */
  3843. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3844. /**
  3845. * Updates the given quaternion with the given rotation matrix values
  3846. * @param matrix defines the source matrix
  3847. * @param result defines the target quaternion
  3848. */
  3849. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3850. /**
  3851. * Returns the dot product (float) between the quaternions "left" and "right"
  3852. * @param left defines the left operand
  3853. * @param right defines the right operand
  3854. * @returns the dot product
  3855. */
  3856. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3857. /**
  3858. * Checks if the two quaternions are close to each other
  3859. * @param quat0 defines the first quaternion to check
  3860. * @param quat1 defines the second quaternion to check
  3861. * @returns true if the two quaternions are close to each other
  3862. */
  3863. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3864. /**
  3865. * Creates an empty quaternion
  3866. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3867. */
  3868. static Zero(): Quaternion;
  3869. /**
  3870. * Inverse a given quaternion
  3871. * @param q defines the source quaternion
  3872. * @returns a new quaternion as the inverted current quaternion
  3873. */
  3874. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3875. /**
  3876. * Inverse a given quaternion
  3877. * @param q defines the source quaternion
  3878. * @param result the quaternion the result will be stored in
  3879. * @returns the result quaternion
  3880. */
  3881. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3882. /**
  3883. * Creates an identity quaternion
  3884. * @returns the identity quaternion
  3885. */
  3886. static Identity(): Quaternion;
  3887. /**
  3888. * Gets a boolean indicating if the given quaternion is identity
  3889. * @param quaternion defines the quaternion to check
  3890. * @returns true if the quaternion is identity
  3891. */
  3892. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3893. /**
  3894. * Creates a quaternion from a rotation around an axis
  3895. * @param axis defines the axis to use
  3896. * @param angle defines the angle to use
  3897. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3898. */
  3899. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3900. /**
  3901. * Creates a rotation around an axis and stores it into the given quaternion
  3902. * @param axis defines the axis to use
  3903. * @param angle defines the angle to use
  3904. * @param result defines the target quaternion
  3905. * @returns the target quaternion
  3906. */
  3907. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3908. /**
  3909. * Creates a new quaternion from data stored into an array
  3910. * @param array defines the data source
  3911. * @param offset defines the offset in the source array where the data starts
  3912. * @returns a new quaternion
  3913. */
  3914. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3915. /**
  3916. * Updates the given quaternion "result" from the starting index of the given array.
  3917. * @param array the array to pull values from
  3918. * @param offset the offset into the array to start at
  3919. * @param result the quaternion to store the result in
  3920. */
  3921. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3922. /**
  3923. * Create a quaternion from Euler rotation angles
  3924. * @param x Pitch
  3925. * @param y Yaw
  3926. * @param z Roll
  3927. * @returns the new Quaternion
  3928. */
  3929. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3930. /**
  3931. * Updates a quaternion from Euler rotation angles
  3932. * @param x Pitch
  3933. * @param y Yaw
  3934. * @param z Roll
  3935. * @param result the quaternion to store the result
  3936. * @returns the updated quaternion
  3937. */
  3938. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3939. /**
  3940. * Create a quaternion from Euler rotation vector
  3941. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3942. * @returns the new Quaternion
  3943. */
  3944. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3945. /**
  3946. * Updates a quaternion from Euler rotation vector
  3947. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3948. * @param result the quaternion to store the result
  3949. * @returns the updated quaternion
  3950. */
  3951. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3952. /**
  3953. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3954. * @param yaw defines the rotation around Y axis
  3955. * @param pitch defines the rotation around X axis
  3956. * @param roll defines the rotation around Z axis
  3957. * @returns the new quaternion
  3958. */
  3959. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3960. /**
  3961. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3962. * @param yaw defines the rotation around Y axis
  3963. * @param pitch defines the rotation around X axis
  3964. * @param roll defines the rotation around Z axis
  3965. * @param result defines the target quaternion
  3966. */
  3967. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3968. /**
  3969. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3970. * @param alpha defines the rotation around first axis
  3971. * @param beta defines the rotation around second axis
  3972. * @param gamma defines the rotation around third axis
  3973. * @returns the new quaternion
  3974. */
  3975. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3976. /**
  3977. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3978. * @param alpha defines the rotation around first axis
  3979. * @param beta defines the rotation around second axis
  3980. * @param gamma defines the rotation around third axis
  3981. * @param result defines the target quaternion
  3982. */
  3983. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3984. /**
  3985. * 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)
  3986. * @param axis1 defines the first axis
  3987. * @param axis2 defines the second axis
  3988. * @param axis3 defines the third axis
  3989. * @returns the new quaternion
  3990. */
  3991. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3992. /**
  3993. * 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
  3994. * @param axis1 defines the first axis
  3995. * @param axis2 defines the second axis
  3996. * @param axis3 defines the third axis
  3997. * @param ref defines the target quaternion
  3998. */
  3999. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4000. /**
  4001. * Interpolates between two quaternions
  4002. * @param left defines first quaternion
  4003. * @param right defines second quaternion
  4004. * @param amount defines the gradient to use
  4005. * @returns the new interpolated quaternion
  4006. */
  4007. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4008. /**
  4009. * Interpolates between two quaternions and stores it into a target quaternion
  4010. * @param left defines first quaternion
  4011. * @param right defines second quaternion
  4012. * @param amount defines the gradient to use
  4013. * @param result defines the target quaternion
  4014. */
  4015. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4016. /**
  4017. * Interpolate between two quaternions using Hermite interpolation
  4018. * @param value1 defines first quaternion
  4019. * @param tangent1 defines the incoming tangent
  4020. * @param value2 defines second quaternion
  4021. * @param tangent2 defines the outgoing tangent
  4022. * @param amount defines the target quaternion
  4023. * @returns the new interpolated quaternion
  4024. */
  4025. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4026. }
  4027. /**
  4028. * Class used to store matrix data (4x4)
  4029. */
  4030. export class Matrix {
  4031. private static _updateFlagSeed;
  4032. private static _identityReadOnly;
  4033. private _isIdentity;
  4034. private _isIdentityDirty;
  4035. private _isIdentity3x2;
  4036. private _isIdentity3x2Dirty;
  4037. /**
  4038. * Gets the update flag of the matrix which is an unique number for the matrix.
  4039. * It will be incremented every time the matrix data change.
  4040. * You can use it to speed the comparison between two versions of the same matrix.
  4041. */
  4042. updateFlag: number;
  4043. private readonly _m;
  4044. /**
  4045. * Gets the internal data of the matrix
  4046. */
  4047. get m(): DeepImmutable<Float32Array>;
  4048. /** @hidden */
  4049. _markAsUpdated(): void;
  4050. /** @hidden */
  4051. private _updateIdentityStatus;
  4052. /**
  4053. * Creates an empty matrix (filled with zeros)
  4054. */
  4055. constructor();
  4056. /**
  4057. * Check if the current matrix is identity
  4058. * @returns true is the matrix is the identity matrix
  4059. */
  4060. isIdentity(): boolean;
  4061. /**
  4062. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4063. * @returns true is the matrix is the identity matrix
  4064. */
  4065. isIdentityAs3x2(): boolean;
  4066. /**
  4067. * Gets the determinant of the matrix
  4068. * @returns the matrix determinant
  4069. */
  4070. determinant(): number;
  4071. /**
  4072. * Returns the matrix as a Float32Array
  4073. * @returns the matrix underlying array
  4074. */
  4075. toArray(): DeepImmutable<Float32Array>;
  4076. /**
  4077. * Returns the matrix as a Float32Array
  4078. * @returns the matrix underlying array.
  4079. */
  4080. asArray(): DeepImmutable<Float32Array>;
  4081. /**
  4082. * Inverts the current matrix in place
  4083. * @returns the current inverted matrix
  4084. */
  4085. invert(): Matrix;
  4086. /**
  4087. * Sets all the matrix elements to zero
  4088. * @returns the current matrix
  4089. */
  4090. reset(): Matrix;
  4091. /**
  4092. * Adds the current matrix with a second one
  4093. * @param other defines the matrix to add
  4094. * @returns a new matrix as the addition of the current matrix and the given one
  4095. */
  4096. add(other: DeepImmutable<Matrix>): Matrix;
  4097. /**
  4098. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4099. * @param other defines the matrix to add
  4100. * @param result defines the target matrix
  4101. * @returns the current matrix
  4102. */
  4103. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4104. /**
  4105. * Adds in place the given matrix to the current matrix
  4106. * @param other defines the second operand
  4107. * @returns the current updated matrix
  4108. */
  4109. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4110. /**
  4111. * Sets the given matrix to the current inverted Matrix
  4112. * @param other defines the target matrix
  4113. * @returns the unmodified current matrix
  4114. */
  4115. invertToRef(other: Matrix): Matrix;
  4116. /**
  4117. * add a value at the specified position in the current Matrix
  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. addAtIndex(index: number, value: number): Matrix;
  4123. /**
  4124. * mutiply the specified position in the current Matrix by a value
  4125. * @param index the index of the value within the matrix. between 0 and 15.
  4126. * @param value the value to be added
  4127. * @returns the current updated matrix
  4128. */
  4129. multiplyAtIndex(index: number, value: number): Matrix;
  4130. /**
  4131. * Inserts the translation vector (using 3 floats) in the current matrix
  4132. * @param x defines the 1st component of the translation
  4133. * @param y defines the 2nd component of the translation
  4134. * @param z defines the 3rd component of the translation
  4135. * @returns the current updated matrix
  4136. */
  4137. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4138. /**
  4139. * Adds the translation vector (using 3 floats) in the current matrix
  4140. * @param x defines the 1st component of the translation
  4141. * @param y defines the 2nd component of the translation
  4142. * @param z defines the 3rd component of the translation
  4143. * @returns the current updated matrix
  4144. */
  4145. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4146. /**
  4147. * Inserts the translation vector in the current matrix
  4148. * @param vector3 defines the translation to insert
  4149. * @returns the current updated matrix
  4150. */
  4151. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4152. /**
  4153. * Gets the translation value of the current matrix
  4154. * @returns a new Vector3 as the extracted translation from the matrix
  4155. */
  4156. getTranslation(): Vector3;
  4157. /**
  4158. * Fill a Vector3 with the extracted translation from the matrix
  4159. * @param result defines the Vector3 where to store the translation
  4160. * @returns the current matrix
  4161. */
  4162. getTranslationToRef(result: Vector3): Matrix;
  4163. /**
  4164. * Remove rotation and scaling part from the matrix
  4165. * @returns the updated matrix
  4166. */
  4167. removeRotationAndScaling(): Matrix;
  4168. /**
  4169. * Multiply two matrices
  4170. * @param other defines the second operand
  4171. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4172. */
  4173. multiply(other: DeepImmutable<Matrix>): Matrix;
  4174. /**
  4175. * Copy the current matrix from the given one
  4176. * @param other defines the source matrix
  4177. * @returns the current updated matrix
  4178. */
  4179. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4180. /**
  4181. * Populates the given array from the starting index with the current matrix values
  4182. * @param array defines the target array
  4183. * @param offset defines the offset in the target array where to start storing values
  4184. * @returns the current matrix
  4185. */
  4186. copyToArray(array: Float32Array, offset?: number): Matrix;
  4187. /**
  4188. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4189. * @param other defines the second operand
  4190. * @param result defines the matrix where to store the multiplication
  4191. * @returns the current matrix
  4192. */
  4193. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4194. /**
  4195. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4196. * @param other defines the second operand
  4197. * @param result defines the array where to store the multiplication
  4198. * @param offset defines the offset in the target array where to start storing values
  4199. * @returns the current matrix
  4200. */
  4201. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4202. /**
  4203. * Check equality between this matrix and a second one
  4204. * @param value defines the second matrix to compare
  4205. * @returns true is the current matrix and the given one values are strictly equal
  4206. */
  4207. equals(value: DeepImmutable<Matrix>): boolean;
  4208. /**
  4209. * Clone the current matrix
  4210. * @returns a new matrix from the current matrix
  4211. */
  4212. clone(): Matrix;
  4213. /**
  4214. * Returns the name of the current matrix class
  4215. * @returns the string "Matrix"
  4216. */
  4217. getClassName(): string;
  4218. /**
  4219. * Gets the hash code of the current matrix
  4220. * @returns the hash code
  4221. */
  4222. getHashCode(): number;
  4223. /**
  4224. * Decomposes the current Matrix into a translation, rotation and scaling components
  4225. * @param scale defines the scale vector3 given as a reference to update
  4226. * @param rotation defines the rotation quaternion given as a reference to update
  4227. * @param translation defines the translation vector3 given as a reference to update
  4228. * @returns true if operation was successful
  4229. */
  4230. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4231. /**
  4232. * Gets specific row of the matrix
  4233. * @param index defines the number of the row to get
  4234. * @returns the index-th row of the current matrix as a new Vector4
  4235. */
  4236. getRow(index: number): Nullable<Vector4>;
  4237. /**
  4238. * Sets the index-th row of the current matrix to the vector4 values
  4239. * @param index defines the number of the row to set
  4240. * @param row defines the target vector4
  4241. * @returns the updated current matrix
  4242. */
  4243. setRow(index: number, row: Vector4): Matrix;
  4244. /**
  4245. * Compute the transpose of the matrix
  4246. * @returns the new transposed matrix
  4247. */
  4248. transpose(): Matrix;
  4249. /**
  4250. * Compute the transpose of the matrix and store it in a given matrix
  4251. * @param result defines the target matrix
  4252. * @returns the current matrix
  4253. */
  4254. transposeToRef(result: Matrix): Matrix;
  4255. /**
  4256. * Sets the index-th row of the current matrix with the given 4 x float values
  4257. * @param index defines the row index
  4258. * @param x defines the x component to set
  4259. * @param y defines the y component to set
  4260. * @param z defines the z component to set
  4261. * @param w defines the w component to set
  4262. * @returns the updated current matrix
  4263. */
  4264. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4265. /**
  4266. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4267. * @param scale defines the scale factor
  4268. * @returns a new matrix
  4269. */
  4270. scale(scale: number): Matrix;
  4271. /**
  4272. * Scale the current matrix values by a factor to a given result 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. scaleToRef(scale: number, result: Matrix): Matrix;
  4278. /**
  4279. * Scale the current matrix values by a factor and add the result to a given matrix
  4280. * @param scale defines the scale factor
  4281. * @param result defines the Matrix to store the result
  4282. * @returns the current matrix
  4283. */
  4284. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4285. /**
  4286. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4287. * @param ref matrix to store the result
  4288. */
  4289. toNormalMatrix(ref: Matrix): void;
  4290. /**
  4291. * Gets only rotation part of the current matrix
  4292. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4293. */
  4294. getRotationMatrix(): Matrix;
  4295. /**
  4296. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4297. * @param result defines the target matrix to store data to
  4298. * @returns the current matrix
  4299. */
  4300. getRotationMatrixToRef(result: Matrix): Matrix;
  4301. /**
  4302. * Toggles model matrix from being right handed to left handed in place and vice versa
  4303. */
  4304. toggleModelMatrixHandInPlace(): void;
  4305. /**
  4306. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4307. */
  4308. toggleProjectionMatrixHandInPlace(): void;
  4309. /**
  4310. * Creates a matrix from an array
  4311. * @param array defines the source array
  4312. * @param offset defines an offset in the source array
  4313. * @returns a new Matrix set from the starting index of the given array
  4314. */
  4315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4316. /**
  4317. * Copy the content of an array into a given matrix
  4318. * @param array defines the source array
  4319. * @param offset defines an offset in the source array
  4320. * @param result defines the target matrix
  4321. */
  4322. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4323. /**
  4324. * Stores an array into a matrix after having multiplied each component by a given factor
  4325. * @param array defines the source array
  4326. * @param offset defines the offset in the source array
  4327. * @param scale defines the scaling factor
  4328. * @param result defines the target matrix
  4329. */
  4330. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4331. /**
  4332. * Gets an identity matrix that must not be updated
  4333. */
  4334. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4335. /**
  4336. * Stores a list of values (16) inside a given matrix
  4337. * @param initialM11 defines 1st value of 1st row
  4338. * @param initialM12 defines 2nd value of 1st row
  4339. * @param initialM13 defines 3rd value of 1st row
  4340. * @param initialM14 defines 4th value of 1st row
  4341. * @param initialM21 defines 1st value of 2nd row
  4342. * @param initialM22 defines 2nd value of 2nd row
  4343. * @param initialM23 defines 3rd value of 2nd row
  4344. * @param initialM24 defines 4th value of 2nd row
  4345. * @param initialM31 defines 1st value of 3rd row
  4346. * @param initialM32 defines 2nd value of 3rd row
  4347. * @param initialM33 defines 3rd value of 3rd row
  4348. * @param initialM34 defines 4th value of 3rd row
  4349. * @param initialM41 defines 1st value of 4th row
  4350. * @param initialM42 defines 2nd value of 4th row
  4351. * @param initialM43 defines 3rd value of 4th row
  4352. * @param initialM44 defines 4th value of 4th row
  4353. * @param result defines the target matrix
  4354. */
  4355. 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;
  4356. /**
  4357. * Creates new matrix from a list of values (16)
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @returns the new matrix
  4375. */
  4376. 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;
  4377. /**
  4378. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4379. * @param scale defines the scale vector3
  4380. * @param rotation defines the rotation quaternion
  4381. * @param translation defines the translation vector3
  4382. * @returns a new matrix
  4383. */
  4384. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4385. /**
  4386. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4387. * @param scale defines the scale vector3
  4388. * @param rotation defines the rotation quaternion
  4389. * @param translation defines the translation vector3
  4390. * @param result defines the target matrix
  4391. */
  4392. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4393. /**
  4394. * Creates a new identity matrix
  4395. * @returns a new identity matrix
  4396. */
  4397. static Identity(): Matrix;
  4398. /**
  4399. * Creates a new identity matrix and stores the result in a given matrix
  4400. * @param result defines the target matrix
  4401. */
  4402. static IdentityToRef(result: Matrix): void;
  4403. /**
  4404. * Creates a new zero matrix
  4405. * @returns a new zero matrix
  4406. */
  4407. static Zero(): Matrix;
  4408. /**
  4409. * Creates a new rotation matrix for "angle" radians around the X axis
  4410. * @param angle defines the angle (in radians) to use
  4411. * @return the new matrix
  4412. */
  4413. static RotationX(angle: number): Matrix;
  4414. /**
  4415. * Creates a new matrix as the invert of a given matrix
  4416. * @param source defines the source matrix
  4417. * @returns the new matrix
  4418. */
  4419. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4420. /**
  4421. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4422. * @param angle defines the angle (in radians) to use
  4423. * @param result defines the target matrix
  4424. */
  4425. static RotationXToRef(angle: number, result: Matrix): void;
  4426. /**
  4427. * Creates a new rotation matrix for "angle" radians around the Y axis
  4428. * @param angle defines the angle (in radians) to use
  4429. * @return the new matrix
  4430. */
  4431. static RotationY(angle: number): Matrix;
  4432. /**
  4433. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4434. * @param angle defines the angle (in radians) to use
  4435. * @param result defines the target matrix
  4436. */
  4437. static RotationYToRef(angle: number, result: Matrix): void;
  4438. /**
  4439. * Creates a new rotation matrix for "angle" radians around the Z axis
  4440. * @param angle defines the angle (in radians) to use
  4441. * @return the new matrix
  4442. */
  4443. static RotationZ(angle: number): Matrix;
  4444. /**
  4445. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4446. * @param angle defines the angle (in radians) to use
  4447. * @param result defines the target matrix
  4448. */
  4449. static RotationZToRef(angle: number, result: Matrix): void;
  4450. /**
  4451. * Creates a new rotation matrix for "angle" radians around the given axis
  4452. * @param axis defines the axis to use
  4453. * @param angle defines the angle (in radians) to use
  4454. * @return the new matrix
  4455. */
  4456. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4457. /**
  4458. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4459. * @param axis defines the axis to use
  4460. * @param angle defines the angle (in radians) to use
  4461. * @param result defines the target matrix
  4462. */
  4463. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4464. /**
  4465. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4466. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4467. * @param from defines the vector to align
  4468. * @param to defines the vector to align to
  4469. * @param result defines the target matrix
  4470. */
  4471. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4472. /**
  4473. * Creates a rotation matrix
  4474. * @param yaw defines the yaw angle in radians (Y axis)
  4475. * @param pitch defines the pitch angle in radians (X axis)
  4476. * @param roll defines the roll angle in radians (X axis)
  4477. * @returns the new rotation matrix
  4478. */
  4479. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4480. /**
  4481. * Creates a rotation matrix and stores it in a given matrix
  4482. * @param yaw defines the yaw angle in radians (Y axis)
  4483. * @param pitch defines the pitch angle in radians (X axis)
  4484. * @param roll defines the roll angle in radians (X axis)
  4485. * @param result defines the target matrix
  4486. */
  4487. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4488. /**
  4489. * Creates a scaling matrix
  4490. * @param x defines the scale factor on X axis
  4491. * @param y defines the scale factor on Y axis
  4492. * @param z defines the scale factor on Z axis
  4493. * @returns the new matrix
  4494. */
  4495. static Scaling(x: number, y: number, z: number): Matrix;
  4496. /**
  4497. * Creates a scaling matrix and stores it in a given matrix
  4498. * @param x defines the scale factor on X axis
  4499. * @param y defines the scale factor on Y axis
  4500. * @param z defines the scale factor on Z axis
  4501. * @param result defines the target matrix
  4502. */
  4503. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4504. /**
  4505. * Creates a translation matrix
  4506. * @param x defines the translation on X axis
  4507. * @param y defines the translation on Y axis
  4508. * @param z defines the translationon Z axis
  4509. * @returns the new matrix
  4510. */
  4511. static Translation(x: number, y: number, z: number): Matrix;
  4512. /**
  4513. * Creates a translation matrix and stores it in a given matrix
  4514. * @param x defines the translation on X axis
  4515. * @param y defines the translation on Y axis
  4516. * @param z defines the translationon Z axis
  4517. * @param result defines the target matrix
  4518. */
  4519. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4520. /**
  4521. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4522. * @param startValue defines the start value
  4523. * @param endValue defines the end value
  4524. * @param gradient defines the gradient factor
  4525. * @returns the new matrix
  4526. */
  4527. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4528. /**
  4529. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4530. * @param startValue defines the start value
  4531. * @param endValue defines the end value
  4532. * @param gradient defines the gradient factor
  4533. * @param result defines the Matrix object where to store data
  4534. */
  4535. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4536. /**
  4537. * Builds a new matrix whose values are computed by:
  4538. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4539. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4540. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4541. * @param startValue defines the first matrix
  4542. * @param endValue defines the second matrix
  4543. * @param gradient defines the gradient between the two matrices
  4544. * @returns the new matrix
  4545. */
  4546. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4547. /**
  4548. * Update a matrix to values which are computed by:
  4549. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4550. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4551. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4552. * @param startValue defines the first matrix
  4553. * @param endValue defines the second matrix
  4554. * @param gradient defines the gradient between the two matrices
  4555. * @param result defines the target matrix
  4556. */
  4557. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4558. /**
  4559. * 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"
  4560. * This function works in left handed mode
  4561. * @param eye defines the final position of the entity
  4562. * @param target defines where the entity should look at
  4563. * @param up defines the up vector for the entity
  4564. * @returns the new matrix
  4565. */
  4566. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4567. /**
  4568. * 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".
  4569. * This function works in left handed mode
  4570. * @param eye defines the final position of the entity
  4571. * @param target defines where the entity should look at
  4572. * @param up defines the up vector for the entity
  4573. * @param result defines the target matrix
  4574. */
  4575. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4576. /**
  4577. * 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"
  4578. * This function works in right handed mode
  4579. * @param eye defines the final position of the entity
  4580. * @param target defines where the entity should look at
  4581. * @param up defines the up vector for the entity
  4582. * @returns the new matrix
  4583. */
  4584. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4585. /**
  4586. * 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".
  4587. * This function works in right handed mode
  4588. * @param eye defines the final position of the entity
  4589. * @param target defines where the entity should look at
  4590. * @param up defines the up vector for the entity
  4591. * @param result defines the target matrix
  4592. */
  4593. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4594. /**
  4595. * Create a left-handed orthographic projection matrix
  4596. * @param width defines the viewport width
  4597. * @param height defines the viewport height
  4598. * @param znear defines the near clip plane
  4599. * @param zfar defines the far clip plane
  4600. * @returns a new matrix as a left-handed orthographic projection matrix
  4601. */
  4602. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4603. /**
  4604. * Store a left-handed orthographic projection to a given matrix
  4605. * @param width defines the viewport width
  4606. * @param height defines the viewport height
  4607. * @param znear defines the near clip plane
  4608. * @param zfar defines the far clip plane
  4609. * @param result defines the target matrix
  4610. */
  4611. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4612. /**
  4613. * Create a left-handed orthographic projection matrix
  4614. * @param left defines the viewport left coordinate
  4615. * @param right defines the viewport right coordinate
  4616. * @param bottom defines the viewport bottom coordinate
  4617. * @param top defines the viewport top coordinate
  4618. * @param znear defines the near clip plane
  4619. * @param zfar defines the far clip plane
  4620. * @returns a new matrix as a left-handed orthographic projection matrix
  4621. */
  4622. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4623. /**
  4624. * Stores a left-handed orthographic projection into a given matrix
  4625. * @param left defines the viewport left coordinate
  4626. * @param right defines the viewport right coordinate
  4627. * @param bottom defines the viewport bottom coordinate
  4628. * @param top defines the viewport top coordinate
  4629. * @param znear defines the near clip plane
  4630. * @param zfar defines the far clip plane
  4631. * @param result defines the target matrix
  4632. */
  4633. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4634. /**
  4635. * Creates a right-handed orthographic projection matrix
  4636. * @param left defines the viewport left coordinate
  4637. * @param right defines the viewport right coordinate
  4638. * @param bottom defines the viewport bottom coordinate
  4639. * @param top defines the viewport top coordinate
  4640. * @param znear defines the near clip plane
  4641. * @param zfar defines the far clip plane
  4642. * @returns a new matrix as a right-handed orthographic projection matrix
  4643. */
  4644. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4645. /**
  4646. * Stores a right-handed orthographic projection into a given matrix
  4647. * @param left defines the viewport left coordinate
  4648. * @param right defines the viewport right coordinate
  4649. * @param bottom defines the viewport bottom coordinate
  4650. * @param top defines the viewport top coordinate
  4651. * @param znear defines the near clip plane
  4652. * @param zfar defines the far clip plane
  4653. * @param result defines the target matrix
  4654. */
  4655. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4656. /**
  4657. * Creates a left-handed perspective projection matrix
  4658. * @param width defines the viewport width
  4659. * @param height defines the viewport height
  4660. * @param znear defines the near clip plane
  4661. * @param zfar defines the far clip plane
  4662. * @returns a new matrix as a left-handed perspective projection matrix
  4663. */
  4664. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4665. /**
  4666. * Creates a left-handed perspective projection matrix
  4667. * @param fov defines the horizontal field of view
  4668. * @param aspect defines the aspect ratio
  4669. * @param znear defines the near clip plane
  4670. * @param zfar defines the far clip plane
  4671. * @returns a new matrix as a left-handed perspective projection matrix
  4672. */
  4673. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4674. /**
  4675. * Stores a left-handed perspective projection into a given matrix
  4676. * @param fov defines the horizontal field of view
  4677. * @param aspect defines the aspect ratio
  4678. * @param znear defines the near clip plane
  4679. * @param zfar defines the far clip plane
  4680. * @param result defines the target matrix
  4681. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4682. */
  4683. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4684. /**
  4685. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4686. * @param fov defines the horizontal field of view
  4687. * @param aspect defines the aspect ratio
  4688. * @param znear defines the near clip plane
  4689. * @param zfar not used as infinity is used as far clip
  4690. * @param result defines the target matrix
  4691. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4692. */
  4693. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4694. /**
  4695. * Creates a right-handed perspective projection matrix
  4696. * @param fov defines the horizontal field of view
  4697. * @param aspect defines the aspect ratio
  4698. * @param znear defines the near clip plane
  4699. * @param zfar defines the far clip plane
  4700. * @returns a new matrix as a right-handed perspective projection matrix
  4701. */
  4702. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4703. /**
  4704. * Stores a right-handed perspective projection into a given matrix
  4705. * @param fov defines the horizontal field of view
  4706. * @param aspect defines the aspect ratio
  4707. * @param znear defines the near clip plane
  4708. * @param zfar defines the far clip plane
  4709. * @param result defines the target matrix
  4710. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4711. */
  4712. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4713. /**
  4714. * Stores a right-handed perspective projection into a given matrix
  4715. * @param fov defines the horizontal field of view
  4716. * @param aspect defines the aspect ratio
  4717. * @param znear defines the near clip plane
  4718. * @param zfar not used as infinity is used as far clip
  4719. * @param result defines the target matrix
  4720. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4721. */
  4722. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4723. /**
  4724. * Stores a perspective projection for WebVR info a given matrix
  4725. * @param fov defines the field of view
  4726. * @param znear defines the near clip plane
  4727. * @param zfar defines the far clip plane
  4728. * @param result defines the target matrix
  4729. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4730. */
  4731. static PerspectiveFovWebVRToRef(fov: {
  4732. upDegrees: number;
  4733. downDegrees: number;
  4734. leftDegrees: number;
  4735. rightDegrees: number;
  4736. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4737. /**
  4738. * Computes a complete transformation matrix
  4739. * @param viewport defines the viewport to use
  4740. * @param world defines the world matrix
  4741. * @param view defines the view matrix
  4742. * @param projection defines the projection matrix
  4743. * @param zmin defines the near clip plane
  4744. * @param zmax defines the far clip plane
  4745. * @returns the transformation matrix
  4746. */
  4747. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4748. /**
  4749. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4750. * @param matrix defines the matrix to use
  4751. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4752. */
  4753. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4754. /**
  4755. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4756. * @param matrix defines the matrix to use
  4757. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4758. */
  4759. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4760. /**
  4761. * Compute the transpose of a given matrix
  4762. * @param matrix defines the matrix to transpose
  4763. * @returns the new matrix
  4764. */
  4765. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4766. /**
  4767. * Compute the transpose of a matrix and store it in a target matrix
  4768. * @param matrix defines the matrix to transpose
  4769. * @param result defines the target matrix
  4770. */
  4771. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4772. /**
  4773. * Computes a reflection matrix from a plane
  4774. * @param plane defines the reflection plane
  4775. * @returns a new matrix
  4776. */
  4777. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4778. /**
  4779. * Computes a reflection matrix from a plane
  4780. * @param plane defines the reflection plane
  4781. * @param result defines the target matrix
  4782. */
  4783. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4784. /**
  4785. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4786. * @param xaxis defines the value of the 1st axis
  4787. * @param yaxis defines the value of the 2nd axis
  4788. * @param zaxis defines the value of the 3rd axis
  4789. * @param result defines the target matrix
  4790. */
  4791. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4792. /**
  4793. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4794. * @param quat defines the quaternion to use
  4795. * @param result defines the target matrix
  4796. */
  4797. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4798. }
  4799. /**
  4800. * @hidden
  4801. */
  4802. export class TmpVectors {
  4803. static Vector2: Vector2[];
  4804. static Vector3: Vector3[];
  4805. static Vector4: Vector4[];
  4806. static Quaternion: Quaternion[];
  4807. static Matrix: Matrix[];
  4808. }
  4809. }
  4810. declare module "babylonjs/Maths/math.path" {
  4811. import { DeepImmutable, Nullable } from "babylonjs/types";
  4812. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4813. /**
  4814. * Defines potential orientation for back face culling
  4815. */
  4816. export enum Orientation {
  4817. /**
  4818. * Clockwise
  4819. */
  4820. CW = 0,
  4821. /** Counter clockwise */
  4822. CCW = 1
  4823. }
  4824. /** Class used to represent a Bezier curve */
  4825. export class BezierCurve {
  4826. /**
  4827. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4828. * @param t defines the time
  4829. * @param x1 defines the left coordinate on X axis
  4830. * @param y1 defines the left coordinate on Y axis
  4831. * @param x2 defines the right coordinate on X axis
  4832. * @param y2 defines the right coordinate on Y axis
  4833. * @returns the interpolated value
  4834. */
  4835. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4836. }
  4837. /**
  4838. * Defines angle representation
  4839. */
  4840. export class Angle {
  4841. private _radians;
  4842. /**
  4843. * Creates an Angle object of "radians" radians (float).
  4844. * @param radians the angle in radians
  4845. */
  4846. constructor(radians: number);
  4847. /**
  4848. * Get value in degrees
  4849. * @returns the Angle value in degrees (float)
  4850. */
  4851. degrees(): number;
  4852. /**
  4853. * Get value in radians
  4854. * @returns the Angle value in radians (float)
  4855. */
  4856. radians(): number;
  4857. /**
  4858. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4859. * @param a defines first vector
  4860. * @param b defines second vector
  4861. * @returns a new Angle
  4862. */
  4863. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4864. /**
  4865. * Gets a new Angle object from the given float in radians
  4866. * @param radians defines the angle value in radians
  4867. * @returns a new Angle
  4868. */
  4869. static FromRadians(radians: number): Angle;
  4870. /**
  4871. * Gets a new Angle object from the given float in degrees
  4872. * @param degrees defines the angle value in degrees
  4873. * @returns a new Angle
  4874. */
  4875. static FromDegrees(degrees: number): Angle;
  4876. }
  4877. /**
  4878. * This represents an arc in a 2d space.
  4879. */
  4880. export class Arc2 {
  4881. /** Defines the start point of the arc */
  4882. startPoint: Vector2;
  4883. /** Defines the mid point of the arc */
  4884. midPoint: Vector2;
  4885. /** Defines the end point of the arc */
  4886. endPoint: Vector2;
  4887. /**
  4888. * Defines the center point of the arc.
  4889. */
  4890. centerPoint: Vector2;
  4891. /**
  4892. * Defines the radius of the arc.
  4893. */
  4894. radius: number;
  4895. /**
  4896. * Defines the angle of the arc (from mid point to end point).
  4897. */
  4898. angle: Angle;
  4899. /**
  4900. * Defines the start angle of the arc (from start point to middle point).
  4901. */
  4902. startAngle: Angle;
  4903. /**
  4904. * Defines the orientation of the arc (clock wise/counter clock wise).
  4905. */
  4906. orientation: Orientation;
  4907. /**
  4908. * Creates an Arc object from the three given points : start, middle and end.
  4909. * @param startPoint Defines the start point of the arc
  4910. * @param midPoint Defines the midlle point of the arc
  4911. * @param endPoint Defines the end point of the arc
  4912. */
  4913. constructor(
  4914. /** Defines the start point of the arc */
  4915. startPoint: Vector2,
  4916. /** Defines the mid point of the arc */
  4917. midPoint: Vector2,
  4918. /** Defines the end point of the arc */
  4919. endPoint: Vector2);
  4920. }
  4921. /**
  4922. * Represents a 2D path made up of multiple 2D points
  4923. */
  4924. export class Path2 {
  4925. private _points;
  4926. private _length;
  4927. /**
  4928. * If the path start and end point are the same
  4929. */
  4930. closed: boolean;
  4931. /**
  4932. * Creates a Path2 object from the starting 2D coordinates x and y.
  4933. * @param x the starting points x value
  4934. * @param y the starting points y value
  4935. */
  4936. constructor(x: number, y: number);
  4937. /**
  4938. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4939. * @param x the added points x value
  4940. * @param y the added points y value
  4941. * @returns the updated Path2.
  4942. */
  4943. addLineTo(x: number, y: number): Path2;
  4944. /**
  4945. * 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.
  4946. * @param midX middle point x value
  4947. * @param midY middle point y value
  4948. * @param endX end point x value
  4949. * @param endY end point y value
  4950. * @param numberOfSegments (default: 36)
  4951. * @returns the updated Path2.
  4952. */
  4953. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4954. /**
  4955. * Closes the Path2.
  4956. * @returns the Path2.
  4957. */
  4958. close(): Path2;
  4959. /**
  4960. * Gets the sum of the distance between each sequential point in the path
  4961. * @returns the Path2 total length (float).
  4962. */
  4963. length(): number;
  4964. /**
  4965. * Gets the points which construct the path
  4966. * @returns the Path2 internal array of points.
  4967. */
  4968. getPoints(): Vector2[];
  4969. /**
  4970. * Retreives the point at the distance aways from the starting point
  4971. * @param normalizedLengthPosition the length along the path to retreive the point from
  4972. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4973. */
  4974. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4975. /**
  4976. * Creates a new path starting from an x and y position
  4977. * @param x starting x value
  4978. * @param y starting y value
  4979. * @returns a new Path2 starting at the coordinates (x, y).
  4980. */
  4981. static StartingAt(x: number, y: number): Path2;
  4982. }
  4983. /**
  4984. * Represents a 3D path made up of multiple 3D points
  4985. */
  4986. export class Path3D {
  4987. /**
  4988. * an array of Vector3, the curve axis of the Path3D
  4989. */
  4990. path: Vector3[];
  4991. private _curve;
  4992. private _distances;
  4993. private _tangents;
  4994. private _normals;
  4995. private _binormals;
  4996. private _raw;
  4997. private _alignTangentsWithPath;
  4998. private readonly _pointAtData;
  4999. /**
  5000. * new Path3D(path, normal, raw)
  5001. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5002. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5003. * @param path an array of Vector3, the curve axis of the Path3D
  5004. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5005. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5006. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5007. */
  5008. constructor(
  5009. /**
  5010. * an array of Vector3, the curve axis of the Path3D
  5011. */
  5012. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5013. /**
  5014. * Returns the Path3D array of successive Vector3 designing its curve.
  5015. * @returns the Path3D array of successive Vector3 designing its curve.
  5016. */
  5017. getCurve(): Vector3[];
  5018. /**
  5019. * Returns the Path3D array of successive Vector3 designing its curve.
  5020. * @returns the Path3D array of successive Vector3 designing its curve.
  5021. */
  5022. getPoints(): Vector3[];
  5023. /**
  5024. * @returns the computed length (float) of the path.
  5025. */
  5026. length(): number;
  5027. /**
  5028. * Returns an array populated with tangent vectors on each Path3D curve point.
  5029. * @returns an array populated with tangent vectors on each Path3D curve point.
  5030. */
  5031. getTangents(): Vector3[];
  5032. /**
  5033. * Returns an array populated with normal vectors on each Path3D curve point.
  5034. * @returns an array populated with normal vectors on each Path3D curve point.
  5035. */
  5036. getNormals(): Vector3[];
  5037. /**
  5038. * Returns an array populated with binormal vectors on each Path3D curve point.
  5039. * @returns an array populated with binormal vectors on each Path3D curve point.
  5040. */
  5041. getBinormals(): Vector3[];
  5042. /**
  5043. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5044. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5045. */
  5046. getDistances(): number[];
  5047. /**
  5048. * Returns an interpolated point along this path
  5049. * @param position the position of the point along this path, from 0.0 to 1.0
  5050. * @returns a new Vector3 as the point
  5051. */
  5052. getPointAt(position: number): 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 tangent instead of the tangent of the previous path point.
  5057. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5058. */
  5059. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5060. /**
  5061. * Returns the tangent 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 normal instead of the normal of the previous path point.
  5064. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5065. */
  5066. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5067. /**
  5068. * Returns the binormal vector 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. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5071. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5072. */
  5073. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5074. /**
  5075. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5076. * @param position the position of the point along this path, from 0.0 to 1.0
  5077. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5078. */
  5079. getDistanceAt(position: number): number;
  5080. /**
  5081. * Returns the array index of the previous point of an interpolated point along this path
  5082. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5083. * @returns the array index
  5084. */
  5085. getPreviousPointIndexAt(position: number): number;
  5086. /**
  5087. * 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)
  5088. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5089. * @returns the sub position
  5090. */
  5091. getSubPositionAt(position: number): number;
  5092. /**
  5093. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5094. * @param target the vector of which to get the closest position to
  5095. * @returns the position of the closest virtual point on this path to the target vector
  5096. */
  5097. getClosestPositionTo(target: Vector3): number;
  5098. /**
  5099. * Returns a sub path (slice) of this path
  5100. * @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
  5101. * @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
  5102. * @returns a sub path (slice) of this path
  5103. */
  5104. slice(start?: number, end?: number): Path3D;
  5105. /**
  5106. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5107. * @param path path which all values are copied into the curves points
  5108. * @param firstNormal which should be projected onto the curve
  5109. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5110. * @returns the same object updated.
  5111. */
  5112. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5113. private _compute;
  5114. private _getFirstNonNullVector;
  5115. private _getLastNonNullVector;
  5116. private _normalVector;
  5117. /**
  5118. * Updates the point at data for an interpolated point along this curve
  5119. * @param position the position of the point along this curve, from 0.0 to 1.0
  5120. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5121. * @returns the (updated) point at data
  5122. */
  5123. private _updatePointAtData;
  5124. /**
  5125. * Updates the point at data from the specified parameters
  5126. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5127. * @param point the interpolated point
  5128. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5129. */
  5130. private _setPointAtData;
  5131. /**
  5132. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5133. */
  5134. private _updateInterpolationMatrix;
  5135. }
  5136. /**
  5137. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5138. * A Curve3 is designed from a series of successive Vector3.
  5139. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5140. */
  5141. export class Curve3 {
  5142. private _points;
  5143. private _length;
  5144. /**
  5145. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5146. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5147. * @param v1 (Vector3) the control point
  5148. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5149. * @param nbPoints (integer) the wanted number of points in the curve
  5150. * @returns the created Curve3
  5151. */
  5152. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5153. /**
  5154. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5155. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5156. * @param v1 (Vector3) the first control point
  5157. * @param v2 (Vector3) the second control point
  5158. * @param v3 (Vector3) the end point of the Cubic Bezier
  5159. * @param nbPoints (integer) the wanted number of points in the curve
  5160. * @returns the created Curve3
  5161. */
  5162. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5163. /**
  5164. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5165. * @param p1 (Vector3) the origin point of the Hermite Spline
  5166. * @param t1 (Vector3) the tangent vector at the origin point
  5167. * @param p2 (Vector3) the end point of the Hermite Spline
  5168. * @param t2 (Vector3) the tangent vector at the end point
  5169. * @param nbPoints (integer) the wanted number of points in the curve
  5170. * @returns the created Curve3
  5171. */
  5172. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5173. /**
  5174. * Returns a Curve3 object along a CatmullRom Spline curve :
  5175. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5176. * @param nbPoints (integer) the wanted number of points between each curve control points
  5177. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5178. * @returns the created Curve3
  5179. */
  5180. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5181. /**
  5182. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5183. * A Curve3 is designed from a series of successive Vector3.
  5184. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5185. * @param points points which make up the curve
  5186. */
  5187. constructor(points: Vector3[]);
  5188. /**
  5189. * @returns the Curve3 stored array of successive Vector3
  5190. */
  5191. getPoints(): Vector3[];
  5192. /**
  5193. * @returns the computed length (float) of the curve.
  5194. */
  5195. length(): number;
  5196. /**
  5197. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5198. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5199. * curveA and curveB keep unchanged.
  5200. * @param curve the curve to continue from this curve
  5201. * @returns the newly constructed curve
  5202. */
  5203. continue(curve: DeepImmutable<Curve3>): Curve3;
  5204. private _computeLength;
  5205. }
  5206. }
  5207. declare module "babylonjs/Animations/easing" {
  5208. /**
  5209. * This represents the main contract an easing function should follow.
  5210. * Easing functions are used throughout the animation system.
  5211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5212. */
  5213. export interface IEasingFunction {
  5214. /**
  5215. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5216. * of the easing function.
  5217. * The link below provides some of the most common examples of easing functions.
  5218. * @see https://easings.net/
  5219. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5220. * @returns the corresponding value on the curve defined by the easing function
  5221. */
  5222. ease(gradient: number): number;
  5223. }
  5224. /**
  5225. * Base class used for every default easing function.
  5226. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5227. */
  5228. export class EasingFunction implements IEasingFunction {
  5229. /**
  5230. * Interpolation follows the mathematical formula associated with the easing function.
  5231. */
  5232. static readonly EASINGMODE_EASEIN: number;
  5233. /**
  5234. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5235. */
  5236. static readonly EASINGMODE_EASEOUT: number;
  5237. /**
  5238. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5239. */
  5240. static readonly EASINGMODE_EASEINOUT: number;
  5241. private _easingMode;
  5242. /**
  5243. * Sets the easing mode of the current function.
  5244. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5245. */
  5246. setEasingMode(easingMode: number): void;
  5247. /**
  5248. * Gets the current easing mode.
  5249. * @returns the easing mode
  5250. */
  5251. getEasingMode(): number;
  5252. /**
  5253. * @hidden
  5254. */
  5255. easeInCore(gradient: number): number;
  5256. /**
  5257. * Given an input gradient between 0 and 1, this returns the corresponding value
  5258. * of the easing function.
  5259. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5260. * @returns the corresponding value on the curve defined by the easing function
  5261. */
  5262. ease(gradient: number): number;
  5263. }
  5264. /**
  5265. * Easing function with a circle shape (see link below).
  5266. * @see https://easings.net/#easeInCirc
  5267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5268. */
  5269. export class CircleEase extends EasingFunction implements IEasingFunction {
  5270. /** @hidden */
  5271. easeInCore(gradient: number): number;
  5272. }
  5273. /**
  5274. * Easing function with a ease back shape (see link below).
  5275. * @see https://easings.net/#easeInBack
  5276. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5277. */
  5278. export class BackEase extends EasingFunction implements IEasingFunction {
  5279. /** Defines the amplitude of the function */
  5280. amplitude: number;
  5281. /**
  5282. * Instantiates a back ease easing
  5283. * @see https://easings.net/#easeInBack
  5284. * @param amplitude Defines the amplitude of the function
  5285. */
  5286. constructor(
  5287. /** Defines the amplitude of the function */
  5288. amplitude?: number);
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a bouncing shape (see link below).
  5294. * @see https://easings.net/#easeInBounce
  5295. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BounceEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the number of bounces */
  5299. bounces: number;
  5300. /** Defines the amplitude of the bounce */
  5301. bounciness: number;
  5302. /**
  5303. * Instantiates a bounce easing
  5304. * @see https://easings.net/#easeInBounce
  5305. * @param bounces Defines the number of bounces
  5306. * @param bounciness Defines the amplitude of the bounce
  5307. */
  5308. constructor(
  5309. /** Defines the number of bounces */
  5310. bounces?: number,
  5311. /** Defines the amplitude of the bounce */
  5312. bounciness?: number);
  5313. /** @hidden */
  5314. easeInCore(gradient: number): number;
  5315. }
  5316. /**
  5317. * Easing function with a power of 3 shape (see link below).
  5318. * @see https://easings.net/#easeInCubic
  5319. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5320. */
  5321. export class CubicEase extends EasingFunction implements IEasingFunction {
  5322. /** @hidden */
  5323. easeInCore(gradient: number): number;
  5324. }
  5325. /**
  5326. * Easing function with an elastic shape (see link below).
  5327. * @see https://easings.net/#easeInElastic
  5328. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5329. */
  5330. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5331. /** Defines the number of oscillations*/
  5332. oscillations: number;
  5333. /** Defines the amplitude of the oscillations*/
  5334. springiness: number;
  5335. /**
  5336. * Instantiates an elastic easing function
  5337. * @see https://easings.net/#easeInElastic
  5338. * @param oscillations Defines the number of oscillations
  5339. * @param springiness Defines the amplitude of the oscillations
  5340. */
  5341. constructor(
  5342. /** Defines the number of oscillations*/
  5343. oscillations?: number,
  5344. /** Defines the amplitude of the oscillations*/
  5345. springiness?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with an exponential shape (see link below).
  5351. * @see https://easings.net/#easeInExpo
  5352. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the exponent of the function */
  5356. exponent: number;
  5357. /**
  5358. * Instantiates an exponential easing function
  5359. * @see https://easings.net/#easeInExpo
  5360. * @param exponent Defines the exponent of the function
  5361. */
  5362. constructor(
  5363. /** Defines the exponent of the function */
  5364. exponent?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a power shape (see link below).
  5370. * @see https://easings.net/#easeInQuad
  5371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class PowerEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the power of the function */
  5375. power: number;
  5376. /**
  5377. * Instantiates an power base easing function
  5378. * @see https://easings.net/#easeInQuad
  5379. * @param power Defines the power of the function
  5380. */
  5381. constructor(
  5382. /** Defines the power of the function */
  5383. power?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power of 2 shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5393. /** @hidden */
  5394. easeInCore(gradient: number): number;
  5395. }
  5396. /**
  5397. * Easing function with a power of 4 shape (see link below).
  5398. * @see https://easings.net/#easeInQuart
  5399. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5400. */
  5401. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5402. /** @hidden */
  5403. easeInCore(gradient: number): number;
  5404. }
  5405. /**
  5406. * Easing function with a power of 5 shape (see link below).
  5407. * @see https://easings.net/#easeInQuint
  5408. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5409. */
  5410. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5411. /** @hidden */
  5412. easeInCore(gradient: number): number;
  5413. }
  5414. /**
  5415. * Easing function with a sin shape (see link below).
  5416. * @see https://easings.net/#easeInSine
  5417. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5418. */
  5419. export class SineEase extends EasingFunction implements IEasingFunction {
  5420. /** @hidden */
  5421. easeInCore(gradient: number): number;
  5422. }
  5423. /**
  5424. * Easing function with a bezier shape (see link below).
  5425. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5426. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5427. */
  5428. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5429. /** Defines the x component of the start tangent in the bezier curve */
  5430. x1: number;
  5431. /** Defines the y component of the start tangent in the bezier curve */
  5432. y1: number;
  5433. /** Defines the x component of the end tangent in the bezier curve */
  5434. x2: number;
  5435. /** Defines the y component of the end tangent in the bezier curve */
  5436. y2: number;
  5437. /**
  5438. * Instantiates a bezier function
  5439. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5440. * @param x1 Defines the x component of the start tangent in the bezier curve
  5441. * @param y1 Defines the y component of the start tangent in the bezier curve
  5442. * @param x2 Defines the x component of the end tangent in the bezier curve
  5443. * @param y2 Defines the y component of the end tangent in the bezier curve
  5444. */
  5445. constructor(
  5446. /** Defines the x component of the start tangent in the bezier curve */
  5447. x1?: number,
  5448. /** Defines the y component of the start tangent in the bezier curve */
  5449. y1?: number,
  5450. /** Defines the x component of the end tangent in the bezier curve */
  5451. x2?: number,
  5452. /** Defines the y component of the end tangent in the bezier curve */
  5453. y2?: number);
  5454. /** @hidden */
  5455. easeInCore(gradient: number): number;
  5456. }
  5457. }
  5458. declare module "babylonjs/Maths/math.color" {
  5459. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5460. /**
  5461. * Class used to hold a RBG color
  5462. */
  5463. export class Color3 {
  5464. /**
  5465. * Defines the red component (between 0 and 1, default is 0)
  5466. */
  5467. r: number;
  5468. /**
  5469. * Defines the green component (between 0 and 1, default is 0)
  5470. */
  5471. g: number;
  5472. /**
  5473. * Defines the blue component (between 0 and 1, default is 0)
  5474. */
  5475. b: number;
  5476. /**
  5477. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5478. * @param r defines the red component (between 0 and 1, default is 0)
  5479. * @param g defines the green component (between 0 and 1, default is 0)
  5480. * @param b defines the blue component (between 0 and 1, default is 0)
  5481. */
  5482. constructor(
  5483. /**
  5484. * Defines the red component (between 0 and 1, default is 0)
  5485. */
  5486. r?: number,
  5487. /**
  5488. * Defines the green component (between 0 and 1, default is 0)
  5489. */
  5490. g?: number,
  5491. /**
  5492. * Defines the blue component (between 0 and 1, default is 0)
  5493. */
  5494. b?: number);
  5495. /**
  5496. * Creates a string with the Color3 current values
  5497. * @returns the string representation of the Color3 object
  5498. */
  5499. toString(): string;
  5500. /**
  5501. * Returns the string "Color3"
  5502. * @returns "Color3"
  5503. */
  5504. getClassName(): string;
  5505. /**
  5506. * Compute the Color3 hash code
  5507. * @returns an unique number that can be used to hash Color3 objects
  5508. */
  5509. getHashCode(): number;
  5510. /**
  5511. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5512. * @param array defines the array where to store the r,g,b components
  5513. * @param index defines an optional index in the target array to define where to start storing values
  5514. * @returns the current Color3 object
  5515. */
  5516. toArray(array: FloatArray, index?: number): Color3;
  5517. /**
  5518. * Returns a new Color4 object from the current Color3 and the given alpha
  5519. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5520. * @returns a new Color4 object
  5521. */
  5522. toColor4(alpha?: number): Color4;
  5523. /**
  5524. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5525. * @returns the new array
  5526. */
  5527. asArray(): number[];
  5528. /**
  5529. * Returns the luminance value
  5530. * @returns a float value
  5531. */
  5532. toLuminance(): number;
  5533. /**
  5534. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5535. * @param otherColor defines the second operand
  5536. * @returns the new Color3 object
  5537. */
  5538. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5539. /**
  5540. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5541. * @param otherColor defines the second operand
  5542. * @param result defines the Color3 object where to store the result
  5543. * @returns the current Color3
  5544. */
  5545. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5546. /**
  5547. * Determines equality between Color3 objects
  5548. * @param otherColor defines the second operand
  5549. * @returns true if the rgb values are equal to the given ones
  5550. */
  5551. equals(otherColor: DeepImmutable<Color3>): boolean;
  5552. /**
  5553. * Determines equality between the current Color3 object and a set of r,b,g values
  5554. * @param r defines the red component to check
  5555. * @param g defines the green component to check
  5556. * @param b defines the blue component to check
  5557. * @returns true if the rgb values are equal to the given ones
  5558. */
  5559. equalsFloats(r: number, g: number, b: number): boolean;
  5560. /**
  5561. * Multiplies in place each rgb value by scale
  5562. * @param scale defines the scaling factor
  5563. * @returns the updated Color3
  5564. */
  5565. scale(scale: number): Color3;
  5566. /**
  5567. * Multiplies the rgb values by scale and stores the result into "result"
  5568. * @param scale defines the scaling factor
  5569. * @param result defines the Color3 object where to store the result
  5570. * @returns the unmodified current Color3
  5571. */
  5572. scaleToRef(scale: number, result: Color3): Color3;
  5573. /**
  5574. * Scale the current Color3 values by a factor and add the result to a given Color3
  5575. * @param scale defines the scale factor
  5576. * @param result defines color to store the result into
  5577. * @returns the unmodified current Color3
  5578. */
  5579. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5580. /**
  5581. * Clamps the rgb values by the min and max values and stores the result into "result"
  5582. * @param min defines minimum clamping value (default is 0)
  5583. * @param max defines maximum clamping value (default is 1)
  5584. * @param result defines color to store the result into
  5585. * @returns the original Color3
  5586. */
  5587. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5588. /**
  5589. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5590. * @param otherColor defines the second operand
  5591. * @returns the new Color3
  5592. */
  5593. add(otherColor: DeepImmutable<Color3>): Color3;
  5594. /**
  5595. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5596. * @param otherColor defines the second operand
  5597. * @param result defines Color3 object to store the result into
  5598. * @returns the unmodified current Color3
  5599. */
  5600. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5601. /**
  5602. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5603. * @param otherColor defines the second operand
  5604. * @returns the new Color3
  5605. */
  5606. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5607. /**
  5608. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5609. * @param otherColor defines the second operand
  5610. * @param result defines Color3 object to store the result into
  5611. * @returns the unmodified current Color3
  5612. */
  5613. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5614. /**
  5615. * Copy the current object
  5616. * @returns a new Color3 copied the current one
  5617. */
  5618. clone(): Color3;
  5619. /**
  5620. * Copies the rgb values from the source in the current Color3
  5621. * @param source defines the source Color3 object
  5622. * @returns the updated Color3 object
  5623. */
  5624. copyFrom(source: DeepImmutable<Color3>): Color3;
  5625. /**
  5626. * Updates the Color3 rgb values from the given floats
  5627. * @param r defines the red component to read from
  5628. * @param g defines the green component to read from
  5629. * @param b defines the blue component to read from
  5630. * @returns the current Color3 object
  5631. */
  5632. copyFromFloats(r: number, g: number, b: number): Color3;
  5633. /**
  5634. * Updates the Color3 rgb values from the given floats
  5635. * @param r defines the red component to read from
  5636. * @param g defines the green component to read from
  5637. * @param b defines the blue component to read from
  5638. * @returns the current Color3 object
  5639. */
  5640. set(r: number, g: number, b: number): Color3;
  5641. /**
  5642. * Compute the Color3 hexadecimal code as a string
  5643. * @returns a string containing the hexadecimal representation of the Color3 object
  5644. */
  5645. toHexString(): string;
  5646. /**
  5647. * Computes a new Color3 converted from the current one to linear space
  5648. * @returns a new Color3 object
  5649. */
  5650. toLinearSpace(): Color3;
  5651. /**
  5652. * Converts current color in rgb space to HSV values
  5653. * @returns a new color3 representing the HSV values
  5654. */
  5655. toHSV(): Color3;
  5656. /**
  5657. * Converts current color in rgb space to HSV values
  5658. * @param result defines the Color3 where to store the HSV values
  5659. */
  5660. toHSVToRef(result: Color3): void;
  5661. /**
  5662. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5663. * @param convertedColor defines the Color3 object where to store the linear space version
  5664. * @returns the unmodified Color3
  5665. */
  5666. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5667. /**
  5668. * Computes a new Color3 converted from the current one to gamma space
  5669. * @returns a new Color3 object
  5670. */
  5671. toGammaSpace(): Color3;
  5672. /**
  5673. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5674. * @param convertedColor defines the Color3 object where to store the gamma space version
  5675. * @returns the unmodified Color3
  5676. */
  5677. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5678. private static _BlackReadOnly;
  5679. /**
  5680. * Convert Hue, saturation and value to a Color3 (RGB)
  5681. * @param hue defines the hue
  5682. * @param saturation defines the saturation
  5683. * @param value defines the value
  5684. * @param result defines the Color3 where to store the RGB values
  5685. */
  5686. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5687. /**
  5688. * Creates a new Color3 from the string containing valid hexadecimal values
  5689. * @param hex defines a string containing valid hexadecimal values
  5690. * @returns a new Color3 object
  5691. */
  5692. static FromHexString(hex: string): Color3;
  5693. /**
  5694. * Creates a new Color3 from the starting index of the given array
  5695. * @param array defines the source array
  5696. * @param offset defines an offset in the source array
  5697. * @returns a new Color3 object
  5698. */
  5699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5700. /**
  5701. * Creates a new Color3 from integer values (< 256)
  5702. * @param r defines the red component to read from (value between 0 and 255)
  5703. * @param g defines the green component to read from (value between 0 and 255)
  5704. * @param b defines the blue component to read from (value between 0 and 255)
  5705. * @returns a new Color3 object
  5706. */
  5707. static FromInts(r: number, g: number, b: number): Color3;
  5708. /**
  5709. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5710. * @param start defines the start Color3 value
  5711. * @param end defines the end Color3 value
  5712. * @param amount defines the gradient value between start and end
  5713. * @returns a new Color3 object
  5714. */
  5715. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5716. /**
  5717. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5718. * @param left defines the start value
  5719. * @param right defines the end value
  5720. * @param amount defines the gradient factor
  5721. * @param result defines the Color3 object where to store the result
  5722. */
  5723. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5724. /**
  5725. * Returns a Color3 value containing a red color
  5726. * @returns a new Color3 object
  5727. */
  5728. static Red(): Color3;
  5729. /**
  5730. * Returns a Color3 value containing a green color
  5731. * @returns a new Color3 object
  5732. */
  5733. static Green(): Color3;
  5734. /**
  5735. * Returns a Color3 value containing a blue color
  5736. * @returns a new Color3 object
  5737. */
  5738. static Blue(): Color3;
  5739. /**
  5740. * Returns a Color3 value containing a black color
  5741. * @returns a new Color3 object
  5742. */
  5743. static Black(): Color3;
  5744. /**
  5745. * Gets a Color3 value containing a black color that must not be updated
  5746. */
  5747. static get BlackReadOnly(): DeepImmutable<Color3>;
  5748. /**
  5749. * Returns a Color3 value containing a white color
  5750. * @returns a new Color3 object
  5751. */
  5752. static White(): Color3;
  5753. /**
  5754. * Returns a Color3 value containing a purple color
  5755. * @returns a new Color3 object
  5756. */
  5757. static Purple(): Color3;
  5758. /**
  5759. * Returns a Color3 value containing a magenta color
  5760. * @returns a new Color3 object
  5761. */
  5762. static Magenta(): Color3;
  5763. /**
  5764. * Returns a Color3 value containing a yellow color
  5765. * @returns a new Color3 object
  5766. */
  5767. static Yellow(): Color3;
  5768. /**
  5769. * Returns a Color3 value containing a gray color
  5770. * @returns a new Color3 object
  5771. */
  5772. static Gray(): Color3;
  5773. /**
  5774. * Returns a Color3 value containing a teal color
  5775. * @returns a new Color3 object
  5776. */
  5777. static Teal(): Color3;
  5778. /**
  5779. * Returns a Color3 value containing a random color
  5780. * @returns a new Color3 object
  5781. */
  5782. static Random(): Color3;
  5783. }
  5784. /**
  5785. * Class used to hold a RBGA color
  5786. */
  5787. export class Color4 {
  5788. /**
  5789. * Defines the red component (between 0 and 1, default is 0)
  5790. */
  5791. r: number;
  5792. /**
  5793. * Defines the green component (between 0 and 1, default is 0)
  5794. */
  5795. g: number;
  5796. /**
  5797. * Defines the blue component (between 0 and 1, default is 0)
  5798. */
  5799. b: number;
  5800. /**
  5801. * Defines the alpha component (between 0 and 1, default is 1)
  5802. */
  5803. a: number;
  5804. /**
  5805. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5806. * @param r defines the red component (between 0 and 1, default is 0)
  5807. * @param g defines the green component (between 0 and 1, default is 0)
  5808. * @param b defines the blue component (between 0 and 1, default is 0)
  5809. * @param a defines the alpha component (between 0 and 1, default is 1)
  5810. */
  5811. constructor(
  5812. /**
  5813. * Defines the red component (between 0 and 1, default is 0)
  5814. */
  5815. r?: number,
  5816. /**
  5817. * Defines the green component (between 0 and 1, default is 0)
  5818. */
  5819. g?: number,
  5820. /**
  5821. * Defines the blue component (between 0 and 1, default is 0)
  5822. */
  5823. b?: number,
  5824. /**
  5825. * Defines the alpha component (between 0 and 1, default is 1)
  5826. */
  5827. a?: number);
  5828. /**
  5829. * Adds in place the given Color4 values to the current Color4 object
  5830. * @param right defines the second operand
  5831. * @returns the current updated Color4 object
  5832. */
  5833. addInPlace(right: DeepImmutable<Color4>): Color4;
  5834. /**
  5835. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5836. * @returns the new array
  5837. */
  5838. asArray(): number[];
  5839. /**
  5840. * Stores from the starting index in the given array the Color4 successive values
  5841. * @param array defines the array where to store the r,g,b components
  5842. * @param index defines an optional index in the target array to define where to start storing values
  5843. * @returns the current Color4 object
  5844. */
  5845. toArray(array: number[], index?: number): Color4;
  5846. /**
  5847. * Determines equality between Color4 objects
  5848. * @param otherColor defines the second operand
  5849. * @returns true if the rgba values are equal to the given ones
  5850. */
  5851. equals(otherColor: DeepImmutable<Color4>): boolean;
  5852. /**
  5853. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5854. * @param right defines the second operand
  5855. * @returns a new Color4 object
  5856. */
  5857. add(right: DeepImmutable<Color4>): Color4;
  5858. /**
  5859. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5860. * @param right defines the second operand
  5861. * @returns a new Color4 object
  5862. */
  5863. subtract(right: DeepImmutable<Color4>): Color4;
  5864. /**
  5865. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5866. * @param right defines the second operand
  5867. * @param result defines the Color4 object where to store the result
  5868. * @returns the current Color4 object
  5869. */
  5870. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5871. /**
  5872. * Creates a new Color4 with the current Color4 values multiplied by scale
  5873. * @param scale defines the scaling factor to apply
  5874. * @returns a new Color4 object
  5875. */
  5876. scale(scale: number): Color4;
  5877. /**
  5878. * Multiplies the current Color4 values by scale and stores the result in "result"
  5879. * @param scale defines the scaling factor to apply
  5880. * @param result defines the Color4 object where to store the result
  5881. * @returns the current unmodified Color4
  5882. */
  5883. scaleToRef(scale: number, result: Color4): Color4;
  5884. /**
  5885. * Scale the current Color4 values by a factor and add the result to a given Color4
  5886. * @param scale defines the scale factor
  5887. * @param result defines the Color4 object where to store the result
  5888. * @returns the unmodified current Color4
  5889. */
  5890. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5891. /**
  5892. * Clamps the rgb values by the min and max values and stores the result into "result"
  5893. * @param min defines minimum clamping value (default is 0)
  5894. * @param max defines maximum clamping value (default is 1)
  5895. * @param result defines color to store the result into.
  5896. * @returns the cuurent Color4
  5897. */
  5898. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5899. /**
  5900. * Multipy an Color4 value by another and return a new Color4 object
  5901. * @param color defines the Color4 value to multiply by
  5902. * @returns a new Color4 object
  5903. */
  5904. multiply(color: Color4): Color4;
  5905. /**
  5906. * Multipy a Color4 value by another and push the result in a reference value
  5907. * @param color defines the Color4 value to multiply by
  5908. * @param result defines the Color4 to fill the result in
  5909. * @returns the result Color4
  5910. */
  5911. multiplyToRef(color: Color4, result: Color4): Color4;
  5912. /**
  5913. * Creates a string with the Color4 current values
  5914. * @returns the string representation of the Color4 object
  5915. */
  5916. toString(): string;
  5917. /**
  5918. * Returns the string "Color4"
  5919. * @returns "Color4"
  5920. */
  5921. getClassName(): string;
  5922. /**
  5923. * Compute the Color4 hash code
  5924. * @returns an unique number that can be used to hash Color4 objects
  5925. */
  5926. getHashCode(): number;
  5927. /**
  5928. * Creates a new Color4 copied from the current one
  5929. * @returns a new Color4 object
  5930. */
  5931. clone(): Color4;
  5932. /**
  5933. * Copies the given Color4 values into the current one
  5934. * @param source defines the source Color4 object
  5935. * @returns the current updated Color4 object
  5936. */
  5937. copyFrom(source: Color4): Color4;
  5938. /**
  5939. * Copies the given float values into the current one
  5940. * @param r defines the red component to read from
  5941. * @param g defines the green component to read from
  5942. * @param b defines the blue component to read from
  5943. * @param a defines the alpha component to read from
  5944. * @returns the current updated Color4 object
  5945. */
  5946. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5947. /**
  5948. * Copies the given float values into the current one
  5949. * @param r defines the red component to read from
  5950. * @param g defines the green component to read from
  5951. * @param b defines the blue component to read from
  5952. * @param a defines the alpha component to read from
  5953. * @returns the current updated Color4 object
  5954. */
  5955. set(r: number, g: number, b: number, a: number): Color4;
  5956. /**
  5957. * Compute the Color4 hexadecimal code as a string
  5958. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5959. * @returns a string containing the hexadecimal representation of the Color4 object
  5960. */
  5961. toHexString(returnAsColor3?: boolean): string;
  5962. /**
  5963. * Computes a new Color4 converted from the current one to linear space
  5964. * @returns a new Color4 object
  5965. */
  5966. toLinearSpace(): Color4;
  5967. /**
  5968. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5969. * @param convertedColor defines the Color4 object where to store the linear space version
  5970. * @returns the unmodified Color4
  5971. */
  5972. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5973. /**
  5974. * Computes a new Color4 converted from the current one to gamma space
  5975. * @returns a new Color4 object
  5976. */
  5977. toGammaSpace(): Color4;
  5978. /**
  5979. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5980. * @param convertedColor defines the Color4 object where to store the gamma space version
  5981. * @returns the unmodified Color4
  5982. */
  5983. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5984. /**
  5985. * Creates a new Color4 from the string containing valid hexadecimal values
  5986. * @param hex defines a string containing valid hexadecimal values
  5987. * @returns a new Color4 object
  5988. */
  5989. static FromHexString(hex: string): Color4;
  5990. /**
  5991. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5992. * @param left defines the start value
  5993. * @param right defines the end value
  5994. * @param amount defines the gradient factor
  5995. * @returns a new Color4 object
  5996. */
  5997. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5998. /**
  5999. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6000. * @param left defines the start value
  6001. * @param right defines the end value
  6002. * @param amount defines the gradient factor
  6003. * @param result defines the Color4 object where to store data
  6004. */
  6005. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6006. /**
  6007. * Creates a new Color4 from a Color3 and an alpha value
  6008. * @param color3 defines the source Color3 to read from
  6009. * @param alpha defines the alpha component (1.0 by default)
  6010. * @returns a new Color4 object
  6011. */
  6012. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6013. /**
  6014. * Creates a new Color4 from the starting index element of the given array
  6015. * @param array defines the source array to read from
  6016. * @param offset defines the offset in the source array
  6017. * @returns a new Color4 object
  6018. */
  6019. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6020. /**
  6021. * Creates a new Color3 from integer values (< 256)
  6022. * @param r defines the red component to read from (value between 0 and 255)
  6023. * @param g defines the green component to read from (value between 0 and 255)
  6024. * @param b defines the blue component to read from (value between 0 and 255)
  6025. * @param a defines the alpha component to read from (value between 0 and 255)
  6026. * @returns a new Color3 object
  6027. */
  6028. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6029. /**
  6030. * Check the content of a given array and convert it to an array containing RGBA data
  6031. * If the original array was already containing count * 4 values then it is returned directly
  6032. * @param colors defines the array to check
  6033. * @param count defines the number of RGBA data to expect
  6034. * @returns an array containing count * 4 values (RGBA)
  6035. */
  6036. static CheckColors4(colors: number[], count: number): number[];
  6037. }
  6038. /**
  6039. * @hidden
  6040. */
  6041. export class TmpColors {
  6042. static Color3: Color3[];
  6043. static Color4: Color4[];
  6044. }
  6045. }
  6046. declare module "babylonjs/Animations/animationKey" {
  6047. /**
  6048. * Defines an interface which represents an animation key frame
  6049. */
  6050. export interface IAnimationKey {
  6051. /**
  6052. * Frame of the key frame
  6053. */
  6054. frame: number;
  6055. /**
  6056. * Value at the specifies key frame
  6057. */
  6058. value: any;
  6059. /**
  6060. * The input tangent for the cubic hermite spline
  6061. */
  6062. inTangent?: any;
  6063. /**
  6064. * The output tangent for the cubic hermite spline
  6065. */
  6066. outTangent?: any;
  6067. /**
  6068. * The animation interpolation type
  6069. */
  6070. interpolation?: AnimationKeyInterpolation;
  6071. }
  6072. /**
  6073. * Enum for the animation key frame interpolation type
  6074. */
  6075. export enum AnimationKeyInterpolation {
  6076. /**
  6077. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6078. */
  6079. STEP = 1
  6080. }
  6081. }
  6082. declare module "babylonjs/Animations/animationRange" {
  6083. /**
  6084. * Represents the range of an animation
  6085. */
  6086. export class AnimationRange {
  6087. /**The name of the animation range**/
  6088. name: string;
  6089. /**The starting frame of the animation */
  6090. from: number;
  6091. /**The ending frame of the animation*/
  6092. to: number;
  6093. /**
  6094. * Initializes the range of an animation
  6095. * @param name The name of the animation range
  6096. * @param from The starting frame of the animation
  6097. * @param to The ending frame of the animation
  6098. */
  6099. constructor(
  6100. /**The name of the animation range**/
  6101. name: string,
  6102. /**The starting frame of the animation */
  6103. from: number,
  6104. /**The ending frame of the animation*/
  6105. to: number);
  6106. /**
  6107. * Makes a copy of the animation range
  6108. * @returns A copy of the animation range
  6109. */
  6110. clone(): AnimationRange;
  6111. }
  6112. }
  6113. declare module "babylonjs/Animations/animationEvent" {
  6114. /**
  6115. * Composed of a frame, and an action function
  6116. */
  6117. export class AnimationEvent {
  6118. /** The frame for which the event is triggered **/
  6119. frame: number;
  6120. /** The event to perform when triggered **/
  6121. action: (currentFrame: number) => void;
  6122. /** Specifies if the event should be triggered only once**/
  6123. onlyOnce?: boolean | undefined;
  6124. /**
  6125. * Specifies if the animation event is done
  6126. */
  6127. isDone: boolean;
  6128. /**
  6129. * Initializes the animation event
  6130. * @param frame The frame for which the event is triggered
  6131. * @param action The event to perform when triggered
  6132. * @param onlyOnce Specifies if the event should be triggered only once
  6133. */
  6134. constructor(
  6135. /** The frame for which the event is triggered **/
  6136. frame: number,
  6137. /** The event to perform when triggered **/
  6138. action: (currentFrame: number) => void,
  6139. /** Specifies if the event should be triggered only once**/
  6140. onlyOnce?: boolean | undefined);
  6141. /** @hidden */
  6142. _clone(): AnimationEvent;
  6143. }
  6144. }
  6145. declare module "babylonjs/Behaviors/behavior" {
  6146. import { Nullable } from "babylonjs/types";
  6147. /**
  6148. * Interface used to define a behavior
  6149. */
  6150. export interface Behavior<T> {
  6151. /** gets or sets behavior's name */
  6152. name: string;
  6153. /**
  6154. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6155. */
  6156. init(): void;
  6157. /**
  6158. * Called when the behavior is attached to a target
  6159. * @param target defines the target where the behavior is attached to
  6160. */
  6161. attach(target: T): void;
  6162. /**
  6163. * Called when the behavior is detached from its target
  6164. */
  6165. detach(): void;
  6166. }
  6167. /**
  6168. * Interface implemented by classes supporting behaviors
  6169. */
  6170. export interface IBehaviorAware<T> {
  6171. /**
  6172. * Attach a behavior
  6173. * @param behavior defines the behavior to attach
  6174. * @returns the current host
  6175. */
  6176. addBehavior(behavior: Behavior<T>): T;
  6177. /**
  6178. * Remove a behavior from the current object
  6179. * @param behavior defines the behavior to detach
  6180. * @returns the current host
  6181. */
  6182. removeBehavior(behavior: Behavior<T>): T;
  6183. /**
  6184. * Gets a behavior using its name to search
  6185. * @param name defines the name to search
  6186. * @returns the behavior or null if not found
  6187. */
  6188. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6189. }
  6190. }
  6191. declare module "babylonjs/Misc/smartArray" {
  6192. /**
  6193. * Defines an array and its length.
  6194. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6195. */
  6196. export interface ISmartArrayLike<T> {
  6197. /**
  6198. * The data of the array.
  6199. */
  6200. data: Array<T>;
  6201. /**
  6202. * The active length of the array.
  6203. */
  6204. length: number;
  6205. }
  6206. /**
  6207. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6208. */
  6209. export class SmartArray<T> implements ISmartArrayLike<T> {
  6210. /**
  6211. * The full set of data from the array.
  6212. */
  6213. data: Array<T>;
  6214. /**
  6215. * The active length of the array.
  6216. */
  6217. length: number;
  6218. protected _id: number;
  6219. /**
  6220. * Instantiates a Smart Array.
  6221. * @param capacity defines the default capacity of the array.
  6222. */
  6223. constructor(capacity: number);
  6224. /**
  6225. * Pushes a value at the end of the active data.
  6226. * @param value defines the object to push in the array.
  6227. */
  6228. push(value: T): void;
  6229. /**
  6230. * Iterates over the active data and apply the lambda to them.
  6231. * @param func defines the action to apply on each value.
  6232. */
  6233. forEach(func: (content: T) => void): void;
  6234. /**
  6235. * Sorts the full sets of data.
  6236. * @param compareFn defines the comparison function to apply.
  6237. */
  6238. sort(compareFn: (a: T, b: T) => number): void;
  6239. /**
  6240. * Resets the active data to an empty array.
  6241. */
  6242. reset(): void;
  6243. /**
  6244. * Releases all the data from the array as well as the array.
  6245. */
  6246. dispose(): void;
  6247. /**
  6248. * Concats the active data with a given array.
  6249. * @param array defines the data to concatenate with.
  6250. */
  6251. concat(array: any): void;
  6252. /**
  6253. * Returns the position of a value in the active data.
  6254. * @param value defines the value to find the index for
  6255. * @returns the index if found in the active data otherwise -1
  6256. */
  6257. indexOf(value: T): number;
  6258. /**
  6259. * Returns whether an element is part of the active data.
  6260. * @param value defines the value to look for
  6261. * @returns true if found in the active data otherwise false
  6262. */
  6263. contains(value: T): boolean;
  6264. private static _GlobalId;
  6265. }
  6266. /**
  6267. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6268. * The data in this array can only be present once
  6269. */
  6270. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6271. private _duplicateId;
  6272. /**
  6273. * Pushes a value at the end of the active data.
  6274. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6275. * @param value defines the object to push in the array.
  6276. */
  6277. push(value: T): void;
  6278. /**
  6279. * Pushes a value at the end of the active data.
  6280. * If the data is already present, it won t be added again
  6281. * @param value defines the object to push in the array.
  6282. * @returns true if added false if it was already present
  6283. */
  6284. pushNoDuplicate(value: T): boolean;
  6285. /**
  6286. * Resets the active data to an empty array.
  6287. */
  6288. reset(): void;
  6289. /**
  6290. * Concats the active data with a given array.
  6291. * This ensures no dupplicate will be present in the result.
  6292. * @param array defines the data to concatenate with.
  6293. */
  6294. concatWithNoDuplicate(array: any): void;
  6295. }
  6296. }
  6297. declare module "babylonjs/Cameras/cameraInputsManager" {
  6298. import { Nullable } from "babylonjs/types";
  6299. import { Camera } from "babylonjs/Cameras/camera";
  6300. /**
  6301. * @ignore
  6302. * This is a list of all the different input types that are available in the application.
  6303. * Fo instance: ArcRotateCameraGamepadInput...
  6304. */
  6305. export var CameraInputTypes: {};
  6306. /**
  6307. * This is the contract to implement in order to create a new input class.
  6308. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6309. */
  6310. export interface ICameraInput<TCamera extends Camera> {
  6311. /**
  6312. * Defines the camera the input is attached to.
  6313. */
  6314. camera: Nullable<TCamera>;
  6315. /**
  6316. * Gets the class name of the current intput.
  6317. * @returns the class name
  6318. */
  6319. getClassName(): string;
  6320. /**
  6321. * Get the friendly name associated with the input class.
  6322. * @returns the input friendly name
  6323. */
  6324. getSimpleName(): string;
  6325. /**
  6326. * Attach the input controls to a specific dom element to get the input from.
  6327. * @param element Defines the element the controls should be listened from
  6328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6329. */
  6330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6331. /**
  6332. * Detach the current controls from the specified dom element.
  6333. * @param element Defines the element to stop listening the inputs from
  6334. */
  6335. detachControl(element: Nullable<HTMLElement>): void;
  6336. /**
  6337. * Update the current camera state depending on the inputs that have been used this frame.
  6338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6339. */
  6340. checkInputs?: () => void;
  6341. }
  6342. /**
  6343. * Represents a map of input types to input instance or input index to input instance.
  6344. */
  6345. export interface CameraInputsMap<TCamera extends Camera> {
  6346. /**
  6347. * Accessor to the input by input type.
  6348. */
  6349. [name: string]: ICameraInput<TCamera>;
  6350. /**
  6351. * Accessor to the input by input index.
  6352. */
  6353. [idx: number]: ICameraInput<TCamera>;
  6354. }
  6355. /**
  6356. * This represents the input manager used within a camera.
  6357. * It helps dealing with all the different kind of input attached to a camera.
  6358. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6359. */
  6360. export class CameraInputsManager<TCamera extends Camera> {
  6361. /**
  6362. * Defines the list of inputs attahed to the camera.
  6363. */
  6364. attached: CameraInputsMap<TCamera>;
  6365. /**
  6366. * Defines the dom element the camera is collecting inputs from.
  6367. * This is null if the controls have not been attached.
  6368. */
  6369. attachedElement: Nullable<HTMLElement>;
  6370. /**
  6371. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. noPreventDefault: boolean;
  6374. /**
  6375. * Defined the camera the input manager belongs to.
  6376. */
  6377. camera: TCamera;
  6378. /**
  6379. * Update the current camera state depending on the inputs that have been used this frame.
  6380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6381. */
  6382. checkInputs: () => void;
  6383. /**
  6384. * Instantiate a new Camera Input Manager.
  6385. * @param camera Defines the camera the input manager blongs to
  6386. */
  6387. constructor(camera: TCamera);
  6388. /**
  6389. * Add an input method to a camera
  6390. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6391. * @param input camera input method
  6392. */
  6393. add(input: ICameraInput<TCamera>): void;
  6394. /**
  6395. * Remove a specific input method from a camera
  6396. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6397. * @param inputToRemove camera input method
  6398. */
  6399. remove(inputToRemove: ICameraInput<TCamera>): void;
  6400. /**
  6401. * Remove a specific input type from a camera
  6402. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6403. * @param inputType the type of the input to remove
  6404. */
  6405. removeByType(inputType: string): void;
  6406. private _addCheckInputs;
  6407. /**
  6408. * Attach the input controls to the currently attached dom element to listen the events from.
  6409. * @param input Defines the input to attach
  6410. */
  6411. attachInput(input: ICameraInput<TCamera>): void;
  6412. /**
  6413. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6414. * @param element Defines the dom element to collect the events from
  6415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6416. */
  6417. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6418. /**
  6419. * Detach the current manager inputs controls from a specific dom element.
  6420. * @param element Defines the dom element to collect the events from
  6421. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6422. */
  6423. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6424. /**
  6425. * Rebuild the dynamic inputCheck function from the current list of
  6426. * defined inputs in the manager.
  6427. */
  6428. rebuildInputCheck(): void;
  6429. /**
  6430. * Remove all attached input methods from a camera
  6431. */
  6432. clear(): void;
  6433. /**
  6434. * Serialize the current input manager attached to a camera.
  6435. * This ensures than once parsed,
  6436. * the input associated to the camera will be identical to the current ones
  6437. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6438. */
  6439. serialize(serializedCamera: any): void;
  6440. /**
  6441. * Parses an input manager serialized JSON to restore the previous list of inputs
  6442. * and states associated to a camera.
  6443. * @param parsedCamera Defines the JSON to parse
  6444. */
  6445. parse(parsedCamera: any): void;
  6446. }
  6447. }
  6448. declare module "babylonjs/Meshes/buffer" {
  6449. import { Nullable, DataArray } from "babylonjs/types";
  6450. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6451. /**
  6452. * Class used to store data that will be store in GPU memory
  6453. */
  6454. export class Buffer {
  6455. private _engine;
  6456. private _buffer;
  6457. /** @hidden */
  6458. _data: Nullable<DataArray>;
  6459. private _updatable;
  6460. private _instanced;
  6461. private _divisor;
  6462. /**
  6463. * Gets the byte stride.
  6464. */
  6465. readonly byteStride: number;
  6466. /**
  6467. * Constructor
  6468. * @param engine the engine
  6469. * @param data the data to use for this buffer
  6470. * @param updatable whether the data is updatable
  6471. * @param stride the stride (optional)
  6472. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6473. * @param instanced whether the buffer is instanced (optional)
  6474. * @param useBytes set to true if the stride in in bytes (optional)
  6475. * @param divisor sets an optional divisor for instances (1 by default)
  6476. */
  6477. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6478. /**
  6479. * Create a new VertexBuffer based on the current buffer
  6480. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6481. * @param offset defines offset in the buffer (0 by default)
  6482. * @param size defines the size in floats of attributes (position is 3 for instance)
  6483. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6484. * @param instanced defines if the vertex buffer contains indexed data
  6485. * @param useBytes defines if the offset and stride are in bytes *
  6486. * @param divisor sets an optional divisor for instances (1 by default)
  6487. * @returns the new vertex buffer
  6488. */
  6489. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6490. /**
  6491. * Gets a boolean indicating if the Buffer is updatable?
  6492. * @returns true if the buffer is updatable
  6493. */
  6494. isUpdatable(): boolean;
  6495. /**
  6496. * Gets current buffer's data
  6497. * @returns a DataArray or null
  6498. */
  6499. getData(): Nullable<DataArray>;
  6500. /**
  6501. * Gets underlying native buffer
  6502. * @returns underlying native buffer
  6503. */
  6504. getBuffer(): Nullable<DataBuffer>;
  6505. /**
  6506. * Gets the stride in float32 units (i.e. byte stride / 4).
  6507. * May not be an integer if the byte stride is not divisible by 4.
  6508. * @returns the stride in float32 units
  6509. * @deprecated Please use byteStride instead.
  6510. */
  6511. getStrideSize(): number;
  6512. /**
  6513. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6514. * @param data defines the data to store
  6515. */
  6516. create(data?: Nullable<DataArray>): void;
  6517. /** @hidden */
  6518. _rebuild(): void;
  6519. /**
  6520. * Update current buffer data
  6521. * @param data defines the data to store
  6522. */
  6523. update(data: DataArray): void;
  6524. /**
  6525. * Updates the data directly.
  6526. * @param data the new data
  6527. * @param offset the new offset
  6528. * @param vertexCount the vertex count (optional)
  6529. * @param useBytes set to true if the offset is in bytes
  6530. */
  6531. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6532. /**
  6533. * Release all resources
  6534. */
  6535. dispose(): void;
  6536. }
  6537. /**
  6538. * Specialized buffer used to store vertex data
  6539. */
  6540. export class VertexBuffer {
  6541. /** @hidden */
  6542. _buffer: Buffer;
  6543. private _kind;
  6544. private _size;
  6545. private _ownsBuffer;
  6546. private _instanced;
  6547. private _instanceDivisor;
  6548. /**
  6549. * The byte type.
  6550. */
  6551. static readonly BYTE: number;
  6552. /**
  6553. * The unsigned byte type.
  6554. */
  6555. static readonly UNSIGNED_BYTE: number;
  6556. /**
  6557. * The short type.
  6558. */
  6559. static readonly SHORT: number;
  6560. /**
  6561. * The unsigned short type.
  6562. */
  6563. static readonly UNSIGNED_SHORT: number;
  6564. /**
  6565. * The integer type.
  6566. */
  6567. static readonly INT: number;
  6568. /**
  6569. * The unsigned integer type.
  6570. */
  6571. static readonly UNSIGNED_INT: number;
  6572. /**
  6573. * The float type.
  6574. */
  6575. static readonly FLOAT: number;
  6576. /**
  6577. * Gets or sets the instance divisor when in instanced mode
  6578. */
  6579. get instanceDivisor(): number;
  6580. set instanceDivisor(value: number);
  6581. /**
  6582. * Gets the byte stride.
  6583. */
  6584. readonly byteStride: number;
  6585. /**
  6586. * Gets the byte offset.
  6587. */
  6588. readonly byteOffset: number;
  6589. /**
  6590. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6591. */
  6592. readonly normalized: boolean;
  6593. /**
  6594. * Gets the data type of each component in the array.
  6595. */
  6596. readonly type: number;
  6597. /**
  6598. * Constructor
  6599. * @param engine the engine
  6600. * @param data the data to use for this vertex buffer
  6601. * @param kind the vertex buffer kind
  6602. * @param updatable whether the data is updatable
  6603. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6604. * @param stride the stride (optional)
  6605. * @param instanced whether the buffer is instanced (optional)
  6606. * @param offset the offset of the data (optional)
  6607. * @param size the number of components (optional)
  6608. * @param type the type of the component (optional)
  6609. * @param normalized whether the data contains normalized data (optional)
  6610. * @param useBytes set to true if stride and offset are in bytes (optional)
  6611. * @param divisor defines the instance divisor to use (1 by default)
  6612. */
  6613. 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);
  6614. /** @hidden */
  6615. _rebuild(): void;
  6616. /**
  6617. * Returns the kind of the VertexBuffer (string)
  6618. * @returns a string
  6619. */
  6620. getKind(): string;
  6621. /**
  6622. * Gets a boolean indicating if the VertexBuffer is updatable?
  6623. * @returns true if the buffer is updatable
  6624. */
  6625. isUpdatable(): boolean;
  6626. /**
  6627. * Gets current buffer's data
  6628. * @returns a DataArray or null
  6629. */
  6630. getData(): Nullable<DataArray>;
  6631. /**
  6632. * Gets underlying native buffer
  6633. * @returns underlying native buffer
  6634. */
  6635. getBuffer(): Nullable<DataBuffer>;
  6636. /**
  6637. * Gets the stride in float32 units (i.e. byte stride / 4).
  6638. * May not be an integer if the byte stride is not divisible by 4.
  6639. * @returns the stride in float32 units
  6640. * @deprecated Please use byteStride instead.
  6641. */
  6642. getStrideSize(): number;
  6643. /**
  6644. * Returns the offset as a multiple of the type byte length.
  6645. * @returns the offset in bytes
  6646. * @deprecated Please use byteOffset instead.
  6647. */
  6648. getOffset(): number;
  6649. /**
  6650. * Returns the number of components per vertex attribute (integer)
  6651. * @returns the size in float
  6652. */
  6653. getSize(): number;
  6654. /**
  6655. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6656. * @returns true if this buffer is instanced
  6657. */
  6658. getIsInstanced(): boolean;
  6659. /**
  6660. * Returns the instancing divisor, zero for non-instanced (integer).
  6661. * @returns a number
  6662. */
  6663. getInstanceDivisor(): number;
  6664. /**
  6665. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6666. * @param data defines the data to store
  6667. */
  6668. create(data?: DataArray): void;
  6669. /**
  6670. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6671. * This function will create a new buffer if the current one is not updatable
  6672. * @param data defines the data to store
  6673. */
  6674. update(data: DataArray): void;
  6675. /**
  6676. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6677. * Returns the directly updated WebGLBuffer.
  6678. * @param data the new data
  6679. * @param offset the new offset
  6680. * @param useBytes set to true if the offset is in bytes
  6681. */
  6682. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6683. /**
  6684. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6685. */
  6686. dispose(): void;
  6687. /**
  6688. * Enumerates each value of this vertex buffer as numbers.
  6689. * @param count the number of values to enumerate
  6690. * @param callback the callback function called for each value
  6691. */
  6692. forEach(count: number, callback: (value: number, index: number) => void): void;
  6693. /**
  6694. * Positions
  6695. */
  6696. static readonly PositionKind: string;
  6697. /**
  6698. * Normals
  6699. */
  6700. static readonly NormalKind: string;
  6701. /**
  6702. * Tangents
  6703. */
  6704. static readonly TangentKind: string;
  6705. /**
  6706. * Texture coordinates
  6707. */
  6708. static readonly UVKind: string;
  6709. /**
  6710. * Texture coordinates 2
  6711. */
  6712. static readonly UV2Kind: string;
  6713. /**
  6714. * Texture coordinates 3
  6715. */
  6716. static readonly UV3Kind: string;
  6717. /**
  6718. * Texture coordinates 4
  6719. */
  6720. static readonly UV4Kind: string;
  6721. /**
  6722. * Texture coordinates 5
  6723. */
  6724. static readonly UV5Kind: string;
  6725. /**
  6726. * Texture coordinates 6
  6727. */
  6728. static readonly UV6Kind: string;
  6729. /**
  6730. * Colors
  6731. */
  6732. static readonly ColorKind: string;
  6733. /**
  6734. * Matrix indices (for bones)
  6735. */
  6736. static readonly MatricesIndicesKind: string;
  6737. /**
  6738. * Matrix weights (for bones)
  6739. */
  6740. static readonly MatricesWeightsKind: string;
  6741. /**
  6742. * Additional matrix indices (for bones)
  6743. */
  6744. static readonly MatricesIndicesExtraKind: string;
  6745. /**
  6746. * Additional matrix weights (for bones)
  6747. */
  6748. static readonly MatricesWeightsExtraKind: string;
  6749. /**
  6750. * Deduces the stride given a kind.
  6751. * @param kind The kind string to deduce
  6752. * @returns The deduced stride
  6753. */
  6754. static DeduceStride(kind: string): number;
  6755. /**
  6756. * Gets the byte length of the given type.
  6757. * @param type the type
  6758. * @returns the number of bytes
  6759. */
  6760. static GetTypeByteLength(type: number): number;
  6761. /**
  6762. * Enumerates each value of the given parameters as numbers.
  6763. * @param data the data to enumerate
  6764. * @param byteOffset the byte offset of the data
  6765. * @param byteStride the byte stride of the data
  6766. * @param componentCount the number of components per element
  6767. * @param componentType the type of the component
  6768. * @param count the number of values to enumerate
  6769. * @param normalized whether the data is normalized
  6770. * @param callback the callback function called for each value
  6771. */
  6772. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6773. private static _GetFloatValue;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/intersectionInfo" {
  6777. import { Nullable } from "babylonjs/types";
  6778. /**
  6779. * @hidden
  6780. */
  6781. export class IntersectionInfo {
  6782. bu: Nullable<number>;
  6783. bv: Nullable<number>;
  6784. distance: number;
  6785. faceId: number;
  6786. subMeshId: number;
  6787. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6788. }
  6789. }
  6790. declare module "babylonjs/Culling/boundingSphere" {
  6791. import { DeepImmutable } from "babylonjs/types";
  6792. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6793. import { Plane } from "babylonjs/Maths/math.plane";
  6794. /**
  6795. * Class used to store bounding sphere information
  6796. */
  6797. export class BoundingSphere {
  6798. /**
  6799. * Gets the center of the bounding sphere in local space
  6800. */
  6801. readonly center: Vector3;
  6802. /**
  6803. * Radius of the bounding sphere in local space
  6804. */
  6805. radius: number;
  6806. /**
  6807. * Gets the center of the bounding sphere in world space
  6808. */
  6809. readonly centerWorld: Vector3;
  6810. /**
  6811. * Radius of the bounding sphere in world space
  6812. */
  6813. radiusWorld: number;
  6814. /**
  6815. * Gets the minimum vector in local space
  6816. */
  6817. readonly minimum: Vector3;
  6818. /**
  6819. * Gets the maximum vector in local space
  6820. */
  6821. readonly maximum: Vector3;
  6822. private _worldMatrix;
  6823. private static readonly TmpVector3;
  6824. /**
  6825. * Creates a new bounding sphere
  6826. * @param min defines the minimum vector (in local space)
  6827. * @param max defines the maximum vector (in local space)
  6828. * @param worldMatrix defines the new world matrix
  6829. */
  6830. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6831. /**
  6832. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6833. * @param min defines the new minimum vector (in local space)
  6834. * @param max defines the new maximum vector (in local space)
  6835. * @param worldMatrix defines the new world matrix
  6836. */
  6837. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6838. /**
  6839. * Scale the current bounding sphere by applying a scale factor
  6840. * @param factor defines the scale factor to apply
  6841. * @returns the current bounding box
  6842. */
  6843. scale(factor: number): BoundingSphere;
  6844. /**
  6845. * Gets the world matrix of the bounding box
  6846. * @returns a matrix
  6847. */
  6848. getWorldMatrix(): DeepImmutable<Matrix>;
  6849. /** @hidden */
  6850. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6851. /**
  6852. * Tests if the bounding sphere is intersecting the frustum planes
  6853. * @param frustumPlanes defines the frustum planes to test
  6854. * @returns true if there is an intersection
  6855. */
  6856. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6857. /**
  6858. * Tests if the bounding sphere center is in between the frustum planes.
  6859. * Used for optimistic fast inclusion.
  6860. * @param frustumPlanes defines the frustum planes to test
  6861. * @returns true if the sphere center is in between the frustum planes
  6862. */
  6863. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6864. /**
  6865. * Tests if a point is inside the bounding sphere
  6866. * @param point defines the point to test
  6867. * @returns true if the point is inside the bounding sphere
  6868. */
  6869. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6870. /**
  6871. * Checks if two sphere intersct
  6872. * @param sphere0 sphere 0
  6873. * @param sphere1 sphere 1
  6874. * @returns true if the speres intersect
  6875. */
  6876. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6877. }
  6878. }
  6879. declare module "babylonjs/Culling/boundingBox" {
  6880. import { DeepImmutable } from "babylonjs/types";
  6881. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6882. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6883. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6884. import { Plane } from "babylonjs/Maths/math.plane";
  6885. /**
  6886. * Class used to store bounding box information
  6887. */
  6888. export class BoundingBox implements ICullable {
  6889. /**
  6890. * Gets the 8 vectors representing the bounding box in local space
  6891. */
  6892. readonly vectors: Vector3[];
  6893. /**
  6894. * Gets the center of the bounding box in local space
  6895. */
  6896. readonly center: Vector3;
  6897. /**
  6898. * Gets the center of the bounding box in world space
  6899. */
  6900. readonly centerWorld: Vector3;
  6901. /**
  6902. * Gets the extend size in local space
  6903. */
  6904. readonly extendSize: Vector3;
  6905. /**
  6906. * Gets the extend size in world space
  6907. */
  6908. readonly extendSizeWorld: Vector3;
  6909. /**
  6910. * Gets the OBB (object bounding box) directions
  6911. */
  6912. readonly directions: Vector3[];
  6913. /**
  6914. * Gets the 8 vectors representing the bounding box in world space
  6915. */
  6916. readonly vectorsWorld: Vector3[];
  6917. /**
  6918. * Gets the minimum vector in world space
  6919. */
  6920. readonly minimumWorld: Vector3;
  6921. /**
  6922. * Gets the maximum vector in world space
  6923. */
  6924. readonly maximumWorld: Vector3;
  6925. /**
  6926. * Gets the minimum vector in local space
  6927. */
  6928. readonly minimum: Vector3;
  6929. /**
  6930. * Gets the maximum vector in local space
  6931. */
  6932. readonly maximum: Vector3;
  6933. private _worldMatrix;
  6934. private static readonly TmpVector3;
  6935. /**
  6936. * @hidden
  6937. */
  6938. _tag: number;
  6939. /**
  6940. * Creates a new bounding box
  6941. * @param min defines the minimum vector (in local space)
  6942. * @param max defines the maximum vector (in local space)
  6943. * @param worldMatrix defines the new world matrix
  6944. */
  6945. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6946. /**
  6947. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6948. * @param min defines the new minimum vector (in local space)
  6949. * @param max defines the new maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6953. /**
  6954. * Scale the current bounding box by applying a scale factor
  6955. * @param factor defines the scale factor to apply
  6956. * @returns the current bounding box
  6957. */
  6958. scale(factor: number): BoundingBox;
  6959. /**
  6960. * Gets the world matrix of the bounding box
  6961. * @returns a matrix
  6962. */
  6963. getWorldMatrix(): DeepImmutable<Matrix>;
  6964. /** @hidden */
  6965. _update(world: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Tests if the bounding box is intersecting the frustum planes
  6968. * @param frustumPlanes defines the frustum planes to test
  6969. * @returns true if there is an intersection
  6970. */
  6971. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6972. /**
  6973. * Tests if the bounding box is entirely inside the frustum planes
  6974. * @param frustumPlanes defines the frustum planes to test
  6975. * @returns true if there is an inclusion
  6976. */
  6977. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6978. /**
  6979. * Tests if a point is inside the bounding box
  6980. * @param point defines the point to test
  6981. * @returns true if the point is inside the bounding box
  6982. */
  6983. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6984. /**
  6985. * Tests if the bounding box intersects with a bounding sphere
  6986. * @param sphere defines the sphere to test
  6987. * @returns true if there is an intersection
  6988. */
  6989. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6990. /**
  6991. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6992. * @param min defines the min vector to use
  6993. * @param max defines the max vector to use
  6994. * @returns true if there is an intersection
  6995. */
  6996. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6997. /**
  6998. * Tests if two bounding boxes are intersections
  6999. * @param box0 defines the first box to test
  7000. * @param box1 defines the second box to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7004. /**
  7005. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7006. * @param minPoint defines the minimum vector of the bounding box
  7007. * @param maxPoint defines the maximum vector of the bounding box
  7008. * @param sphereCenter defines the sphere center
  7009. * @param sphereRadius defines the sphere radius
  7010. * @returns true if there is an intersection
  7011. */
  7012. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7013. /**
  7014. * Tests if a bounding box defined with 8 vectors is entirely inside 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 inclusion
  7018. */
  7019. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7020. /**
  7021. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7022. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7023. * @param frustumPlanes defines the frustum planes to test
  7024. * @return true if there is an intersection
  7025. */
  7026. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7027. }
  7028. }
  7029. declare module "babylonjs/Collisions/collider" {
  7030. import { Nullable, IndicesArray } from "babylonjs/types";
  7031. import { Vector3 } from "babylonjs/Maths/math.vector";
  7032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7033. import { Plane } from "babylonjs/Maths/math.plane";
  7034. /** @hidden */
  7035. export class Collider {
  7036. /** Define if a collision was found */
  7037. collisionFound: boolean;
  7038. /**
  7039. * Define last intersection point in local space
  7040. */
  7041. intersectionPoint: Vector3;
  7042. /**
  7043. * Define last collided mesh
  7044. */
  7045. collidedMesh: Nullable<AbstractMesh>;
  7046. private _collisionPoint;
  7047. private _planeIntersectionPoint;
  7048. private _tempVector;
  7049. private _tempVector2;
  7050. private _tempVector3;
  7051. private _tempVector4;
  7052. private _edge;
  7053. private _baseToVertex;
  7054. private _destinationPoint;
  7055. private _slidePlaneNormal;
  7056. private _displacementVector;
  7057. /** @hidden */
  7058. _radius: Vector3;
  7059. /** @hidden */
  7060. _retry: number;
  7061. private _velocity;
  7062. private _basePoint;
  7063. private _epsilon;
  7064. /** @hidden */
  7065. _velocityWorldLength: number;
  7066. /** @hidden */
  7067. _basePointWorld: Vector3;
  7068. private _velocityWorld;
  7069. private _normalizedVelocity;
  7070. /** @hidden */
  7071. _initialVelocity: Vector3;
  7072. /** @hidden */
  7073. _initialPosition: Vector3;
  7074. private _nearestDistance;
  7075. private _collisionMask;
  7076. get collisionMask(): number;
  7077. set collisionMask(mask: number);
  7078. /**
  7079. * Gets the plane normal used to compute the sliding response (in local space)
  7080. */
  7081. get slidePlaneNormal(): Vector3;
  7082. /** @hidden */
  7083. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7084. /** @hidden */
  7085. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7086. /** @hidden */
  7087. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7088. /** @hidden */
  7089. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7090. /** @hidden */
  7091. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7092. /** @hidden */
  7093. _getResponse(pos: Vector3, vel: Vector3): void;
  7094. }
  7095. }
  7096. declare module "babylonjs/Culling/boundingInfo" {
  7097. import { DeepImmutable } from "babylonjs/types";
  7098. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7099. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7100. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7101. import { Plane } from "babylonjs/Maths/math.plane";
  7102. import { Collider } from "babylonjs/Collisions/collider";
  7103. /**
  7104. * Interface for cullable objects
  7105. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7106. */
  7107. export interface ICullable {
  7108. /**
  7109. * Checks if the object or part of the object is in the frustum
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isInFrustum(frustumPlanes: Plane[]): boolean;
  7114. /**
  7115. * Checks if a cullable object (mesh...) is in the camera frustum
  7116. * Unlike isInFrustum this cheks the full bounding box
  7117. * @param frustumPlanes Camera near/planes
  7118. * @returns true if the object is in frustum otherwise false
  7119. */
  7120. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7121. }
  7122. /**
  7123. * Info for a bounding data of a mesh
  7124. */
  7125. export class BoundingInfo implements ICullable {
  7126. /**
  7127. * Bounding box for the mesh
  7128. */
  7129. readonly boundingBox: BoundingBox;
  7130. /**
  7131. * Bounding sphere for the mesh
  7132. */
  7133. readonly boundingSphere: BoundingSphere;
  7134. private _isLocked;
  7135. private static readonly TmpVector3;
  7136. /**
  7137. * Constructs bounding info
  7138. * @param minimum min vector of the bounding box/sphere
  7139. * @param maximum max vector of the bounding box/sphere
  7140. * @param worldMatrix defines the new world matrix
  7141. */
  7142. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7143. /**
  7144. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7145. * @param min defines the new minimum vector (in local space)
  7146. * @param max defines the new maximum vector (in local space)
  7147. * @param worldMatrix defines the new world matrix
  7148. */
  7149. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7150. /**
  7151. * min vector of the bounding box/sphere
  7152. */
  7153. get minimum(): Vector3;
  7154. /**
  7155. * max vector of the bounding box/sphere
  7156. */
  7157. get maximum(): Vector3;
  7158. /**
  7159. * If the info is locked and won't be updated to avoid perf overhead
  7160. */
  7161. get isLocked(): boolean;
  7162. set isLocked(value: boolean);
  7163. /**
  7164. * Updates the bounding sphere and box
  7165. * @param world world matrix to be used to update
  7166. */
  7167. update(world: DeepImmutable<Matrix>): void;
  7168. /**
  7169. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7170. * @param center New center of the bounding info
  7171. * @param extend New extend of the bounding info
  7172. * @returns the current bounding info
  7173. */
  7174. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7175. /**
  7176. * Scale the current bounding info by applying a scale factor
  7177. * @param factor defines the scale factor to apply
  7178. * @returns the current bounding info
  7179. */
  7180. scale(factor: number): BoundingInfo;
  7181. /**
  7182. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7183. * @param frustumPlanes defines the frustum to test
  7184. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7185. * @returns true if the bounding info is in the frustum planes
  7186. */
  7187. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7188. /**
  7189. * Gets the world distance between the min and max points of the bounding box
  7190. */
  7191. get diagonalLength(): number;
  7192. /**
  7193. * Checks if a cullable object (mesh...) is in the camera frustum
  7194. * Unlike isInFrustum this cheks the full bounding box
  7195. * @param frustumPlanes Camera near/planes
  7196. * @returns true if the object is in frustum otherwise false
  7197. */
  7198. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7199. /** @hidden */
  7200. _checkCollision(collider: Collider): boolean;
  7201. /**
  7202. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7203. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7204. * @param point the point to check intersection with
  7205. * @returns if the point intersects
  7206. */
  7207. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7208. /**
  7209. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7210. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7211. * @param boundingInfo the bounding info to check intersection with
  7212. * @param precise if the intersection should be done using OBB
  7213. * @returns if the bounding info intersects
  7214. */
  7215. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7216. }
  7217. }
  7218. declare module "babylonjs/Maths/math.functions" {
  7219. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7220. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7221. /**
  7222. * Extracts minimum and maximum values from a list of indexed positions
  7223. * @param positions defines the positions to use
  7224. * @param indices defines the indices to the positions
  7225. * @param indexStart defines the start index
  7226. * @param indexCount defines the end index
  7227. * @param bias defines bias value to add to the result
  7228. * @return minimum and maximum values
  7229. */
  7230. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7231. minimum: Vector3;
  7232. maximum: Vector3;
  7233. };
  7234. /**
  7235. * Extracts minimum and maximum values from a list of positions
  7236. * @param positions defines the positions to use
  7237. * @param start defines the start index in the positions array
  7238. * @param count defines the number of positions to handle
  7239. * @param bias defines bias value to add to the result
  7240. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7241. * @return minimum and maximum values
  7242. */
  7243. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7244. minimum: Vector3;
  7245. maximum: Vector3;
  7246. };
  7247. }
  7248. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7249. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7250. /** @hidden */
  7251. export class WebGLDataBuffer extends DataBuffer {
  7252. private _buffer;
  7253. constructor(resource: WebGLBuffer);
  7254. get underlyingResource(): any;
  7255. }
  7256. }
  7257. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7258. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7259. import { Nullable } from "babylonjs/types";
  7260. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7261. /** @hidden */
  7262. export class WebGLPipelineContext implements IPipelineContext {
  7263. engine: ThinEngine;
  7264. program: Nullable<WebGLProgram>;
  7265. context?: WebGLRenderingContext;
  7266. vertexShader?: WebGLShader;
  7267. fragmentShader?: WebGLShader;
  7268. isParallelCompiled: boolean;
  7269. onCompiled?: () => void;
  7270. transformFeedback?: WebGLTransformFeedback | null;
  7271. vertexCompilationError: Nullable<string>;
  7272. fragmentCompilationError: Nullable<string>;
  7273. programLinkError: Nullable<string>;
  7274. programValidationError: Nullable<string>;
  7275. get isAsync(): boolean;
  7276. get isReady(): boolean;
  7277. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7278. _getVertexShaderCode(): string | null;
  7279. _getFragmentShaderCode(): string | null;
  7280. }
  7281. }
  7282. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7283. import { FloatArray, Nullable } from "babylonjs/types";
  7284. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7285. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7286. module "babylonjs/Engines/thinEngine" {
  7287. interface ThinEngine {
  7288. /**
  7289. * Create an 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. createUniformBuffer(elements: FloatArray): DataBuffer;
  7295. /**
  7296. * Create a dynamic uniform buffer
  7297. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7298. * @param elements defines the content of the uniform buffer
  7299. * @returns the webGL uniform buffer
  7300. */
  7301. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7302. /**
  7303. * Update an existing uniform buffer
  7304. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7305. * @param uniformBuffer defines the target uniform buffer
  7306. * @param elements defines the content to update
  7307. * @param offset defines the offset in the uniform buffer where update should start
  7308. * @param count defines the size of the data to update
  7309. */
  7310. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7311. /**
  7312. * Bind an uniform buffer to the current webGL context
  7313. * @param buffer defines the buffer to bind
  7314. */
  7315. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7316. /**
  7317. * Bind a buffer to the current webGL context at a given location
  7318. * @param buffer defines the buffer to bind
  7319. * @param location defines the index where to bind the buffer
  7320. */
  7321. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7322. /**
  7323. * Bind a specific block at a given index in a specific shader program
  7324. * @param pipelineContext defines the pipeline context to use
  7325. * @param blockName defines the block name
  7326. * @param index defines the index where to bind the block
  7327. */
  7328. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7329. }
  7330. }
  7331. }
  7332. declare module "babylonjs/Materials/uniformBuffer" {
  7333. import { Nullable, FloatArray } from "babylonjs/types";
  7334. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7335. import { Engine } from "babylonjs/Engines/engine";
  7336. import { Effect } from "babylonjs/Materials/effect";
  7337. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7338. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7339. import { Color3 } from "babylonjs/Maths/math.color";
  7340. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7341. /**
  7342. * Uniform buffer objects.
  7343. *
  7344. * Handles blocks of uniform on the GPU.
  7345. *
  7346. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7347. *
  7348. * For more information, please refer to :
  7349. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7350. */
  7351. export class UniformBuffer {
  7352. private _engine;
  7353. private _buffer;
  7354. private _data;
  7355. private _bufferData;
  7356. private _dynamic?;
  7357. private _uniformLocations;
  7358. private _uniformSizes;
  7359. private _uniformLocationPointer;
  7360. private _needSync;
  7361. private _noUBO;
  7362. private _currentEffect;
  7363. /** @hidden */
  7364. _alreadyBound: boolean;
  7365. private static _MAX_UNIFORM_SIZE;
  7366. private static _tempBuffer;
  7367. /**
  7368. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7373. /**
  7374. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7379. /**
  7380. * Lambda to Update a single float in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateFloat: (name: string, x: number) => void;
  7385. /**
  7386. * Lambda to Update a vec2 of float in a uniform buffer.
  7387. * This is dynamic to allow compat with webgl 1 and 2.
  7388. * You will need to pass the name of the uniform as well as the value.
  7389. */
  7390. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7391. /**
  7392. * Lambda to Update a vec3 of float in a uniform buffer.
  7393. * This is dynamic to allow compat with webgl 1 and 2.
  7394. * You will need to pass the name of the uniform as well as the value.
  7395. */
  7396. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7397. /**
  7398. * Lambda to Update a vec4 of float in a uniform buffer.
  7399. * This is dynamic to allow compat with webgl 1 and 2.
  7400. * You will need to pass the name of the uniform as well as the value.
  7401. */
  7402. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7403. /**
  7404. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7405. * This is dynamic to allow compat with webgl 1 and 2.
  7406. * You will need to pass the name of the uniform as well as the value.
  7407. */
  7408. updateMatrix: (name: string, mat: Matrix) => void;
  7409. /**
  7410. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7411. * This is dynamic to allow compat with webgl 1 and 2.
  7412. * You will need to pass the name of the uniform as well as the value.
  7413. */
  7414. updateVector3: (name: string, vector: Vector3) => void;
  7415. /**
  7416. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7417. * This is dynamic to allow compat with webgl 1 and 2.
  7418. * You will need to pass the name of the uniform as well as the value.
  7419. */
  7420. updateVector4: (name: string, vector: Vector4) => void;
  7421. /**
  7422. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7423. * This is dynamic to allow compat with webgl 1 and 2.
  7424. * You will need to pass the name of the uniform as well as the value.
  7425. */
  7426. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7427. /**
  7428. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7429. * This is dynamic to allow compat with webgl 1 and 2.
  7430. * You will need to pass the name of the uniform as well as the value.
  7431. */
  7432. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7433. /**
  7434. * Instantiates a new Uniform buffer objects.
  7435. *
  7436. * Handles blocks of uniform on the GPU.
  7437. *
  7438. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7439. *
  7440. * For more information, please refer to :
  7441. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7442. * @param engine Define the engine the buffer is associated with
  7443. * @param data Define the data contained in the buffer
  7444. * @param dynamic Define if the buffer is updatable
  7445. */
  7446. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7447. /**
  7448. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7449. * or just falling back on setUniformXXX calls.
  7450. */
  7451. get useUbo(): boolean;
  7452. /**
  7453. * Indicates if the WebGL underlying uniform buffer is in sync
  7454. * with the javascript cache data.
  7455. */
  7456. get isSync(): boolean;
  7457. /**
  7458. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7459. * Also, a dynamic UniformBuffer will disable cache verification and always
  7460. * update the underlying WebGL uniform buffer to the GPU.
  7461. * @returns if Dynamic, otherwise false
  7462. */
  7463. isDynamic(): boolean;
  7464. /**
  7465. * The data cache on JS side.
  7466. * @returns the underlying data as a float array
  7467. */
  7468. getData(): Float32Array;
  7469. /**
  7470. * The underlying WebGL Uniform buffer.
  7471. * @returns the webgl buffer
  7472. */
  7473. getBuffer(): Nullable<DataBuffer>;
  7474. /**
  7475. * std140 layout specifies how to align data within an UBO structure.
  7476. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7477. * for specs.
  7478. */
  7479. private _fillAlignment;
  7480. /**
  7481. * Adds an uniform in the buffer.
  7482. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7483. * for the layout to be correct !
  7484. * @param name Name of the uniform, as used in the uniform block in the shader.
  7485. * @param size Data size, or data directly.
  7486. */
  7487. addUniform(name: string, size: number | number[]): void;
  7488. /**
  7489. * Adds a Matrix 4x4 to the uniform buffer.
  7490. * @param name Name of the uniform, as used in the uniform block in the shader.
  7491. * @param mat A 4x4 matrix.
  7492. */
  7493. addMatrix(name: string, mat: Matrix): void;
  7494. /**
  7495. * Adds a vec2 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 vec2
  7498. * @param y Define the y component value of the vec2
  7499. */
  7500. addFloat2(name: string, x: number, y: number): void;
  7501. /**
  7502. * Adds a vec3 to the uniform buffer.
  7503. * @param name Name of the uniform, as used in the uniform block in the shader.
  7504. * @param x Define the x component value of the vec3
  7505. * @param y Define the y component value of the vec3
  7506. * @param z Define the z component value of the vec3
  7507. */
  7508. addFloat3(name: string, x: number, y: number, z: number): void;
  7509. /**
  7510. * Adds a vec3 to the uniform buffer.
  7511. * @param name Name of the uniform, as used in the uniform block in the shader.
  7512. * @param color Define the vec3 from a Color
  7513. */
  7514. addColor3(name: string, color: Color3): void;
  7515. /**
  7516. * Adds a vec4 to the uniform buffer.
  7517. * @param name Name of the uniform, as used in the uniform block in the shader.
  7518. * @param color Define the rgb components from a Color
  7519. * @param alpha Define the a component of the vec4
  7520. */
  7521. addColor4(name: string, color: Color3, alpha: number): void;
  7522. /**
  7523. * Adds a vec3 to the uniform buffer.
  7524. * @param name Name of the uniform, as used in the uniform block in the shader.
  7525. * @param vector Define the vec3 components from a Vector
  7526. */
  7527. addVector3(name: string, vector: Vector3): void;
  7528. /**
  7529. * Adds a Matrix 3x3 to the uniform buffer.
  7530. * @param name Name of the uniform, as used in the uniform block in the shader.
  7531. */
  7532. addMatrix3x3(name: string): void;
  7533. /**
  7534. * Adds a Matrix 2x2 to the uniform buffer.
  7535. * @param name Name of the uniform, as used in the uniform block in the shader.
  7536. */
  7537. addMatrix2x2(name: string): void;
  7538. /**
  7539. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7540. */
  7541. create(): void;
  7542. /** @hidden */
  7543. _rebuild(): void;
  7544. /**
  7545. * Updates the WebGL Uniform Buffer on the GPU.
  7546. * If the `dynamic` flag is set to true, no cache comparison is done.
  7547. * Otherwise, the buffer will be updated only if the cache differs.
  7548. */
  7549. update(): void;
  7550. /**
  7551. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7552. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7553. * @param data Define the flattened data
  7554. * @param size Define the size of the data.
  7555. */
  7556. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7557. private _valueCache;
  7558. private _cacheMatrix;
  7559. private _updateMatrix3x3ForUniform;
  7560. private _updateMatrix3x3ForEffect;
  7561. private _updateMatrix2x2ForEffect;
  7562. private _updateMatrix2x2ForUniform;
  7563. private _updateFloatForEffect;
  7564. private _updateFloatForUniform;
  7565. private _updateFloat2ForEffect;
  7566. private _updateFloat2ForUniform;
  7567. private _updateFloat3ForEffect;
  7568. private _updateFloat3ForUniform;
  7569. private _updateFloat4ForEffect;
  7570. private _updateFloat4ForUniform;
  7571. private _updateMatrixForEffect;
  7572. private _updateMatrixForUniform;
  7573. private _updateVector3ForEffect;
  7574. private _updateVector3ForUniform;
  7575. private _updateVector4ForEffect;
  7576. private _updateVector4ForUniform;
  7577. private _updateColor3ForEffect;
  7578. private _updateColor3ForUniform;
  7579. private _updateColor4ForEffect;
  7580. private _updateColor4ForUniform;
  7581. /**
  7582. * Sets a sampler uniform on the effect.
  7583. * @param name Define the name of the sampler.
  7584. * @param texture Define the texture to set in the sampler
  7585. */
  7586. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7587. /**
  7588. * Directly updates the value of the uniform in the cache AND on the GPU.
  7589. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7590. * @param data Define the flattened data
  7591. */
  7592. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7593. /**
  7594. * Binds this uniform buffer to an effect.
  7595. * @param effect Define the effect to bind the buffer to
  7596. * @param name Name of the uniform block in the shader.
  7597. */
  7598. bindToEffect(effect: Effect, name: string): void;
  7599. /**
  7600. * Disposes the uniform buffer.
  7601. */
  7602. dispose(): void;
  7603. }
  7604. }
  7605. declare module "babylonjs/Misc/iInspectable" {
  7606. /**
  7607. * Enum that determines the text-wrapping mode to use.
  7608. */
  7609. export enum InspectableType {
  7610. /**
  7611. * Checkbox for booleans
  7612. */
  7613. Checkbox = 0,
  7614. /**
  7615. * Sliders for numbers
  7616. */
  7617. Slider = 1,
  7618. /**
  7619. * Vector3
  7620. */
  7621. Vector3 = 2,
  7622. /**
  7623. * Quaternions
  7624. */
  7625. Quaternion = 3,
  7626. /**
  7627. * Color3
  7628. */
  7629. Color3 = 4,
  7630. /**
  7631. * String
  7632. */
  7633. String = 5
  7634. }
  7635. /**
  7636. * Interface used to define custom inspectable properties.
  7637. * This interface is used by the inspector to display custom property grids
  7638. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7639. */
  7640. export interface IInspectable {
  7641. /**
  7642. * Gets the label to display
  7643. */
  7644. label: string;
  7645. /**
  7646. * Gets the name of the property to edit
  7647. */
  7648. propertyName: string;
  7649. /**
  7650. * Gets the type of the editor to use
  7651. */
  7652. type: InspectableType;
  7653. /**
  7654. * Gets the minimum value of the property when using in "slider" mode
  7655. */
  7656. min?: number;
  7657. /**
  7658. * Gets the maximum value of the property when using in "slider" mode
  7659. */
  7660. max?: number;
  7661. /**
  7662. * Gets the setp to use when using in "slider" mode
  7663. */
  7664. step?: number;
  7665. }
  7666. }
  7667. declare module "babylonjs/Misc/timingTools" {
  7668. /**
  7669. * Class used to provide helper for timing
  7670. */
  7671. export class TimingTools {
  7672. /**
  7673. * Polyfill for setImmediate
  7674. * @param action defines the action to execute after the current execution block
  7675. */
  7676. static SetImmediate(action: () => void): void;
  7677. }
  7678. }
  7679. declare module "babylonjs/Misc/instantiationTools" {
  7680. /**
  7681. * Class used to enable instatition of objects by class name
  7682. */
  7683. export class InstantiationTools {
  7684. /**
  7685. * Use this object to register external classes like custom textures or material
  7686. * to allow the laoders to instantiate them
  7687. */
  7688. static RegisteredExternalClasses: {
  7689. [key: string]: Object;
  7690. };
  7691. /**
  7692. * Tries to instantiate a new object from a given class name
  7693. * @param className defines the class name to instantiate
  7694. * @returns the new object or null if the system was not able to do the instantiation
  7695. */
  7696. static Instantiate(className: string): any;
  7697. }
  7698. }
  7699. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7700. /**
  7701. * Define options used to create a depth texture
  7702. */
  7703. export class DepthTextureCreationOptions {
  7704. /** Specifies whether or not a stencil should be allocated in the texture */
  7705. generateStencil?: boolean;
  7706. /** Specifies whether or not bilinear filtering is enable on the texture */
  7707. bilinearFiltering?: boolean;
  7708. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7709. comparisonFunction?: number;
  7710. /** Specifies if the created texture is a cube texture */
  7711. isCube?: boolean;
  7712. }
  7713. }
  7714. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7715. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7716. import { Nullable } from "babylonjs/types";
  7717. import { Scene } from "babylonjs/scene";
  7718. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7719. module "babylonjs/Engines/thinEngine" {
  7720. interface ThinEngine {
  7721. /**
  7722. * Creates a depth stencil cube texture.
  7723. * This is only available in WebGL 2.
  7724. * @param size The size of face edge in the cube texture.
  7725. * @param options The options defining the cube texture.
  7726. * @returns The cube texture
  7727. */
  7728. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7729. /**
  7730. * Creates a cube texture
  7731. * @param rootUrl defines the url where the files to load is located
  7732. * @param scene defines the current scene
  7733. * @param files defines the list of files to load (1 per face)
  7734. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7735. * @param onLoad defines an optional callback raised when the texture is loaded
  7736. * @param onError defines an optional callback raised if there is an issue to load the texture
  7737. * @param format defines the format of the data
  7738. * @param forcedExtension defines the extension to use to pick the right loader
  7739. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7740. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7741. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7742. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7743. * @returns the cube texture as an InternalTexture
  7744. */
  7745. 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;
  7746. /**
  7747. * Creates a cube texture
  7748. * @param rootUrl defines the url where the files to load is located
  7749. * @param scene defines the current scene
  7750. * @param files defines the list of files to load (1 per face)
  7751. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7752. * @param onLoad defines an optional callback raised when the texture is loaded
  7753. * @param onError defines an optional callback raised if there is an issue to load the texture
  7754. * @param format defines the format of the data
  7755. * @param forcedExtension defines the extension to use to pick the right loader
  7756. * @returns the cube texture as an InternalTexture
  7757. */
  7758. 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;
  7759. /**
  7760. * Creates a cube texture
  7761. * @param rootUrl defines the url where the files to load is located
  7762. * @param scene defines the current scene
  7763. * @param files defines the list of files to load (1 per face)
  7764. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7765. * @param onLoad defines an optional callback raised when the texture is loaded
  7766. * @param onError defines an optional callback raised if there is an issue to load the texture
  7767. * @param format defines the format of the data
  7768. * @param forcedExtension defines the extension to use to pick the right loader
  7769. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7770. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7771. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7772. * @returns the cube texture as an InternalTexture
  7773. */
  7774. 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;
  7775. /** @hidden */
  7776. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7779. /** @hidden */
  7780. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /** @hidden */
  7782. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7783. /**
  7784. * @hidden
  7785. */
  7786. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7787. }
  7788. }
  7789. }
  7790. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7791. import { Nullable } from "babylonjs/types";
  7792. import { Scene } from "babylonjs/scene";
  7793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7795. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7796. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7797. import { Observable } from "babylonjs/Misc/observable";
  7798. /**
  7799. * Class for creating a cube texture
  7800. */
  7801. export class CubeTexture extends BaseTexture {
  7802. private _delayedOnLoad;
  7803. /**
  7804. * Observable triggered once the texture has been loaded.
  7805. */
  7806. onLoadObservable: Observable<CubeTexture>;
  7807. /**
  7808. * The url of the texture
  7809. */
  7810. url: string;
  7811. /**
  7812. * Gets or sets the center of the bounding box associated with the cube texture.
  7813. * It must define where the camera used to render the texture was set
  7814. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7815. */
  7816. boundingBoxPosition: Vector3;
  7817. private _boundingBoxSize;
  7818. /**
  7819. * Gets or sets the size of the bounding box associated with the cube texture
  7820. * When defined, the cubemap will switch to local mode
  7821. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7822. * @example https://www.babylonjs-playground.com/#RNASML
  7823. */
  7824. set boundingBoxSize(value: Vector3);
  7825. /**
  7826. * Returns the bounding box size
  7827. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7828. */
  7829. get boundingBoxSize(): Vector3;
  7830. protected _rotationY: number;
  7831. /**
  7832. * Sets texture matrix rotation angle around Y axis in radians.
  7833. */
  7834. set rotationY(value: number);
  7835. /**
  7836. * Gets texture matrix rotation angle around Y axis radians.
  7837. */
  7838. get rotationY(): number;
  7839. /**
  7840. * Are mip maps generated for this texture or not.
  7841. */
  7842. get noMipmap(): boolean;
  7843. private _noMipmap;
  7844. private _files;
  7845. protected _forcedExtension: Nullable<string>;
  7846. private _extensions;
  7847. private _textureMatrix;
  7848. private _format;
  7849. private _createPolynomials;
  7850. /**
  7851. * Creates a cube texture from an array of image urls
  7852. * @param files defines an array of image urls
  7853. * @param scene defines the hosting scene
  7854. * @param noMipmap specifies if mip maps are not used
  7855. * @returns a cube texture
  7856. */
  7857. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7858. /**
  7859. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7860. * @param url defines the url of the prefiltered texture
  7861. * @param scene defines the scene the texture is attached to
  7862. * @param forcedExtension defines the extension of the file if different from the url
  7863. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7864. * @return the prefiltered texture
  7865. */
  7866. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7867. /**
  7868. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7869. * as prefiltered data.
  7870. * @param rootUrl defines the url of the texture or the root name of the six images
  7871. * @param null defines the scene or engine the texture is attached to
  7872. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7873. * @param noMipmap defines if mipmaps should be created or not
  7874. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7875. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7876. * @param onError defines a callback triggered in case of error during load
  7877. * @param format defines the internal format to use for the texture once loaded
  7878. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7879. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7880. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7881. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7882. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7883. * @return the cube texture
  7884. */
  7885. 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);
  7886. /**
  7887. * Get the current class name of the texture useful for serialization or dynamic coding.
  7888. * @returns "CubeTexture"
  7889. */
  7890. getClassName(): string;
  7891. /**
  7892. * Update the url (and optional buffer) of this texture if url was null during construction.
  7893. * @param url the url of the texture
  7894. * @param forcedExtension defines the extension to use
  7895. * @param onLoad callback called when the texture is loaded (defaults to null)
  7896. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7897. */
  7898. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7899. /**
  7900. * Delays loading of the cube texture
  7901. * @param forcedExtension defines the extension to use
  7902. */
  7903. delayLoad(forcedExtension?: string): void;
  7904. /**
  7905. * Returns the reflection texture matrix
  7906. * @returns the reflection texture matrix
  7907. */
  7908. getReflectionTextureMatrix(): Matrix;
  7909. /**
  7910. * Sets the reflection texture matrix
  7911. * @param value Reflection texture matrix
  7912. */
  7913. setReflectionTextureMatrix(value: Matrix): void;
  7914. /**
  7915. * Parses text to create a cube texture
  7916. * @param parsedTexture define the serialized text to read from
  7917. * @param scene defines the hosting scene
  7918. * @param rootUrl defines the root url of the cube texture
  7919. * @returns a cube texture
  7920. */
  7921. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7922. /**
  7923. * Makes a clone, or deep copy, of the cube texture
  7924. * @returns a new cube texture
  7925. */
  7926. clone(): CubeTexture;
  7927. }
  7928. }
  7929. declare module "babylonjs/Materials/materialDefines" {
  7930. /**
  7931. * Manages the defines for the Material
  7932. */
  7933. export class MaterialDefines {
  7934. /** @hidden */
  7935. protected _keys: string[];
  7936. private _isDirty;
  7937. /** @hidden */
  7938. _renderId: number;
  7939. /** @hidden */
  7940. _areLightsDirty: boolean;
  7941. /** @hidden */
  7942. _areLightsDisposed: boolean;
  7943. /** @hidden */
  7944. _areAttributesDirty: boolean;
  7945. /** @hidden */
  7946. _areTexturesDirty: boolean;
  7947. /** @hidden */
  7948. _areFresnelDirty: boolean;
  7949. /** @hidden */
  7950. _areMiscDirty: boolean;
  7951. /** @hidden */
  7952. _areImageProcessingDirty: boolean;
  7953. /** @hidden */
  7954. _normals: boolean;
  7955. /** @hidden */
  7956. _uvs: boolean;
  7957. /** @hidden */
  7958. _needNormals: boolean;
  7959. /** @hidden */
  7960. _needUVs: boolean;
  7961. [id: string]: any;
  7962. /**
  7963. * Specifies if the material needs to be re-calculated
  7964. */
  7965. get isDirty(): boolean;
  7966. /**
  7967. * Marks the material to indicate that it has been re-calculated
  7968. */
  7969. markAsProcessed(): void;
  7970. /**
  7971. * Marks the material to indicate that it needs to be re-calculated
  7972. */
  7973. markAsUnprocessed(): void;
  7974. /**
  7975. * Marks the material to indicate all of its defines need to be re-calculated
  7976. */
  7977. markAllAsDirty(): void;
  7978. /**
  7979. * Marks the material to indicate that image processing needs to be re-calculated
  7980. */
  7981. markAsImageProcessingDirty(): void;
  7982. /**
  7983. * Marks the material to indicate the lights need to be re-calculated
  7984. * @param disposed Defines whether the light is dirty due to dispose or not
  7985. */
  7986. markAsLightDirty(disposed?: boolean): void;
  7987. /**
  7988. * Marks the attribute state as changed
  7989. */
  7990. markAsAttributesDirty(): void;
  7991. /**
  7992. * Marks the texture state as changed
  7993. */
  7994. markAsTexturesDirty(): void;
  7995. /**
  7996. * Marks the fresnel state as changed
  7997. */
  7998. markAsFresnelDirty(): void;
  7999. /**
  8000. * Marks the misc state as changed
  8001. */
  8002. markAsMiscDirty(): void;
  8003. /**
  8004. * Rebuilds the material defines
  8005. */
  8006. rebuild(): void;
  8007. /**
  8008. * Specifies if two material defines are equal
  8009. * @param other - A material define instance to compare to
  8010. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8011. */
  8012. isEqual(other: MaterialDefines): boolean;
  8013. /**
  8014. * Clones this instance's defines to another instance
  8015. * @param other - material defines to clone values to
  8016. */
  8017. cloneTo(other: MaterialDefines): void;
  8018. /**
  8019. * Resets the material define values
  8020. */
  8021. reset(): void;
  8022. /**
  8023. * Converts the material define values to a string
  8024. * @returns - String of material define information
  8025. */
  8026. toString(): string;
  8027. }
  8028. }
  8029. declare module "babylonjs/Materials/colorCurves" {
  8030. import { Effect } from "babylonjs/Materials/effect";
  8031. /**
  8032. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8033. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8034. * 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;
  8035. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8036. */
  8037. export class ColorCurves {
  8038. private _dirty;
  8039. private _tempColor;
  8040. private _globalCurve;
  8041. private _highlightsCurve;
  8042. private _midtonesCurve;
  8043. private _shadowsCurve;
  8044. private _positiveCurve;
  8045. private _negativeCurve;
  8046. private _globalHue;
  8047. private _globalDensity;
  8048. private _globalSaturation;
  8049. private _globalExposure;
  8050. /**
  8051. * Gets the global Hue value.
  8052. * 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).
  8053. */
  8054. get globalHue(): number;
  8055. /**
  8056. * Sets the global Hue value.
  8057. * 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).
  8058. */
  8059. set globalHue(value: number);
  8060. /**
  8061. * Gets the global Density value.
  8062. * 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.
  8063. * Values less than zero provide a filter of opposite hue.
  8064. */
  8065. get globalDensity(): number;
  8066. /**
  8067. * Sets the global Density value.
  8068. * 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.
  8069. * Values less than zero provide a filter of opposite hue.
  8070. */
  8071. set globalDensity(value: number);
  8072. /**
  8073. * Gets the global Saturation value.
  8074. * 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.
  8075. */
  8076. get globalSaturation(): number;
  8077. /**
  8078. * Sets the global Saturation value.
  8079. * 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.
  8080. */
  8081. set globalSaturation(value: number);
  8082. /**
  8083. * Gets the global Exposure value.
  8084. * 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.
  8085. */
  8086. get globalExposure(): number;
  8087. /**
  8088. * Sets the global Exposure value.
  8089. * 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.
  8090. */
  8091. set globalExposure(value: number);
  8092. private _highlightsHue;
  8093. private _highlightsDensity;
  8094. private _highlightsSaturation;
  8095. private _highlightsExposure;
  8096. /**
  8097. * Gets the highlights Hue value.
  8098. * 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).
  8099. */
  8100. get highlightsHue(): number;
  8101. /**
  8102. * Sets the highlights Hue value.
  8103. * 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).
  8104. */
  8105. set highlightsHue(value: number);
  8106. /**
  8107. * Gets the highlights Density value.
  8108. * 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.
  8109. * Values less than zero provide a filter of opposite hue.
  8110. */
  8111. get highlightsDensity(): number;
  8112. /**
  8113. * Sets the highlights Density value.
  8114. * 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.
  8115. * Values less than zero provide a filter of opposite hue.
  8116. */
  8117. set highlightsDensity(value: number);
  8118. /**
  8119. * Gets the highlights Saturation value.
  8120. * 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.
  8121. */
  8122. get highlightsSaturation(): number;
  8123. /**
  8124. * Sets the highlights Saturation value.
  8125. * 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.
  8126. */
  8127. set highlightsSaturation(value: number);
  8128. /**
  8129. * Gets the highlights Exposure value.
  8130. * 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.
  8131. */
  8132. get highlightsExposure(): number;
  8133. /**
  8134. * Sets the highlights Exposure value.
  8135. * 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.
  8136. */
  8137. set highlightsExposure(value: number);
  8138. private _midtonesHue;
  8139. private _midtonesDensity;
  8140. private _midtonesSaturation;
  8141. private _midtonesExposure;
  8142. /**
  8143. * Gets the midtones Hue value.
  8144. * 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).
  8145. */
  8146. get midtonesHue(): number;
  8147. /**
  8148. * Sets the midtones Hue value.
  8149. * 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).
  8150. */
  8151. set midtonesHue(value: number);
  8152. /**
  8153. * Gets the midtones Density value.
  8154. * 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.
  8155. * Values less than zero provide a filter of opposite hue.
  8156. */
  8157. get midtonesDensity(): number;
  8158. /**
  8159. * Sets the midtones Density value.
  8160. * 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.
  8161. * Values less than zero provide a filter of opposite hue.
  8162. */
  8163. set midtonesDensity(value: number);
  8164. /**
  8165. * Gets the midtones Saturation value.
  8166. * 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.
  8167. */
  8168. get midtonesSaturation(): number;
  8169. /**
  8170. * Sets the midtones Saturation value.
  8171. * 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.
  8172. */
  8173. set midtonesSaturation(value: number);
  8174. /**
  8175. * Gets the midtones Exposure value.
  8176. * 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.
  8177. */
  8178. get midtonesExposure(): number;
  8179. /**
  8180. * Sets the midtones Exposure value.
  8181. * 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.
  8182. */
  8183. set midtonesExposure(value: number);
  8184. private _shadowsHue;
  8185. private _shadowsDensity;
  8186. private _shadowsSaturation;
  8187. private _shadowsExposure;
  8188. /**
  8189. * Gets the shadows Hue value.
  8190. * 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).
  8191. */
  8192. get shadowsHue(): number;
  8193. /**
  8194. * Sets the shadows Hue value.
  8195. * 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).
  8196. */
  8197. set shadowsHue(value: number);
  8198. /**
  8199. * Gets the shadows Density value.
  8200. * 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.
  8201. * Values less than zero provide a filter of opposite hue.
  8202. */
  8203. get shadowsDensity(): number;
  8204. /**
  8205. * Sets the shadows Density value.
  8206. * 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.
  8207. * Values less than zero provide a filter of opposite hue.
  8208. */
  8209. set shadowsDensity(value: number);
  8210. /**
  8211. * Gets the shadows Saturation value.
  8212. * 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.
  8213. */
  8214. get shadowsSaturation(): number;
  8215. /**
  8216. * Sets the shadows Saturation value.
  8217. * 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.
  8218. */
  8219. set shadowsSaturation(value: number);
  8220. /**
  8221. * Gets the shadows Exposure value.
  8222. * 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.
  8223. */
  8224. get shadowsExposure(): number;
  8225. /**
  8226. * Sets the shadows Exposure value.
  8227. * 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.
  8228. */
  8229. set shadowsExposure(value: number);
  8230. /**
  8231. * Returns the class name
  8232. * @returns The class name
  8233. */
  8234. getClassName(): string;
  8235. /**
  8236. * Binds the color curves to the shader.
  8237. * @param colorCurves The color curve to bind
  8238. * @param effect The effect to bind to
  8239. * @param positiveUniform The positive uniform shader parameter
  8240. * @param neutralUniform The neutral uniform shader parameter
  8241. * @param negativeUniform The negative uniform shader parameter
  8242. */
  8243. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8244. /**
  8245. * Prepare the list of uniforms associated with the ColorCurves effects.
  8246. * @param uniformsList The list of uniforms used in the effect
  8247. */
  8248. static PrepareUniforms(uniformsList: string[]): void;
  8249. /**
  8250. * Returns color grading data based on a hue, density, saturation and exposure value.
  8251. * @param filterHue The hue of the color filter.
  8252. * @param filterDensity The density of the color filter.
  8253. * @param saturation The saturation.
  8254. * @param exposure The exposure.
  8255. * @param result The result data container.
  8256. */
  8257. private getColorGradingDataToRef;
  8258. /**
  8259. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8260. * @param value The input slider value in range [-100,100].
  8261. * @returns Adjusted value.
  8262. */
  8263. private static applyColorGradingSliderNonlinear;
  8264. /**
  8265. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8266. * @param hue The hue (H) input.
  8267. * @param saturation The saturation (S) input.
  8268. * @param brightness The brightness (B) input.
  8269. * @result An RGBA color represented as Vector4.
  8270. */
  8271. private static fromHSBToRef;
  8272. /**
  8273. * Returns a value clamped between min and max
  8274. * @param value The value to clamp
  8275. * @param min The minimum of value
  8276. * @param max The maximum of value
  8277. * @returns The clamped value.
  8278. */
  8279. private static clamp;
  8280. /**
  8281. * Clones the current color curve instance.
  8282. * @return The cloned curves
  8283. */
  8284. clone(): ColorCurves;
  8285. /**
  8286. * Serializes the current color curve instance to a json representation.
  8287. * @return a JSON representation
  8288. */
  8289. serialize(): any;
  8290. /**
  8291. * Parses the color curve from a json representation.
  8292. * @param source the JSON source to parse
  8293. * @return The parsed curves
  8294. */
  8295. static Parse(source: any): ColorCurves;
  8296. }
  8297. }
  8298. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8299. import { Observable } from "babylonjs/Misc/observable";
  8300. import { Nullable } from "babylonjs/types";
  8301. import { Color4 } from "babylonjs/Maths/math.color";
  8302. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8303. import { Effect } from "babylonjs/Materials/effect";
  8304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8305. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8306. /**
  8307. * Interface to follow in your material defines to integrate easily the
  8308. * Image proccessing functions.
  8309. * @hidden
  8310. */
  8311. export interface IImageProcessingConfigurationDefines {
  8312. IMAGEPROCESSING: boolean;
  8313. VIGNETTE: boolean;
  8314. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8315. VIGNETTEBLENDMODEOPAQUE: boolean;
  8316. TONEMAPPING: boolean;
  8317. TONEMAPPING_ACES: boolean;
  8318. CONTRAST: boolean;
  8319. EXPOSURE: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. }
  8327. /**
  8328. * @hidden
  8329. */
  8330. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8331. IMAGEPROCESSING: boolean;
  8332. VIGNETTE: boolean;
  8333. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8334. VIGNETTEBLENDMODEOPAQUE: boolean;
  8335. TONEMAPPING: boolean;
  8336. TONEMAPPING_ACES: boolean;
  8337. CONTRAST: boolean;
  8338. COLORCURVES: boolean;
  8339. COLORGRADING: boolean;
  8340. COLORGRADING3D: boolean;
  8341. SAMPLER3DGREENDEPTH: boolean;
  8342. SAMPLER3DBGRMAP: boolean;
  8343. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8344. EXPOSURE: boolean;
  8345. constructor();
  8346. }
  8347. /**
  8348. * This groups together the common properties used for image processing either in direct forward pass
  8349. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8350. * or not.
  8351. */
  8352. export class ImageProcessingConfiguration {
  8353. /**
  8354. * Default tone mapping applied in BabylonJS.
  8355. */
  8356. static readonly TONEMAPPING_STANDARD: number;
  8357. /**
  8358. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8359. * to other engines rendering to increase portability.
  8360. */
  8361. static readonly TONEMAPPING_ACES: number;
  8362. /**
  8363. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8364. */
  8365. colorCurves: Nullable<ColorCurves>;
  8366. private _colorCurvesEnabled;
  8367. /**
  8368. * Gets wether the color curves effect is enabled.
  8369. */
  8370. get colorCurvesEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color curves effect is enabled.
  8373. */
  8374. set colorCurvesEnabled(value: boolean);
  8375. private _colorGradingTexture;
  8376. /**
  8377. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8378. */
  8379. get colorGradingTexture(): Nullable<BaseTexture>;
  8380. /**
  8381. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8382. */
  8383. set colorGradingTexture(value: Nullable<BaseTexture>);
  8384. private _colorGradingEnabled;
  8385. /**
  8386. * Gets wether the color grading effect is enabled.
  8387. */
  8388. get colorGradingEnabled(): boolean;
  8389. /**
  8390. * Sets wether the color grading effect is enabled.
  8391. */
  8392. set colorGradingEnabled(value: boolean);
  8393. private _colorGradingWithGreenDepth;
  8394. /**
  8395. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8396. */
  8397. get colorGradingWithGreenDepth(): boolean;
  8398. /**
  8399. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8400. */
  8401. set colorGradingWithGreenDepth(value: boolean);
  8402. private _colorGradingBGR;
  8403. /**
  8404. * Gets wether the color grading texture contains BGR values.
  8405. */
  8406. get colorGradingBGR(): boolean;
  8407. /**
  8408. * Sets wether the color grading texture contains BGR values.
  8409. */
  8410. set colorGradingBGR(value: boolean);
  8411. /** @hidden */
  8412. _exposure: number;
  8413. /**
  8414. * Gets the Exposure used in the effect.
  8415. */
  8416. get exposure(): number;
  8417. /**
  8418. * Sets the Exposure used in the effect.
  8419. */
  8420. set exposure(value: number);
  8421. private _toneMappingEnabled;
  8422. /**
  8423. * Gets wether the tone mapping effect is enabled.
  8424. */
  8425. get toneMappingEnabled(): boolean;
  8426. /**
  8427. * Sets wether the tone mapping effect is enabled.
  8428. */
  8429. set toneMappingEnabled(value: boolean);
  8430. private _toneMappingType;
  8431. /**
  8432. * Gets the type of tone mapping effect.
  8433. */
  8434. get toneMappingType(): number;
  8435. /**
  8436. * Sets the type of tone mapping effect used in BabylonJS.
  8437. */
  8438. set toneMappingType(value: number);
  8439. protected _contrast: number;
  8440. /**
  8441. * Gets the contrast used in the effect.
  8442. */
  8443. get contrast(): number;
  8444. /**
  8445. * Sets the contrast used in the effect.
  8446. */
  8447. set contrast(value: number);
  8448. /**
  8449. * Vignette stretch size.
  8450. */
  8451. vignetteStretch: number;
  8452. /**
  8453. * Vignette centre X Offset.
  8454. */
  8455. vignetteCentreX: number;
  8456. /**
  8457. * Vignette centre Y Offset.
  8458. */
  8459. vignetteCentreY: number;
  8460. /**
  8461. * Vignette weight or intensity of the vignette effect.
  8462. */
  8463. vignetteWeight: number;
  8464. /**
  8465. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8466. * if vignetteEnabled is set to true.
  8467. */
  8468. vignetteColor: Color4;
  8469. /**
  8470. * Camera field of view used by the Vignette effect.
  8471. */
  8472. vignetteCameraFov: number;
  8473. private _vignetteBlendMode;
  8474. /**
  8475. * Gets the vignette blend mode allowing different kind of effect.
  8476. */
  8477. get vignetteBlendMode(): number;
  8478. /**
  8479. * Sets the vignette blend mode allowing different kind of effect.
  8480. */
  8481. set vignetteBlendMode(value: number);
  8482. private _vignetteEnabled;
  8483. /**
  8484. * Gets wether the vignette effect is enabled.
  8485. */
  8486. get vignetteEnabled(): boolean;
  8487. /**
  8488. * Sets wether the vignette effect is enabled.
  8489. */
  8490. set vignetteEnabled(value: boolean);
  8491. private _applyByPostProcess;
  8492. /**
  8493. * Gets wether the image processing is applied through a post process or not.
  8494. */
  8495. get applyByPostProcess(): boolean;
  8496. /**
  8497. * Sets wether the image processing is applied through a post process or not.
  8498. */
  8499. set applyByPostProcess(value: boolean);
  8500. private _isEnabled;
  8501. /**
  8502. * Gets wether the image processing is enabled or not.
  8503. */
  8504. get isEnabled(): boolean;
  8505. /**
  8506. * Sets wether the image processing is enabled or not.
  8507. */
  8508. set isEnabled(value: boolean);
  8509. /**
  8510. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8511. */
  8512. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8513. /**
  8514. * Method called each time the image processing information changes requires to recompile the effect.
  8515. */
  8516. protected _updateParameters(): void;
  8517. /**
  8518. * Gets the current class name.
  8519. * @return "ImageProcessingConfiguration"
  8520. */
  8521. getClassName(): string;
  8522. /**
  8523. * Prepare the list of uniforms associated with the Image Processing effects.
  8524. * @param uniforms The list of uniforms used in the effect
  8525. * @param defines the list of defines currently in use
  8526. */
  8527. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8528. /**
  8529. * Prepare the list of samplers associated with the Image Processing effects.
  8530. * @param samplersList The list of uniforms used in the effect
  8531. * @param defines the list of defines currently in use
  8532. */
  8533. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8534. /**
  8535. * Prepare the list of defines associated to the shader.
  8536. * @param defines the list of defines to complete
  8537. * @param forPostProcess Define if we are currently in post process mode or not
  8538. */
  8539. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8540. /**
  8541. * Returns true if all the image processing information are ready.
  8542. * @returns True if ready, otherwise, false
  8543. */
  8544. isReady(): boolean;
  8545. /**
  8546. * Binds the image processing to the shader.
  8547. * @param effect The effect to bind to
  8548. * @param overrideAspectRatio Override the aspect ratio of the effect
  8549. */
  8550. bind(effect: Effect, overrideAspectRatio?: number): void;
  8551. /**
  8552. * Clones the current image processing instance.
  8553. * @return The cloned image processing
  8554. */
  8555. clone(): ImageProcessingConfiguration;
  8556. /**
  8557. * Serializes the current image processing instance to a json representation.
  8558. * @return a JSON representation
  8559. */
  8560. serialize(): any;
  8561. /**
  8562. * Parses the image processing from a json representation.
  8563. * @param source the JSON source to parse
  8564. * @return The parsed image processing
  8565. */
  8566. static Parse(source: any): ImageProcessingConfiguration;
  8567. private static _VIGNETTEMODE_MULTIPLY;
  8568. private static _VIGNETTEMODE_OPAQUE;
  8569. /**
  8570. * Used to apply the vignette as a mix with the pixel color.
  8571. */
  8572. static get VIGNETTEMODE_MULTIPLY(): number;
  8573. /**
  8574. * Used to apply the vignette as a replacement of the pixel color.
  8575. */
  8576. static get VIGNETTEMODE_OPAQUE(): number;
  8577. }
  8578. }
  8579. declare module "babylonjs/Shaders/postprocess.vertex" {
  8580. /** @hidden */
  8581. export var postprocessVertexShader: {
  8582. name: string;
  8583. shader: string;
  8584. };
  8585. }
  8586. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8587. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8588. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8589. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8590. module "babylonjs/Engines/thinEngine" {
  8591. interface ThinEngine {
  8592. /**
  8593. * Creates a new render target texture
  8594. * @param size defines the size of the texture
  8595. * @param options defines the options used to create the texture
  8596. * @returns a new render target texture stored in an InternalTexture
  8597. */
  8598. createRenderTargetTexture(size: number | {
  8599. width: number;
  8600. height: number;
  8601. layers?: number;
  8602. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8603. /**
  8604. * Creates a depth stencil texture.
  8605. * This is only available in WebGL 2 or with the depth texture extension available.
  8606. * @param size The size of face edge in the texture.
  8607. * @param options The options defining the texture.
  8608. * @returns The texture
  8609. */
  8610. createDepthStencilTexture(size: number | {
  8611. width: number;
  8612. height: number;
  8613. layers?: number;
  8614. }, options: DepthTextureCreationOptions): InternalTexture;
  8615. /** @hidden */
  8616. _createDepthStencilTexture(size: number | {
  8617. width: number;
  8618. height: number;
  8619. layers?: number;
  8620. }, options: DepthTextureCreationOptions): InternalTexture;
  8621. }
  8622. }
  8623. }
  8624. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8625. /**
  8626. * Defines the kind of connection point for node based material
  8627. */
  8628. export enum NodeMaterialBlockConnectionPointTypes {
  8629. /** Float */
  8630. Float = 1,
  8631. /** Int */
  8632. Int = 2,
  8633. /** Vector2 */
  8634. Vector2 = 4,
  8635. /** Vector3 */
  8636. Vector3 = 8,
  8637. /** Vector4 */
  8638. Vector4 = 16,
  8639. /** Color3 */
  8640. Color3 = 32,
  8641. /** Color4 */
  8642. Color4 = 64,
  8643. /** Matrix */
  8644. Matrix = 128,
  8645. /** Custom object */
  8646. Object = 256,
  8647. /** Detect type based on connection */
  8648. AutoDetect = 1024,
  8649. /** Output type that will be defined by input type */
  8650. BasedOnInput = 2048
  8651. }
  8652. }
  8653. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8654. /**
  8655. * Enum used to define the target of a block
  8656. */
  8657. export enum NodeMaterialBlockTargets {
  8658. /** Vertex shader */
  8659. Vertex = 1,
  8660. /** Fragment shader */
  8661. Fragment = 2,
  8662. /** Neutral */
  8663. Neutral = 4,
  8664. /** Vertex and Fragment */
  8665. VertexAndFragment = 3
  8666. }
  8667. }
  8668. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8669. /**
  8670. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8671. */
  8672. export enum NodeMaterialBlockConnectionPointMode {
  8673. /** Value is an uniform */
  8674. Uniform = 0,
  8675. /** Value is a mesh attribute */
  8676. Attribute = 1,
  8677. /** Value is a varying between vertex and fragment shaders */
  8678. Varying = 2,
  8679. /** Mode is undefined */
  8680. Undefined = 3
  8681. }
  8682. }
  8683. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8684. /**
  8685. * Enum used to define system values e.g. values automatically provided by the system
  8686. */
  8687. export enum NodeMaterialSystemValues {
  8688. /** World */
  8689. World = 1,
  8690. /** View */
  8691. View = 2,
  8692. /** Projection */
  8693. Projection = 3,
  8694. /** ViewProjection */
  8695. ViewProjection = 4,
  8696. /** WorldView */
  8697. WorldView = 5,
  8698. /** WorldViewProjection */
  8699. WorldViewProjection = 6,
  8700. /** CameraPosition */
  8701. CameraPosition = 7,
  8702. /** Fog Color */
  8703. FogColor = 8,
  8704. /** Delta time */
  8705. DeltaTime = 9
  8706. }
  8707. }
  8708. declare module "babylonjs/Maths/math.axis" {
  8709. import { Vector3 } from "babylonjs/Maths/math.vector";
  8710. /** Defines supported spaces */
  8711. export enum Space {
  8712. /** Local (object) space */
  8713. LOCAL = 0,
  8714. /** World space */
  8715. WORLD = 1,
  8716. /** Bone space */
  8717. BONE = 2
  8718. }
  8719. /** Defines the 3 main axes */
  8720. export class Axis {
  8721. /** X axis */
  8722. static X: Vector3;
  8723. /** Y axis */
  8724. static Y: Vector3;
  8725. /** Z axis */
  8726. static Z: Vector3;
  8727. }
  8728. }
  8729. declare module "babylonjs/Maths/math.frustum" {
  8730. import { Matrix } from "babylonjs/Maths/math.vector";
  8731. import { DeepImmutable } from "babylonjs/types";
  8732. import { Plane } from "babylonjs/Maths/math.plane";
  8733. /**
  8734. * Represents a camera frustum
  8735. */
  8736. export class Frustum {
  8737. /**
  8738. * Gets the planes representing the frustum
  8739. * @param transform matrix to be applied to the returned planes
  8740. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8741. */
  8742. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8743. /**
  8744. * Gets the near frustum plane transformed by the transform matrix
  8745. * @param transform transformation matrix to be applied to the resulting frustum plane
  8746. * @param frustumPlane the resuling frustum plane
  8747. */
  8748. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8749. /**
  8750. * Gets the far frustum plane transformed by the transform matrix
  8751. * @param transform transformation matrix to be applied to the resulting frustum plane
  8752. * @param frustumPlane the resuling frustum plane
  8753. */
  8754. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8755. /**
  8756. * Gets the left frustum plane transformed by the transform matrix
  8757. * @param transform transformation matrix to be applied to the resulting frustum plane
  8758. * @param frustumPlane the resuling frustum plane
  8759. */
  8760. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8761. /**
  8762. * Gets the right frustum plane transformed by the transform matrix
  8763. * @param transform transformation matrix to be applied to the resulting frustum plane
  8764. * @param frustumPlane the resuling frustum plane
  8765. */
  8766. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8767. /**
  8768. * Gets the top frustum plane transformed by the transform matrix
  8769. * @param transform transformation matrix to be applied to the resulting frustum plane
  8770. * @param frustumPlane the resuling frustum plane
  8771. */
  8772. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8773. /**
  8774. * Gets the bottom frustum plane transformed by the transform matrix
  8775. * @param transform transformation matrix to be applied to the resulting frustum plane
  8776. * @param frustumPlane the resuling frustum plane
  8777. */
  8778. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8779. /**
  8780. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8781. * @param transform transformation matrix to be applied to the resulting frustum planes
  8782. * @param frustumPlanes the resuling frustum planes
  8783. */
  8784. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8785. }
  8786. }
  8787. declare module "babylonjs/Maths/math.size" {
  8788. /**
  8789. * Interface for the size containing width and height
  8790. */
  8791. export interface ISize {
  8792. /**
  8793. * Width
  8794. */
  8795. width: number;
  8796. /**
  8797. * Heighht
  8798. */
  8799. height: number;
  8800. }
  8801. /**
  8802. * Size containing widht and height
  8803. */
  8804. export class Size implements ISize {
  8805. /**
  8806. * Width
  8807. */
  8808. width: number;
  8809. /**
  8810. * Height
  8811. */
  8812. height: number;
  8813. /**
  8814. * Creates a Size object from the given width and height (floats).
  8815. * @param width width of the new size
  8816. * @param height height of the new size
  8817. */
  8818. constructor(width: number, height: number);
  8819. /**
  8820. * Returns a string with the Size width and height
  8821. * @returns a string with the Size width and height
  8822. */
  8823. toString(): string;
  8824. /**
  8825. * "Size"
  8826. * @returns the string "Size"
  8827. */
  8828. getClassName(): string;
  8829. /**
  8830. * Returns the Size hash code.
  8831. * @returns a hash code for a unique width and height
  8832. */
  8833. getHashCode(): number;
  8834. /**
  8835. * Updates the current size from the given one.
  8836. * @param src the given size
  8837. */
  8838. copyFrom(src: Size): void;
  8839. /**
  8840. * Updates in place the current Size from the given floats.
  8841. * @param width width of the new size
  8842. * @param height height of the new size
  8843. * @returns the updated Size.
  8844. */
  8845. copyFromFloats(width: number, height: number): Size;
  8846. /**
  8847. * Updates in place the current Size from the given floats.
  8848. * @param width width to set
  8849. * @param height height to set
  8850. * @returns the updated Size.
  8851. */
  8852. set(width: number, height: number): Size;
  8853. /**
  8854. * Multiplies the width and height by numbers
  8855. * @param w factor to multiple the width by
  8856. * @param h factor to multiple the height by
  8857. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8858. */
  8859. multiplyByFloats(w: number, h: number): Size;
  8860. /**
  8861. * Clones the size
  8862. * @returns a new Size copied from the given one.
  8863. */
  8864. clone(): Size;
  8865. /**
  8866. * True if the current Size and the given one width and height are strictly equal.
  8867. * @param other the other size to compare against
  8868. * @returns True if the current Size and the given one width and height are strictly equal.
  8869. */
  8870. equals(other: Size): boolean;
  8871. /**
  8872. * The surface of the Size : width * height (float).
  8873. */
  8874. get surface(): number;
  8875. /**
  8876. * Create a new size of zero
  8877. * @returns a new Size set to (0.0, 0.0)
  8878. */
  8879. static Zero(): Size;
  8880. /**
  8881. * Sums the width and height of two sizes
  8882. * @param otherSize size to add to this size
  8883. * @returns a new Size set as the addition result of the current Size and the given one.
  8884. */
  8885. add(otherSize: Size): Size;
  8886. /**
  8887. * Subtracts the width and height of two
  8888. * @param otherSize size to subtract to this size
  8889. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8890. */
  8891. subtract(otherSize: Size): Size;
  8892. /**
  8893. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8894. * @param start starting size to lerp between
  8895. * @param end end size to lerp between
  8896. * @param amount amount to lerp between the start and end values
  8897. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8898. */
  8899. static Lerp(start: Size, end: Size, amount: number): Size;
  8900. }
  8901. }
  8902. declare module "babylonjs/Maths/math.vertexFormat" {
  8903. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8904. /**
  8905. * Contains position and normal vectors for a vertex
  8906. */
  8907. export class PositionNormalVertex {
  8908. /** the position of the vertex (defaut: 0,0,0) */
  8909. position: Vector3;
  8910. /** the normal of the vertex (defaut: 0,1,0) */
  8911. normal: Vector3;
  8912. /**
  8913. * Creates a PositionNormalVertex
  8914. * @param position the position of the vertex (defaut: 0,0,0)
  8915. * @param normal the normal of the vertex (defaut: 0,1,0)
  8916. */
  8917. constructor(
  8918. /** the position of the vertex (defaut: 0,0,0) */
  8919. position?: Vector3,
  8920. /** the normal of the vertex (defaut: 0,1,0) */
  8921. normal?: Vector3);
  8922. /**
  8923. * Clones the PositionNormalVertex
  8924. * @returns the cloned PositionNormalVertex
  8925. */
  8926. clone(): PositionNormalVertex;
  8927. }
  8928. /**
  8929. * Contains position, normal and uv vectors for a vertex
  8930. */
  8931. export class PositionNormalTextureVertex {
  8932. /** the position of the vertex (defaut: 0,0,0) */
  8933. position: Vector3;
  8934. /** the normal of the vertex (defaut: 0,1,0) */
  8935. normal: Vector3;
  8936. /** the uv of the vertex (default: 0,0) */
  8937. uv: Vector2;
  8938. /**
  8939. * Creates a PositionNormalTextureVertex
  8940. * @param position the position of the vertex (defaut: 0,0,0)
  8941. * @param normal the normal of the vertex (defaut: 0,1,0)
  8942. * @param uv the uv of the vertex (default: 0,0)
  8943. */
  8944. constructor(
  8945. /** the position of the vertex (defaut: 0,0,0) */
  8946. position?: Vector3,
  8947. /** the normal of the vertex (defaut: 0,1,0) */
  8948. normal?: Vector3,
  8949. /** the uv of the vertex (default: 0,0) */
  8950. uv?: Vector2);
  8951. /**
  8952. * Clones the PositionNormalTextureVertex
  8953. * @returns the cloned PositionNormalTextureVertex
  8954. */
  8955. clone(): PositionNormalTextureVertex;
  8956. }
  8957. }
  8958. declare module "babylonjs/Maths/math" {
  8959. export * from "babylonjs/Maths/math.axis";
  8960. export * from "babylonjs/Maths/math.color";
  8961. export * from "babylonjs/Maths/math.constants";
  8962. export * from "babylonjs/Maths/math.frustum";
  8963. export * from "babylonjs/Maths/math.path";
  8964. export * from "babylonjs/Maths/math.plane";
  8965. export * from "babylonjs/Maths/math.size";
  8966. export * from "babylonjs/Maths/math.vector";
  8967. export * from "babylonjs/Maths/math.vertexFormat";
  8968. export * from "babylonjs/Maths/math.viewport";
  8969. }
  8970. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8971. /**
  8972. * Enum defining the type of animations supported by InputBlock
  8973. */
  8974. export enum AnimatedInputBlockTypes {
  8975. /** No animation */
  8976. None = 0,
  8977. /** Time based animation. Will only work for floats */
  8978. Time = 1
  8979. }
  8980. }
  8981. declare module "babylonjs/Lights/shadowLight" {
  8982. import { Camera } from "babylonjs/Cameras/camera";
  8983. import { Scene } from "babylonjs/scene";
  8984. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8986. import { Light } from "babylonjs/Lights/light";
  8987. /**
  8988. * Interface describing all the common properties and methods a shadow light needs to implement.
  8989. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8990. * as well as binding the different shadow properties to the effects.
  8991. */
  8992. export interface IShadowLight extends Light {
  8993. /**
  8994. * The light id in the scene (used in scene.findLighById for instance)
  8995. */
  8996. id: string;
  8997. /**
  8998. * The position the shdow will be casted from.
  8999. */
  9000. position: Vector3;
  9001. /**
  9002. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9003. */
  9004. direction: Vector3;
  9005. /**
  9006. * The transformed position. Position of the light in world space taking parenting in account.
  9007. */
  9008. transformedPosition: Vector3;
  9009. /**
  9010. * The transformed direction. Direction of the light in world space taking parenting in account.
  9011. */
  9012. transformedDirection: Vector3;
  9013. /**
  9014. * The friendly name of the light in the scene.
  9015. */
  9016. name: string;
  9017. /**
  9018. * Defines the shadow projection clipping minimum z value.
  9019. */
  9020. shadowMinZ: number;
  9021. /**
  9022. * Defines the shadow projection clipping maximum z value.
  9023. */
  9024. shadowMaxZ: number;
  9025. /**
  9026. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9027. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9028. */
  9029. computeTransformedInformation(): boolean;
  9030. /**
  9031. * Gets the scene the light belongs to.
  9032. * @returns The scene
  9033. */
  9034. getScene(): Scene;
  9035. /**
  9036. * Callback defining a custom Projection Matrix Builder.
  9037. * This can be used to override the default projection matrix computation.
  9038. */
  9039. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9040. /**
  9041. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9042. * @param matrix The materix to updated with the projection information
  9043. * @param viewMatrix The transform matrix of the light
  9044. * @param renderList The list of mesh to render in the map
  9045. * @returns The current light
  9046. */
  9047. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9048. /**
  9049. * Gets the current depth scale used in ESM.
  9050. * @returns The scale
  9051. */
  9052. getDepthScale(): number;
  9053. /**
  9054. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9055. * @returns true if a cube texture needs to be use
  9056. */
  9057. needCube(): boolean;
  9058. /**
  9059. * Detects if the projection matrix requires to be recomputed this frame.
  9060. * @returns true if it requires to be recomputed otherwise, false.
  9061. */
  9062. needProjectionMatrixCompute(): boolean;
  9063. /**
  9064. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9065. */
  9066. forceProjectionMatrixCompute(): void;
  9067. /**
  9068. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9069. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9070. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9071. */
  9072. getShadowDirection(faceIndex?: number): Vector3;
  9073. /**
  9074. * Gets the minZ used for shadow according to both the scene and the light.
  9075. * @param activeCamera The camera we are returning the min for
  9076. * @returns the depth min z
  9077. */
  9078. getDepthMinZ(activeCamera: Camera): number;
  9079. /**
  9080. * Gets the maxZ used for shadow according to both the scene and the light.
  9081. * @param activeCamera The camera we are returning the max for
  9082. * @returns the depth max z
  9083. */
  9084. getDepthMaxZ(activeCamera: Camera): number;
  9085. }
  9086. /**
  9087. * Base implementation IShadowLight
  9088. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9089. */
  9090. export abstract class ShadowLight extends Light implements IShadowLight {
  9091. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9092. protected _position: Vector3;
  9093. protected _setPosition(value: Vector3): void;
  9094. /**
  9095. * Sets the position the shadow will be casted from. Also use as the light position for both
  9096. * point and spot lights.
  9097. */
  9098. get position(): Vector3;
  9099. /**
  9100. * Sets the position the shadow will be casted from. Also use as the light position for both
  9101. * point and spot lights.
  9102. */
  9103. set position(value: Vector3);
  9104. protected _direction: Vector3;
  9105. protected _setDirection(value: Vector3): void;
  9106. /**
  9107. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9108. * Also use as the light direction on spot and directional lights.
  9109. */
  9110. get direction(): Vector3;
  9111. /**
  9112. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9113. * Also use as the light direction on spot and directional lights.
  9114. */
  9115. set direction(value: Vector3);
  9116. protected _shadowMinZ: number;
  9117. /**
  9118. * Gets the shadow projection clipping minimum z value.
  9119. */
  9120. get shadowMinZ(): number;
  9121. /**
  9122. * Sets the shadow projection clipping minimum z value.
  9123. */
  9124. set shadowMinZ(value: number);
  9125. protected _shadowMaxZ: number;
  9126. /**
  9127. * Sets the shadow projection clipping maximum z value.
  9128. */
  9129. get shadowMaxZ(): number;
  9130. /**
  9131. * Gets the shadow projection clipping maximum z value.
  9132. */
  9133. set shadowMaxZ(value: number);
  9134. /**
  9135. * Callback defining a custom Projection Matrix Builder.
  9136. * This can be used to override the default projection matrix computation.
  9137. */
  9138. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9139. /**
  9140. * The transformed position. Position of the light in world space taking parenting in account.
  9141. */
  9142. transformedPosition: Vector3;
  9143. /**
  9144. * The transformed direction. Direction of the light in world space taking parenting in account.
  9145. */
  9146. transformedDirection: Vector3;
  9147. private _needProjectionMatrixCompute;
  9148. /**
  9149. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9150. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9151. */
  9152. computeTransformedInformation(): boolean;
  9153. /**
  9154. * Return the depth scale used for the shadow map.
  9155. * @returns the depth scale.
  9156. */
  9157. getDepthScale(): number;
  9158. /**
  9159. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9160. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9161. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9162. */
  9163. getShadowDirection(faceIndex?: number): Vector3;
  9164. /**
  9165. * Returns the ShadowLight absolute position in the World.
  9166. * @returns the position vector in world space
  9167. */
  9168. getAbsolutePosition(): Vector3;
  9169. /**
  9170. * Sets the ShadowLight direction toward the passed target.
  9171. * @param target The point to target in local space
  9172. * @returns the updated ShadowLight direction
  9173. */
  9174. setDirectionToTarget(target: Vector3): Vector3;
  9175. /**
  9176. * Returns the light rotation in euler definition.
  9177. * @returns the x y z rotation in local space.
  9178. */
  9179. getRotation(): Vector3;
  9180. /**
  9181. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9182. * @returns true if a cube texture needs to be use
  9183. */
  9184. needCube(): boolean;
  9185. /**
  9186. * Detects if the projection matrix requires to be recomputed this frame.
  9187. * @returns true if it requires to be recomputed otherwise, false.
  9188. */
  9189. needProjectionMatrixCompute(): boolean;
  9190. /**
  9191. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9192. */
  9193. forceProjectionMatrixCompute(): void;
  9194. /** @hidden */
  9195. _initCache(): void;
  9196. /** @hidden */
  9197. _isSynchronized(): boolean;
  9198. /**
  9199. * Computes the world matrix of the node
  9200. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9201. * @returns the world matrix
  9202. */
  9203. computeWorldMatrix(force?: boolean): Matrix;
  9204. /**
  9205. * Gets the minZ used for shadow according to both the scene and the light.
  9206. * @param activeCamera The camera we are returning the min for
  9207. * @returns the depth min z
  9208. */
  9209. getDepthMinZ(activeCamera: Camera): number;
  9210. /**
  9211. * Gets the maxZ used for shadow according to both the scene and the light.
  9212. * @param activeCamera The camera we are returning the max for
  9213. * @returns the depth max z
  9214. */
  9215. getDepthMaxZ(activeCamera: Camera): number;
  9216. /**
  9217. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9218. * @param matrix The materix to updated with the projection information
  9219. * @param viewMatrix The transform matrix of the light
  9220. * @param renderList The list of mesh to render in the map
  9221. * @returns The current light
  9222. */
  9223. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9224. }
  9225. }
  9226. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9227. /** @hidden */
  9228. export var packingFunctions: {
  9229. name: string;
  9230. shader: string;
  9231. };
  9232. }
  9233. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9234. /** @hidden */
  9235. export var bayerDitherFunctions: {
  9236. name: string;
  9237. shader: string;
  9238. };
  9239. }
  9240. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9241. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9242. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9243. /** @hidden */
  9244. export var shadowMapFragmentDeclaration: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9250. /** @hidden */
  9251. export var clipPlaneFragmentDeclaration: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9257. /** @hidden */
  9258. export var clipPlaneFragment: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9264. /** @hidden */
  9265. export var shadowMapFragment: {
  9266. name: string;
  9267. shader: string;
  9268. };
  9269. }
  9270. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9271. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9272. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9273. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9274. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9275. /** @hidden */
  9276. export var shadowMapPixelShader: {
  9277. name: string;
  9278. shader: string;
  9279. };
  9280. }
  9281. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9282. /** @hidden */
  9283. export var bonesDeclaration: {
  9284. name: string;
  9285. shader: string;
  9286. };
  9287. }
  9288. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9289. /** @hidden */
  9290. export var morphTargetsVertexGlobalDeclaration: {
  9291. name: string;
  9292. shader: string;
  9293. };
  9294. }
  9295. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9296. /** @hidden */
  9297. export var morphTargetsVertexDeclaration: {
  9298. name: string;
  9299. shader: string;
  9300. };
  9301. }
  9302. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9303. /** @hidden */
  9304. export var instancesDeclaration: {
  9305. name: string;
  9306. shader: string;
  9307. };
  9308. }
  9309. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9310. /** @hidden */
  9311. export var helperFunctions: {
  9312. name: string;
  9313. shader: string;
  9314. };
  9315. }
  9316. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9317. /** @hidden */
  9318. export var shadowMapVertexDeclaration: {
  9319. name: string;
  9320. shader: string;
  9321. };
  9322. }
  9323. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9324. /** @hidden */
  9325. export var clipPlaneVertexDeclaration: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9331. /** @hidden */
  9332. export var morphTargetsVertex: {
  9333. name: string;
  9334. shader: string;
  9335. };
  9336. }
  9337. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9338. /** @hidden */
  9339. export var instancesVertex: {
  9340. name: string;
  9341. shader: string;
  9342. };
  9343. }
  9344. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9345. /** @hidden */
  9346. export var bonesVertex: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9352. /** @hidden */
  9353. export var shadowMapVertexNormalBias: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9359. /** @hidden */
  9360. export var shadowMapVertexMetric: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9366. /** @hidden */
  9367. export var clipPlaneVertex: {
  9368. name: string;
  9369. shader: string;
  9370. };
  9371. }
  9372. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9373. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9374. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9375. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9376. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9377. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9378. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9379. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9380. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9381. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9382. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9383. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9384. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9385. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9386. /** @hidden */
  9387. export var shadowMapVertexShader: {
  9388. name: string;
  9389. shader: string;
  9390. };
  9391. }
  9392. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9393. /** @hidden */
  9394. export var depthBoxBlurPixelShader: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9400. /** @hidden */
  9401. export var shadowMapFragmentSoftTransparentShadow: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module "babylonjs/Materials/effectFallbacks" {
  9407. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9408. import { Effect } from "babylonjs/Materials/effect";
  9409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9410. /**
  9411. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9412. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9413. */
  9414. export class EffectFallbacks implements IEffectFallbacks {
  9415. private _defines;
  9416. private _currentRank;
  9417. private _maxRank;
  9418. private _mesh;
  9419. /**
  9420. * Removes the fallback from the bound mesh.
  9421. */
  9422. unBindMesh(): void;
  9423. /**
  9424. * Adds a fallback on the specified property.
  9425. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9426. * @param define The name of the define in the shader
  9427. */
  9428. addFallback(rank: number, define: string): void;
  9429. /**
  9430. * Sets the mesh to use CPU skinning when needing to fallback.
  9431. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9432. * @param mesh The mesh to use the fallbacks.
  9433. */
  9434. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9435. /**
  9436. * Checks to see if more fallbacks are still availible.
  9437. */
  9438. get hasMoreFallbacks(): boolean;
  9439. /**
  9440. * Removes the defines that should be removed when falling back.
  9441. * @param currentDefines defines the current define statements for the shader.
  9442. * @param effect defines the current effect we try to compile
  9443. * @returns The resulting defines with defines of the current rank removed.
  9444. */
  9445. reduce(currentDefines: string, effect: Effect): string;
  9446. }
  9447. }
  9448. declare module "babylonjs/Actions/action" {
  9449. import { Observable } from "babylonjs/Misc/observable";
  9450. import { Condition } from "babylonjs/Actions/condition";
  9451. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9452. import { ActionManager } from "babylonjs/Actions/actionManager";
  9453. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9454. /**
  9455. * Interface used to define Action
  9456. */
  9457. export interface IAction {
  9458. /**
  9459. * Trigger for the action
  9460. */
  9461. trigger: number;
  9462. /** Options of the trigger */
  9463. triggerOptions: any;
  9464. /**
  9465. * Gets the trigger parameters
  9466. * @returns the trigger parameters
  9467. */
  9468. getTriggerParameter(): any;
  9469. /**
  9470. * Internal only - executes current action event
  9471. * @hidden
  9472. */
  9473. _executeCurrent(evt?: ActionEvent): void;
  9474. /**
  9475. * Serialize placeholder for child classes
  9476. * @param parent of child
  9477. * @returns the serialized object
  9478. */
  9479. serialize(parent: any): any;
  9480. /**
  9481. * Internal only
  9482. * @hidden
  9483. */
  9484. _prepare(): void;
  9485. /**
  9486. * Internal only - manager for action
  9487. * @hidden
  9488. */
  9489. _actionManager: AbstractActionManager;
  9490. /**
  9491. * Adds action to chain of actions, may be a DoNothingAction
  9492. * @param action defines the next action to execute
  9493. * @returns The action passed in
  9494. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9495. */
  9496. then(action: IAction): IAction;
  9497. }
  9498. /**
  9499. * The action to be carried out following a trigger
  9500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9501. */
  9502. export class Action implements IAction {
  9503. /** the trigger, with or without parameters, for the action */
  9504. triggerOptions: any;
  9505. /**
  9506. * Trigger for the action
  9507. */
  9508. trigger: number;
  9509. /**
  9510. * Internal only - manager for action
  9511. * @hidden
  9512. */
  9513. _actionManager: ActionManager;
  9514. private _nextActiveAction;
  9515. private _child;
  9516. private _condition?;
  9517. private _triggerParameter;
  9518. /**
  9519. * An event triggered prior to action being executed.
  9520. */
  9521. onBeforeExecuteObservable: Observable<Action>;
  9522. /**
  9523. * Creates a new Action
  9524. * @param triggerOptions the trigger, with or without parameters, for the action
  9525. * @param condition an optional determinant of action
  9526. */
  9527. constructor(
  9528. /** the trigger, with or without parameters, for the action */
  9529. triggerOptions: any, condition?: Condition);
  9530. /**
  9531. * Internal only
  9532. * @hidden
  9533. */
  9534. _prepare(): void;
  9535. /**
  9536. * Gets the trigger parameters
  9537. * @returns the trigger parameters
  9538. */
  9539. getTriggerParameter(): any;
  9540. /**
  9541. * Internal only - executes current action event
  9542. * @hidden
  9543. */
  9544. _executeCurrent(evt?: ActionEvent): void;
  9545. /**
  9546. * Execute placeholder for child classes
  9547. * @param evt optional action event
  9548. */
  9549. execute(evt?: ActionEvent): void;
  9550. /**
  9551. * Skips to next active action
  9552. */
  9553. skipToNextActiveAction(): void;
  9554. /**
  9555. * Adds action to chain of actions, may be a DoNothingAction
  9556. * @param action defines the next action to execute
  9557. * @returns The action passed in
  9558. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9559. */
  9560. then(action: Action): Action;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getProperty(propertyPath: string): string;
  9566. /**
  9567. * Internal only
  9568. * @hidden
  9569. */
  9570. _getEffectiveTarget(target: any, propertyPath: string): any;
  9571. /**
  9572. * Serialize placeholder for child classes
  9573. * @param parent of child
  9574. * @returns the serialized object
  9575. */
  9576. serialize(parent: any): any;
  9577. /**
  9578. * Internal only called by serialize
  9579. * @hidden
  9580. */
  9581. protected _serialize(serializedAction: any, parent?: any): any;
  9582. /**
  9583. * Internal only
  9584. * @hidden
  9585. */
  9586. static _SerializeValueAsString: (value: any) => string;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  9592. name: string;
  9593. targetType: string;
  9594. value: string;
  9595. };
  9596. }
  9597. }
  9598. declare module "babylonjs/Actions/condition" {
  9599. import { ActionManager } from "babylonjs/Actions/actionManager";
  9600. /**
  9601. * A Condition applied to an Action
  9602. */
  9603. export class Condition {
  9604. /**
  9605. * Internal only - manager for action
  9606. * @hidden
  9607. */
  9608. _actionManager: ActionManager;
  9609. /**
  9610. * Internal only
  9611. * @hidden
  9612. */
  9613. _evaluationId: number;
  9614. /**
  9615. * Internal only
  9616. * @hidden
  9617. */
  9618. _currentResult: boolean;
  9619. /**
  9620. * Creates a new Condition
  9621. * @param actionManager the manager of the action the condition is applied to
  9622. */
  9623. constructor(actionManager: ActionManager);
  9624. /**
  9625. * Check if the current condition is valid
  9626. * @returns a boolean
  9627. */
  9628. isValid(): boolean;
  9629. /**
  9630. * Internal only
  9631. * @hidden
  9632. */
  9633. _getProperty(propertyPath: string): string;
  9634. /**
  9635. * Internal only
  9636. * @hidden
  9637. */
  9638. _getEffectiveTarget(target: any, propertyPath: string): any;
  9639. /**
  9640. * Serialize placeholder for child classes
  9641. * @returns the serialized object
  9642. */
  9643. serialize(): any;
  9644. /**
  9645. * Internal only
  9646. * @hidden
  9647. */
  9648. protected _serialize(serializedCondition: any): any;
  9649. }
  9650. /**
  9651. * Defines specific conditional operators as extensions of Condition
  9652. */
  9653. export class ValueCondition extends Condition {
  9654. /** path to specify the property of the target the conditional operator uses */
  9655. propertyPath: string;
  9656. /** the value compared by the conditional operator against the current value of the property */
  9657. value: any;
  9658. /** the conditional operator, default ValueCondition.IsEqual */
  9659. operator: number;
  9660. /**
  9661. * Internal only
  9662. * @hidden
  9663. */
  9664. private static _IsEqual;
  9665. /**
  9666. * Internal only
  9667. * @hidden
  9668. */
  9669. private static _IsDifferent;
  9670. /**
  9671. * Internal only
  9672. * @hidden
  9673. */
  9674. private static _IsGreater;
  9675. /**
  9676. * Internal only
  9677. * @hidden
  9678. */
  9679. private static _IsLesser;
  9680. /**
  9681. * returns the number for IsEqual
  9682. */
  9683. static get IsEqual(): number;
  9684. /**
  9685. * Returns the number for IsDifferent
  9686. */
  9687. static get IsDifferent(): number;
  9688. /**
  9689. * Returns the number for IsGreater
  9690. */
  9691. static get IsGreater(): number;
  9692. /**
  9693. * Returns the number for IsLesser
  9694. */
  9695. static get IsLesser(): number;
  9696. /**
  9697. * Internal only The action manager for the condition
  9698. * @hidden
  9699. */
  9700. _actionManager: ActionManager;
  9701. /**
  9702. * Internal only
  9703. * @hidden
  9704. */
  9705. private _target;
  9706. /**
  9707. * Internal only
  9708. * @hidden
  9709. */
  9710. private _effectiveTarget;
  9711. /**
  9712. * Internal only
  9713. * @hidden
  9714. */
  9715. private _property;
  9716. /**
  9717. * Creates a new ValueCondition
  9718. * @param actionManager manager for the action the condition applies to
  9719. * @param target for the action
  9720. * @param propertyPath path to specify the property of the target the conditional operator uses
  9721. * @param value the value compared by the conditional operator against the current value of the property
  9722. * @param operator the conditional operator, default ValueCondition.IsEqual
  9723. */
  9724. constructor(actionManager: ActionManager, target: any,
  9725. /** path to specify the property of the target the conditional operator uses */
  9726. propertyPath: string,
  9727. /** the value compared by the conditional operator against the current value of the property */
  9728. value: any,
  9729. /** the conditional operator, default ValueCondition.IsEqual */
  9730. operator?: number);
  9731. /**
  9732. * Compares the given value with the property value for the specified conditional operator
  9733. * @returns the result of the comparison
  9734. */
  9735. isValid(): boolean;
  9736. /**
  9737. * Serialize the ValueCondition into a JSON compatible object
  9738. * @returns serialization object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Gets the name of the conditional operator for the ValueCondition
  9743. * @param operator the conditional operator
  9744. * @returns the name
  9745. */
  9746. static GetOperatorName(operator: number): string;
  9747. }
  9748. /**
  9749. * Defines a predicate condition as an extension of Condition
  9750. */
  9751. export class PredicateCondition extends Condition {
  9752. /** defines the predicate function used to validate the condition */
  9753. predicate: () => boolean;
  9754. /**
  9755. * Internal only - manager for action
  9756. * @hidden
  9757. */
  9758. _actionManager: ActionManager;
  9759. /**
  9760. * Creates a new PredicateCondition
  9761. * @param actionManager manager for the action the condition applies to
  9762. * @param predicate defines the predicate function used to validate the condition
  9763. */
  9764. constructor(actionManager: ActionManager,
  9765. /** defines the predicate function used to validate the condition */
  9766. predicate: () => boolean);
  9767. /**
  9768. * @returns the validity of the predicate condition
  9769. */
  9770. isValid(): boolean;
  9771. }
  9772. /**
  9773. * Defines a state condition as an extension of Condition
  9774. */
  9775. export class StateCondition extends Condition {
  9776. /** Value to compare with target state */
  9777. value: string;
  9778. /**
  9779. * Internal only - manager for action
  9780. * @hidden
  9781. */
  9782. _actionManager: ActionManager;
  9783. /**
  9784. * Internal only
  9785. * @hidden
  9786. */
  9787. private _target;
  9788. /**
  9789. * Creates a new StateCondition
  9790. * @param actionManager manager for the action the condition applies to
  9791. * @param target of the condition
  9792. * @param value to compare with target state
  9793. */
  9794. constructor(actionManager: ActionManager, target: any,
  9795. /** Value to compare with target state */
  9796. value: string);
  9797. /**
  9798. * Gets a boolean indicating if the current condition is met
  9799. * @returns the validity of the state
  9800. */
  9801. isValid(): boolean;
  9802. /**
  9803. * Serialize the StateCondition into a JSON compatible object
  9804. * @returns serialization object
  9805. */
  9806. serialize(): any;
  9807. }
  9808. }
  9809. declare module "babylonjs/Actions/directActions" {
  9810. import { Action } from "babylonjs/Actions/action";
  9811. import { Condition } from "babylonjs/Actions/condition";
  9812. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9813. /**
  9814. * This defines an action responsible to toggle a boolean once triggered.
  9815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9816. */
  9817. export class SwitchBooleanAction extends Action {
  9818. /**
  9819. * The path to the boolean property in the target object
  9820. */
  9821. propertyPath: string;
  9822. private _target;
  9823. private _effectiveTarget;
  9824. private _property;
  9825. /**
  9826. * Instantiate the action
  9827. * @param triggerOptions defines the trigger options
  9828. * @param target defines the object containing the boolean
  9829. * @param propertyPath defines the path to the boolean property in the target object
  9830. * @param condition defines the trigger related conditions
  9831. */
  9832. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9833. /** @hidden */
  9834. _prepare(): void;
  9835. /**
  9836. * Execute the action toggle the boolean value.
  9837. */
  9838. execute(): void;
  9839. /**
  9840. * Serializes the actions and its related information.
  9841. * @param parent defines the object to serialize in
  9842. * @returns the serialized object
  9843. */
  9844. serialize(parent: any): any;
  9845. }
  9846. /**
  9847. * This defines an action responsible to set a the state field of the target
  9848. * to a desired value once triggered.
  9849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9850. */
  9851. export class SetStateAction extends Action {
  9852. /**
  9853. * The value to store in the state field.
  9854. */
  9855. value: string;
  9856. private _target;
  9857. /**
  9858. * Instantiate the action
  9859. * @param triggerOptions defines the trigger options
  9860. * @param target defines the object containing the state property
  9861. * @param value defines the value to store in the state field
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9865. /**
  9866. * Execute the action and store the value on the target state property.
  9867. */
  9868. execute(): void;
  9869. /**
  9870. * Serializes the actions and its related information.
  9871. * @param parent defines the object to serialize in
  9872. * @returns the serialized object
  9873. */
  9874. serialize(parent: any): any;
  9875. }
  9876. /**
  9877. * This defines an action responsible to set a property of the target
  9878. * to a desired value once triggered.
  9879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9880. */
  9881. export class SetValueAction extends Action {
  9882. /**
  9883. * The path of the property to set in the target.
  9884. */
  9885. propertyPath: string;
  9886. /**
  9887. * The value to set in the property
  9888. */
  9889. value: any;
  9890. private _target;
  9891. private _effectiveTarget;
  9892. private _property;
  9893. /**
  9894. * Instantiate the action
  9895. * @param triggerOptions defines the trigger options
  9896. * @param target defines the object containing the property
  9897. * @param propertyPath defines the path of the property to set in the target
  9898. * @param value defines the value to set in the property
  9899. * @param condition defines the trigger related conditions
  9900. */
  9901. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9902. /** @hidden */
  9903. _prepare(): void;
  9904. /**
  9905. * Execute the action and set the targetted property to the desired value.
  9906. */
  9907. execute(): void;
  9908. /**
  9909. * Serializes the actions and its related information.
  9910. * @param parent defines the object to serialize in
  9911. * @returns the serialized object
  9912. */
  9913. serialize(parent: any): any;
  9914. }
  9915. /**
  9916. * This defines an action responsible to increment the target value
  9917. * to a desired value once triggered.
  9918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9919. */
  9920. export class IncrementValueAction extends Action {
  9921. /**
  9922. * The path of the property to increment in the target.
  9923. */
  9924. propertyPath: string;
  9925. /**
  9926. * The value we should increment the property by.
  9927. */
  9928. value: any;
  9929. private _target;
  9930. private _effectiveTarget;
  9931. private _property;
  9932. /**
  9933. * Instantiate the action
  9934. * @param triggerOptions defines the trigger options
  9935. * @param target defines the object containing the property
  9936. * @param propertyPath defines the path of the property to increment in the target
  9937. * @param value defines the value value we should increment the property by
  9938. * @param condition defines the trigger related conditions
  9939. */
  9940. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9941. /** @hidden */
  9942. _prepare(): void;
  9943. /**
  9944. * Execute the action and increment the target of the value amount.
  9945. */
  9946. execute(): void;
  9947. /**
  9948. * Serializes the actions and its related information.
  9949. * @param parent defines the object to serialize in
  9950. * @returns the serialized object
  9951. */
  9952. serialize(parent: any): any;
  9953. }
  9954. /**
  9955. * This defines an action responsible to start an animation once triggered.
  9956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9957. */
  9958. export class PlayAnimationAction extends Action {
  9959. /**
  9960. * Where the animation should start (animation frame)
  9961. */
  9962. from: number;
  9963. /**
  9964. * Where the animation should stop (animation frame)
  9965. */
  9966. to: number;
  9967. /**
  9968. * Define if the animation should loop or stop after the first play.
  9969. */
  9970. loop?: boolean;
  9971. private _target;
  9972. /**
  9973. * Instantiate the action
  9974. * @param triggerOptions defines the trigger options
  9975. * @param target defines the target animation or animation name
  9976. * @param from defines from where the animation should start (animation frame)
  9977. * @param end defines where the animation should stop (animation frame)
  9978. * @param loop defines if the animation should loop or stop after the first play
  9979. * @param condition defines the trigger related conditions
  9980. */
  9981. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9982. /** @hidden */
  9983. _prepare(): void;
  9984. /**
  9985. * Execute the action and play the animation.
  9986. */
  9987. execute(): void;
  9988. /**
  9989. * Serializes the actions and its related information.
  9990. * @param parent defines the object to serialize in
  9991. * @returns the serialized object
  9992. */
  9993. serialize(parent: any): any;
  9994. }
  9995. /**
  9996. * This defines an action responsible to stop an animation once triggered.
  9997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9998. */
  9999. export class StopAnimationAction extends Action {
  10000. private _target;
  10001. /**
  10002. * Instantiate the action
  10003. * @param triggerOptions defines the trigger options
  10004. * @param target defines the target animation or animation name
  10005. * @param condition defines the trigger related conditions
  10006. */
  10007. constructor(triggerOptions: any, target: any, condition?: Condition);
  10008. /** @hidden */
  10009. _prepare(): void;
  10010. /**
  10011. * Execute the action and stop the animation.
  10012. */
  10013. execute(): void;
  10014. /**
  10015. * Serializes the actions and its related information.
  10016. * @param parent defines the object to serialize in
  10017. * @returns the serialized object
  10018. */
  10019. serialize(parent: any): any;
  10020. }
  10021. /**
  10022. * This defines an action responsible that does nothing once triggered.
  10023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10024. */
  10025. export class DoNothingAction extends Action {
  10026. /**
  10027. * Instantiate the action
  10028. * @param triggerOptions defines the trigger options
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions?: any, condition?: Condition);
  10032. /**
  10033. * Execute the action and do nothing.
  10034. */
  10035. execute(): void;
  10036. /**
  10037. * Serializes the actions and its related information.
  10038. * @param parent defines the object to serialize in
  10039. * @returns the serialized object
  10040. */
  10041. serialize(parent: any): any;
  10042. }
  10043. /**
  10044. * This defines an action responsible to trigger several actions once triggered.
  10045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10046. */
  10047. export class CombineAction extends Action {
  10048. /**
  10049. * The list of aggregated animations to run.
  10050. */
  10051. children: Action[];
  10052. /**
  10053. * Instantiate the action
  10054. * @param triggerOptions defines the trigger options
  10055. * @param children defines the list of aggregated animations to run
  10056. * @param condition defines the trigger related conditions
  10057. */
  10058. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10059. /** @hidden */
  10060. _prepare(): void;
  10061. /**
  10062. * Execute the action and executes all the aggregated actions.
  10063. */
  10064. execute(evt: ActionEvent): void;
  10065. /**
  10066. * Serializes the actions and its related information.
  10067. * @param parent defines the object to serialize in
  10068. * @returns the serialized object
  10069. */
  10070. serialize(parent: any): any;
  10071. }
  10072. /**
  10073. * This defines an action responsible to run code (external event) once triggered.
  10074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10075. */
  10076. export class ExecuteCodeAction extends Action {
  10077. /**
  10078. * The callback function to run.
  10079. */
  10080. func: (evt: ActionEvent) => void;
  10081. /**
  10082. * Instantiate the action
  10083. * @param triggerOptions defines the trigger options
  10084. * @param func defines the callback function to run
  10085. * @param condition defines the trigger related conditions
  10086. */
  10087. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10088. /**
  10089. * Execute the action and run the attached code.
  10090. */
  10091. execute(evt: ActionEvent): void;
  10092. }
  10093. /**
  10094. * This defines an action responsible to set the parent property of the target once triggered.
  10095. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10096. */
  10097. export class SetParentAction extends Action {
  10098. private _parent;
  10099. private _target;
  10100. /**
  10101. * Instantiate the action
  10102. * @param triggerOptions defines the trigger options
  10103. * @param target defines the target containing the parent property
  10104. * @param parent defines from where the animation should start (animation frame)
  10105. * @param condition defines the trigger related conditions
  10106. */
  10107. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10108. /** @hidden */
  10109. _prepare(): void;
  10110. /**
  10111. * Execute the action and set the parent property.
  10112. */
  10113. execute(): void;
  10114. /**
  10115. * Serializes the actions and its related information.
  10116. * @param parent defines the object to serialize in
  10117. * @returns the serialized object
  10118. */
  10119. serialize(parent: any): any;
  10120. }
  10121. }
  10122. declare module "babylonjs/Actions/actionManager" {
  10123. import { Nullable } from "babylonjs/types";
  10124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10125. import { Scene } from "babylonjs/scene";
  10126. import { IAction } from "babylonjs/Actions/action";
  10127. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10128. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10129. /**
  10130. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10131. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10133. */
  10134. export class ActionManager extends AbstractActionManager {
  10135. /**
  10136. * Nothing
  10137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10138. */
  10139. static readonly NothingTrigger: number;
  10140. /**
  10141. * On pick
  10142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10143. */
  10144. static readonly OnPickTrigger: number;
  10145. /**
  10146. * On left pick
  10147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10148. */
  10149. static readonly OnLeftPickTrigger: number;
  10150. /**
  10151. * On right pick
  10152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10153. */
  10154. static readonly OnRightPickTrigger: number;
  10155. /**
  10156. * On center pick
  10157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10158. */
  10159. static readonly OnCenterPickTrigger: number;
  10160. /**
  10161. * On pick down
  10162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10163. */
  10164. static readonly OnPickDownTrigger: number;
  10165. /**
  10166. * On double pick
  10167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10168. */
  10169. static readonly OnDoublePickTrigger: number;
  10170. /**
  10171. * On pick up
  10172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10173. */
  10174. static readonly OnPickUpTrigger: number;
  10175. /**
  10176. * On pick out.
  10177. * This trigger will only be raised if you also declared a OnPickDown
  10178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10179. */
  10180. static readonly OnPickOutTrigger: number;
  10181. /**
  10182. * On long press
  10183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10184. */
  10185. static readonly OnLongPressTrigger: number;
  10186. /**
  10187. * On pointer over
  10188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10189. */
  10190. static readonly OnPointerOverTrigger: number;
  10191. /**
  10192. * On pointer out
  10193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10194. */
  10195. static readonly OnPointerOutTrigger: number;
  10196. /**
  10197. * On every frame
  10198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10199. */
  10200. static readonly OnEveryFrameTrigger: number;
  10201. /**
  10202. * On intersection enter
  10203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10204. */
  10205. static readonly OnIntersectionEnterTrigger: number;
  10206. /**
  10207. * On intersection exit
  10208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10209. */
  10210. static readonly OnIntersectionExitTrigger: number;
  10211. /**
  10212. * On key down
  10213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10214. */
  10215. static readonly OnKeyDownTrigger: number;
  10216. /**
  10217. * On key up
  10218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10219. */
  10220. static readonly OnKeyUpTrigger: number;
  10221. private _scene;
  10222. /**
  10223. * Creates a new action manager
  10224. * @param scene defines the hosting scene
  10225. */
  10226. constructor(scene: Scene);
  10227. /**
  10228. * Releases all associated resources
  10229. */
  10230. dispose(): void;
  10231. /**
  10232. * Gets hosting scene
  10233. * @returns the hosting scene
  10234. */
  10235. getScene(): Scene;
  10236. /**
  10237. * Does this action manager handles actions of any of the given triggers
  10238. * @param triggers defines the triggers to be tested
  10239. * @return a boolean indicating whether one (or more) of the triggers is handled
  10240. */
  10241. hasSpecificTriggers(triggers: number[]): boolean;
  10242. /**
  10243. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10244. * speed.
  10245. * @param triggerA defines the trigger to be tested
  10246. * @param triggerB defines the trigger to be tested
  10247. * @return a boolean indicating whether one (or more) of the triggers is handled
  10248. */
  10249. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10250. /**
  10251. * Does this action manager handles actions of a given trigger
  10252. * @param trigger defines the trigger to be tested
  10253. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10254. * @return whether the trigger is handled
  10255. */
  10256. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10257. /**
  10258. * Does this action manager has pointer triggers
  10259. */
  10260. get hasPointerTriggers(): boolean;
  10261. /**
  10262. * Does this action manager has pick triggers
  10263. */
  10264. get hasPickTriggers(): boolean;
  10265. /**
  10266. * Registers an action to this action manager
  10267. * @param action defines the action to be registered
  10268. * @return the action amended (prepared) after registration
  10269. */
  10270. registerAction(action: IAction): Nullable<IAction>;
  10271. /**
  10272. * Unregisters an action to this action manager
  10273. * @param action defines the action to be unregistered
  10274. * @return a boolean indicating whether the action has been unregistered
  10275. */
  10276. unregisterAction(action: IAction): Boolean;
  10277. /**
  10278. * Process a specific trigger
  10279. * @param trigger defines the trigger to process
  10280. * @param evt defines the event details to be processed
  10281. */
  10282. processTrigger(trigger: number, evt?: IActionEvent): void;
  10283. /** @hidden */
  10284. _getEffectiveTarget(target: any, propertyPath: string): any;
  10285. /** @hidden */
  10286. _getProperty(propertyPath: string): string;
  10287. /**
  10288. * Serialize this manager to a JSON object
  10289. * @param name defines the property name to store this manager
  10290. * @returns a JSON representation of this manager
  10291. */
  10292. serialize(name: string): any;
  10293. /**
  10294. * Creates a new ActionManager from a JSON data
  10295. * @param parsedActions defines the JSON data to read from
  10296. * @param object defines the hosting mesh
  10297. * @param scene defines the hosting scene
  10298. */
  10299. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10300. /**
  10301. * Get a trigger name by index
  10302. * @param trigger defines the trigger index
  10303. * @returns a trigger name
  10304. */
  10305. static GetTriggerName(trigger: number): string;
  10306. }
  10307. }
  10308. declare module "babylonjs/Sprites/sprite" {
  10309. import { Vector3 } from "babylonjs/Maths/math.vector";
  10310. import { Nullable } from "babylonjs/types";
  10311. import { ActionManager } from "babylonjs/Actions/actionManager";
  10312. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10313. import { Color4 } from "babylonjs/Maths/math.color";
  10314. import { Observable } from "babylonjs/Misc/observable";
  10315. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10316. import { Animation } from "babylonjs/Animations/animation";
  10317. /**
  10318. * Class used to represent a sprite
  10319. * @see http://doc.babylonjs.com/babylon101/sprites
  10320. */
  10321. export class Sprite implements IAnimatable {
  10322. /** defines the name */
  10323. name: string;
  10324. /** Gets or sets the current world position */
  10325. position: Vector3;
  10326. /** Gets or sets the main color */
  10327. color: Color4;
  10328. /** Gets or sets the width */
  10329. width: number;
  10330. /** Gets or sets the height */
  10331. height: number;
  10332. /** Gets or sets rotation angle */
  10333. angle: number;
  10334. /** Gets or sets the cell index in the sprite sheet */
  10335. cellIndex: number;
  10336. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10337. cellRef: string;
  10338. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10339. invertU: boolean;
  10340. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10341. invertV: boolean;
  10342. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10343. disposeWhenFinishedAnimating: boolean;
  10344. /** Gets the list of attached animations */
  10345. animations: Nullable<Array<Animation>>;
  10346. /** Gets or sets a boolean indicating if the sprite can be picked */
  10347. isPickable: boolean;
  10348. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10349. useAlphaForPicking: boolean;
  10350. /** @hidden */
  10351. _xOffset: number;
  10352. /** @hidden */
  10353. _yOffset: number;
  10354. /** @hidden */
  10355. _xSize: number;
  10356. /** @hidden */
  10357. _ySize: number;
  10358. /**
  10359. * Gets or sets the associated action manager
  10360. */
  10361. actionManager: Nullable<ActionManager>;
  10362. /**
  10363. * An event triggered when the control has been disposed
  10364. */
  10365. onDisposeObservable: Observable<Sprite>;
  10366. private _animationStarted;
  10367. private _loopAnimation;
  10368. private _fromIndex;
  10369. private _toIndex;
  10370. private _delay;
  10371. private _direction;
  10372. private _manager;
  10373. private _time;
  10374. private _onAnimationEnd;
  10375. /**
  10376. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10377. */
  10378. isVisible: boolean;
  10379. /**
  10380. * Gets or sets the sprite size
  10381. */
  10382. get size(): number;
  10383. set size(value: number);
  10384. /**
  10385. * Returns a boolean indicating if the animation is started
  10386. */
  10387. get animationStarted(): boolean;
  10388. /**
  10389. * Gets or sets the unique id of the sprite
  10390. */
  10391. uniqueId: number;
  10392. /**
  10393. * Gets the manager of this sprite
  10394. */
  10395. get manager(): ISpriteManager;
  10396. /**
  10397. * Creates a new Sprite
  10398. * @param name defines the name
  10399. * @param manager defines the manager
  10400. */
  10401. constructor(
  10402. /** defines the name */
  10403. name: string, manager: ISpriteManager);
  10404. /**
  10405. * Returns the string "Sprite"
  10406. * @returns "Sprite"
  10407. */
  10408. getClassName(): string;
  10409. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10410. get fromIndex(): number;
  10411. set fromIndex(value: number);
  10412. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10413. get toIndex(): number;
  10414. set toIndex(value: number);
  10415. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10416. get loopAnimation(): boolean;
  10417. set loopAnimation(value: boolean);
  10418. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10419. get delay(): number;
  10420. set delay(value: number);
  10421. /**
  10422. * Starts an animation
  10423. * @param from defines the initial key
  10424. * @param to defines the end key
  10425. * @param loop defines if the animation must loop
  10426. * @param delay defines the start delay (in ms)
  10427. * @param onAnimationEnd defines a callback to call when animation ends
  10428. */
  10429. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10430. /** Stops current animation (if any) */
  10431. stopAnimation(): void;
  10432. /** @hidden */
  10433. _animate(deltaTime: number): void;
  10434. /** Release associated resources */
  10435. dispose(): void;
  10436. /**
  10437. * Serializes the sprite to a JSON object
  10438. * @returns the JSON object
  10439. */
  10440. serialize(): any;
  10441. /**
  10442. * Parses a JSON object to create a new sprite
  10443. * @param parsedSprite The JSON object to parse
  10444. * @param manager defines the hosting manager
  10445. * @returns the new sprite
  10446. */
  10447. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10448. }
  10449. }
  10450. declare module "babylonjs/Collisions/pickingInfo" {
  10451. import { Nullable } from "babylonjs/types";
  10452. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10454. import { Sprite } from "babylonjs/Sprites/sprite";
  10455. import { Ray } from "babylonjs/Culling/ray";
  10456. /**
  10457. * Information about the result of picking within a scene
  10458. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10459. */
  10460. export class PickingInfo {
  10461. /** @hidden */
  10462. _pickingUnavailable: boolean;
  10463. /**
  10464. * If the pick collided with an object
  10465. */
  10466. hit: boolean;
  10467. /**
  10468. * Distance away where the pick collided
  10469. */
  10470. distance: number;
  10471. /**
  10472. * The location of pick collision
  10473. */
  10474. pickedPoint: Nullable<Vector3>;
  10475. /**
  10476. * The mesh corresponding the the pick collision
  10477. */
  10478. pickedMesh: Nullable<AbstractMesh>;
  10479. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10480. bu: number;
  10481. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10482. bv: number;
  10483. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10484. faceId: number;
  10485. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10486. subMeshFaceId: number;
  10487. /** Id of the the submesh that was picked */
  10488. subMeshId: number;
  10489. /** If a sprite was picked, this will be the sprite the pick collided with */
  10490. pickedSprite: Nullable<Sprite>;
  10491. /**
  10492. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10493. */
  10494. originMesh: Nullable<AbstractMesh>;
  10495. /**
  10496. * The ray that was used to perform the picking.
  10497. */
  10498. ray: Nullable<Ray>;
  10499. /**
  10500. * Gets the normal correspodning to the face the pick collided with
  10501. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10502. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10503. * @returns The normal correspodning to the face the pick collided with
  10504. */
  10505. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10506. /**
  10507. * Gets the texture coordinates of where the pick occured
  10508. * @returns the vector containing the coordnates of the texture
  10509. */
  10510. getTextureCoordinates(): Nullable<Vector2>;
  10511. }
  10512. }
  10513. declare module "babylonjs/Culling/ray" {
  10514. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10515. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10517. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10518. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10519. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10520. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10521. import { Plane } from "babylonjs/Maths/math.plane";
  10522. /**
  10523. * Class representing a ray with position and direction
  10524. */
  10525. export class Ray {
  10526. /** origin point */
  10527. origin: Vector3;
  10528. /** direction */
  10529. direction: Vector3;
  10530. /** length of the ray */
  10531. length: number;
  10532. private static readonly TmpVector3;
  10533. private _tmpRay;
  10534. /**
  10535. * Creates a new ray
  10536. * @param origin origin point
  10537. * @param direction direction
  10538. * @param length length of the ray
  10539. */
  10540. constructor(
  10541. /** origin point */
  10542. origin: Vector3,
  10543. /** direction */
  10544. direction: Vector3,
  10545. /** length of the ray */
  10546. length?: number);
  10547. /**
  10548. * Checks if the ray intersects a box
  10549. * This does not account for the ray lenght by design to improve perfs.
  10550. * @param minimum bound of the box
  10551. * @param maximum bound of the box
  10552. * @param intersectionTreshold extra extend to be added to the box in all direction
  10553. * @returns if the box was hit
  10554. */
  10555. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10556. /**
  10557. * Checks if the ray intersects a box
  10558. * This does not account for the ray lenght by design to improve perfs.
  10559. * @param box the bounding box to check
  10560. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10561. * @returns if the box was hit
  10562. */
  10563. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10564. /**
  10565. * If the ray hits a sphere
  10566. * @param sphere the bounding sphere to check
  10567. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10568. * @returns true if it hits the sphere
  10569. */
  10570. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10571. /**
  10572. * If the ray hits a triange
  10573. * @param vertex0 triangle vertex
  10574. * @param vertex1 triangle vertex
  10575. * @param vertex2 triangle vertex
  10576. * @returns intersection information if hit
  10577. */
  10578. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10579. /**
  10580. * Checks if ray intersects a plane
  10581. * @param plane the plane to check
  10582. * @returns the distance away it was hit
  10583. */
  10584. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10585. /**
  10586. * Calculate the intercept of a ray on a given axis
  10587. * @param axis to check 'x' | 'y' | 'z'
  10588. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10589. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10590. */
  10591. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10592. /**
  10593. * Checks if ray intersects a mesh
  10594. * @param mesh the mesh to check
  10595. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10596. * @returns picking info of the intersecton
  10597. */
  10598. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10599. /**
  10600. * Checks if ray intersects a mesh
  10601. * @param meshes the meshes to check
  10602. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10603. * @param results array to store result in
  10604. * @returns Array of picking infos
  10605. */
  10606. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10607. private _comparePickingInfo;
  10608. private static smallnum;
  10609. private static rayl;
  10610. /**
  10611. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10612. * @param sega the first point of the segment to test the intersection against
  10613. * @param segb the second point of the segment to test the intersection against
  10614. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10615. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10616. */
  10617. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10618. /**
  10619. * Update the ray from viewport position
  10620. * @param x position
  10621. * @param y y position
  10622. * @param viewportWidth viewport width
  10623. * @param viewportHeight viewport height
  10624. * @param world world matrix
  10625. * @param view view matrix
  10626. * @param projection projection matrix
  10627. * @returns this ray updated
  10628. */
  10629. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10630. /**
  10631. * Creates a ray with origin and direction of 0,0,0
  10632. * @returns the new ray
  10633. */
  10634. static Zero(): Ray;
  10635. /**
  10636. * Creates a new ray from screen space and viewport
  10637. * @param x position
  10638. * @param y y position
  10639. * @param viewportWidth viewport width
  10640. * @param viewportHeight viewport height
  10641. * @param world world matrix
  10642. * @param view view matrix
  10643. * @param projection projection matrix
  10644. * @returns new ray
  10645. */
  10646. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10647. /**
  10648. * 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
  10649. * transformed to the given world matrix.
  10650. * @param origin The origin point
  10651. * @param end The end point
  10652. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10653. * @returns the new ray
  10654. */
  10655. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10656. /**
  10657. * Transforms a ray by a matrix
  10658. * @param ray ray to transform
  10659. * @param matrix matrix to apply
  10660. * @returns the resulting new ray
  10661. */
  10662. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10663. /**
  10664. * Transforms a ray by a matrix
  10665. * @param ray ray to transform
  10666. * @param matrix matrix to apply
  10667. * @param result ray to store result in
  10668. */
  10669. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10670. /**
  10671. * Unproject a ray from screen space to object space
  10672. * @param sourceX defines the screen space x coordinate to use
  10673. * @param sourceY defines the screen space y coordinate to use
  10674. * @param viewportWidth defines the current width of the viewport
  10675. * @param viewportHeight defines the current height of the viewport
  10676. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10677. * @param view defines the view matrix to use
  10678. * @param projection defines the projection matrix to use
  10679. */
  10680. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10681. }
  10682. /**
  10683. * Type used to define predicate used to select faces when a mesh intersection is detected
  10684. */
  10685. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10686. module "babylonjs/scene" {
  10687. interface Scene {
  10688. /** @hidden */
  10689. _tempPickingRay: Nullable<Ray>;
  10690. /** @hidden */
  10691. _cachedRayForTransform: Ray;
  10692. /** @hidden */
  10693. _pickWithRayInverseMatrix: Matrix;
  10694. /** @hidden */
  10695. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10696. /** @hidden */
  10697. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10698. }
  10699. }
  10700. }
  10701. declare module "babylonjs/sceneComponent" {
  10702. import { Scene } from "babylonjs/scene";
  10703. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10704. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10705. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10706. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10707. import { Nullable } from "babylonjs/types";
  10708. import { Camera } from "babylonjs/Cameras/camera";
  10709. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10710. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10711. import { AbstractScene } from "babylonjs/abstractScene";
  10712. import { Mesh } from "babylonjs/Meshes/mesh";
  10713. /**
  10714. * Groups all the scene component constants in one place to ease maintenance.
  10715. * @hidden
  10716. */
  10717. export class SceneComponentConstants {
  10718. static readonly NAME_EFFECTLAYER: string;
  10719. static readonly NAME_LAYER: string;
  10720. static readonly NAME_LENSFLARESYSTEM: string;
  10721. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10722. static readonly NAME_PARTICLESYSTEM: string;
  10723. static readonly NAME_GAMEPAD: string;
  10724. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10725. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10726. static readonly NAME_DEPTHRENDERER: string;
  10727. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10728. static readonly NAME_SPRITE: string;
  10729. static readonly NAME_OUTLINERENDERER: string;
  10730. static readonly NAME_PROCEDURALTEXTURE: string;
  10731. static readonly NAME_SHADOWGENERATOR: string;
  10732. static readonly NAME_OCTREE: string;
  10733. static readonly NAME_PHYSICSENGINE: string;
  10734. static readonly NAME_AUDIO: string;
  10735. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10736. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10737. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10738. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10739. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10740. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10741. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10742. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10743. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10744. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10745. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10746. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10747. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10748. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10749. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10750. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10751. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10752. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10753. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10754. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10755. static readonly STEP_AFTERRENDER_AUDIO: number;
  10756. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10757. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10758. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10759. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10760. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10761. static readonly STEP_POINTERMOVE_SPRITE: number;
  10762. static readonly STEP_POINTERDOWN_SPRITE: number;
  10763. static readonly STEP_POINTERUP_SPRITE: number;
  10764. }
  10765. /**
  10766. * This represents a scene component.
  10767. *
  10768. * This is used to decouple the dependency the scene is having on the different workloads like
  10769. * layers, post processes...
  10770. */
  10771. export interface ISceneComponent {
  10772. /**
  10773. * The name of the component. Each component must have a unique name.
  10774. */
  10775. name: string;
  10776. /**
  10777. * The scene the component belongs to.
  10778. */
  10779. scene: Scene;
  10780. /**
  10781. * Register the component to one instance of a scene.
  10782. */
  10783. register(): void;
  10784. /**
  10785. * Rebuilds the elements related to this component in case of
  10786. * context lost for instance.
  10787. */
  10788. rebuild(): void;
  10789. /**
  10790. * Disposes the component and the associated ressources.
  10791. */
  10792. dispose(): void;
  10793. }
  10794. /**
  10795. * This represents a SERIALIZABLE scene component.
  10796. *
  10797. * This extends Scene Component to add Serialization methods on top.
  10798. */
  10799. export interface ISceneSerializableComponent extends ISceneComponent {
  10800. /**
  10801. * Adds all the elements from the container to the scene
  10802. * @param container the container holding the elements
  10803. */
  10804. addFromContainer(container: AbstractScene): void;
  10805. /**
  10806. * Removes all the elements in the container from the scene
  10807. * @param container contains the elements to remove
  10808. * @param dispose if the removed element should be disposed (default: false)
  10809. */
  10810. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10811. /**
  10812. * Serializes the component data to the specified json object
  10813. * @param serializationObject The object to serialize to
  10814. */
  10815. serialize(serializationObject: any): void;
  10816. }
  10817. /**
  10818. * Strong typing of a Mesh related stage step action
  10819. */
  10820. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10821. /**
  10822. * Strong typing of a Evaluate Sub Mesh related stage step action
  10823. */
  10824. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10825. /**
  10826. * Strong typing of a Active Mesh related stage step action
  10827. */
  10828. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10829. /**
  10830. * Strong typing of a Camera related stage step action
  10831. */
  10832. export type CameraStageAction = (camera: Camera) => void;
  10833. /**
  10834. * Strong typing of a Camera Frame buffer related stage step action
  10835. */
  10836. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10837. /**
  10838. * Strong typing of a Render Target related stage step action
  10839. */
  10840. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10841. /**
  10842. * Strong typing of a RenderingGroup related stage step action
  10843. */
  10844. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10845. /**
  10846. * Strong typing of a Mesh Render related stage step action
  10847. */
  10848. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10849. /**
  10850. * Strong typing of a simple stage step action
  10851. */
  10852. export type SimpleStageAction = () => void;
  10853. /**
  10854. * Strong typing of a render target action.
  10855. */
  10856. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10857. /**
  10858. * Strong typing of a pointer move action.
  10859. */
  10860. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10861. /**
  10862. * Strong typing of a pointer up/down action.
  10863. */
  10864. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10865. /**
  10866. * Representation of a stage in the scene (Basically a list of ordered steps)
  10867. * @hidden
  10868. */
  10869. export class Stage<T extends Function> extends Array<{
  10870. index: number;
  10871. component: ISceneComponent;
  10872. action: T;
  10873. }> {
  10874. /**
  10875. * Hide ctor from the rest of the world.
  10876. * @param items The items to add.
  10877. */
  10878. private constructor();
  10879. /**
  10880. * Creates a new Stage.
  10881. * @returns A new instance of a Stage
  10882. */
  10883. static Create<T extends Function>(): Stage<T>;
  10884. /**
  10885. * Registers a step in an ordered way in the targeted stage.
  10886. * @param index Defines the position to register the step in
  10887. * @param component Defines the component attached to the step
  10888. * @param action Defines the action to launch during the step
  10889. */
  10890. registerStep(index: number, component: ISceneComponent, action: T): void;
  10891. /**
  10892. * Clears all the steps from the stage.
  10893. */
  10894. clear(): void;
  10895. }
  10896. }
  10897. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10898. import { Nullable } from "babylonjs/types";
  10899. import { Observable } from "babylonjs/Misc/observable";
  10900. import { Scene } from "babylonjs/scene";
  10901. import { Sprite } from "babylonjs/Sprites/sprite";
  10902. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10903. import { Ray } from "babylonjs/Culling/ray";
  10904. import { Camera } from "babylonjs/Cameras/camera";
  10905. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10906. import { ISceneComponent } from "babylonjs/sceneComponent";
  10907. module "babylonjs/scene" {
  10908. interface Scene {
  10909. /** @hidden */
  10910. _pointerOverSprite: Nullable<Sprite>;
  10911. /** @hidden */
  10912. _pickedDownSprite: Nullable<Sprite>;
  10913. /** @hidden */
  10914. _tempSpritePickingRay: Nullable<Ray>;
  10915. /**
  10916. * All of the sprite managers added to this scene
  10917. * @see http://doc.babylonjs.com/babylon101/sprites
  10918. */
  10919. spriteManagers: Array<ISpriteManager>;
  10920. /**
  10921. * An event triggered when sprites rendering is about to start
  10922. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10923. */
  10924. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10925. /**
  10926. * An event triggered when sprites rendering is done
  10927. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10928. */
  10929. onAfterSpritesRenderingObservable: Observable<Scene>;
  10930. /** @hidden */
  10931. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10932. /** Launch a ray to try to pick a sprite in the scene
  10933. * @param x position on screen
  10934. * @param y position on screen
  10935. * @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
  10936. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10937. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10938. * @returns a PickingInfo
  10939. */
  10940. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10941. /** Use the given ray to pick a sprite in the scene
  10942. * @param ray The ray (in world space) to use to pick meshes
  10943. * @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
  10944. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10945. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10946. * @returns a PickingInfo
  10947. */
  10948. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10949. /** @hidden */
  10950. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10951. /** Launch a ray to try to pick sprites in the scene
  10952. * @param x position on screen
  10953. * @param y position on screen
  10954. * @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
  10955. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10956. * @returns a PickingInfo array
  10957. */
  10958. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10959. /** Use the given ray to pick sprites in the scene
  10960. * @param ray The ray (in world space) to use to pick meshes
  10961. * @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
  10962. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10963. * @returns a PickingInfo array
  10964. */
  10965. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10966. /**
  10967. * Force the sprite under the pointer
  10968. * @param sprite defines the sprite to use
  10969. */
  10970. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10971. /**
  10972. * Gets the sprite under the pointer
  10973. * @returns a Sprite or null if no sprite is under the pointer
  10974. */
  10975. getPointerOverSprite(): Nullable<Sprite>;
  10976. }
  10977. }
  10978. /**
  10979. * Defines the sprite scene component responsible to manage sprites
  10980. * in a given scene.
  10981. */
  10982. export class SpriteSceneComponent implements ISceneComponent {
  10983. /**
  10984. * The component name helpfull to identify the component in the list of scene components.
  10985. */
  10986. readonly name: string;
  10987. /**
  10988. * The scene the component belongs to.
  10989. */
  10990. scene: Scene;
  10991. /** @hidden */
  10992. private _spritePredicate;
  10993. /**
  10994. * Creates a new instance of the component for the given scene
  10995. * @param scene Defines the scene to register the component in
  10996. */
  10997. constructor(scene: Scene);
  10998. /**
  10999. * Registers the component in a given scene
  11000. */
  11001. register(): void;
  11002. /**
  11003. * Rebuilds the elements related to this component in case of
  11004. * context lost for instance.
  11005. */
  11006. rebuild(): void;
  11007. /**
  11008. * Disposes the component and the associated ressources.
  11009. */
  11010. dispose(): void;
  11011. private _pickSpriteButKeepRay;
  11012. private _pointerMove;
  11013. private _pointerDown;
  11014. private _pointerUp;
  11015. }
  11016. }
  11017. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11018. /** @hidden */
  11019. export var fogFragmentDeclaration: {
  11020. name: string;
  11021. shader: string;
  11022. };
  11023. }
  11024. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11025. /** @hidden */
  11026. export var fogFragment: {
  11027. name: string;
  11028. shader: string;
  11029. };
  11030. }
  11031. declare module "babylonjs/Shaders/sprites.fragment" {
  11032. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11033. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11034. /** @hidden */
  11035. export var spritesPixelShader: {
  11036. name: string;
  11037. shader: string;
  11038. };
  11039. }
  11040. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11041. /** @hidden */
  11042. export var fogVertexDeclaration: {
  11043. name: string;
  11044. shader: string;
  11045. };
  11046. }
  11047. declare module "babylonjs/Shaders/sprites.vertex" {
  11048. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11049. /** @hidden */
  11050. export var spritesVertexShader: {
  11051. name: string;
  11052. shader: string;
  11053. };
  11054. }
  11055. declare module "babylonjs/Sprites/spriteManager" {
  11056. import { IDisposable, Scene } from "babylonjs/scene";
  11057. import { Nullable } from "babylonjs/types";
  11058. import { Observable } from "babylonjs/Misc/observable";
  11059. import { Sprite } from "babylonjs/Sprites/sprite";
  11060. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11061. import { Camera } from "babylonjs/Cameras/camera";
  11062. import { Texture } from "babylonjs/Materials/Textures/texture";
  11063. import "babylonjs/Shaders/sprites.fragment";
  11064. import "babylonjs/Shaders/sprites.vertex";
  11065. import { Ray } from "babylonjs/Culling/ray";
  11066. /**
  11067. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11068. */
  11069. export interface ISpriteManager extends IDisposable {
  11070. /**
  11071. * Gets manager's name
  11072. */
  11073. name: string;
  11074. /**
  11075. * Restricts the camera to viewing objects with the same layerMask.
  11076. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11077. */
  11078. layerMask: number;
  11079. /**
  11080. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11081. */
  11082. isPickable: boolean;
  11083. /**
  11084. * Gets the hosting scene
  11085. */
  11086. scene: Scene;
  11087. /**
  11088. * Specifies the rendering group id for this mesh (0 by default)
  11089. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11090. */
  11091. renderingGroupId: number;
  11092. /**
  11093. * Defines the list of sprites managed by the manager.
  11094. */
  11095. sprites: Array<Sprite>;
  11096. /**
  11097. * Gets or sets the spritesheet texture
  11098. */
  11099. texture: Texture;
  11100. /** Defines the default width of a cell in the spritesheet */
  11101. cellWidth: number;
  11102. /** Defines the default height of a cell in the spritesheet */
  11103. cellHeight: number;
  11104. /**
  11105. * Tests the intersection of a sprite with a specific ray.
  11106. * @param ray The ray we are sending to test the collision
  11107. * @param camera The camera space we are sending rays in
  11108. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11109. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11110. * @returns picking info or null.
  11111. */
  11112. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11113. /**
  11114. * Intersects the sprites with a ray
  11115. * @param ray defines the ray to intersect with
  11116. * @param camera defines the current active camera
  11117. * @param predicate defines a predicate used to select candidate sprites
  11118. * @returns null if no hit or a PickingInfo array
  11119. */
  11120. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11121. /**
  11122. * Renders the list of sprites on screen.
  11123. */
  11124. render(): void;
  11125. }
  11126. /**
  11127. * Class used to manage multiple sprites on the same spritesheet
  11128. * @see http://doc.babylonjs.com/babylon101/sprites
  11129. */
  11130. export class SpriteManager implements ISpriteManager {
  11131. /** defines the manager's name */
  11132. name: string;
  11133. /** Define the Url to load snippets */
  11134. static SnippetUrl: string;
  11135. /** Snippet ID if the manager was created from the snippet server */
  11136. snippetId: string;
  11137. /** Gets the list of sprites */
  11138. sprites: Sprite[];
  11139. /** Gets or sets the rendering group id (0 by default) */
  11140. renderingGroupId: number;
  11141. /** Gets or sets camera layer mask */
  11142. layerMask: number;
  11143. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11144. fogEnabled: boolean;
  11145. /** Gets or sets a boolean indicating if the sprites are pickable */
  11146. isPickable: boolean;
  11147. /** Defines the default width of a cell in the spritesheet */
  11148. cellWidth: number;
  11149. /** Defines the default height of a cell in the spritesheet */
  11150. cellHeight: number;
  11151. /** Associative array from JSON sprite data file */
  11152. private _cellData;
  11153. /** Array of sprite names from JSON sprite data file */
  11154. private _spriteMap;
  11155. /** True when packed cell data from JSON file is ready*/
  11156. private _packedAndReady;
  11157. private _textureContent;
  11158. /**
  11159. * An event triggered when the manager is disposed.
  11160. */
  11161. onDisposeObservable: Observable<SpriteManager>;
  11162. private _onDisposeObserver;
  11163. /**
  11164. * Callback called when the manager is disposed
  11165. */
  11166. set onDispose(callback: () => void);
  11167. private _capacity;
  11168. private _fromPacked;
  11169. private _spriteTexture;
  11170. private _epsilon;
  11171. private _scene;
  11172. private _vertexData;
  11173. private _buffer;
  11174. private _vertexBuffers;
  11175. private _indexBuffer;
  11176. private _effectBase;
  11177. private _effectFog;
  11178. /**
  11179. * Gets or sets the unique id of the sprite
  11180. */
  11181. uniqueId: number;
  11182. /**
  11183. * Gets the array of sprites
  11184. */
  11185. get children(): Sprite[];
  11186. /**
  11187. * Gets the hosting scene
  11188. */
  11189. get scene(): Scene;
  11190. /**
  11191. * Gets the capacity of the manager
  11192. */
  11193. get capacity(): number;
  11194. /**
  11195. * Gets or sets the spritesheet texture
  11196. */
  11197. get texture(): Texture;
  11198. set texture(value: Texture);
  11199. private _blendMode;
  11200. /**
  11201. * Blend mode use to render the particle, it can be any of
  11202. * the static Constants.ALPHA_x properties provided in this class.
  11203. * Default value is Constants.ALPHA_COMBINE
  11204. */
  11205. get blendMode(): number;
  11206. set blendMode(blendMode: number);
  11207. /** Disables writing to the depth buffer when rendering the sprites.
  11208. * It can be handy to disable depth writing when using textures without alpha channel
  11209. * and setting some specific blend modes.
  11210. */
  11211. disableDepthWrite: boolean;
  11212. /**
  11213. * Creates a new sprite manager
  11214. * @param name defines the manager's name
  11215. * @param imgUrl defines the sprite sheet url
  11216. * @param capacity defines the maximum allowed number of sprites
  11217. * @param cellSize defines the size of a sprite cell
  11218. * @param scene defines the hosting scene
  11219. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11220. * @param samplingMode defines the smapling mode to use with spritesheet
  11221. * @param fromPacked set to false; do not alter
  11222. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11223. */
  11224. constructor(
  11225. /** defines the manager's name */
  11226. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11227. /**
  11228. * Returns the string "SpriteManager"
  11229. * @returns "SpriteManager"
  11230. */
  11231. getClassName(): string;
  11232. private _makePacked;
  11233. private _appendSpriteVertex;
  11234. private _checkTextureAlpha;
  11235. /**
  11236. * Intersects the sprites with a ray
  11237. * @param ray defines the ray to intersect with
  11238. * @param camera defines the current active camera
  11239. * @param predicate defines a predicate used to select candidate sprites
  11240. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11241. * @returns null if no hit or a PickingInfo
  11242. */
  11243. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11244. /**
  11245. * Intersects the sprites with a ray
  11246. * @param ray defines the ray to intersect with
  11247. * @param camera defines the current active camera
  11248. * @param predicate defines a predicate used to select candidate sprites
  11249. * @returns null if no hit or a PickingInfo array
  11250. */
  11251. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11252. /**
  11253. * Render all child sprites
  11254. */
  11255. render(): void;
  11256. /**
  11257. * Release associated resources
  11258. */
  11259. dispose(): void;
  11260. /**
  11261. * Serializes the sprite manager to a JSON object
  11262. * @param serializeTexture defines if the texture must be serialized as well
  11263. * @returns the JSON object
  11264. */
  11265. serialize(serializeTexture?: boolean): any;
  11266. /**
  11267. * Parses a JSON object to create a new sprite manager.
  11268. * @param parsedManager The JSON object to parse
  11269. * @param scene The scene to create the sprite managerin
  11270. * @param rootUrl The root url to use to load external dependencies like texture
  11271. * @returns the new sprite manager
  11272. */
  11273. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11274. /**
  11275. * Creates a sprite manager from a snippet saved in a remote file
  11276. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11277. * @param url defines the url to load from
  11278. * @param scene defines the hosting scene
  11279. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11280. * @returns a promise that will resolve to the new sprite manager
  11281. */
  11282. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11283. /**
  11284. * Creates a sprite manager from a snippet saved by the sprite editor
  11285. * @param snippetId defines the snippet to load
  11286. * @param scene defines the hosting scene
  11287. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11288. * @returns a promise that will resolve to the new sprite manager
  11289. */
  11290. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11291. }
  11292. }
  11293. declare module "babylonjs/Misc/gradients" {
  11294. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11295. /** Interface used by value gradients (color, factor, ...) */
  11296. export interface IValueGradient {
  11297. /**
  11298. * Gets or sets the gradient value (between 0 and 1)
  11299. */
  11300. gradient: number;
  11301. }
  11302. /** Class used to store color4 gradient */
  11303. export class ColorGradient implements IValueGradient {
  11304. /**
  11305. * Gets or sets the gradient value (between 0 and 1)
  11306. */
  11307. gradient: number;
  11308. /**
  11309. * Gets or sets first associated color
  11310. */
  11311. color1: Color4;
  11312. /**
  11313. * Gets or sets second associated color
  11314. */
  11315. color2?: Color4 | undefined;
  11316. /**
  11317. * Creates a new color4 gradient
  11318. * @param gradient gets or sets the gradient value (between 0 and 1)
  11319. * @param color1 gets or sets first associated color
  11320. * @param color2 gets or sets first second color
  11321. */
  11322. constructor(
  11323. /**
  11324. * Gets or sets the gradient value (between 0 and 1)
  11325. */
  11326. gradient: number,
  11327. /**
  11328. * Gets or sets first associated color
  11329. */
  11330. color1: Color4,
  11331. /**
  11332. * Gets or sets second associated color
  11333. */
  11334. color2?: Color4 | undefined);
  11335. /**
  11336. * Will get a color picked randomly between color1 and color2.
  11337. * If color2 is undefined then color1 will be used
  11338. * @param result defines the target Color4 to store the result in
  11339. */
  11340. getColorToRef(result: Color4): void;
  11341. }
  11342. /** Class used to store color 3 gradient */
  11343. export class Color3Gradient implements IValueGradient {
  11344. /**
  11345. * Gets or sets the gradient value (between 0 and 1)
  11346. */
  11347. gradient: number;
  11348. /**
  11349. * Gets or sets the associated color
  11350. */
  11351. color: Color3;
  11352. /**
  11353. * Creates a new color3 gradient
  11354. * @param gradient gets or sets the gradient value (between 0 and 1)
  11355. * @param color gets or sets associated color
  11356. */
  11357. constructor(
  11358. /**
  11359. * Gets or sets the gradient value (between 0 and 1)
  11360. */
  11361. gradient: number,
  11362. /**
  11363. * Gets or sets the associated color
  11364. */
  11365. color: Color3);
  11366. }
  11367. /** Class used to store factor gradient */
  11368. export class FactorGradient implements IValueGradient {
  11369. /**
  11370. * Gets or sets the gradient value (between 0 and 1)
  11371. */
  11372. gradient: number;
  11373. /**
  11374. * Gets or sets first associated factor
  11375. */
  11376. factor1: number;
  11377. /**
  11378. * Gets or sets second associated factor
  11379. */
  11380. factor2?: number | undefined;
  11381. /**
  11382. * Creates a new factor gradient
  11383. * @param gradient gets or sets the gradient value (between 0 and 1)
  11384. * @param factor1 gets or sets first associated factor
  11385. * @param factor2 gets or sets second associated factor
  11386. */
  11387. constructor(
  11388. /**
  11389. * Gets or sets the gradient value (between 0 and 1)
  11390. */
  11391. gradient: number,
  11392. /**
  11393. * Gets or sets first associated factor
  11394. */
  11395. factor1: number,
  11396. /**
  11397. * Gets or sets second associated factor
  11398. */
  11399. factor2?: number | undefined);
  11400. /**
  11401. * Will get a number picked randomly between factor1 and factor2.
  11402. * If factor2 is undefined then factor1 will be used
  11403. * @returns the picked number
  11404. */
  11405. getFactor(): number;
  11406. }
  11407. /**
  11408. * Helper used to simplify some generic gradient tasks
  11409. */
  11410. export class GradientHelper {
  11411. /**
  11412. * Gets the current gradient from an array of IValueGradient
  11413. * @param ratio defines the current ratio to get
  11414. * @param gradients defines the array of IValueGradient
  11415. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11416. */
  11417. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11418. }
  11419. }
  11420. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11421. import { Nullable } from "babylonjs/types";
  11422. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11423. import { Scene } from "babylonjs/scene";
  11424. module "babylonjs/Engines/thinEngine" {
  11425. interface ThinEngine {
  11426. /**
  11427. * Creates a raw texture
  11428. * @param data defines the data to store in the texture
  11429. * @param width defines the width of the texture
  11430. * @param height defines the height of the texture
  11431. * @param format defines the format of the data
  11432. * @param generateMipMaps defines if the engine should generate the mip levels
  11433. * @param invertY defines if data must be stored with Y axis inverted
  11434. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11435. * @param compression defines the compression used (null by default)
  11436. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11437. * @returns the raw texture inside an InternalTexture
  11438. */
  11439. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11440. /**
  11441. * Update a raw texture
  11442. * @param texture defines the texture to update
  11443. * @param data defines the data to store in the texture
  11444. * @param format defines the format of the data
  11445. * @param invertY defines if data must be stored with Y axis inverted
  11446. */
  11447. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11448. /**
  11449. * Update a raw texture
  11450. * @param texture defines the texture to update
  11451. * @param data defines the data to store in the texture
  11452. * @param format defines the format of the data
  11453. * @param invertY defines if data must be stored with Y axis inverted
  11454. * @param compression defines the compression used (null by default)
  11455. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11456. */
  11457. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11458. /**
  11459. * Creates a new raw cube texture
  11460. * @param data defines the array of data to use to create each face
  11461. * @param size defines the size of the textures
  11462. * @param format defines the format of the data
  11463. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11464. * @param generateMipMaps defines if the engine should generate the mip levels
  11465. * @param invertY defines if data must be stored with Y axis inverted
  11466. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11467. * @param compression defines the compression used (null by default)
  11468. * @returns the cube texture as an InternalTexture
  11469. */
  11470. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11471. /**
  11472. * Update a raw cube texture
  11473. * @param texture defines the texture to udpdate
  11474. * @param data defines the data to store
  11475. * @param format defines the data format
  11476. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11477. * @param invertY defines if data must be stored with Y axis inverted
  11478. */
  11479. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11480. /**
  11481. * Update a raw cube texture
  11482. * @param texture defines the texture to udpdate
  11483. * @param data defines the data to store
  11484. * @param format defines the data format
  11485. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11486. * @param invertY defines if data must be stored with Y axis inverted
  11487. * @param compression defines the compression used (null by default)
  11488. */
  11489. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11490. /**
  11491. * Update a raw cube texture
  11492. * @param texture defines the texture to udpdate
  11493. * @param data defines the data to store
  11494. * @param format defines the data format
  11495. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11496. * @param invertY defines if data must be stored with Y axis inverted
  11497. * @param compression defines the compression used (null by default)
  11498. * @param level defines which level of the texture to update
  11499. */
  11500. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11501. /**
  11502. * Creates a new raw cube texture from a specified url
  11503. * @param url defines the url where the data is located
  11504. * @param scene defines the current scene
  11505. * @param size defines the size of the textures
  11506. * @param format defines the format of the data
  11507. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11508. * @param noMipmap defines if the engine should avoid generating the mip levels
  11509. * @param callback defines a callback used to extract texture data from loaded data
  11510. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11511. * @param onLoad defines a callback called when texture is loaded
  11512. * @param onError defines a callback called if there is an error
  11513. * @returns the cube texture as an InternalTexture
  11514. */
  11515. 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;
  11516. /**
  11517. * Creates a new raw cube texture from a specified url
  11518. * @param url defines the url where the data is located
  11519. * @param scene defines the current scene
  11520. * @param size defines the size of the textures
  11521. * @param format defines the format of the data
  11522. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11523. * @param noMipmap defines if the engine should avoid generating the mip levels
  11524. * @param callback defines a callback used to extract texture data from loaded data
  11525. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11526. * @param onLoad defines a callback called when texture is loaded
  11527. * @param onError defines a callback called if there is an error
  11528. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11529. * @param invertY defines if data must be stored with Y axis inverted
  11530. * @returns the cube texture as an InternalTexture
  11531. */
  11532. 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;
  11533. /**
  11534. * Creates a new raw 3D texture
  11535. * @param data defines the data used to create the texture
  11536. * @param width defines the width of the texture
  11537. * @param height defines the height of the texture
  11538. * @param depth defines the depth of the texture
  11539. * @param format defines the format of the texture
  11540. * @param generateMipMaps defines if the engine must generate mip levels
  11541. * @param invertY defines if data must be stored with Y axis inverted
  11542. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11543. * @param compression defines the compressed used (can be null)
  11544. * @param textureType defines the compressed used (can be null)
  11545. * @returns a new raw 3D texture (stored in an InternalTexture)
  11546. */
  11547. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11548. /**
  11549. * Update a raw 3D texture
  11550. * @param texture defines the texture to update
  11551. * @param data defines the data to store
  11552. * @param format defines the data format
  11553. * @param invertY defines if data must be stored with Y axis inverted
  11554. */
  11555. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11556. /**
  11557. * Update a raw 3D texture
  11558. * @param texture defines the texture to update
  11559. * @param data defines the data to store
  11560. * @param format defines the data format
  11561. * @param invertY defines if data must be stored with Y axis inverted
  11562. * @param compression defines the used compression (can be null)
  11563. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11564. */
  11565. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11566. /**
  11567. * Creates a new raw 2D array texture
  11568. * @param data defines the data used to create the texture
  11569. * @param width defines the width of the texture
  11570. * @param height defines the height of the texture
  11571. * @param depth defines the number of layers of the texture
  11572. * @param format defines the format of the texture
  11573. * @param generateMipMaps defines if the engine must generate mip levels
  11574. * @param invertY defines if data must be stored with Y axis inverted
  11575. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11576. * @param compression defines the compressed used (can be null)
  11577. * @param textureType defines the compressed used (can be null)
  11578. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11579. */
  11580. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11581. /**
  11582. * Update a raw 2D array texture
  11583. * @param texture defines the texture to update
  11584. * @param data defines the data to store
  11585. * @param format defines the data format
  11586. * @param invertY defines if data must be stored with Y axis inverted
  11587. */
  11588. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11589. /**
  11590. * Update a raw 2D array texture
  11591. * @param texture defines the texture to update
  11592. * @param data defines the data to store
  11593. * @param format defines the data format
  11594. * @param invertY defines if data must be stored with Y axis inverted
  11595. * @param compression defines the used compression (can be null)
  11596. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11597. */
  11598. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11599. }
  11600. }
  11601. }
  11602. declare module "babylonjs/Materials/Textures/rawTexture" {
  11603. import { Scene } from "babylonjs/scene";
  11604. import { Texture } from "babylonjs/Materials/Textures/texture";
  11605. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11606. /**
  11607. * Raw texture can help creating a texture directly from an array of data.
  11608. * This can be super useful if you either get the data from an uncompressed source or
  11609. * if you wish to create your texture pixel by pixel.
  11610. */
  11611. export class RawTexture extends Texture {
  11612. /**
  11613. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11614. */
  11615. format: number;
  11616. /**
  11617. * Instantiates a new RawTexture.
  11618. * Raw texture can help creating a texture directly from an array of data.
  11619. * This can be super useful if you either get the data from an uncompressed source or
  11620. * if you wish to create your texture pixel by pixel.
  11621. * @param data define the array of data to use to create the texture
  11622. * @param width define the width of the texture
  11623. * @param height define the height of the texture
  11624. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11625. * @param scene define the scene the texture belongs to
  11626. * @param generateMipMaps define whether mip maps should be generated or not
  11627. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11628. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11629. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11630. */
  11631. constructor(data: ArrayBufferView, width: number, height: number,
  11632. /**
  11633. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11634. */
  11635. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11636. /**
  11637. * Updates the texture underlying data.
  11638. * @param data Define the new data of the texture
  11639. */
  11640. update(data: ArrayBufferView): void;
  11641. /**
  11642. * Creates a luminance texture from some data.
  11643. * @param data Define the texture data
  11644. * @param width Define the width of the texture
  11645. * @param height Define the height of the texture
  11646. * @param scene Define the scene the texture belongs to
  11647. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11648. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11649. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11650. * @returns the luminance texture
  11651. */
  11652. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11653. /**
  11654. * Creates a luminance alpha texture from some data.
  11655. * @param data Define the texture data
  11656. * @param width Define the width of the texture
  11657. * @param height Define the height of the texture
  11658. * @param scene Define the scene the texture belongs to
  11659. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11660. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11661. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11662. * @returns the luminance alpha texture
  11663. */
  11664. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11665. /**
  11666. * Creates an alpha texture from some data.
  11667. * @param data Define the texture data
  11668. * @param width Define the width of the texture
  11669. * @param height Define the height of the texture
  11670. * @param scene Define the scene the texture belongs to
  11671. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11672. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11673. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11674. * @returns the alpha texture
  11675. */
  11676. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11677. /**
  11678. * Creates a RGB texture from some data.
  11679. * @param data Define the texture data
  11680. * @param width Define the width of the texture
  11681. * @param height Define the height of the texture
  11682. * @param scene Define the scene the texture belongs to
  11683. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11684. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11685. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11686. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11687. * @returns the RGB alpha texture
  11688. */
  11689. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11690. /**
  11691. * Creates a RGBA texture from some data.
  11692. * @param data Define the texture data
  11693. * @param width Define the width of the texture
  11694. * @param height Define the height of the texture
  11695. * @param scene Define the scene the texture belongs to
  11696. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11697. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11698. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11699. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11700. * @returns the RGBA texture
  11701. */
  11702. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11703. /**
  11704. * Creates a R texture from some data.
  11705. * @param data Define the texture data
  11706. * @param width Define the width of the texture
  11707. * @param height Define the height of the texture
  11708. * @param scene Define the scene the texture belongs to
  11709. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11710. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11711. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11712. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11713. * @returns the R texture
  11714. */
  11715. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11716. }
  11717. }
  11718. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11719. import { Scene } from "babylonjs/scene";
  11720. import { ISceneComponent } from "babylonjs/sceneComponent";
  11721. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11722. module "babylonjs/abstractScene" {
  11723. interface AbstractScene {
  11724. /**
  11725. * The list of procedural textures added to the scene
  11726. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11727. */
  11728. proceduralTextures: Array<ProceduralTexture>;
  11729. }
  11730. }
  11731. /**
  11732. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11733. * in a given scene.
  11734. */
  11735. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11736. /**
  11737. * The component name helpfull to identify the component in the list of scene components.
  11738. */
  11739. readonly name: string;
  11740. /**
  11741. * The scene the component belongs to.
  11742. */
  11743. scene: Scene;
  11744. /**
  11745. * Creates a new instance of the component for the given scene
  11746. * @param scene Defines the scene to register the component in
  11747. */
  11748. constructor(scene: Scene);
  11749. /**
  11750. * Registers the component in a given scene
  11751. */
  11752. register(): void;
  11753. /**
  11754. * Rebuilds the elements related to this component in case of
  11755. * context lost for instance.
  11756. */
  11757. rebuild(): void;
  11758. /**
  11759. * Disposes the component and the associated ressources.
  11760. */
  11761. dispose(): void;
  11762. private _beforeClear;
  11763. }
  11764. }
  11765. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11766. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11767. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11768. module "babylonjs/Engines/thinEngine" {
  11769. interface ThinEngine {
  11770. /**
  11771. * Creates a new render target cube texture
  11772. * @param size defines the size of the texture
  11773. * @param options defines the options used to create the texture
  11774. * @returns a new render target cube texture stored in an InternalTexture
  11775. */
  11776. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11777. }
  11778. }
  11779. }
  11780. declare module "babylonjs/Shaders/procedural.vertex" {
  11781. /** @hidden */
  11782. export var proceduralVertexShader: {
  11783. name: string;
  11784. shader: string;
  11785. };
  11786. }
  11787. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11788. import { Observable } from "babylonjs/Misc/observable";
  11789. import { Nullable } from "babylonjs/types";
  11790. import { Scene } from "babylonjs/scene";
  11791. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11792. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11793. import { Effect } from "babylonjs/Materials/effect";
  11794. import { Texture } from "babylonjs/Materials/Textures/texture";
  11795. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11796. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11797. import "babylonjs/Shaders/procedural.vertex";
  11798. /**
  11799. * 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.
  11800. * This is the base class of any Procedural texture and contains most of the shareable code.
  11801. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11802. */
  11803. export class ProceduralTexture extends Texture {
  11804. isCube: boolean;
  11805. /**
  11806. * Define if the texture is enabled or not (disabled texture will not render)
  11807. */
  11808. isEnabled: boolean;
  11809. /**
  11810. * Define if the texture must be cleared before rendering (default is true)
  11811. */
  11812. autoClear: boolean;
  11813. /**
  11814. * Callback called when the texture is generated
  11815. */
  11816. onGenerated: () => void;
  11817. /**
  11818. * Event raised when the texture is generated
  11819. */
  11820. onGeneratedObservable: Observable<ProceduralTexture>;
  11821. /** @hidden */
  11822. _generateMipMaps: boolean;
  11823. /** @hidden **/
  11824. _effect: Effect;
  11825. /** @hidden */
  11826. _textures: {
  11827. [key: string]: Texture;
  11828. };
  11829. /** @hidden */
  11830. protected _fallbackTexture: Nullable<Texture>;
  11831. private _size;
  11832. private _currentRefreshId;
  11833. private _frameId;
  11834. private _refreshRate;
  11835. private _vertexBuffers;
  11836. private _indexBuffer;
  11837. private _uniforms;
  11838. private _samplers;
  11839. private _fragment;
  11840. private _floats;
  11841. private _ints;
  11842. private _floatsArrays;
  11843. private _colors3;
  11844. private _colors4;
  11845. private _vectors2;
  11846. private _vectors3;
  11847. private _matrices;
  11848. private _fallbackTextureUsed;
  11849. private _fullEngine;
  11850. private _cachedDefines;
  11851. private _contentUpdateId;
  11852. private _contentData;
  11853. /**
  11854. * Instantiates a new procedural texture.
  11855. * 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.
  11856. * This is the base class of any Procedural texture and contains most of the shareable code.
  11857. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11858. * @param name Define the name of the texture
  11859. * @param size Define the size of the texture to create
  11860. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11861. * @param scene Define the scene the texture belongs to
  11862. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11863. * @param generateMipMaps Define if the texture should creates mip maps or not
  11864. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11865. */
  11866. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11867. /**
  11868. * The effect that is created when initializing the post process.
  11869. * @returns The created effect corresponding the the postprocess.
  11870. */
  11871. getEffect(): Effect;
  11872. /**
  11873. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11874. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11875. */
  11876. getContent(): Nullable<ArrayBufferView>;
  11877. private _createIndexBuffer;
  11878. /** @hidden */
  11879. _rebuild(): void;
  11880. /**
  11881. * Resets the texture in order to recreate its associated resources.
  11882. * This can be called in case of context loss
  11883. */
  11884. reset(): void;
  11885. protected _getDefines(): string;
  11886. /**
  11887. * Is the texture ready to be used ? (rendered at least once)
  11888. * @returns true if ready, otherwise, false.
  11889. */
  11890. isReady(): boolean;
  11891. /**
  11892. * Resets the refresh counter of the texture and start bak from scratch.
  11893. * Could be useful to regenerate the texture if it is setup to render only once.
  11894. */
  11895. resetRefreshCounter(): void;
  11896. /**
  11897. * Set the fragment shader to use in order to render the texture.
  11898. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11899. */
  11900. setFragment(fragment: any): void;
  11901. /**
  11902. * Define the refresh rate of the texture or the rendering frequency.
  11903. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11904. */
  11905. get refreshRate(): number;
  11906. set refreshRate(value: number);
  11907. /** @hidden */
  11908. _shouldRender(): boolean;
  11909. /**
  11910. * Get the size the texture is rendering at.
  11911. * @returns the size (texture is always squared)
  11912. */
  11913. getRenderSize(): number;
  11914. /**
  11915. * Resize the texture to new value.
  11916. * @param size Define the new size the texture should have
  11917. * @param generateMipMaps Define whether the new texture should create mip maps
  11918. */
  11919. resize(size: number, generateMipMaps: boolean): void;
  11920. private _checkUniform;
  11921. /**
  11922. * Set a texture in the shader program used to render.
  11923. * @param name Define the name of the uniform samplers as defined in the shader
  11924. * @param texture Define the texture to bind to this sampler
  11925. * @return the texture itself allowing "fluent" like uniform updates
  11926. */
  11927. setTexture(name: string, texture: Texture): ProceduralTexture;
  11928. /**
  11929. * Set a float in the shader.
  11930. * @param name Define the name of the uniform as defined in the shader
  11931. * @param value Define the value to give to the uniform
  11932. * @return the texture itself allowing "fluent" like uniform updates
  11933. */
  11934. setFloat(name: string, value: number): ProceduralTexture;
  11935. /**
  11936. * Set a int in the shader.
  11937. * @param name Define the name of the uniform as defined in the shader
  11938. * @param value Define the value to give to the uniform
  11939. * @return the texture itself allowing "fluent" like uniform updates
  11940. */
  11941. setInt(name: string, value: number): ProceduralTexture;
  11942. /**
  11943. * Set an array of floats in the shader.
  11944. * @param name Define the name of the uniform as defined in the shader
  11945. * @param value Define the value to give to the uniform
  11946. * @return the texture itself allowing "fluent" like uniform updates
  11947. */
  11948. setFloats(name: string, value: number[]): ProceduralTexture;
  11949. /**
  11950. * Set a vec3 in the shader from a Color3.
  11951. * @param name Define the name of the uniform as defined in the shader
  11952. * @param value Define the value to give to the uniform
  11953. * @return the texture itself allowing "fluent" like uniform updates
  11954. */
  11955. setColor3(name: string, value: Color3): ProceduralTexture;
  11956. /**
  11957. * Set a vec4 in the shader from a Color4.
  11958. * @param name Define the name of the uniform as defined in the shader
  11959. * @param value Define the value to give to the uniform
  11960. * @return the texture itself allowing "fluent" like uniform updates
  11961. */
  11962. setColor4(name: string, value: Color4): ProceduralTexture;
  11963. /**
  11964. * Set a vec2 in the shader from a Vector2.
  11965. * @param name Define the name of the uniform as defined in the shader
  11966. * @param value Define the value to give to the uniform
  11967. * @return the texture itself allowing "fluent" like uniform updates
  11968. */
  11969. setVector2(name: string, value: Vector2): ProceduralTexture;
  11970. /**
  11971. * Set a vec3 in the shader from a Vector3.
  11972. * @param name Define the name of the uniform as defined in the shader
  11973. * @param value Define the value to give to the uniform
  11974. * @return the texture itself allowing "fluent" like uniform updates
  11975. */
  11976. setVector3(name: string, value: Vector3): ProceduralTexture;
  11977. /**
  11978. * Set a mat4 in the shader from a MAtrix.
  11979. * @param name Define the name of the uniform as defined in the shader
  11980. * @param value Define the value to give to the uniform
  11981. * @return the texture itself allowing "fluent" like uniform updates
  11982. */
  11983. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11984. /**
  11985. * Render the texture to its associated render target.
  11986. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11987. */
  11988. render(useCameraPostProcess?: boolean): void;
  11989. /**
  11990. * Clone the texture.
  11991. * @returns the cloned texture
  11992. */
  11993. clone(): ProceduralTexture;
  11994. /**
  11995. * Dispose the texture and release its asoociated resources.
  11996. */
  11997. dispose(): void;
  11998. }
  11999. }
  12000. declare module "babylonjs/Particles/baseParticleSystem" {
  12001. import { Nullable } from "babylonjs/types";
  12002. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12004. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12005. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12006. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12007. import { Scene } from "babylonjs/scene";
  12008. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12009. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12010. import { Texture } from "babylonjs/Materials/Textures/texture";
  12011. import { Color4 } from "babylonjs/Maths/math.color";
  12012. import { Animation } from "babylonjs/Animations/animation";
  12013. /**
  12014. * This represents the base class for particle system in Babylon.
  12015. * 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.
  12016. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12017. * @example https://doc.babylonjs.com/babylon101/particles
  12018. */
  12019. export class BaseParticleSystem {
  12020. /**
  12021. * Source color is added to the destination color without alpha affecting the result
  12022. */
  12023. static BLENDMODE_ONEONE: number;
  12024. /**
  12025. * Blend current color and particle color using particle’s alpha
  12026. */
  12027. static BLENDMODE_STANDARD: number;
  12028. /**
  12029. * Add current color and particle color multiplied by particle’s alpha
  12030. */
  12031. static BLENDMODE_ADD: number;
  12032. /**
  12033. * Multiply current color with particle color
  12034. */
  12035. static BLENDMODE_MULTIPLY: number;
  12036. /**
  12037. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12038. */
  12039. static BLENDMODE_MULTIPLYADD: number;
  12040. /**
  12041. * List of animations used by the particle system.
  12042. */
  12043. animations: Animation[];
  12044. /**
  12045. * Gets or sets the unique id of the particle system
  12046. */
  12047. uniqueId: number;
  12048. /**
  12049. * The id of the Particle system.
  12050. */
  12051. id: string;
  12052. /**
  12053. * The friendly name of the Particle system.
  12054. */
  12055. name: string;
  12056. /**
  12057. * Snippet ID if the particle system was created from the snippet server
  12058. */
  12059. snippetId: string;
  12060. /**
  12061. * The rendering group used by the Particle system to chose when to render.
  12062. */
  12063. renderingGroupId: number;
  12064. /**
  12065. * The emitter represents the Mesh or position we are attaching the particle system to.
  12066. */
  12067. emitter: Nullable<AbstractMesh | Vector3>;
  12068. /**
  12069. * The maximum number of particles to emit per frame
  12070. */
  12071. emitRate: number;
  12072. /**
  12073. * If you want to launch only a few particles at once, that can be done, as well.
  12074. */
  12075. manualEmitCount: number;
  12076. /**
  12077. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12078. */
  12079. updateSpeed: number;
  12080. /**
  12081. * The amount of time the particle system is running (depends of the overall update speed).
  12082. */
  12083. targetStopDuration: number;
  12084. /**
  12085. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12086. */
  12087. disposeOnStop: boolean;
  12088. /**
  12089. * Minimum power of emitting particles.
  12090. */
  12091. minEmitPower: number;
  12092. /**
  12093. * Maximum power of emitting particles.
  12094. */
  12095. maxEmitPower: number;
  12096. /**
  12097. * Minimum life time of emitting particles.
  12098. */
  12099. minLifeTime: number;
  12100. /**
  12101. * Maximum life time of emitting particles.
  12102. */
  12103. maxLifeTime: number;
  12104. /**
  12105. * Minimum Size of emitting particles.
  12106. */
  12107. minSize: number;
  12108. /**
  12109. * Maximum Size of emitting particles.
  12110. */
  12111. maxSize: number;
  12112. /**
  12113. * Minimum scale of emitting particles on X axis.
  12114. */
  12115. minScaleX: number;
  12116. /**
  12117. * Maximum scale of emitting particles on X axis.
  12118. */
  12119. maxScaleX: number;
  12120. /**
  12121. * Minimum scale of emitting particles on Y axis.
  12122. */
  12123. minScaleY: number;
  12124. /**
  12125. * Maximum scale of emitting particles on Y axis.
  12126. */
  12127. maxScaleY: number;
  12128. /**
  12129. * Gets or sets the minimal initial rotation in radians.
  12130. */
  12131. minInitialRotation: number;
  12132. /**
  12133. * Gets or sets the maximal initial rotation in radians.
  12134. */
  12135. maxInitialRotation: number;
  12136. /**
  12137. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12138. */
  12139. minAngularSpeed: number;
  12140. /**
  12141. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12142. */
  12143. maxAngularSpeed: number;
  12144. /**
  12145. * The texture used to render each particle. (this can be a spritesheet)
  12146. */
  12147. particleTexture: Nullable<Texture>;
  12148. /**
  12149. * The layer mask we are rendering the particles through.
  12150. */
  12151. layerMask: number;
  12152. /**
  12153. * This can help using your own shader to render the particle system.
  12154. * The according effect will be created
  12155. */
  12156. customShader: any;
  12157. /**
  12158. * By default particle system starts as soon as they are created. This prevents the
  12159. * automatic start to happen and let you decide when to start emitting particles.
  12160. */
  12161. preventAutoStart: boolean;
  12162. private _noiseTexture;
  12163. /**
  12164. * Gets or sets a texture used to add random noise to particle positions
  12165. */
  12166. get noiseTexture(): Nullable<ProceduralTexture>;
  12167. set noiseTexture(value: Nullable<ProceduralTexture>);
  12168. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12169. noiseStrength: Vector3;
  12170. /**
  12171. * Callback triggered when the particle animation is ending.
  12172. */
  12173. onAnimationEnd: Nullable<() => void>;
  12174. /**
  12175. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12176. */
  12177. blendMode: number;
  12178. /**
  12179. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12180. * to override the particles.
  12181. */
  12182. forceDepthWrite: boolean;
  12183. /** 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 */
  12184. preWarmCycles: number;
  12185. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12186. preWarmStepOffset: number;
  12187. /**
  12188. * 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)
  12189. */
  12190. spriteCellChangeSpeed: number;
  12191. /**
  12192. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12193. */
  12194. startSpriteCellID: number;
  12195. /**
  12196. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12197. */
  12198. endSpriteCellID: number;
  12199. /**
  12200. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12201. */
  12202. spriteCellWidth: number;
  12203. /**
  12204. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12205. */
  12206. spriteCellHeight: number;
  12207. /**
  12208. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12209. */
  12210. spriteRandomStartCell: boolean;
  12211. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12212. translationPivot: Vector2;
  12213. /** @hidden */
  12214. protected _isAnimationSheetEnabled: boolean;
  12215. /**
  12216. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12217. */
  12218. beginAnimationOnStart: boolean;
  12219. /**
  12220. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12221. */
  12222. beginAnimationFrom: number;
  12223. /**
  12224. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12225. */
  12226. beginAnimationTo: number;
  12227. /**
  12228. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12229. */
  12230. beginAnimationLoop: boolean;
  12231. /**
  12232. * Gets or sets a world offset applied to all particles
  12233. */
  12234. worldOffset: Vector3;
  12235. /**
  12236. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12237. */
  12238. get isAnimationSheetEnabled(): boolean;
  12239. set isAnimationSheetEnabled(value: boolean);
  12240. /**
  12241. * Get hosting scene
  12242. * @returns the scene
  12243. */
  12244. getScene(): Scene;
  12245. /**
  12246. * You can use gravity if you want to give an orientation to your particles.
  12247. */
  12248. gravity: Vector3;
  12249. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12250. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12251. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12252. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12253. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12254. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12255. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12256. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12257. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12258. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12259. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12260. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12261. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12262. /**
  12263. * Defines the delay in milliseconds before starting the system (0 by default)
  12264. */
  12265. startDelay: number;
  12266. /**
  12267. * Gets the current list of drag gradients.
  12268. * You must use addDragGradient and removeDragGradient to udpate this list
  12269. * @returns the list of drag gradients
  12270. */
  12271. getDragGradients(): Nullable<Array<FactorGradient>>;
  12272. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12273. limitVelocityDamping: number;
  12274. /**
  12275. * Gets the current list of limit velocity gradients.
  12276. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12277. * @returns the list of limit velocity gradients
  12278. */
  12279. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12280. /**
  12281. * Gets the current list of color gradients.
  12282. * You must use addColorGradient and removeColorGradient to udpate this list
  12283. * @returns the list of color gradients
  12284. */
  12285. getColorGradients(): Nullable<Array<ColorGradient>>;
  12286. /**
  12287. * Gets the current list of size gradients.
  12288. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12289. * @returns the list of size gradients
  12290. */
  12291. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12292. /**
  12293. * Gets the current list of color remap gradients.
  12294. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12295. * @returns the list of color remap gradients
  12296. */
  12297. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12298. /**
  12299. * Gets the current list of alpha remap gradients.
  12300. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12301. * @returns the list of alpha remap gradients
  12302. */
  12303. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12304. /**
  12305. * Gets the current list of life time gradients.
  12306. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12307. * @returns the list of life time gradients
  12308. */
  12309. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12310. /**
  12311. * Gets the current list of angular speed gradients.
  12312. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12313. * @returns the list of angular speed gradients
  12314. */
  12315. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12316. /**
  12317. * Gets the current list of velocity gradients.
  12318. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12319. * @returns the list of velocity gradients
  12320. */
  12321. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12322. /**
  12323. * Gets the current list of start size gradients.
  12324. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12325. * @returns the list of start size gradients
  12326. */
  12327. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12328. /**
  12329. * Gets the current list of emit rate gradients.
  12330. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12331. * @returns the list of emit rate gradients
  12332. */
  12333. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12334. /**
  12335. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12336. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12337. */
  12338. get direction1(): Vector3;
  12339. set direction1(value: Vector3);
  12340. /**
  12341. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12342. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12343. */
  12344. get direction2(): Vector3;
  12345. set direction2(value: Vector3);
  12346. /**
  12347. * 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.
  12348. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12349. */
  12350. get minEmitBox(): Vector3;
  12351. set minEmitBox(value: Vector3);
  12352. /**
  12353. * 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.
  12354. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12355. */
  12356. get maxEmitBox(): Vector3;
  12357. set maxEmitBox(value: Vector3);
  12358. /**
  12359. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12360. */
  12361. color1: Color4;
  12362. /**
  12363. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12364. */
  12365. color2: Color4;
  12366. /**
  12367. * Color the particle will have at the end of its lifetime
  12368. */
  12369. colorDead: Color4;
  12370. /**
  12371. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12372. */
  12373. textureMask: Color4;
  12374. /**
  12375. * The particle emitter type defines the emitter used by the particle system.
  12376. * It can be for example box, sphere, or cone...
  12377. */
  12378. particleEmitterType: IParticleEmitterType;
  12379. /** @hidden */
  12380. _isSubEmitter: boolean;
  12381. /**
  12382. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12383. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12384. */
  12385. billboardMode: number;
  12386. protected _isBillboardBased: boolean;
  12387. /**
  12388. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12389. */
  12390. get isBillboardBased(): boolean;
  12391. set isBillboardBased(value: boolean);
  12392. /**
  12393. * The scene the particle system belongs to.
  12394. */
  12395. protected _scene: Scene;
  12396. /**
  12397. * Local cache of defines for image processing.
  12398. */
  12399. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12400. /**
  12401. * Default configuration related to image processing available in the standard Material.
  12402. */
  12403. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12404. /**
  12405. * Gets the image processing configuration used either in this material.
  12406. */
  12407. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12408. /**
  12409. * Sets the Default image processing configuration used either in the this material.
  12410. *
  12411. * If sets to null, the scene one is in use.
  12412. */
  12413. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12414. /**
  12415. * Attaches a new image processing configuration to the Standard Material.
  12416. * @param configuration
  12417. */
  12418. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12419. /** @hidden */
  12420. protected _reset(): void;
  12421. /** @hidden */
  12422. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12423. /**
  12424. * Instantiates a particle system.
  12425. * 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.
  12426. * @param name The name of the particle system
  12427. */
  12428. constructor(name: string);
  12429. /**
  12430. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12431. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12432. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12433. * @returns the emitter
  12434. */
  12435. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12436. /**
  12437. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12438. * @param radius The radius of the hemisphere to emit from
  12439. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12440. * @returns the emitter
  12441. */
  12442. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12443. /**
  12444. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12445. * @param radius The radius of the sphere to emit from
  12446. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12447. * @returns the emitter
  12448. */
  12449. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12450. /**
  12451. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12452. * @param radius The radius of the sphere to emit from
  12453. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12454. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12455. * @returns the emitter
  12456. */
  12457. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12458. /**
  12459. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12460. * @param radius The radius of the emission cylinder
  12461. * @param height The height of the emission cylinder
  12462. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12463. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12464. * @returns the emitter
  12465. */
  12466. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12467. /**
  12468. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12469. * @param radius The radius of the cylinder to emit from
  12470. * @param height The height of the emission cylinder
  12471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12472. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12473. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12474. * @returns the emitter
  12475. */
  12476. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12477. /**
  12478. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12479. * @param radius The radius of the cone to emit from
  12480. * @param angle The base angle of the cone
  12481. * @returns the emitter
  12482. */
  12483. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12484. /**
  12485. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12488. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12489. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12490. * @returns the emitter
  12491. */
  12492. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12493. }
  12494. }
  12495. declare module "babylonjs/Particles/subEmitter" {
  12496. import { Scene } from "babylonjs/scene";
  12497. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12498. /**
  12499. * Type of sub emitter
  12500. */
  12501. export enum SubEmitterType {
  12502. /**
  12503. * Attached to the particle over it's lifetime
  12504. */
  12505. ATTACHED = 0,
  12506. /**
  12507. * Created when the particle dies
  12508. */
  12509. END = 1
  12510. }
  12511. /**
  12512. * Sub emitter class used to emit particles from an existing particle
  12513. */
  12514. export class SubEmitter {
  12515. /**
  12516. * the particle system to be used by the sub emitter
  12517. */
  12518. particleSystem: ParticleSystem;
  12519. /**
  12520. * Type of the submitter (Default: END)
  12521. */
  12522. type: SubEmitterType;
  12523. /**
  12524. * 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)
  12525. * Note: This only is supported when using an emitter of type Mesh
  12526. */
  12527. inheritDirection: boolean;
  12528. /**
  12529. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12530. */
  12531. inheritedVelocityAmount: number;
  12532. /**
  12533. * Creates a sub emitter
  12534. * @param particleSystem the particle system to be used by the sub emitter
  12535. */
  12536. constructor(
  12537. /**
  12538. * the particle system to be used by the sub emitter
  12539. */
  12540. particleSystem: ParticleSystem);
  12541. /**
  12542. * Clones the sub emitter
  12543. * @returns the cloned sub emitter
  12544. */
  12545. clone(): SubEmitter;
  12546. /**
  12547. * Serialize current object to a JSON object
  12548. * @returns the serialized object
  12549. */
  12550. serialize(): any;
  12551. /** @hidden */
  12552. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12553. /**
  12554. * Creates a new SubEmitter from a serialized JSON version
  12555. * @param serializationObject defines the JSON object to read from
  12556. * @param scene defines the hosting scene
  12557. * @param rootUrl defines the rootUrl for data loading
  12558. * @returns a new SubEmitter
  12559. */
  12560. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12561. /** Release associated resources */
  12562. dispose(): void;
  12563. }
  12564. }
  12565. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12566. /** @hidden */
  12567. export var imageProcessingDeclaration: {
  12568. name: string;
  12569. shader: string;
  12570. };
  12571. }
  12572. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12573. /** @hidden */
  12574. export var imageProcessingFunctions: {
  12575. name: string;
  12576. shader: string;
  12577. };
  12578. }
  12579. declare module "babylonjs/Shaders/particles.fragment" {
  12580. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12581. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12582. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12583. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12584. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12585. /** @hidden */
  12586. export var particlesPixelShader: {
  12587. name: string;
  12588. shader: string;
  12589. };
  12590. }
  12591. declare module "babylonjs/Shaders/particles.vertex" {
  12592. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12593. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12594. /** @hidden */
  12595. export var particlesVertexShader: {
  12596. name: string;
  12597. shader: string;
  12598. };
  12599. }
  12600. declare module "babylonjs/Particles/particleSystem" {
  12601. import { Nullable } from "babylonjs/types";
  12602. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12603. import { Observable } from "babylonjs/Misc/observable";
  12604. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12605. import { Effect } from "babylonjs/Materials/effect";
  12606. import { Scene, IDisposable } from "babylonjs/scene";
  12607. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12608. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12609. import { Particle } from "babylonjs/Particles/particle";
  12610. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12611. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12612. import "babylonjs/Shaders/particles.fragment";
  12613. import "babylonjs/Shaders/particles.vertex";
  12614. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12615. /**
  12616. * This represents a particle system in Babylon.
  12617. * 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.
  12618. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12619. * @example https://doc.babylonjs.com/babylon101/particles
  12620. */
  12621. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12622. /**
  12623. * Billboard mode will only apply to Y axis
  12624. */
  12625. static readonly BILLBOARDMODE_Y: number;
  12626. /**
  12627. * Billboard mode will apply to all axes
  12628. */
  12629. static readonly BILLBOARDMODE_ALL: number;
  12630. /**
  12631. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12632. */
  12633. static readonly BILLBOARDMODE_STRETCHED: number;
  12634. /**
  12635. * This function can be defined to provide custom update for active particles.
  12636. * This function will be called instead of regular update (age, position, color, etc.).
  12637. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12638. */
  12639. updateFunction: (particles: Particle[]) => void;
  12640. private _emitterWorldMatrix;
  12641. /**
  12642. * This function can be defined to specify initial direction for every new particle.
  12643. * It by default use the emitterType defined function
  12644. */
  12645. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12646. /**
  12647. * This function can be defined to specify initial position for every new particle.
  12648. * It by default use the emitterType defined function
  12649. */
  12650. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12651. /**
  12652. * @hidden
  12653. */
  12654. _inheritedVelocityOffset: Vector3;
  12655. /**
  12656. * An event triggered when the system is disposed
  12657. */
  12658. onDisposeObservable: Observable<IParticleSystem>;
  12659. private _onDisposeObserver;
  12660. /**
  12661. * Sets a callback that will be triggered when the system is disposed
  12662. */
  12663. set onDispose(callback: () => void);
  12664. private _particles;
  12665. private _epsilon;
  12666. private _capacity;
  12667. private _stockParticles;
  12668. private _newPartsExcess;
  12669. private _vertexData;
  12670. private _vertexBuffer;
  12671. private _vertexBuffers;
  12672. private _spriteBuffer;
  12673. private _indexBuffer;
  12674. private _effect;
  12675. private _customEffect;
  12676. private _cachedDefines;
  12677. private _scaledColorStep;
  12678. private _colorDiff;
  12679. private _scaledDirection;
  12680. private _scaledGravity;
  12681. private _currentRenderId;
  12682. private _alive;
  12683. private _useInstancing;
  12684. private _started;
  12685. private _stopped;
  12686. private _actualFrame;
  12687. private _scaledUpdateSpeed;
  12688. private _vertexBufferSize;
  12689. /** @hidden */
  12690. _currentEmitRateGradient: Nullable<FactorGradient>;
  12691. /** @hidden */
  12692. _currentEmitRate1: number;
  12693. /** @hidden */
  12694. _currentEmitRate2: number;
  12695. /** @hidden */
  12696. _currentStartSizeGradient: Nullable<FactorGradient>;
  12697. /** @hidden */
  12698. _currentStartSize1: number;
  12699. /** @hidden */
  12700. _currentStartSize2: number;
  12701. private readonly _rawTextureWidth;
  12702. private _rampGradientsTexture;
  12703. private _useRampGradients;
  12704. /** Gets or sets a boolean indicating that ramp gradients must be used
  12705. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12706. */
  12707. get useRampGradients(): boolean;
  12708. set useRampGradients(value: boolean);
  12709. /**
  12710. * 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.
  12711. * 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: [])
  12712. */
  12713. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12714. private _subEmitters;
  12715. /**
  12716. * @hidden
  12717. * If the particle systems emitter should be disposed when the particle system is disposed
  12718. */
  12719. _disposeEmitterOnDispose: boolean;
  12720. /**
  12721. * The current active Sub-systems, this property is used by the root particle system only.
  12722. */
  12723. activeSubSystems: Array<ParticleSystem>;
  12724. /**
  12725. * Specifies if the particles are updated in emitter local space or world space
  12726. */
  12727. isLocal: boolean;
  12728. private _rootParticleSystem;
  12729. /**
  12730. * Gets the current list of active particles
  12731. */
  12732. get particles(): Particle[];
  12733. /**
  12734. * Gets the number of particles active at the same time.
  12735. * @returns The number of active particles.
  12736. */
  12737. getActiveCount(): number;
  12738. /**
  12739. * Returns the string "ParticleSystem"
  12740. * @returns a string containing the class name
  12741. */
  12742. getClassName(): string;
  12743. /**
  12744. * Gets a boolean indicating that the system is stopping
  12745. * @returns true if the system is currently stopping
  12746. */
  12747. isStopping(): boolean;
  12748. /**
  12749. * Gets the custom effect used to render the particles
  12750. * @param blendMode Blend mode for which the effect should be retrieved
  12751. * @returns The effect
  12752. */
  12753. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12754. /**
  12755. * Sets the custom effect used to render the particles
  12756. * @param effect The effect to set
  12757. * @param blendMode Blend mode for which the effect should be set
  12758. */
  12759. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12760. /** @hidden */
  12761. private _onBeforeDrawParticlesObservable;
  12762. /**
  12763. * Observable that will be called just before the particles are drawn
  12764. */
  12765. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12766. /**
  12767. * Gets the name of the particle vertex shader
  12768. */
  12769. get vertexShaderName(): string;
  12770. /**
  12771. * Instantiates a particle system.
  12772. * 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.
  12773. * @param name The name of the particle system
  12774. * @param capacity The max number of particles alive at the same time
  12775. * @param scene The scene the particle system belongs to
  12776. * @param customEffect a custom effect used to change the way particles are rendered by default
  12777. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12778. * @param epsilon Offset used to render the particles
  12779. */
  12780. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12781. private _addFactorGradient;
  12782. private _removeFactorGradient;
  12783. /**
  12784. * Adds a new life time gradient
  12785. * @param gradient defines the gradient to use (between 0 and 1)
  12786. * @param factor defines the life time factor to affect to the specified gradient
  12787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12788. * @returns the current particle system
  12789. */
  12790. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12791. /**
  12792. * Remove a specific life time gradient
  12793. * @param gradient defines the gradient to remove
  12794. * @returns the current particle system
  12795. */
  12796. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12797. /**
  12798. * Adds a new size gradient
  12799. * @param gradient defines the gradient to use (between 0 and 1)
  12800. * @param factor defines the size factor to affect to the specified gradient
  12801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12802. * @returns the current particle system
  12803. */
  12804. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12805. /**
  12806. * Remove a specific size gradient
  12807. * @param gradient defines the gradient to remove
  12808. * @returns the current particle system
  12809. */
  12810. removeSizeGradient(gradient: number): IParticleSystem;
  12811. /**
  12812. * Adds a new color remap gradient
  12813. * @param gradient defines the gradient to use (between 0 and 1)
  12814. * @param min defines the color remap minimal range
  12815. * @param max defines the color remap maximal range
  12816. * @returns the current particle system
  12817. */
  12818. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12819. /**
  12820. * Remove a specific color remap gradient
  12821. * @param gradient defines the gradient to remove
  12822. * @returns the current particle system
  12823. */
  12824. removeColorRemapGradient(gradient: number): IParticleSystem;
  12825. /**
  12826. * Adds a new alpha remap gradient
  12827. * @param gradient defines the gradient to use (between 0 and 1)
  12828. * @param min defines the alpha remap minimal range
  12829. * @param max defines the alpha remap maximal range
  12830. * @returns the current particle system
  12831. */
  12832. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12833. /**
  12834. * Remove a specific alpha remap gradient
  12835. * @param gradient defines the gradient to remove
  12836. * @returns the current particle system
  12837. */
  12838. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12839. /**
  12840. * Adds a new angular speed gradient
  12841. * @param gradient defines the gradient to use (between 0 and 1)
  12842. * @param factor defines the angular speed to affect to the specified gradient
  12843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12844. * @returns the current particle system
  12845. */
  12846. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12847. /**
  12848. * Remove a specific angular speed gradient
  12849. * @param gradient defines the gradient to remove
  12850. * @returns the current particle system
  12851. */
  12852. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12853. /**
  12854. * Adds a new velocity gradient
  12855. * @param gradient defines the gradient to use (between 0 and 1)
  12856. * @param factor defines the velocity to affect to the specified gradient
  12857. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12858. * @returns the current particle system
  12859. */
  12860. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12861. /**
  12862. * Remove a specific velocity gradient
  12863. * @param gradient defines the gradient to remove
  12864. * @returns the current particle system
  12865. */
  12866. removeVelocityGradient(gradient: number): IParticleSystem;
  12867. /**
  12868. * Adds a new limit velocity gradient
  12869. * @param gradient defines the gradient to use (between 0 and 1)
  12870. * @param factor defines the limit velocity value to affect to the specified gradient
  12871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12872. * @returns the current particle system
  12873. */
  12874. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12875. /**
  12876. * Remove a specific limit velocity gradient
  12877. * @param gradient defines the gradient to remove
  12878. * @returns the current particle system
  12879. */
  12880. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12881. /**
  12882. * Adds a new drag gradient
  12883. * @param gradient defines the gradient to use (between 0 and 1)
  12884. * @param factor defines the drag value to affect to the specified gradient
  12885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12886. * @returns the current particle system
  12887. */
  12888. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12889. /**
  12890. * Remove a specific drag gradient
  12891. * @param gradient defines the gradient to remove
  12892. * @returns the current particle system
  12893. */
  12894. removeDragGradient(gradient: number): IParticleSystem;
  12895. /**
  12896. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12897. * @param gradient defines the gradient to use (between 0 and 1)
  12898. * @param factor defines the emit rate value to affect to the specified gradient
  12899. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12900. * @returns the current particle system
  12901. */
  12902. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12903. /**
  12904. * Remove a specific emit rate gradient
  12905. * @param gradient defines the gradient to remove
  12906. * @returns the current particle system
  12907. */
  12908. removeEmitRateGradient(gradient: number): IParticleSystem;
  12909. /**
  12910. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12911. * @param gradient defines the gradient to use (between 0 and 1)
  12912. * @param factor defines the start size value to affect to the specified gradient
  12913. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12914. * @returns the current particle system
  12915. */
  12916. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12917. /**
  12918. * Remove a specific start size gradient
  12919. * @param gradient defines the gradient to remove
  12920. * @returns the current particle system
  12921. */
  12922. removeStartSizeGradient(gradient: number): IParticleSystem;
  12923. private _createRampGradientTexture;
  12924. /**
  12925. * Gets the current list of ramp gradients.
  12926. * You must use addRampGradient and removeRampGradient to udpate this list
  12927. * @returns the list of ramp gradients
  12928. */
  12929. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12930. /** Force the system to rebuild all gradients that need to be resync */
  12931. forceRefreshGradients(): void;
  12932. private _syncRampGradientTexture;
  12933. /**
  12934. * Adds a new ramp gradient used to remap particle colors
  12935. * @param gradient defines the gradient to use (between 0 and 1)
  12936. * @param color defines the color to affect to the specified gradient
  12937. * @returns the current particle system
  12938. */
  12939. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12940. /**
  12941. * Remove a specific ramp gradient
  12942. * @param gradient defines the gradient to remove
  12943. * @returns the current particle system
  12944. */
  12945. removeRampGradient(gradient: number): ParticleSystem;
  12946. /**
  12947. * Adds a new color gradient
  12948. * @param gradient defines the gradient to use (between 0 and 1)
  12949. * @param color1 defines the color to affect to the specified gradient
  12950. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12951. * @returns this particle system
  12952. */
  12953. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12954. /**
  12955. * Remove a specific color gradient
  12956. * @param gradient defines the gradient to remove
  12957. * @returns this particle system
  12958. */
  12959. removeColorGradient(gradient: number): IParticleSystem;
  12960. private _fetchR;
  12961. protected _reset(): void;
  12962. private _resetEffect;
  12963. private _createVertexBuffers;
  12964. private _createIndexBuffer;
  12965. /**
  12966. * Gets the maximum number of particles active at the same time.
  12967. * @returns The max number of active particles.
  12968. */
  12969. getCapacity(): number;
  12970. /**
  12971. * Gets whether there are still active particles in the system.
  12972. * @returns True if it is alive, otherwise false.
  12973. */
  12974. isAlive(): boolean;
  12975. /**
  12976. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12977. * @returns True if it has been started, otherwise false.
  12978. */
  12979. isStarted(): boolean;
  12980. private _prepareSubEmitterInternalArray;
  12981. /**
  12982. * Starts the particle system and begins to emit
  12983. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12984. */
  12985. start(delay?: number): void;
  12986. /**
  12987. * Stops the particle system.
  12988. * @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.
  12989. */
  12990. stop(stopSubEmitters?: boolean): void;
  12991. /**
  12992. * Remove all active particles
  12993. */
  12994. reset(): void;
  12995. /**
  12996. * @hidden (for internal use only)
  12997. */
  12998. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12999. /**
  13000. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13001. * Its lifetime will start back at 0.
  13002. */
  13003. recycleParticle: (particle: Particle) => void;
  13004. private _stopSubEmitters;
  13005. private _createParticle;
  13006. private _removeFromRoot;
  13007. private _emitFromParticle;
  13008. private _update;
  13009. /** @hidden */
  13010. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13011. /** @hidden */
  13012. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13013. /**
  13014. * Fill the defines array according to the current settings of the particle system
  13015. * @param defines Array to be updated
  13016. * @param blendMode blend mode to take into account when updating the array
  13017. */
  13018. fillDefines(defines: Array<string>, blendMode: number): void;
  13019. /**
  13020. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13021. * @param uniforms Uniforms array to fill
  13022. * @param attributes Attributes array to fill
  13023. * @param samplers Samplers array to fill
  13024. */
  13025. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13026. /** @hidden */
  13027. private _getEffect;
  13028. /**
  13029. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13030. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13031. */
  13032. animate(preWarmOnly?: boolean): void;
  13033. private _appendParticleVertices;
  13034. /**
  13035. * Rebuilds the particle system.
  13036. */
  13037. rebuild(): void;
  13038. /**
  13039. * Is this system ready to be used/rendered
  13040. * @return true if the system is ready
  13041. */
  13042. isReady(): boolean;
  13043. private _render;
  13044. /**
  13045. * Renders the particle system in its current state.
  13046. * @returns the current number of particles
  13047. */
  13048. render(): number;
  13049. /**
  13050. * Disposes the particle system and free the associated resources
  13051. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13052. */
  13053. dispose(disposeTexture?: boolean): void;
  13054. /**
  13055. * Clones the particle system.
  13056. * @param name The name of the cloned object
  13057. * @param newEmitter The new emitter to use
  13058. * @returns the cloned particle system
  13059. */
  13060. clone(name: string, newEmitter: any): ParticleSystem;
  13061. /**
  13062. * Serializes the particle system to a JSON object
  13063. * @param serializeTexture defines if the texture must be serialized as well
  13064. * @returns the JSON object
  13065. */
  13066. serialize(serializeTexture?: boolean): any;
  13067. /** @hidden */
  13068. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13069. /** @hidden */
  13070. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13071. /**
  13072. * Parses a JSON object to create a particle system.
  13073. * @param parsedParticleSystem The JSON object to parse
  13074. * @param scene The scene to create the particle system in
  13075. * @param rootUrl The root url to use to load external dependencies like texture
  13076. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13077. * @returns the Parsed particle system
  13078. */
  13079. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13080. }
  13081. }
  13082. declare module "babylonjs/Particles/particle" {
  13083. import { Nullable } from "babylonjs/types";
  13084. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13085. import { Color4 } from "babylonjs/Maths/math.color";
  13086. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13087. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13088. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13089. /**
  13090. * A particle represents one of the element emitted by a particle system.
  13091. * This is mainly define by its coordinates, direction, velocity and age.
  13092. */
  13093. export class Particle {
  13094. /**
  13095. * The particle system the particle belongs to.
  13096. */
  13097. particleSystem: ParticleSystem;
  13098. private static _Count;
  13099. /**
  13100. * Unique ID of the particle
  13101. */
  13102. id: number;
  13103. /**
  13104. * The world position of the particle in the scene.
  13105. */
  13106. position: Vector3;
  13107. /**
  13108. * The world direction of the particle in the scene.
  13109. */
  13110. direction: Vector3;
  13111. /**
  13112. * The color of the particle.
  13113. */
  13114. color: Color4;
  13115. /**
  13116. * The color change of the particle per step.
  13117. */
  13118. colorStep: Color4;
  13119. /**
  13120. * Defines how long will the life of the particle be.
  13121. */
  13122. lifeTime: number;
  13123. /**
  13124. * The current age of the particle.
  13125. */
  13126. age: number;
  13127. /**
  13128. * The current size of the particle.
  13129. */
  13130. size: number;
  13131. /**
  13132. * The current scale of the particle.
  13133. */
  13134. scale: Vector2;
  13135. /**
  13136. * The current angle of the particle.
  13137. */
  13138. angle: number;
  13139. /**
  13140. * Defines how fast is the angle changing.
  13141. */
  13142. angularSpeed: number;
  13143. /**
  13144. * Defines the cell index used by the particle to be rendered from a sprite.
  13145. */
  13146. cellIndex: number;
  13147. /**
  13148. * The information required to support color remapping
  13149. */
  13150. remapData: Vector4;
  13151. /** @hidden */
  13152. _randomCellOffset?: number;
  13153. /** @hidden */
  13154. _initialDirection: Nullable<Vector3>;
  13155. /** @hidden */
  13156. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13157. /** @hidden */
  13158. _initialStartSpriteCellID: number;
  13159. /** @hidden */
  13160. _initialEndSpriteCellID: number;
  13161. /** @hidden */
  13162. _currentColorGradient: Nullable<ColorGradient>;
  13163. /** @hidden */
  13164. _currentColor1: Color4;
  13165. /** @hidden */
  13166. _currentColor2: Color4;
  13167. /** @hidden */
  13168. _currentSizeGradient: Nullable<FactorGradient>;
  13169. /** @hidden */
  13170. _currentSize1: number;
  13171. /** @hidden */
  13172. _currentSize2: number;
  13173. /** @hidden */
  13174. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13175. /** @hidden */
  13176. _currentAngularSpeed1: number;
  13177. /** @hidden */
  13178. _currentAngularSpeed2: number;
  13179. /** @hidden */
  13180. _currentVelocityGradient: Nullable<FactorGradient>;
  13181. /** @hidden */
  13182. _currentVelocity1: number;
  13183. /** @hidden */
  13184. _currentVelocity2: number;
  13185. /** @hidden */
  13186. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13187. /** @hidden */
  13188. _currentLimitVelocity1: number;
  13189. /** @hidden */
  13190. _currentLimitVelocity2: number;
  13191. /** @hidden */
  13192. _currentDragGradient: Nullable<FactorGradient>;
  13193. /** @hidden */
  13194. _currentDrag1: number;
  13195. /** @hidden */
  13196. _currentDrag2: number;
  13197. /** @hidden */
  13198. _randomNoiseCoordinates1: Vector3;
  13199. /** @hidden */
  13200. _randomNoiseCoordinates2: Vector3;
  13201. /** @hidden */
  13202. _localPosition?: Vector3;
  13203. /**
  13204. * Creates a new instance Particle
  13205. * @param particleSystem the particle system the particle belongs to
  13206. */
  13207. constructor(
  13208. /**
  13209. * The particle system the particle belongs to.
  13210. */
  13211. particleSystem: ParticleSystem);
  13212. private updateCellInfoFromSystem;
  13213. /**
  13214. * Defines how the sprite cell index is updated for the particle
  13215. */
  13216. updateCellIndex(): void;
  13217. /** @hidden */
  13218. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13219. /** @hidden */
  13220. _inheritParticleInfoToSubEmitters(): void;
  13221. /** @hidden */
  13222. _reset(): void;
  13223. /**
  13224. * Copy the properties of particle to another one.
  13225. * @param other the particle to copy the information to.
  13226. */
  13227. copyTo(other: Particle): void;
  13228. }
  13229. }
  13230. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13231. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13232. import { Effect } from "babylonjs/Materials/effect";
  13233. import { Particle } from "babylonjs/Particles/particle";
  13234. import { Scene } from "babylonjs/scene";
  13235. /**
  13236. * Particle emitter represents a volume emitting particles.
  13237. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13238. */
  13239. export interface IParticleEmitterType {
  13240. /**
  13241. * Called by the particle System when the direction is computed for the created particle.
  13242. * @param worldMatrix is the world matrix of the particle system
  13243. * @param directionToUpdate is the direction vector to update with the result
  13244. * @param particle is the particle we are computed the direction for
  13245. * @param isLocal defines if the direction should be set in local space
  13246. */
  13247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13248. /**
  13249. * Called by the particle System when the position is computed for the created particle.
  13250. * @param worldMatrix is the world matrix of the particle system
  13251. * @param positionToUpdate is the position vector to update with the result
  13252. * @param particle is the particle we are computed the position for
  13253. * @param isLocal defines if the position should be set in local space
  13254. */
  13255. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13256. /**
  13257. * Clones the current emitter and returns a copy of it
  13258. * @returns the new emitter
  13259. */
  13260. clone(): IParticleEmitterType;
  13261. /**
  13262. * Called by the GPUParticleSystem to setup the update shader
  13263. * @param effect defines the update shader
  13264. */
  13265. applyToShader(effect: Effect): void;
  13266. /**
  13267. * Returns a string to use to update the GPU particles update shader
  13268. * @returns the effect defines string
  13269. */
  13270. getEffectDefines(): string;
  13271. /**
  13272. * Returns a string representing the class name
  13273. * @returns a string containing the class name
  13274. */
  13275. getClassName(): string;
  13276. /**
  13277. * Serializes the particle system to a JSON object.
  13278. * @returns the JSON object
  13279. */
  13280. serialize(): any;
  13281. /**
  13282. * Parse properties from a JSON object
  13283. * @param serializationObject defines the JSON object
  13284. * @param scene defines the hosting scene
  13285. */
  13286. parse(serializationObject: any, scene: Scene): void;
  13287. }
  13288. }
  13289. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13290. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13291. import { Effect } from "babylonjs/Materials/effect";
  13292. import { Particle } from "babylonjs/Particles/particle";
  13293. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13294. /**
  13295. * Particle emitter emitting particles from the inside of a box.
  13296. * It emits the particles randomly between 2 given directions.
  13297. */
  13298. export class BoxParticleEmitter implements IParticleEmitterType {
  13299. /**
  13300. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13301. */
  13302. direction1: Vector3;
  13303. /**
  13304. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13305. */
  13306. direction2: Vector3;
  13307. /**
  13308. * 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.
  13309. */
  13310. minEmitBox: Vector3;
  13311. /**
  13312. * 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.
  13313. */
  13314. maxEmitBox: Vector3;
  13315. /**
  13316. * Creates a new instance BoxParticleEmitter
  13317. */
  13318. constructor();
  13319. /**
  13320. * Called by the particle System when the direction is computed for the created particle.
  13321. * @param worldMatrix is the world matrix of the particle system
  13322. * @param directionToUpdate is the direction vector to update with the result
  13323. * @param particle is the particle we are computed the direction for
  13324. * @param isLocal defines if the direction should be set in local space
  13325. */
  13326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13327. /**
  13328. * Called by the particle System when the position is computed for the created particle.
  13329. * @param worldMatrix is the world matrix of the particle system
  13330. * @param positionToUpdate is the position vector to update with the result
  13331. * @param particle is the particle we are computed the position for
  13332. * @param isLocal defines if the position should be set in local space
  13333. */
  13334. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13335. /**
  13336. * Clones the current emitter and returns a copy of it
  13337. * @returns the new emitter
  13338. */
  13339. clone(): BoxParticleEmitter;
  13340. /**
  13341. * Called by the GPUParticleSystem to setup the update shader
  13342. * @param effect defines the update shader
  13343. */
  13344. applyToShader(effect: Effect): void;
  13345. /**
  13346. * Returns a string to use to update the GPU particles update shader
  13347. * @returns a string containng the defines string
  13348. */
  13349. getEffectDefines(): string;
  13350. /**
  13351. * Returns the string "BoxParticleEmitter"
  13352. * @returns a string containing the class name
  13353. */
  13354. getClassName(): string;
  13355. /**
  13356. * Serializes the particle system to a JSON object.
  13357. * @returns the JSON object
  13358. */
  13359. serialize(): any;
  13360. /**
  13361. * Parse properties from a JSON object
  13362. * @param serializationObject defines the JSON object
  13363. */
  13364. parse(serializationObject: any): void;
  13365. }
  13366. }
  13367. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13368. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13369. import { Effect } from "babylonjs/Materials/effect";
  13370. import { Particle } from "babylonjs/Particles/particle";
  13371. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13372. /**
  13373. * Particle emitter emitting particles from the inside of a cone.
  13374. * It emits the particles alongside the cone volume from the base to the particle.
  13375. * The emission direction might be randomized.
  13376. */
  13377. export class ConeParticleEmitter implements IParticleEmitterType {
  13378. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13379. directionRandomizer: number;
  13380. private _radius;
  13381. private _angle;
  13382. private _height;
  13383. /**
  13384. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13385. */
  13386. radiusRange: number;
  13387. /**
  13388. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13389. */
  13390. heightRange: number;
  13391. /**
  13392. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13393. */
  13394. emitFromSpawnPointOnly: boolean;
  13395. /**
  13396. * Gets or sets the radius of the emission cone
  13397. */
  13398. get radius(): number;
  13399. set radius(value: number);
  13400. /**
  13401. * Gets or sets the angle of the emission cone
  13402. */
  13403. get angle(): number;
  13404. set angle(value: number);
  13405. private _buildHeight;
  13406. /**
  13407. * Creates a new instance ConeParticleEmitter
  13408. * @param radius the radius of the emission cone (1 by default)
  13409. * @param angle the cone base angle (PI by default)
  13410. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13411. */
  13412. constructor(radius?: number, angle?: number,
  13413. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13414. directionRandomizer?: number);
  13415. /**
  13416. * Called by the particle System when the direction is computed for the created particle.
  13417. * @param worldMatrix is the world matrix of the particle system
  13418. * @param directionToUpdate is the direction vector to update with the result
  13419. * @param particle is the particle we are computed the direction for
  13420. * @param isLocal defines if the direction should be set in local space
  13421. */
  13422. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13423. /**
  13424. * Called by the particle System when the position is computed for the created particle.
  13425. * @param worldMatrix is the world matrix of the particle system
  13426. * @param positionToUpdate is the position vector to update with the result
  13427. * @param particle is the particle we are computed the position for
  13428. * @param isLocal defines if the position should be set in local space
  13429. */
  13430. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13431. /**
  13432. * Clones the current emitter and returns a copy of it
  13433. * @returns the new emitter
  13434. */
  13435. clone(): ConeParticleEmitter;
  13436. /**
  13437. * Called by the GPUParticleSystem to setup the update shader
  13438. * @param effect defines the update shader
  13439. */
  13440. applyToShader(effect: Effect): void;
  13441. /**
  13442. * Returns a string to use to update the GPU particles update shader
  13443. * @returns a string containng the defines string
  13444. */
  13445. getEffectDefines(): string;
  13446. /**
  13447. * Returns the string "ConeParticleEmitter"
  13448. * @returns a string containing the class name
  13449. */
  13450. getClassName(): string;
  13451. /**
  13452. * Serializes the particle system to a JSON object.
  13453. * @returns the JSON object
  13454. */
  13455. serialize(): any;
  13456. /**
  13457. * Parse properties from a JSON object
  13458. * @param serializationObject defines the JSON object
  13459. */
  13460. parse(serializationObject: any): void;
  13461. }
  13462. }
  13463. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13464. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13465. import { Effect } from "babylonjs/Materials/effect";
  13466. import { Particle } from "babylonjs/Particles/particle";
  13467. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13468. /**
  13469. * Particle emitter emitting particles from the inside of a cylinder.
  13470. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13471. */
  13472. export class CylinderParticleEmitter implements IParticleEmitterType {
  13473. /**
  13474. * The radius of the emission cylinder.
  13475. */
  13476. radius: number;
  13477. /**
  13478. * The height of the emission cylinder.
  13479. */
  13480. height: number;
  13481. /**
  13482. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13483. */
  13484. radiusRange: number;
  13485. /**
  13486. * How much to randomize the particle direction [0-1].
  13487. */
  13488. directionRandomizer: number;
  13489. /**
  13490. * Creates a new instance CylinderParticleEmitter
  13491. * @param radius the radius of the emission cylinder (1 by default)
  13492. * @param height the height of the emission cylinder (1 by default)
  13493. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13494. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13495. */
  13496. constructor(
  13497. /**
  13498. * The radius of the emission cylinder.
  13499. */
  13500. radius?: number,
  13501. /**
  13502. * The height of the emission cylinder.
  13503. */
  13504. height?: number,
  13505. /**
  13506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13507. */
  13508. radiusRange?: number,
  13509. /**
  13510. * How much to randomize the particle direction [0-1].
  13511. */
  13512. directionRandomizer?: number);
  13513. /**
  13514. * Called by the particle System when the direction is computed for the created particle.
  13515. * @param worldMatrix is the world matrix of the particle system
  13516. * @param directionToUpdate is the direction vector to update with the result
  13517. * @param particle is the particle we are computed the direction for
  13518. * @param isLocal defines if the direction should be set in local space
  13519. */
  13520. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13521. /**
  13522. * Called by the particle System when the position is computed for the created particle.
  13523. * @param worldMatrix is the world matrix of the particle system
  13524. * @param positionToUpdate is the position vector to update with the result
  13525. * @param particle is the particle we are computed the position for
  13526. * @param isLocal defines if the position should be set in local space
  13527. */
  13528. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13529. /**
  13530. * Clones the current emitter and returns a copy of it
  13531. * @returns the new emitter
  13532. */
  13533. clone(): CylinderParticleEmitter;
  13534. /**
  13535. * Called by the GPUParticleSystem to setup the update shader
  13536. * @param effect defines the update shader
  13537. */
  13538. applyToShader(effect: Effect): void;
  13539. /**
  13540. * Returns a string to use to update the GPU particles update shader
  13541. * @returns a string containng the defines string
  13542. */
  13543. getEffectDefines(): string;
  13544. /**
  13545. * Returns the string "CylinderParticleEmitter"
  13546. * @returns a string containing the class name
  13547. */
  13548. getClassName(): string;
  13549. /**
  13550. * Serializes the particle system to a JSON object.
  13551. * @returns the JSON object
  13552. */
  13553. serialize(): any;
  13554. /**
  13555. * Parse properties from a JSON object
  13556. * @param serializationObject defines the JSON object
  13557. */
  13558. parse(serializationObject: any): void;
  13559. }
  13560. /**
  13561. * Particle emitter emitting particles from the inside of a cylinder.
  13562. * It emits the particles randomly between two vectors.
  13563. */
  13564. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13565. /**
  13566. * The min limit of the emission direction.
  13567. */
  13568. direction1: Vector3;
  13569. /**
  13570. * The max limit of the emission direction.
  13571. */
  13572. direction2: Vector3;
  13573. /**
  13574. * Creates a new instance CylinderDirectedParticleEmitter
  13575. * @param radius the radius of the emission cylinder (1 by default)
  13576. * @param height the height of the emission cylinder (1 by default)
  13577. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13578. * @param direction1 the min limit of the emission direction (up vector by default)
  13579. * @param direction2 the max limit of the emission direction (up vector by default)
  13580. */
  13581. constructor(radius?: number, height?: number, radiusRange?: number,
  13582. /**
  13583. * The min limit of the emission direction.
  13584. */
  13585. direction1?: Vector3,
  13586. /**
  13587. * The max limit of the emission direction.
  13588. */
  13589. direction2?: Vector3);
  13590. /**
  13591. * Called by the particle System when the direction is computed for the created particle.
  13592. * @param worldMatrix is the world matrix of the particle system
  13593. * @param directionToUpdate is the direction vector to update with the result
  13594. * @param particle is the particle we are computed the direction for
  13595. */
  13596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13597. /**
  13598. * Clones the current emitter and returns a copy of it
  13599. * @returns the new emitter
  13600. */
  13601. clone(): CylinderDirectedParticleEmitter;
  13602. /**
  13603. * Called by the GPUParticleSystem to setup the update shader
  13604. * @param effect defines the update shader
  13605. */
  13606. applyToShader(effect: Effect): void;
  13607. /**
  13608. * Returns a string to use to update the GPU particles update shader
  13609. * @returns a string containng the defines string
  13610. */
  13611. getEffectDefines(): string;
  13612. /**
  13613. * Returns the string "CylinderDirectedParticleEmitter"
  13614. * @returns a string containing the class name
  13615. */
  13616. getClassName(): string;
  13617. /**
  13618. * Serializes the particle system to a JSON object.
  13619. * @returns the JSON object
  13620. */
  13621. serialize(): any;
  13622. /**
  13623. * Parse properties from a JSON object
  13624. * @param serializationObject defines the JSON object
  13625. */
  13626. parse(serializationObject: any): void;
  13627. }
  13628. }
  13629. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13630. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13631. import { Effect } from "babylonjs/Materials/effect";
  13632. import { Particle } from "babylonjs/Particles/particle";
  13633. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13634. /**
  13635. * Particle emitter emitting particles from the inside of a hemisphere.
  13636. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13637. */
  13638. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13639. /**
  13640. * The radius of the emission hemisphere.
  13641. */
  13642. radius: number;
  13643. /**
  13644. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13645. */
  13646. radiusRange: number;
  13647. /**
  13648. * How much to randomize the particle direction [0-1].
  13649. */
  13650. directionRandomizer: number;
  13651. /**
  13652. * Creates a new instance HemisphericParticleEmitter
  13653. * @param radius the radius of the emission hemisphere (1 by default)
  13654. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13655. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13656. */
  13657. constructor(
  13658. /**
  13659. * The radius of the emission hemisphere.
  13660. */
  13661. radius?: number,
  13662. /**
  13663. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13664. */
  13665. radiusRange?: number,
  13666. /**
  13667. * How much to randomize the particle direction [0-1].
  13668. */
  13669. directionRandomizer?: number);
  13670. /**
  13671. * Called by the particle System when the direction is computed for the created particle.
  13672. * @param worldMatrix is the world matrix of the particle system
  13673. * @param directionToUpdate is the direction vector to update with the result
  13674. * @param particle is the particle we are computed the direction for
  13675. * @param isLocal defines if the direction should be set in local space
  13676. */
  13677. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13678. /**
  13679. * Called by the particle System when the position is computed for the created particle.
  13680. * @param worldMatrix is the world matrix of the particle system
  13681. * @param positionToUpdate is the position vector to update with the result
  13682. * @param particle is the particle we are computed the position for
  13683. * @param isLocal defines if the position should be set in local space
  13684. */
  13685. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13686. /**
  13687. * Clones the current emitter and returns a copy of it
  13688. * @returns the new emitter
  13689. */
  13690. clone(): HemisphericParticleEmitter;
  13691. /**
  13692. * Called by the GPUParticleSystem to setup the update shader
  13693. * @param effect defines the update shader
  13694. */
  13695. applyToShader(effect: Effect): void;
  13696. /**
  13697. * Returns a string to use to update the GPU particles update shader
  13698. * @returns a string containng the defines string
  13699. */
  13700. getEffectDefines(): string;
  13701. /**
  13702. * Returns the string "HemisphericParticleEmitter"
  13703. * @returns a string containing the class name
  13704. */
  13705. getClassName(): string;
  13706. /**
  13707. * Serializes the particle system to a JSON object.
  13708. * @returns the JSON object
  13709. */
  13710. serialize(): any;
  13711. /**
  13712. * Parse properties from a JSON object
  13713. * @param serializationObject defines the JSON object
  13714. */
  13715. parse(serializationObject: any): void;
  13716. }
  13717. }
  13718. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13719. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13720. import { Effect } from "babylonjs/Materials/effect";
  13721. import { Particle } from "babylonjs/Particles/particle";
  13722. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13723. /**
  13724. * Particle emitter emitting particles from a point.
  13725. * It emits the particles randomly between 2 given directions.
  13726. */
  13727. export class PointParticleEmitter implements IParticleEmitterType {
  13728. /**
  13729. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13730. */
  13731. direction1: Vector3;
  13732. /**
  13733. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13734. */
  13735. direction2: Vector3;
  13736. /**
  13737. * Creates a new instance PointParticleEmitter
  13738. */
  13739. constructor();
  13740. /**
  13741. * Called by the particle System when the direction is computed for the created particle.
  13742. * @param worldMatrix is the world matrix of the particle system
  13743. * @param directionToUpdate is the direction vector to update with the result
  13744. * @param particle is the particle we are computed the direction for
  13745. * @param isLocal defines if the direction should be set in local space
  13746. */
  13747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13748. /**
  13749. * Called by the particle System when the position is computed for the created particle.
  13750. * @param worldMatrix is the world matrix of the particle system
  13751. * @param positionToUpdate is the position vector to update with the result
  13752. * @param particle is the particle we are computed the position for
  13753. * @param isLocal defines if the position should be set in local space
  13754. */
  13755. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13756. /**
  13757. * Clones the current emitter and returns a copy of it
  13758. * @returns the new emitter
  13759. */
  13760. clone(): PointParticleEmitter;
  13761. /**
  13762. * Called by the GPUParticleSystem to setup the update shader
  13763. * @param effect defines the update shader
  13764. */
  13765. applyToShader(effect: Effect): void;
  13766. /**
  13767. * Returns a string to use to update the GPU particles update shader
  13768. * @returns a string containng the defines string
  13769. */
  13770. getEffectDefines(): string;
  13771. /**
  13772. * Returns the string "PointParticleEmitter"
  13773. * @returns a string containing the class name
  13774. */
  13775. getClassName(): string;
  13776. /**
  13777. * Serializes the particle system to a JSON object.
  13778. * @returns the JSON object
  13779. */
  13780. serialize(): any;
  13781. /**
  13782. * Parse properties from a JSON object
  13783. * @param serializationObject defines the JSON object
  13784. */
  13785. parse(serializationObject: any): void;
  13786. }
  13787. }
  13788. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13789. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13790. import { Effect } from "babylonjs/Materials/effect";
  13791. import { Particle } from "babylonjs/Particles/particle";
  13792. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13793. /**
  13794. * Particle emitter emitting particles from the inside of a sphere.
  13795. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13796. */
  13797. export class SphereParticleEmitter implements IParticleEmitterType {
  13798. /**
  13799. * The radius of the emission sphere.
  13800. */
  13801. radius: number;
  13802. /**
  13803. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13804. */
  13805. radiusRange: number;
  13806. /**
  13807. * How much to randomize the particle direction [0-1].
  13808. */
  13809. directionRandomizer: number;
  13810. /**
  13811. * Creates a new instance SphereParticleEmitter
  13812. * @param radius the radius of the emission sphere (1 by default)
  13813. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13814. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13815. */
  13816. constructor(
  13817. /**
  13818. * The radius of the emission sphere.
  13819. */
  13820. radius?: number,
  13821. /**
  13822. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13823. */
  13824. radiusRange?: number,
  13825. /**
  13826. * How much to randomize the particle direction [0-1].
  13827. */
  13828. directionRandomizer?: number);
  13829. /**
  13830. * Called by the particle System when the direction is computed for the created particle.
  13831. * @param worldMatrix is the world matrix of the particle system
  13832. * @param directionToUpdate is the direction vector to update with the result
  13833. * @param particle is the particle we are computed the direction for
  13834. * @param isLocal defines if the direction should be set in local space
  13835. */
  13836. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13837. /**
  13838. * Called by the particle System when the position is computed for the created particle.
  13839. * @param worldMatrix is the world matrix of the particle system
  13840. * @param positionToUpdate is the position vector to update with the result
  13841. * @param particle is the particle we are computed the position for
  13842. * @param isLocal defines if the position should be set in local space
  13843. */
  13844. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13845. /**
  13846. * Clones the current emitter and returns a copy of it
  13847. * @returns the new emitter
  13848. */
  13849. clone(): SphereParticleEmitter;
  13850. /**
  13851. * Called by the GPUParticleSystem to setup the update shader
  13852. * @param effect defines the update shader
  13853. */
  13854. applyToShader(effect: Effect): void;
  13855. /**
  13856. * Returns a string to use to update the GPU particles update shader
  13857. * @returns a string containng the defines string
  13858. */
  13859. getEffectDefines(): string;
  13860. /**
  13861. * Returns the string "SphereParticleEmitter"
  13862. * @returns a string containing the class name
  13863. */
  13864. getClassName(): string;
  13865. /**
  13866. * Serializes the particle system to a JSON object.
  13867. * @returns the JSON object
  13868. */
  13869. serialize(): any;
  13870. /**
  13871. * Parse properties from a JSON object
  13872. * @param serializationObject defines the JSON object
  13873. */
  13874. parse(serializationObject: any): void;
  13875. }
  13876. /**
  13877. * Particle emitter emitting particles from the inside of a sphere.
  13878. * It emits the particles randomly between two vectors.
  13879. */
  13880. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13881. /**
  13882. * The min limit of the emission direction.
  13883. */
  13884. direction1: Vector3;
  13885. /**
  13886. * The max limit of the emission direction.
  13887. */
  13888. direction2: Vector3;
  13889. /**
  13890. * Creates a new instance SphereDirectedParticleEmitter
  13891. * @param radius the radius of the emission sphere (1 by default)
  13892. * @param direction1 the min limit of the emission direction (up vector by default)
  13893. * @param direction2 the max limit of the emission direction (up vector by default)
  13894. */
  13895. constructor(radius?: number,
  13896. /**
  13897. * The min limit of the emission direction.
  13898. */
  13899. direction1?: Vector3,
  13900. /**
  13901. * The max limit of the emission direction.
  13902. */
  13903. direction2?: Vector3);
  13904. /**
  13905. * Called by the particle System when the direction is computed for the created particle.
  13906. * @param worldMatrix is the world matrix of the particle system
  13907. * @param directionToUpdate is the direction vector to update with the result
  13908. * @param particle is the particle we are computed the direction for
  13909. */
  13910. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13911. /**
  13912. * Clones the current emitter and returns a copy of it
  13913. * @returns the new emitter
  13914. */
  13915. clone(): SphereDirectedParticleEmitter;
  13916. /**
  13917. * Called by the GPUParticleSystem to setup the update shader
  13918. * @param effect defines the update shader
  13919. */
  13920. applyToShader(effect: Effect): void;
  13921. /**
  13922. * Returns a string to use to update the GPU particles update shader
  13923. * @returns a string containng the defines string
  13924. */
  13925. getEffectDefines(): string;
  13926. /**
  13927. * Returns the string "SphereDirectedParticleEmitter"
  13928. * @returns a string containing the class name
  13929. */
  13930. getClassName(): string;
  13931. /**
  13932. * Serializes the particle system to a JSON object.
  13933. * @returns the JSON object
  13934. */
  13935. serialize(): any;
  13936. /**
  13937. * Parse properties from a JSON object
  13938. * @param serializationObject defines the JSON object
  13939. */
  13940. parse(serializationObject: any): void;
  13941. }
  13942. }
  13943. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13944. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13945. import { Effect } from "babylonjs/Materials/effect";
  13946. import { Particle } from "babylonjs/Particles/particle";
  13947. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13948. import { Nullable } from "babylonjs/types";
  13949. /**
  13950. * Particle emitter emitting particles from a custom list of positions.
  13951. */
  13952. export class CustomParticleEmitter implements IParticleEmitterType {
  13953. /**
  13954. * Gets or sets the position generator that will create the inital position of each particle.
  13955. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13956. */
  13957. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13958. /**
  13959. * Gets or sets the destination generator that will create the final destination of each particle.
  13960. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13961. */
  13962. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13963. /**
  13964. * Creates a new instance CustomParticleEmitter
  13965. */
  13966. constructor();
  13967. /**
  13968. * Called by the particle System when the direction is computed for the created particle.
  13969. * @param worldMatrix is the world matrix of the particle system
  13970. * @param directionToUpdate is the direction vector to update with the result
  13971. * @param particle is the particle we are computed the direction for
  13972. * @param isLocal defines if the direction should be set in local space
  13973. */
  13974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13975. /**
  13976. * Called by the particle System when the position is computed for the created particle.
  13977. * @param worldMatrix is the world matrix of the particle system
  13978. * @param positionToUpdate is the position vector to update with the result
  13979. * @param particle is the particle we are computed the position for
  13980. * @param isLocal defines if the position should be set in local space
  13981. */
  13982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13983. /**
  13984. * Clones the current emitter and returns a copy of it
  13985. * @returns the new emitter
  13986. */
  13987. clone(): CustomParticleEmitter;
  13988. /**
  13989. * Called by the GPUParticleSystem to setup the update shader
  13990. * @param effect defines the update shader
  13991. */
  13992. applyToShader(effect: Effect): void;
  13993. /**
  13994. * Returns a string to use to update the GPU particles update shader
  13995. * @returns a string containng the defines string
  13996. */
  13997. getEffectDefines(): string;
  13998. /**
  13999. * Returns the string "PointParticleEmitter"
  14000. * @returns a string containing the class name
  14001. */
  14002. getClassName(): string;
  14003. /**
  14004. * Serializes the particle system to a JSON object.
  14005. * @returns the JSON object
  14006. */
  14007. serialize(): any;
  14008. /**
  14009. * Parse properties from a JSON object
  14010. * @param serializationObject defines the JSON object
  14011. */
  14012. parse(serializationObject: any): void;
  14013. }
  14014. }
  14015. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14016. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14017. import { Effect } from "babylonjs/Materials/effect";
  14018. import { Particle } from "babylonjs/Particles/particle";
  14019. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14020. import { Nullable } from "babylonjs/types";
  14021. import { Scene } from "babylonjs/scene";
  14022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14023. /**
  14024. * Particle emitter emitting particles from the inside of a box.
  14025. * It emits the particles randomly between 2 given directions.
  14026. */
  14027. export class MeshParticleEmitter implements IParticleEmitterType {
  14028. private _indices;
  14029. private _positions;
  14030. private _normals;
  14031. private _storedNormal;
  14032. private _mesh;
  14033. /**
  14034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14035. */
  14036. direction1: Vector3;
  14037. /**
  14038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14039. */
  14040. direction2: Vector3;
  14041. /**
  14042. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14043. */
  14044. useMeshNormalsForDirection: boolean;
  14045. /** Defines the mesh to use as source */
  14046. get mesh(): Nullable<AbstractMesh>;
  14047. set mesh(value: Nullable<AbstractMesh>);
  14048. /**
  14049. * Creates a new instance MeshParticleEmitter
  14050. * @param mesh defines the mesh to use as source
  14051. */
  14052. constructor(mesh?: Nullable<AbstractMesh>);
  14053. /**
  14054. * Called by the particle System when the direction is computed for the created particle.
  14055. * @param worldMatrix is the world matrix of the particle system
  14056. * @param directionToUpdate is the direction vector to update with the result
  14057. * @param particle is the particle we are computed the direction for
  14058. * @param isLocal defines if the direction should be set in local space
  14059. */
  14060. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14061. /**
  14062. * Called by the particle System when the position is computed for the created particle.
  14063. * @param worldMatrix is the world matrix of the particle system
  14064. * @param positionToUpdate is the position vector to update with the result
  14065. * @param particle is the particle we are computed the position for
  14066. * @param isLocal defines if the position should be set in local space
  14067. */
  14068. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14069. /**
  14070. * Clones the current emitter and returns a copy of it
  14071. * @returns the new emitter
  14072. */
  14073. clone(): MeshParticleEmitter;
  14074. /**
  14075. * Called by the GPUParticleSystem to setup the update shader
  14076. * @param effect defines the update shader
  14077. */
  14078. applyToShader(effect: Effect): void;
  14079. /**
  14080. * Returns a string to use to update the GPU particles update shader
  14081. * @returns a string containng the defines string
  14082. */
  14083. getEffectDefines(): string;
  14084. /**
  14085. * Returns the string "BoxParticleEmitter"
  14086. * @returns a string containing the class name
  14087. */
  14088. getClassName(): string;
  14089. /**
  14090. * Serializes the particle system to a JSON object.
  14091. * @returns the JSON object
  14092. */
  14093. serialize(): any;
  14094. /**
  14095. * Parse properties from a JSON object
  14096. * @param serializationObject defines the JSON object
  14097. * @param scene defines the hosting scene
  14098. */
  14099. parse(serializationObject: any, scene: Scene): void;
  14100. }
  14101. }
  14102. declare module "babylonjs/Particles/EmitterTypes/index" {
  14103. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14104. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14105. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14106. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14107. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14108. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14109. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14110. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14111. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14112. }
  14113. declare module "babylonjs/Particles/IParticleSystem" {
  14114. import { Nullable } from "babylonjs/types";
  14115. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14116. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14117. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14118. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14119. import { Texture } from "babylonjs/Materials/Textures/texture";
  14120. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14121. import { Scene } from "babylonjs/scene";
  14122. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14123. import { Effect } from "babylonjs/Materials/effect";
  14124. import { Observable } from "babylonjs/Misc/observable";
  14125. import { Animation } from "babylonjs/Animations/animation";
  14126. /**
  14127. * Interface representing a particle system in Babylon.js.
  14128. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14129. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14130. */
  14131. export interface IParticleSystem {
  14132. /**
  14133. * List of animations used by the particle system.
  14134. */
  14135. animations: Animation[];
  14136. /**
  14137. * The id of the Particle system.
  14138. */
  14139. id: string;
  14140. /**
  14141. * The name of the Particle system.
  14142. */
  14143. name: string;
  14144. /**
  14145. * The emitter represents the Mesh or position we are attaching the particle system to.
  14146. */
  14147. emitter: Nullable<AbstractMesh | Vector3>;
  14148. /**
  14149. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14150. */
  14151. isBillboardBased: boolean;
  14152. /**
  14153. * The rendering group used by the Particle system to chose when to render.
  14154. */
  14155. renderingGroupId: number;
  14156. /**
  14157. * The layer mask we are rendering the particles through.
  14158. */
  14159. layerMask: number;
  14160. /**
  14161. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14162. */
  14163. updateSpeed: number;
  14164. /**
  14165. * The amount of time the particle system is running (depends of the overall update speed).
  14166. */
  14167. targetStopDuration: number;
  14168. /**
  14169. * The texture used to render each particle. (this can be a spritesheet)
  14170. */
  14171. particleTexture: Nullable<Texture>;
  14172. /**
  14173. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14174. */
  14175. blendMode: number;
  14176. /**
  14177. * Minimum life time of emitting particles.
  14178. */
  14179. minLifeTime: number;
  14180. /**
  14181. * Maximum life time of emitting particles.
  14182. */
  14183. maxLifeTime: number;
  14184. /**
  14185. * Minimum Size of emitting particles.
  14186. */
  14187. minSize: number;
  14188. /**
  14189. * Maximum Size of emitting particles.
  14190. */
  14191. maxSize: number;
  14192. /**
  14193. * Minimum scale of emitting particles on X axis.
  14194. */
  14195. minScaleX: number;
  14196. /**
  14197. * Maximum scale of emitting particles on X axis.
  14198. */
  14199. maxScaleX: number;
  14200. /**
  14201. * Minimum scale of emitting particles on Y axis.
  14202. */
  14203. minScaleY: number;
  14204. /**
  14205. * Maximum scale of emitting particles on Y axis.
  14206. */
  14207. maxScaleY: number;
  14208. /**
  14209. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14210. */
  14211. color1: Color4;
  14212. /**
  14213. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14214. */
  14215. color2: Color4;
  14216. /**
  14217. * Color the particle will have at the end of its lifetime.
  14218. */
  14219. colorDead: Color4;
  14220. /**
  14221. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14222. */
  14223. emitRate: number;
  14224. /**
  14225. * You can use gravity if you want to give an orientation to your particles.
  14226. */
  14227. gravity: Vector3;
  14228. /**
  14229. * Minimum power of emitting particles.
  14230. */
  14231. minEmitPower: number;
  14232. /**
  14233. * Maximum power of emitting particles.
  14234. */
  14235. maxEmitPower: number;
  14236. /**
  14237. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14238. */
  14239. minAngularSpeed: number;
  14240. /**
  14241. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14242. */
  14243. maxAngularSpeed: number;
  14244. /**
  14245. * Gets or sets the minimal initial rotation in radians.
  14246. */
  14247. minInitialRotation: number;
  14248. /**
  14249. * Gets or sets the maximal initial rotation in radians.
  14250. */
  14251. maxInitialRotation: number;
  14252. /**
  14253. * The particle emitter type defines the emitter used by the particle system.
  14254. * It can be for example box, sphere, or cone...
  14255. */
  14256. particleEmitterType: Nullable<IParticleEmitterType>;
  14257. /**
  14258. * Defines the delay in milliseconds before starting the system (0 by default)
  14259. */
  14260. startDelay: number;
  14261. /**
  14262. * 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
  14263. */
  14264. preWarmCycles: number;
  14265. /**
  14266. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14267. */
  14268. preWarmStepOffset: number;
  14269. /**
  14270. * 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)
  14271. */
  14272. spriteCellChangeSpeed: number;
  14273. /**
  14274. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14275. */
  14276. startSpriteCellID: number;
  14277. /**
  14278. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14279. */
  14280. endSpriteCellID: number;
  14281. /**
  14282. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14283. */
  14284. spriteCellWidth: number;
  14285. /**
  14286. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14287. */
  14288. spriteCellHeight: number;
  14289. /**
  14290. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14291. */
  14292. spriteRandomStartCell: boolean;
  14293. /**
  14294. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14295. */
  14296. isAnimationSheetEnabled: boolean;
  14297. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14298. translationPivot: Vector2;
  14299. /**
  14300. * Gets or sets a texture used to add random noise to particle positions
  14301. */
  14302. noiseTexture: Nullable<BaseTexture>;
  14303. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14304. noiseStrength: Vector3;
  14305. /**
  14306. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14307. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14308. */
  14309. billboardMode: number;
  14310. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14311. limitVelocityDamping: number;
  14312. /**
  14313. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14314. */
  14315. beginAnimationOnStart: boolean;
  14316. /**
  14317. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14318. */
  14319. beginAnimationFrom: number;
  14320. /**
  14321. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14322. */
  14323. beginAnimationTo: number;
  14324. /**
  14325. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14326. */
  14327. beginAnimationLoop: boolean;
  14328. /**
  14329. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14330. */
  14331. disposeOnStop: boolean;
  14332. /**
  14333. * Specifies if the particles are updated in emitter local space or world space
  14334. */
  14335. isLocal: boolean;
  14336. /** Snippet ID if the particle system was created from the snippet server */
  14337. snippetId: string;
  14338. /**
  14339. * Gets the maximum number of particles active at the same time.
  14340. * @returns The max number of active particles.
  14341. */
  14342. getCapacity(): number;
  14343. /**
  14344. * Gets the number of particles active at the same time.
  14345. * @returns The number of active particles.
  14346. */
  14347. getActiveCount(): number;
  14348. /**
  14349. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14350. * @returns True if it has been started, otherwise false.
  14351. */
  14352. isStarted(): boolean;
  14353. /**
  14354. * Animates the particle system for this frame.
  14355. */
  14356. animate(): void;
  14357. /**
  14358. * Renders the particle system in its current state.
  14359. * @returns the current number of particles
  14360. */
  14361. render(): number;
  14362. /**
  14363. * Dispose the particle system and frees its associated resources.
  14364. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14365. */
  14366. dispose(disposeTexture?: boolean): void;
  14367. /**
  14368. * An event triggered when the system is disposed
  14369. */
  14370. onDisposeObservable: Observable<IParticleSystem>;
  14371. /**
  14372. * Clones the particle system.
  14373. * @param name The name of the cloned object
  14374. * @param newEmitter The new emitter to use
  14375. * @returns the cloned particle system
  14376. */
  14377. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14378. /**
  14379. * Serializes the particle system to a JSON object
  14380. * @param serializeTexture defines if the texture must be serialized as well
  14381. * @returns the JSON object
  14382. */
  14383. serialize(serializeTexture: boolean): any;
  14384. /**
  14385. * Rebuild the particle system
  14386. */
  14387. rebuild(): void;
  14388. /** Force the system to rebuild all gradients that need to be resync */
  14389. forceRefreshGradients(): void;
  14390. /**
  14391. * Starts the particle system and begins to emit
  14392. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14393. */
  14394. start(delay?: number): void;
  14395. /**
  14396. * Stops the particle system.
  14397. */
  14398. stop(): void;
  14399. /**
  14400. * Remove all active particles
  14401. */
  14402. reset(): void;
  14403. /**
  14404. * Gets a boolean indicating that the system is stopping
  14405. * @returns true if the system is currently stopping
  14406. */
  14407. isStopping(): boolean;
  14408. /**
  14409. * Is this system ready to be used/rendered
  14410. * @return true if the system is ready
  14411. */
  14412. isReady(): boolean;
  14413. /**
  14414. * Returns the string "ParticleSystem"
  14415. * @returns a string containing the class name
  14416. */
  14417. getClassName(): string;
  14418. /**
  14419. * Gets the custom effect used to render the particles
  14420. * @param blendMode Blend mode for which the effect should be retrieved
  14421. * @returns The effect
  14422. */
  14423. getCustomEffect(blendMode: number): Nullable<Effect>;
  14424. /**
  14425. * Sets the custom effect used to render the particles
  14426. * @param effect The effect to set
  14427. * @param blendMode Blend mode for which the effect should be set
  14428. */
  14429. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14430. /**
  14431. * Fill the defines array according to the current settings of the particle system
  14432. * @param defines Array to be updated
  14433. * @param blendMode blend mode to take into account when updating the array
  14434. */
  14435. fillDefines(defines: Array<string>, blendMode: number): void;
  14436. /**
  14437. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14438. * @param uniforms Uniforms array to fill
  14439. * @param attributes Attributes array to fill
  14440. * @param samplers Samplers array to fill
  14441. */
  14442. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14443. /**
  14444. * Observable that will be called just before the particles are drawn
  14445. */
  14446. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14447. /**
  14448. * Gets the name of the particle vertex shader
  14449. */
  14450. vertexShaderName: string;
  14451. /**
  14452. * Adds a new color gradient
  14453. * @param gradient defines the gradient to use (between 0 and 1)
  14454. * @param color1 defines the color to affect to the specified gradient
  14455. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14456. * @returns the current particle system
  14457. */
  14458. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14459. /**
  14460. * Remove a specific color gradient
  14461. * @param gradient defines the gradient to remove
  14462. * @returns the current particle system
  14463. */
  14464. removeColorGradient(gradient: number): IParticleSystem;
  14465. /**
  14466. * Adds a new size gradient
  14467. * @param gradient defines the gradient to use (between 0 and 1)
  14468. * @param factor defines the size factor to affect to the specified gradient
  14469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14470. * @returns the current particle system
  14471. */
  14472. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14473. /**
  14474. * Remove a specific size gradient
  14475. * @param gradient defines the gradient to remove
  14476. * @returns the current particle system
  14477. */
  14478. removeSizeGradient(gradient: number): IParticleSystem;
  14479. /**
  14480. * Gets the current list of color gradients.
  14481. * You must use addColorGradient and removeColorGradient to udpate this list
  14482. * @returns the list of color gradients
  14483. */
  14484. getColorGradients(): Nullable<Array<ColorGradient>>;
  14485. /**
  14486. * Gets the current list of size gradients.
  14487. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14488. * @returns the list of size gradients
  14489. */
  14490. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14491. /**
  14492. * Gets the current list of angular speed gradients.
  14493. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14494. * @returns the list of angular speed gradients
  14495. */
  14496. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14497. /**
  14498. * Adds a new angular speed gradient
  14499. * @param gradient defines the gradient to use (between 0 and 1)
  14500. * @param factor defines the angular speed to affect to the specified gradient
  14501. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14502. * @returns the current particle system
  14503. */
  14504. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14505. /**
  14506. * Remove a specific angular speed gradient
  14507. * @param gradient defines the gradient to remove
  14508. * @returns the current particle system
  14509. */
  14510. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14511. /**
  14512. * Gets the current list of velocity gradients.
  14513. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14514. * @returns the list of velocity gradients
  14515. */
  14516. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14517. /**
  14518. * Adds a new velocity gradient
  14519. * @param gradient defines the gradient to use (between 0 and 1)
  14520. * @param factor defines the velocity to affect to the specified gradient
  14521. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14522. * @returns the current particle system
  14523. */
  14524. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14525. /**
  14526. * Remove a specific velocity gradient
  14527. * @param gradient defines the gradient to remove
  14528. * @returns the current particle system
  14529. */
  14530. removeVelocityGradient(gradient: number): IParticleSystem;
  14531. /**
  14532. * Gets the current list of limit velocity gradients.
  14533. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14534. * @returns the list of limit velocity gradients
  14535. */
  14536. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14537. /**
  14538. * Adds a new limit velocity gradient
  14539. * @param gradient defines the gradient to use (between 0 and 1)
  14540. * @param factor defines the limit velocity to affect to the specified gradient
  14541. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14542. * @returns the current particle system
  14543. */
  14544. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14545. /**
  14546. * Remove a specific limit velocity gradient
  14547. * @param gradient defines the gradient to remove
  14548. * @returns the current particle system
  14549. */
  14550. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14551. /**
  14552. * Adds a new drag gradient
  14553. * @param gradient defines the gradient to use (between 0 and 1)
  14554. * @param factor defines the drag to affect to the specified gradient
  14555. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14556. * @returns the current particle system
  14557. */
  14558. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14559. /**
  14560. * Remove a specific drag gradient
  14561. * @param gradient defines the gradient to remove
  14562. * @returns the current particle system
  14563. */
  14564. removeDragGradient(gradient: number): IParticleSystem;
  14565. /**
  14566. * Gets the current list of drag gradients.
  14567. * You must use addDragGradient and removeDragGradient to udpate this list
  14568. * @returns the list of drag gradients
  14569. */
  14570. getDragGradients(): Nullable<Array<FactorGradient>>;
  14571. /**
  14572. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14573. * @param gradient defines the gradient to use (between 0 and 1)
  14574. * @param factor defines the emit rate to affect to the specified gradient
  14575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14576. * @returns the current particle system
  14577. */
  14578. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14579. /**
  14580. * Remove a specific emit rate gradient
  14581. * @param gradient defines the gradient to remove
  14582. * @returns the current particle system
  14583. */
  14584. removeEmitRateGradient(gradient: number): IParticleSystem;
  14585. /**
  14586. * Gets the current list of emit rate gradients.
  14587. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14588. * @returns the list of emit rate gradients
  14589. */
  14590. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14591. /**
  14592. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14593. * @param gradient defines the gradient to use (between 0 and 1)
  14594. * @param factor defines the start size to affect to the specified gradient
  14595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14596. * @returns the current particle system
  14597. */
  14598. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14599. /**
  14600. * Remove a specific start size gradient
  14601. * @param gradient defines the gradient to remove
  14602. * @returns the current particle system
  14603. */
  14604. removeStartSizeGradient(gradient: number): IParticleSystem;
  14605. /**
  14606. * Gets the current list of start size gradients.
  14607. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14608. * @returns the list of start size gradients
  14609. */
  14610. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14611. /**
  14612. * Adds a new life time gradient
  14613. * @param gradient defines the gradient to use (between 0 and 1)
  14614. * @param factor defines the life time factor to affect to the specified gradient
  14615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14616. * @returns the current particle system
  14617. */
  14618. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14619. /**
  14620. * Remove a specific life time gradient
  14621. * @param gradient defines the gradient to remove
  14622. * @returns the current particle system
  14623. */
  14624. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14625. /**
  14626. * Gets the current list of life time gradients.
  14627. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14628. * @returns the list of life time gradients
  14629. */
  14630. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14631. /**
  14632. * Gets the current list of color gradients.
  14633. * You must use addColorGradient and removeColorGradient to udpate this list
  14634. * @returns the list of color gradients
  14635. */
  14636. getColorGradients(): Nullable<Array<ColorGradient>>;
  14637. /**
  14638. * Adds a new ramp gradient used to remap particle colors
  14639. * @param gradient defines the gradient to use (between 0 and 1)
  14640. * @param color defines the color to affect to the specified gradient
  14641. * @returns the current particle system
  14642. */
  14643. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14644. /**
  14645. * Gets the current list of ramp gradients.
  14646. * You must use addRampGradient and removeRampGradient to udpate this list
  14647. * @returns the list of ramp gradients
  14648. */
  14649. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14650. /** Gets or sets a boolean indicating that ramp gradients must be used
  14651. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14652. */
  14653. useRampGradients: boolean;
  14654. /**
  14655. * Adds a new color remap gradient
  14656. * @param gradient defines the gradient to use (between 0 and 1)
  14657. * @param min defines the color remap minimal range
  14658. * @param max defines the color remap maximal range
  14659. * @returns the current particle system
  14660. */
  14661. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14662. /**
  14663. * Gets the current list of color remap gradients.
  14664. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14665. * @returns the list of color remap gradients
  14666. */
  14667. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14668. /**
  14669. * Adds a new alpha remap gradient
  14670. * @param gradient defines the gradient to use (between 0 and 1)
  14671. * @param min defines the alpha remap minimal range
  14672. * @param max defines the alpha remap maximal range
  14673. * @returns the current particle system
  14674. */
  14675. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14676. /**
  14677. * Gets the current list of alpha remap gradients.
  14678. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14679. * @returns the list of alpha remap gradients
  14680. */
  14681. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14682. /**
  14683. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14684. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14685. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14686. * @returns the emitter
  14687. */
  14688. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14689. /**
  14690. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14691. * @param radius The radius of the hemisphere to emit from
  14692. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14693. * @returns the emitter
  14694. */
  14695. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14696. /**
  14697. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14698. * @param radius The radius of the sphere to emit from
  14699. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14700. * @returns the emitter
  14701. */
  14702. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14703. /**
  14704. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14705. * @param radius The radius of the sphere to emit from
  14706. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14707. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14708. * @returns the emitter
  14709. */
  14710. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14711. /**
  14712. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14713. * @param radius The radius of the emission cylinder
  14714. * @param height The height of the emission cylinder
  14715. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14716. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14717. * @returns the emitter
  14718. */
  14719. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14720. /**
  14721. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14722. * @param radius The radius of the cylinder to emit from
  14723. * @param height The height of the emission cylinder
  14724. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14725. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14726. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14727. * @returns the emitter
  14728. */
  14729. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14730. /**
  14731. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14732. * @param radius The radius of the cone to emit from
  14733. * @param angle The base angle of the cone
  14734. * @returns the emitter
  14735. */
  14736. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14737. /**
  14738. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14739. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14740. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14741. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14742. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14743. * @returns the emitter
  14744. */
  14745. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14746. /**
  14747. * Get hosting scene
  14748. * @returns the scene
  14749. */
  14750. getScene(): Scene;
  14751. }
  14752. }
  14753. declare module "babylonjs/Meshes/transformNode" {
  14754. import { DeepImmutable } from "babylonjs/types";
  14755. import { Observable } from "babylonjs/Misc/observable";
  14756. import { Nullable } from "babylonjs/types";
  14757. import { Camera } from "babylonjs/Cameras/camera";
  14758. import { Scene } from "babylonjs/scene";
  14759. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14760. import { Node } from "babylonjs/node";
  14761. import { Bone } from "babylonjs/Bones/bone";
  14762. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14763. import { Space } from "babylonjs/Maths/math.axis";
  14764. /**
  14765. * 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.
  14766. * @see https://doc.babylonjs.com/how_to/transformnode
  14767. */
  14768. export class TransformNode extends Node {
  14769. /**
  14770. * Object will not rotate to face the camera
  14771. */
  14772. static BILLBOARDMODE_NONE: number;
  14773. /**
  14774. * Object will rotate to face the camera but only on the x axis
  14775. */
  14776. static BILLBOARDMODE_X: number;
  14777. /**
  14778. * Object will rotate to face the camera but only on the y axis
  14779. */
  14780. static BILLBOARDMODE_Y: number;
  14781. /**
  14782. * Object will rotate to face the camera but only on the z axis
  14783. */
  14784. static BILLBOARDMODE_Z: number;
  14785. /**
  14786. * Object will rotate to face the camera
  14787. */
  14788. static BILLBOARDMODE_ALL: number;
  14789. /**
  14790. * Object will rotate to face the camera's position instead of orientation
  14791. */
  14792. static BILLBOARDMODE_USE_POSITION: number;
  14793. private static _TmpRotation;
  14794. private static _TmpScaling;
  14795. private static _TmpTranslation;
  14796. private _forward;
  14797. private _forwardInverted;
  14798. private _up;
  14799. private _right;
  14800. private _rightInverted;
  14801. private _position;
  14802. private _rotation;
  14803. private _rotationQuaternion;
  14804. protected _scaling: Vector3;
  14805. protected _isDirty: boolean;
  14806. private _transformToBoneReferal;
  14807. private _isAbsoluteSynced;
  14808. private _billboardMode;
  14809. /**
  14810. * Gets or sets the billboard mode. Default is 0.
  14811. *
  14812. * | Value | Type | Description |
  14813. * | --- | --- | --- |
  14814. * | 0 | BILLBOARDMODE_NONE | |
  14815. * | 1 | BILLBOARDMODE_X | |
  14816. * | 2 | BILLBOARDMODE_Y | |
  14817. * | 4 | BILLBOARDMODE_Z | |
  14818. * | 7 | BILLBOARDMODE_ALL | |
  14819. *
  14820. */
  14821. get billboardMode(): number;
  14822. set billboardMode(value: number);
  14823. private _preserveParentRotationForBillboard;
  14824. /**
  14825. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14826. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14827. */
  14828. get preserveParentRotationForBillboard(): boolean;
  14829. set preserveParentRotationForBillboard(value: boolean);
  14830. /**
  14831. * 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
  14832. */
  14833. scalingDeterminant: number;
  14834. private _infiniteDistance;
  14835. /**
  14836. * Gets or sets the distance of the object to max, often used by skybox
  14837. */
  14838. get infiniteDistance(): boolean;
  14839. set infiniteDistance(value: boolean);
  14840. /**
  14841. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14842. * By default the system will update normals to compensate
  14843. */
  14844. ignoreNonUniformScaling: boolean;
  14845. /**
  14846. * 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
  14847. */
  14848. reIntegrateRotationIntoRotationQuaternion: boolean;
  14849. /** @hidden */
  14850. _poseMatrix: Nullable<Matrix>;
  14851. /** @hidden */
  14852. _localMatrix: Matrix;
  14853. private _usePivotMatrix;
  14854. private _absolutePosition;
  14855. private _absoluteScaling;
  14856. private _absoluteRotationQuaternion;
  14857. private _pivotMatrix;
  14858. private _pivotMatrixInverse;
  14859. protected _postMultiplyPivotMatrix: boolean;
  14860. protected _isWorldMatrixFrozen: boolean;
  14861. /** @hidden */
  14862. _indexInSceneTransformNodesArray: number;
  14863. /**
  14864. * An event triggered after the world matrix is updated
  14865. */
  14866. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14867. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14868. /**
  14869. * Gets a string identifying the name of the class
  14870. * @returns "TransformNode" string
  14871. */
  14872. getClassName(): string;
  14873. /**
  14874. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14875. */
  14876. get position(): Vector3;
  14877. set position(newPosition: Vector3);
  14878. /**
  14879. * 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)).
  14880. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14881. */
  14882. get rotation(): Vector3;
  14883. set rotation(newRotation: Vector3);
  14884. /**
  14885. * 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)).
  14886. */
  14887. get scaling(): Vector3;
  14888. set scaling(newScaling: Vector3);
  14889. /**
  14890. * 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).
  14891. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14892. */
  14893. get rotationQuaternion(): Nullable<Quaternion>;
  14894. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14895. /**
  14896. * The forward direction of that transform in world space.
  14897. */
  14898. get forward(): Vector3;
  14899. /**
  14900. * The up direction of that transform in world space.
  14901. */
  14902. get up(): Vector3;
  14903. /**
  14904. * The right direction of that transform in world space.
  14905. */
  14906. get right(): Vector3;
  14907. /**
  14908. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14909. * @param matrix the matrix to copy the pose from
  14910. * @returns this TransformNode.
  14911. */
  14912. updatePoseMatrix(matrix: Matrix): TransformNode;
  14913. /**
  14914. * Returns the mesh Pose matrix.
  14915. * @returns the pose matrix
  14916. */
  14917. getPoseMatrix(): Matrix;
  14918. /** @hidden */
  14919. _isSynchronized(): boolean;
  14920. /** @hidden */
  14921. _initCache(): void;
  14922. /**
  14923. * Flag the transform node as dirty (Forcing it to update everything)
  14924. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14925. * @returns this transform node
  14926. */
  14927. markAsDirty(property: string): TransformNode;
  14928. /**
  14929. * Returns the current mesh absolute position.
  14930. * Returns a Vector3.
  14931. */
  14932. get absolutePosition(): Vector3;
  14933. /**
  14934. * Returns the current mesh absolute scaling.
  14935. * Returns a Vector3.
  14936. */
  14937. get absoluteScaling(): Vector3;
  14938. /**
  14939. * Returns the current mesh absolute rotation.
  14940. * Returns a Quaternion.
  14941. */
  14942. get absoluteRotationQuaternion(): Quaternion;
  14943. /**
  14944. * Sets a new matrix to apply before all other transformation
  14945. * @param matrix defines the transform matrix
  14946. * @returns the current TransformNode
  14947. */
  14948. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14949. /**
  14950. * Sets a new pivot matrix to the current node
  14951. * @param matrix defines the new pivot matrix to use
  14952. * @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
  14953. * @returns the current TransformNode
  14954. */
  14955. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14956. /**
  14957. * Returns the mesh pivot matrix.
  14958. * Default : Identity.
  14959. * @returns the matrix
  14960. */
  14961. getPivotMatrix(): Matrix;
  14962. /**
  14963. * Instantiate (when possible) or clone that node with its hierarchy
  14964. * @param newParent defines the new parent to use for the instance (or clone)
  14965. * @param options defines options to configure how copy is done
  14966. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14967. * @returns an instance (or a clone) of the current node with its hiearchy
  14968. */
  14969. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14970. doNotInstantiate: boolean;
  14971. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14972. /**
  14973. * Prevents the World matrix to be computed any longer
  14974. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14975. * @returns the TransformNode.
  14976. */
  14977. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14978. /**
  14979. * Allows back the World matrix computation.
  14980. * @returns the TransformNode.
  14981. */
  14982. unfreezeWorldMatrix(): this;
  14983. /**
  14984. * True if the World matrix has been frozen.
  14985. */
  14986. get isWorldMatrixFrozen(): boolean;
  14987. /**
  14988. * Retuns the mesh absolute position in the World.
  14989. * @returns a Vector3.
  14990. */
  14991. getAbsolutePosition(): Vector3;
  14992. /**
  14993. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14994. * @param absolutePosition the absolute position to set
  14995. * @returns the TransformNode.
  14996. */
  14997. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14998. /**
  14999. * Sets the mesh position in its local space.
  15000. * @param vector3 the position to set in localspace
  15001. * @returns the TransformNode.
  15002. */
  15003. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15004. /**
  15005. * Returns the mesh position in the local space from the current World matrix values.
  15006. * @returns a new Vector3.
  15007. */
  15008. getPositionExpressedInLocalSpace(): Vector3;
  15009. /**
  15010. * Translates the mesh along the passed Vector3 in its local space.
  15011. * @param vector3 the distance to translate in localspace
  15012. * @returns the TransformNode.
  15013. */
  15014. locallyTranslate(vector3: Vector3): TransformNode;
  15015. private static _lookAtVectorCache;
  15016. /**
  15017. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15018. * @param targetPoint the position (must be in same space as current mesh) to look at
  15019. * @param yawCor optional yaw (y-axis) correction in radians
  15020. * @param pitchCor optional pitch (x-axis) correction in radians
  15021. * @param rollCor optional roll (z-axis) correction in radians
  15022. * @param space the choosen space of the target
  15023. * @returns the TransformNode.
  15024. */
  15025. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15026. /**
  15027. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15028. * This Vector3 is expressed in the World space.
  15029. * @param localAxis axis to rotate
  15030. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15031. */
  15032. getDirection(localAxis: Vector3): Vector3;
  15033. /**
  15034. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15035. * localAxis is expressed in the mesh local space.
  15036. * result is computed in the Wordl space from the mesh World matrix.
  15037. * @param localAxis axis to rotate
  15038. * @param result the resulting transformnode
  15039. * @returns this TransformNode.
  15040. */
  15041. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15042. /**
  15043. * Sets this transform node rotation to the given local axis.
  15044. * @param localAxis the axis in local space
  15045. * @param yawCor optional yaw (y-axis) correction in radians
  15046. * @param pitchCor optional pitch (x-axis) correction in radians
  15047. * @param rollCor optional roll (z-axis) correction in radians
  15048. * @returns this TransformNode
  15049. */
  15050. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15051. /**
  15052. * Sets a new pivot point to the current node
  15053. * @param point defines the new pivot point to use
  15054. * @param space defines if the point is in world or local space (local by default)
  15055. * @returns the current TransformNode
  15056. */
  15057. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15058. /**
  15059. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15060. * @returns the pivot point
  15061. */
  15062. getPivotPoint(): Vector3;
  15063. /**
  15064. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15065. * @param result the vector3 to store the result
  15066. * @returns this TransformNode.
  15067. */
  15068. getPivotPointToRef(result: Vector3): TransformNode;
  15069. /**
  15070. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15071. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15072. */
  15073. getAbsolutePivotPoint(): Vector3;
  15074. /**
  15075. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15076. * @param result vector3 to store the result
  15077. * @returns this TransformNode.
  15078. */
  15079. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15080. /**
  15081. * Defines the passed node as the parent of the current node.
  15082. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15083. * @see https://doc.babylonjs.com/how_to/parenting
  15084. * @param node the node ot set as the parent
  15085. * @returns this TransformNode.
  15086. */
  15087. setParent(node: Nullable<Node>): TransformNode;
  15088. private _nonUniformScaling;
  15089. /**
  15090. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15091. */
  15092. get nonUniformScaling(): boolean;
  15093. /** @hidden */
  15094. _updateNonUniformScalingState(value: boolean): boolean;
  15095. /**
  15096. * Attach the current TransformNode to another TransformNode associated with a bone
  15097. * @param bone Bone affecting the TransformNode
  15098. * @param affectedTransformNode TransformNode associated with the bone
  15099. * @returns this object
  15100. */
  15101. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15102. /**
  15103. * Detach the transform node if its associated with a bone
  15104. * @returns this object
  15105. */
  15106. detachFromBone(): TransformNode;
  15107. private static _rotationAxisCache;
  15108. /**
  15109. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15110. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15111. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15112. * The passed axis is also normalized.
  15113. * @param axis the axis to rotate around
  15114. * @param amount the amount to rotate in radians
  15115. * @param space Space to rotate in (Default: local)
  15116. * @returns the TransformNode.
  15117. */
  15118. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15119. /**
  15120. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15121. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15122. * The passed axis is also normalized. .
  15123. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15124. * @param point the point to rotate around
  15125. * @param axis the axis to rotate around
  15126. * @param amount the amount to rotate in radians
  15127. * @returns the TransformNode
  15128. */
  15129. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15130. /**
  15131. * Translates the mesh along the axis vector for the passed distance in the given space.
  15132. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15133. * @param axis the axis to translate in
  15134. * @param distance the distance to translate
  15135. * @param space Space to rotate in (Default: local)
  15136. * @returns the TransformNode.
  15137. */
  15138. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15139. /**
  15140. * Adds a rotation step to the mesh current rotation.
  15141. * x, y, z are Euler angles expressed in radians.
  15142. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15143. * This means this rotation is made in the mesh local space only.
  15144. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15145. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15146. * ```javascript
  15147. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15148. * ```
  15149. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15150. * 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.
  15151. * @param x Rotation to add
  15152. * @param y Rotation to add
  15153. * @param z Rotation to add
  15154. * @returns the TransformNode.
  15155. */
  15156. addRotation(x: number, y: number, z: number): TransformNode;
  15157. /**
  15158. * @hidden
  15159. */
  15160. protected _getEffectiveParent(): Nullable<Node>;
  15161. /**
  15162. * Computes the world matrix of the node
  15163. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15164. * @returns the world matrix
  15165. */
  15166. computeWorldMatrix(force?: boolean): Matrix;
  15167. /**
  15168. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15169. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15170. */
  15171. resetLocalMatrix(independentOfChildren?: boolean): void;
  15172. protected _afterComputeWorldMatrix(): void;
  15173. /**
  15174. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15175. * @param func callback function to add
  15176. *
  15177. * @returns the TransformNode.
  15178. */
  15179. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15180. /**
  15181. * Removes a registered callback function.
  15182. * @param func callback function to remove
  15183. * @returns the TransformNode.
  15184. */
  15185. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15186. /**
  15187. * Gets the position of the current mesh in camera space
  15188. * @param camera defines the camera to use
  15189. * @returns a position
  15190. */
  15191. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15192. /**
  15193. * Returns the distance from the mesh to the active camera
  15194. * @param camera defines the camera to use
  15195. * @returns the distance
  15196. */
  15197. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15198. /**
  15199. * Clone the current transform node
  15200. * @param name Name of the new clone
  15201. * @param newParent New parent for the clone
  15202. * @param doNotCloneChildren Do not clone children hierarchy
  15203. * @returns the new transform node
  15204. */
  15205. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15206. /**
  15207. * Serializes the objects information.
  15208. * @param currentSerializationObject defines the object to serialize in
  15209. * @returns the serialized object
  15210. */
  15211. serialize(currentSerializationObject?: any): any;
  15212. /**
  15213. * Returns a new TransformNode object parsed from the source provided.
  15214. * @param parsedTransformNode is the source.
  15215. * @param scene the scne the object belongs to
  15216. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15217. * @returns a new TransformNode object parsed from the source provided.
  15218. */
  15219. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15220. /**
  15221. * Get all child-transformNodes of this node
  15222. * @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
  15223. * @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
  15224. * @returns an array of TransformNode
  15225. */
  15226. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15227. /**
  15228. * Releases resources associated with this transform node.
  15229. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15230. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15231. */
  15232. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15233. /**
  15234. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15235. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15236. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15237. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15238. * @returns the current mesh
  15239. */
  15240. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15241. private _syncAbsoluteScalingAndRotation;
  15242. }
  15243. }
  15244. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15245. /**
  15246. * Class used to override all child animations of a given target
  15247. */
  15248. export class AnimationPropertiesOverride {
  15249. /**
  15250. * Gets or sets a value indicating if animation blending must be used
  15251. */
  15252. enableBlending: boolean;
  15253. /**
  15254. * Gets or sets the blending speed to use when enableBlending is true
  15255. */
  15256. blendingSpeed: number;
  15257. /**
  15258. * Gets or sets the default loop mode to use
  15259. */
  15260. loopMode: number;
  15261. }
  15262. }
  15263. declare module "babylonjs/Bones/bone" {
  15264. import { Skeleton } from "babylonjs/Bones/skeleton";
  15265. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15266. import { Nullable } from "babylonjs/types";
  15267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15268. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15269. import { Node } from "babylonjs/node";
  15270. import { Space } from "babylonjs/Maths/math.axis";
  15271. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15272. /**
  15273. * Class used to store bone information
  15274. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15275. */
  15276. export class Bone extends Node {
  15277. /**
  15278. * defines the bone name
  15279. */
  15280. name: string;
  15281. private static _tmpVecs;
  15282. private static _tmpQuat;
  15283. private static _tmpMats;
  15284. /**
  15285. * Gets the list of child bones
  15286. */
  15287. children: Bone[];
  15288. /** Gets the animations associated with this bone */
  15289. animations: import("babylonjs/Animations/animation").Animation[];
  15290. /**
  15291. * Gets or sets bone length
  15292. */
  15293. length: number;
  15294. /**
  15295. * @hidden Internal only
  15296. * Set this value to map this bone to a different index in the transform matrices
  15297. * Set this value to -1 to exclude the bone from the transform matrices
  15298. */
  15299. _index: Nullable<number>;
  15300. private _skeleton;
  15301. private _localMatrix;
  15302. private _restPose;
  15303. private _baseMatrix;
  15304. private _absoluteTransform;
  15305. private _invertedAbsoluteTransform;
  15306. private _parent;
  15307. private _scalingDeterminant;
  15308. private _worldTransform;
  15309. private _localScaling;
  15310. private _localRotation;
  15311. private _localPosition;
  15312. private _needToDecompose;
  15313. private _needToCompose;
  15314. /** @hidden */
  15315. _linkedTransformNode: Nullable<TransformNode>;
  15316. /** @hidden */
  15317. _waitingTransformNodeId: Nullable<string>;
  15318. /** @hidden */
  15319. get _matrix(): Matrix;
  15320. /** @hidden */
  15321. set _matrix(value: Matrix);
  15322. /**
  15323. * Create a new bone
  15324. * @param name defines the bone name
  15325. * @param skeleton defines the parent skeleton
  15326. * @param parentBone defines the parent (can be null if the bone is the root)
  15327. * @param localMatrix defines the local matrix
  15328. * @param restPose defines the rest pose matrix
  15329. * @param baseMatrix defines the base matrix
  15330. * @param index defines index of the bone in the hiearchy
  15331. */
  15332. constructor(
  15333. /**
  15334. * defines the bone name
  15335. */
  15336. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15337. /**
  15338. * Gets the current object class name.
  15339. * @return the class name
  15340. */
  15341. getClassName(): string;
  15342. /**
  15343. * Gets the parent skeleton
  15344. * @returns a skeleton
  15345. */
  15346. getSkeleton(): Skeleton;
  15347. /**
  15348. * Gets parent bone
  15349. * @returns a bone or null if the bone is the root of the bone hierarchy
  15350. */
  15351. getParent(): Nullable<Bone>;
  15352. /**
  15353. * Returns an array containing the root bones
  15354. * @returns an array containing the root bones
  15355. */
  15356. getChildren(): Array<Bone>;
  15357. /**
  15358. * Gets the node index in matrix array generated for rendering
  15359. * @returns the node index
  15360. */
  15361. getIndex(): number;
  15362. /**
  15363. * Sets the parent bone
  15364. * @param parent defines the parent (can be null if the bone is the root)
  15365. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15366. */
  15367. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15368. /**
  15369. * Gets the local matrix
  15370. * @returns a matrix
  15371. */
  15372. getLocalMatrix(): Matrix;
  15373. /**
  15374. * Gets the base matrix (initial matrix which remains unchanged)
  15375. * @returns a matrix
  15376. */
  15377. getBaseMatrix(): Matrix;
  15378. /**
  15379. * Gets the rest pose matrix
  15380. * @returns a matrix
  15381. */
  15382. getRestPose(): Matrix;
  15383. /**
  15384. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15385. */
  15386. getWorldMatrix(): Matrix;
  15387. /**
  15388. * Sets the local matrix to rest pose matrix
  15389. */
  15390. returnToRest(): void;
  15391. /**
  15392. * Gets the inverse of the absolute transform matrix.
  15393. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15394. * @returns a matrix
  15395. */
  15396. getInvertedAbsoluteTransform(): Matrix;
  15397. /**
  15398. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15399. * @returns a matrix
  15400. */
  15401. getAbsoluteTransform(): Matrix;
  15402. /**
  15403. * Links with the given transform node.
  15404. * The local matrix of this bone is copied from the transform node every frame.
  15405. * @param transformNode defines the transform node to link to
  15406. */
  15407. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15408. /**
  15409. * Gets the node used to drive the bone's transformation
  15410. * @returns a transform node or null
  15411. */
  15412. getTransformNode(): Nullable<TransformNode>;
  15413. /** Gets or sets current position (in local space) */
  15414. get position(): Vector3;
  15415. set position(newPosition: Vector3);
  15416. /** Gets or sets current rotation (in local space) */
  15417. get rotation(): Vector3;
  15418. set rotation(newRotation: Vector3);
  15419. /** Gets or sets current rotation quaternion (in local space) */
  15420. get rotationQuaternion(): Quaternion;
  15421. set rotationQuaternion(newRotation: Quaternion);
  15422. /** Gets or sets current scaling (in local space) */
  15423. get scaling(): Vector3;
  15424. set scaling(newScaling: Vector3);
  15425. /**
  15426. * Gets the animation properties override
  15427. */
  15428. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15429. private _decompose;
  15430. private _compose;
  15431. /**
  15432. * Update the base and local matrices
  15433. * @param matrix defines the new base or local matrix
  15434. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15435. * @param updateLocalMatrix defines if the local matrix should be updated
  15436. */
  15437. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15438. /** @hidden */
  15439. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15440. /**
  15441. * Flag the bone as dirty (Forcing it to update everything)
  15442. */
  15443. markAsDirty(): void;
  15444. /** @hidden */
  15445. _markAsDirtyAndCompose(): void;
  15446. private _markAsDirtyAndDecompose;
  15447. /**
  15448. * Translate the bone in local or world space
  15449. * @param vec The amount to translate the bone
  15450. * @param space The space that the translation is in
  15451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15452. */
  15453. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15454. /**
  15455. * Set the postion of the bone in local or world space
  15456. * @param position The position to set the bone
  15457. * @param space The space that the position is in
  15458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15459. */
  15460. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15461. /**
  15462. * Set the absolute position of the bone (world space)
  15463. * @param position The position to set the bone
  15464. * @param mesh The mesh that this bone is attached to
  15465. */
  15466. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15467. /**
  15468. * Scale the bone on the x, y and z axes (in local space)
  15469. * @param x The amount to scale the bone on the x axis
  15470. * @param y The amount to scale the bone on the y axis
  15471. * @param z The amount to scale the bone on the z axis
  15472. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15473. */
  15474. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15475. /**
  15476. * Set the bone scaling in local space
  15477. * @param scale defines the scaling vector
  15478. */
  15479. setScale(scale: Vector3): void;
  15480. /**
  15481. * Gets the current scaling in local space
  15482. * @returns the current scaling vector
  15483. */
  15484. getScale(): Vector3;
  15485. /**
  15486. * Gets the current scaling in local space and stores it in a target vector
  15487. * @param result defines the target vector
  15488. */
  15489. getScaleToRef(result: Vector3): void;
  15490. /**
  15491. * Set the yaw, pitch, and roll of the bone in local or world space
  15492. * @param yaw The rotation of the bone on the y axis
  15493. * @param pitch The rotation of the bone on the x axis
  15494. * @param roll The rotation of the bone on the z axis
  15495. * @param space The space that the axes of rotation are in
  15496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15497. */
  15498. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15499. /**
  15500. * Add a rotation to the bone on an axis in local or world space
  15501. * @param axis The axis to rotate the bone on
  15502. * @param amount The amount to rotate the bone
  15503. * @param space The space that the axis is in
  15504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15505. */
  15506. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15507. /**
  15508. * Set the rotation of the bone to a particular axis angle in local or world space
  15509. * @param axis The axis to rotate the bone on
  15510. * @param angle The angle that the bone should be rotated to
  15511. * @param space The space that the axis is in
  15512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15513. */
  15514. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15515. /**
  15516. * Set the euler rotation of the bone in local of world space
  15517. * @param rotation The euler rotation that the bone should be set to
  15518. * @param space The space that the rotation is in
  15519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15520. */
  15521. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15522. /**
  15523. * Set the quaternion rotation of the bone in local of world space
  15524. * @param quat The quaternion rotation that the bone should be set to
  15525. * @param space The space that the rotation is in
  15526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15527. */
  15528. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15529. /**
  15530. * Set the rotation matrix of the bone in local of world space
  15531. * @param rotMat The rotation matrix that the bone should be set to
  15532. * @param space The space that the rotation is in
  15533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15534. */
  15535. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15536. private _rotateWithMatrix;
  15537. private _getNegativeRotationToRef;
  15538. /**
  15539. * Get the position of the bone in local or world space
  15540. * @param space The space that the returned position is in
  15541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15542. * @returns The position of the bone
  15543. */
  15544. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15545. /**
  15546. * Copy the position of the bone to a vector3 in local or world space
  15547. * @param space The space that the returned position is in
  15548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15549. * @param result The vector3 to copy the position to
  15550. */
  15551. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15552. /**
  15553. * Get the absolute position of the bone (world space)
  15554. * @param mesh The mesh that this bone is attached to
  15555. * @returns The absolute position of the bone
  15556. */
  15557. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15558. /**
  15559. * Copy the absolute position of the bone (world space) to the result param
  15560. * @param mesh The mesh that this bone is attached to
  15561. * @param result The vector3 to copy the absolute position to
  15562. */
  15563. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15564. /**
  15565. * Compute the absolute transforms of this bone and its children
  15566. */
  15567. computeAbsoluteTransforms(): void;
  15568. /**
  15569. * Get the world direction from an axis that is in the local space of the bone
  15570. * @param localAxis The local direction that is used to compute the world direction
  15571. * @param mesh The mesh that this bone is attached to
  15572. * @returns The world direction
  15573. */
  15574. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15575. /**
  15576. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15577. * @param localAxis The local direction that is used to compute the world direction
  15578. * @param mesh The mesh that this bone is attached to
  15579. * @param result The vector3 that the world direction will be copied to
  15580. */
  15581. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15582. /**
  15583. * Get the euler rotation of the bone in local or world space
  15584. * @param space The space that the rotation should be in
  15585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15586. * @returns The euler rotation
  15587. */
  15588. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15589. /**
  15590. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15591. * @param space The space that the rotation should be in
  15592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15593. * @param result The vector3 that the rotation should be copied to
  15594. */
  15595. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15596. /**
  15597. * Get the quaternion rotation of the bone in either local or world space
  15598. * @param space The space that the rotation should be in
  15599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15600. * @returns The quaternion rotation
  15601. */
  15602. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15603. /**
  15604. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15605. * @param space The space that the rotation should be in
  15606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15607. * @param result The quaternion that the rotation should be copied to
  15608. */
  15609. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15610. /**
  15611. * Get the rotation matrix of the bone in local or world space
  15612. * @param space The space that the rotation should be in
  15613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15614. * @returns The rotation matrix
  15615. */
  15616. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15617. /**
  15618. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15619. * @param space The space that the rotation should be in
  15620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15621. * @param result The quaternion that the rotation should be copied to
  15622. */
  15623. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15624. /**
  15625. * Get the world position of a point that is in the local space of the bone
  15626. * @param position The local position
  15627. * @param mesh The mesh that this bone is attached to
  15628. * @returns The world position
  15629. */
  15630. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15631. /**
  15632. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15633. * @param position The local position
  15634. * @param mesh The mesh that this bone is attached to
  15635. * @param result The vector3 that the world position should be copied to
  15636. */
  15637. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15638. /**
  15639. * Get the local position of a point that is in world space
  15640. * @param position The world position
  15641. * @param mesh The mesh that this bone is attached to
  15642. * @returns The local position
  15643. */
  15644. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15645. /**
  15646. * Get the local position of a point that is in world space and copy it to the result param
  15647. * @param position The world position
  15648. * @param mesh The mesh that this bone is attached to
  15649. * @param result The vector3 that the local position should be copied to
  15650. */
  15651. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15652. }
  15653. }
  15654. declare module "babylonjs/Animations/runtimeAnimation" {
  15655. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15656. import { Animatable } from "babylonjs/Animations/animatable";
  15657. import { Scene } from "babylonjs/scene";
  15658. /**
  15659. * Defines a runtime animation
  15660. */
  15661. export class RuntimeAnimation {
  15662. private _events;
  15663. /**
  15664. * The current frame of the runtime animation
  15665. */
  15666. private _currentFrame;
  15667. /**
  15668. * The animation used by the runtime animation
  15669. */
  15670. private _animation;
  15671. /**
  15672. * The target of the runtime animation
  15673. */
  15674. private _target;
  15675. /**
  15676. * The initiating animatable
  15677. */
  15678. private _host;
  15679. /**
  15680. * The original value of the runtime animation
  15681. */
  15682. private _originalValue;
  15683. /**
  15684. * The original blend value of the runtime animation
  15685. */
  15686. private _originalBlendValue;
  15687. /**
  15688. * The offsets cache of the runtime animation
  15689. */
  15690. private _offsetsCache;
  15691. /**
  15692. * The high limits cache of the runtime animation
  15693. */
  15694. private _highLimitsCache;
  15695. /**
  15696. * Specifies if the runtime animation has been stopped
  15697. */
  15698. private _stopped;
  15699. /**
  15700. * The blending factor of the runtime animation
  15701. */
  15702. private _blendingFactor;
  15703. /**
  15704. * The BabylonJS scene
  15705. */
  15706. private _scene;
  15707. /**
  15708. * The current value of the runtime animation
  15709. */
  15710. private _currentValue;
  15711. /** @hidden */
  15712. _animationState: _IAnimationState;
  15713. /**
  15714. * The active target of the runtime animation
  15715. */
  15716. private _activeTargets;
  15717. private _currentActiveTarget;
  15718. private _directTarget;
  15719. /**
  15720. * The target path of the runtime animation
  15721. */
  15722. private _targetPath;
  15723. /**
  15724. * The weight of the runtime animation
  15725. */
  15726. private _weight;
  15727. /**
  15728. * The ratio offset of the runtime animation
  15729. */
  15730. private _ratioOffset;
  15731. /**
  15732. * The previous delay of the runtime animation
  15733. */
  15734. private _previousDelay;
  15735. /**
  15736. * The previous ratio of the runtime animation
  15737. */
  15738. private _previousRatio;
  15739. private _enableBlending;
  15740. private _keys;
  15741. private _minFrame;
  15742. private _maxFrame;
  15743. private _minValue;
  15744. private _maxValue;
  15745. private _targetIsArray;
  15746. /**
  15747. * Gets the current frame of the runtime animation
  15748. */
  15749. get currentFrame(): number;
  15750. /**
  15751. * Gets the weight of the runtime animation
  15752. */
  15753. get weight(): number;
  15754. /**
  15755. * Gets the current value of the runtime animation
  15756. */
  15757. get currentValue(): any;
  15758. /**
  15759. * Gets the target path of the runtime animation
  15760. */
  15761. get targetPath(): string;
  15762. /**
  15763. * Gets the actual target of the runtime animation
  15764. */
  15765. get target(): any;
  15766. /**
  15767. * Gets the additive state of the runtime animation
  15768. */
  15769. get isAdditive(): boolean;
  15770. /** @hidden */
  15771. _onLoop: () => void;
  15772. /**
  15773. * Create a new RuntimeAnimation object
  15774. * @param target defines the target of the animation
  15775. * @param animation defines the source animation object
  15776. * @param scene defines the hosting scene
  15777. * @param host defines the initiating Animatable
  15778. */
  15779. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15780. private _preparePath;
  15781. /**
  15782. * Gets the animation from the runtime animation
  15783. */
  15784. get animation(): Animation;
  15785. /**
  15786. * Resets the runtime animation to the beginning
  15787. * @param restoreOriginal defines whether to restore the target property to the original value
  15788. */
  15789. reset(restoreOriginal?: boolean): void;
  15790. /**
  15791. * Specifies if the runtime animation is stopped
  15792. * @returns Boolean specifying if the runtime animation is stopped
  15793. */
  15794. isStopped(): boolean;
  15795. /**
  15796. * Disposes of the runtime animation
  15797. */
  15798. dispose(): void;
  15799. /**
  15800. * Apply the interpolated value to the target
  15801. * @param currentValue defines the value computed by the animation
  15802. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15803. */
  15804. setValue(currentValue: any, weight: number): void;
  15805. private _getOriginalValues;
  15806. private _setValue;
  15807. /**
  15808. * Gets the loop pmode of the runtime animation
  15809. * @returns Loop Mode
  15810. */
  15811. private _getCorrectLoopMode;
  15812. /**
  15813. * Move the current animation to a given frame
  15814. * @param frame defines the frame to move to
  15815. */
  15816. goToFrame(frame: number): void;
  15817. /**
  15818. * @hidden Internal use only
  15819. */
  15820. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15821. /**
  15822. * Execute the current animation
  15823. * @param delay defines the delay to add to the current frame
  15824. * @param from defines the lower bound of the animation range
  15825. * @param to defines the upper bound of the animation range
  15826. * @param loop defines if the current animation must loop
  15827. * @param speedRatio defines the current speed ratio
  15828. * @param weight defines the weight of the animation (default is -1 so no weight)
  15829. * @param onLoop optional callback called when animation loops
  15830. * @returns a boolean indicating if the animation is running
  15831. */
  15832. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15833. }
  15834. }
  15835. declare module "babylonjs/Animations/animatable" {
  15836. import { Animation } from "babylonjs/Animations/animation";
  15837. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15838. import { Nullable } from "babylonjs/types";
  15839. import { Observable } from "babylonjs/Misc/observable";
  15840. import { Scene } from "babylonjs/scene";
  15841. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15842. import { Node } from "babylonjs/node";
  15843. /**
  15844. * Class used to store an actual running animation
  15845. */
  15846. export class Animatable {
  15847. /** defines the target object */
  15848. target: any;
  15849. /** defines the starting frame number (default is 0) */
  15850. fromFrame: number;
  15851. /** defines the ending frame number (default is 100) */
  15852. toFrame: number;
  15853. /** defines if the animation must loop (default is false) */
  15854. loopAnimation: boolean;
  15855. /** defines a callback to call when animation ends if it is not looping */
  15856. onAnimationEnd?: (() => void) | null | undefined;
  15857. /** defines a callback to call when animation loops */
  15858. onAnimationLoop?: (() => void) | null | undefined;
  15859. /** defines whether the animation should be evaluated additively */
  15860. isAdditive: boolean;
  15861. private _localDelayOffset;
  15862. private _pausedDelay;
  15863. private _runtimeAnimations;
  15864. private _paused;
  15865. private _scene;
  15866. private _speedRatio;
  15867. private _weight;
  15868. private _syncRoot;
  15869. /**
  15870. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15871. * This will only apply for non looping animation (default is true)
  15872. */
  15873. disposeOnEnd: boolean;
  15874. /**
  15875. * Gets a boolean indicating if the animation has started
  15876. */
  15877. animationStarted: boolean;
  15878. /**
  15879. * Observer raised when the animation ends
  15880. */
  15881. onAnimationEndObservable: Observable<Animatable>;
  15882. /**
  15883. * Observer raised when the animation loops
  15884. */
  15885. onAnimationLoopObservable: Observable<Animatable>;
  15886. /**
  15887. * Gets the root Animatable used to synchronize and normalize animations
  15888. */
  15889. get syncRoot(): Nullable<Animatable>;
  15890. /**
  15891. * Gets the current frame of the first RuntimeAnimation
  15892. * Used to synchronize Animatables
  15893. */
  15894. get masterFrame(): number;
  15895. /**
  15896. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15897. */
  15898. get weight(): number;
  15899. set weight(value: number);
  15900. /**
  15901. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15902. */
  15903. get speedRatio(): number;
  15904. set speedRatio(value: number);
  15905. /**
  15906. * Creates a new Animatable
  15907. * @param scene defines the hosting scene
  15908. * @param target defines the target object
  15909. * @param fromFrame defines the starting frame number (default is 0)
  15910. * @param toFrame defines the ending frame number (default is 100)
  15911. * @param loopAnimation defines if the animation must loop (default is false)
  15912. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15913. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15914. * @param animations defines a group of animation to add to the new Animatable
  15915. * @param onAnimationLoop defines a callback to call when animation loops
  15916. * @param isAdditive defines whether the animation should be evaluated additively
  15917. */
  15918. constructor(scene: Scene,
  15919. /** defines the target object */
  15920. target: any,
  15921. /** defines the starting frame number (default is 0) */
  15922. fromFrame?: number,
  15923. /** defines the ending frame number (default is 100) */
  15924. toFrame?: number,
  15925. /** defines if the animation must loop (default is false) */
  15926. loopAnimation?: boolean, speedRatio?: number,
  15927. /** defines a callback to call when animation ends if it is not looping */
  15928. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15929. /** defines a callback to call when animation loops */
  15930. onAnimationLoop?: (() => void) | null | undefined,
  15931. /** defines whether the animation should be evaluated additively */
  15932. isAdditive?: boolean);
  15933. /**
  15934. * Synchronize and normalize current Animatable with a source Animatable
  15935. * This is useful when using animation weights and when animations are not of the same length
  15936. * @param root defines the root Animatable to synchronize with
  15937. * @returns the current Animatable
  15938. */
  15939. syncWith(root: Animatable): Animatable;
  15940. /**
  15941. * Gets the list of runtime animations
  15942. * @returns an array of RuntimeAnimation
  15943. */
  15944. getAnimations(): RuntimeAnimation[];
  15945. /**
  15946. * Adds more animations to the current animatable
  15947. * @param target defines the target of the animations
  15948. * @param animations defines the new animations to add
  15949. */
  15950. appendAnimations(target: any, animations: Animation[]): void;
  15951. /**
  15952. * Gets the source animation for a specific property
  15953. * @param property defines the propertyu to look for
  15954. * @returns null or the source animation for the given property
  15955. */
  15956. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15957. /**
  15958. * Gets the runtime animation for a specific property
  15959. * @param property defines the propertyu to look for
  15960. * @returns null or the runtime animation for the given property
  15961. */
  15962. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15963. /**
  15964. * Resets the animatable to its original state
  15965. */
  15966. reset(): void;
  15967. /**
  15968. * Allows the animatable to blend with current running animations
  15969. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15970. * @param blendingSpeed defines the blending speed to use
  15971. */
  15972. enableBlending(blendingSpeed: number): void;
  15973. /**
  15974. * Disable animation blending
  15975. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15976. */
  15977. disableBlending(): void;
  15978. /**
  15979. * Jump directly to a given frame
  15980. * @param frame defines the frame to jump to
  15981. */
  15982. goToFrame(frame: number): void;
  15983. /**
  15984. * Pause the animation
  15985. */
  15986. pause(): void;
  15987. /**
  15988. * Restart the animation
  15989. */
  15990. restart(): void;
  15991. private _raiseOnAnimationEnd;
  15992. /**
  15993. * Stop and delete the current animation
  15994. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15995. * @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)
  15996. */
  15997. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15998. /**
  15999. * Wait asynchronously for the animation to end
  16000. * @returns a promise which will be fullfilled when the animation ends
  16001. */
  16002. waitAsync(): Promise<Animatable>;
  16003. /** @hidden */
  16004. _animate(delay: number): boolean;
  16005. }
  16006. module "babylonjs/scene" {
  16007. interface Scene {
  16008. /** @hidden */
  16009. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16010. /** @hidden */
  16011. _processLateAnimationBindingsForMatrices(holder: {
  16012. totalWeight: number;
  16013. totalAdditiveWeight: number;
  16014. animations: RuntimeAnimation[];
  16015. additiveAnimations: RuntimeAnimation[];
  16016. originalValue: Matrix;
  16017. }): any;
  16018. /** @hidden */
  16019. _processLateAnimationBindingsForQuaternions(holder: {
  16020. totalWeight: number;
  16021. totalAdditiveWeight: number;
  16022. animations: RuntimeAnimation[];
  16023. additiveAnimations: RuntimeAnimation[];
  16024. originalValue: Quaternion;
  16025. }, refQuaternion: Quaternion): Quaternion;
  16026. /** @hidden */
  16027. _processLateAnimationBindings(): void;
  16028. /**
  16029. * Will start the animation sequence of a given target
  16030. * @param target defines the target
  16031. * @param from defines from which frame should animation start
  16032. * @param to defines until which frame should animation run.
  16033. * @param weight defines the weight to apply to the animation (1.0 by default)
  16034. * @param loop defines if the animation loops
  16035. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16036. * @param onAnimationEnd defines the function to be executed when the animation ends
  16037. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16038. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16039. * @param onAnimationLoop defines the callback to call when an animation loops
  16040. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16041. * @returns the animatable object created for this animation
  16042. */
  16043. 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;
  16044. /**
  16045. * Will start the animation sequence of a given target
  16046. * @param target defines the target
  16047. * @param from defines from which frame should animation start
  16048. * @param to defines until which frame should animation run.
  16049. * @param loop defines if the animation loops
  16050. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16051. * @param onAnimationEnd defines the function to be executed when the animation ends
  16052. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16053. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16054. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16055. * @param onAnimationLoop defines the callback to call when an animation loops
  16056. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16057. * @returns the animatable object created for this animation
  16058. */
  16059. 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;
  16060. /**
  16061. * Will start the animation sequence of a given target and its hierarchy
  16062. * @param target defines the target
  16063. * @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.
  16064. * @param from defines from which frame should animation start
  16065. * @param to defines until which frame should animation run.
  16066. * @param loop defines if the animation loops
  16067. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16068. * @param onAnimationEnd defines the function to be executed when the animation ends
  16069. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16070. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16071. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16072. * @param onAnimationLoop defines the callback to call when an animation loops
  16073. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16074. * @returns the list of created animatables
  16075. */
  16076. 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[];
  16077. /**
  16078. * Begin a new animation on a given node
  16079. * @param target defines the target where the animation will take place
  16080. * @param animations defines the list of animations to start
  16081. * @param from defines the initial value
  16082. * @param to defines the final value
  16083. * @param loop defines if you want animation to loop (off by default)
  16084. * @param speedRatio defines the speed ratio to apply to all animations
  16085. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16086. * @param onAnimationLoop defines the callback to call when an animation loops
  16087. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16088. * @returns the list of created animatables
  16089. */
  16090. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16091. /**
  16092. * Begin a new animation on a given node and its hierarchy
  16093. * @param target defines the root node where the animation will take place
  16094. * @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.
  16095. * @param animations defines the list of animations to start
  16096. * @param from defines the initial value
  16097. * @param to defines the final value
  16098. * @param loop defines if you want animation to loop (off by default)
  16099. * @param speedRatio defines the speed ratio to apply to all animations
  16100. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16101. * @param onAnimationLoop defines the callback to call when an animation loops
  16102. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16103. * @returns the list of animatables created for all nodes
  16104. */
  16105. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16106. /**
  16107. * Gets the animatable associated with a specific target
  16108. * @param target defines the target of the animatable
  16109. * @returns the required animatable if found
  16110. */
  16111. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16112. /**
  16113. * Gets all animatables associated with a given target
  16114. * @param target defines the target to look animatables for
  16115. * @returns an array of Animatables
  16116. */
  16117. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16118. /**
  16119. * Stops and removes all animations that have been applied to the scene
  16120. */
  16121. stopAllAnimations(): void;
  16122. /**
  16123. * Gets the current delta time used by animation engine
  16124. */
  16125. deltaTime: number;
  16126. }
  16127. }
  16128. module "babylonjs/Bones/bone" {
  16129. interface Bone {
  16130. /**
  16131. * Copy an animation range from another bone
  16132. * @param source defines the source bone
  16133. * @param rangeName defines the range name to copy
  16134. * @param frameOffset defines the frame offset
  16135. * @param rescaleAsRequired defines if rescaling must be applied if required
  16136. * @param skelDimensionsRatio defines the scaling ratio
  16137. * @returns true if operation was successful
  16138. */
  16139. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16140. }
  16141. }
  16142. }
  16143. declare module "babylonjs/Bones/skeleton" {
  16144. import { Bone } from "babylonjs/Bones/bone";
  16145. import { Observable } from "babylonjs/Misc/observable";
  16146. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16147. import { Scene } from "babylonjs/scene";
  16148. import { Nullable } from "babylonjs/types";
  16149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16150. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16151. import { Animatable } from "babylonjs/Animations/animatable";
  16152. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16153. import { Animation } from "babylonjs/Animations/animation";
  16154. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16155. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16156. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16157. /**
  16158. * Class used to handle skinning animations
  16159. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16160. */
  16161. export class Skeleton implements IAnimatable {
  16162. /** defines the skeleton name */
  16163. name: string;
  16164. /** defines the skeleton Id */
  16165. id: string;
  16166. /**
  16167. * Defines the list of child bones
  16168. */
  16169. bones: Bone[];
  16170. /**
  16171. * Defines an estimate of the dimension of the skeleton at rest
  16172. */
  16173. dimensionsAtRest: Vector3;
  16174. /**
  16175. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16176. */
  16177. needInitialSkinMatrix: boolean;
  16178. /**
  16179. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16180. */
  16181. overrideMesh: Nullable<AbstractMesh>;
  16182. /**
  16183. * Gets the list of animations attached to this skeleton
  16184. */
  16185. animations: Array<Animation>;
  16186. private _scene;
  16187. private _isDirty;
  16188. private _transformMatrices;
  16189. private _transformMatrixTexture;
  16190. private _meshesWithPoseMatrix;
  16191. private _animatables;
  16192. private _identity;
  16193. private _synchronizedWithMesh;
  16194. private _ranges;
  16195. private _lastAbsoluteTransformsUpdateId;
  16196. private _canUseTextureForBones;
  16197. private _uniqueId;
  16198. /** @hidden */
  16199. _numBonesWithLinkedTransformNode: number;
  16200. /** @hidden */
  16201. _hasWaitingData: Nullable<boolean>;
  16202. /**
  16203. * Specifies if the skeleton should be serialized
  16204. */
  16205. doNotSerialize: boolean;
  16206. private _useTextureToStoreBoneMatrices;
  16207. /**
  16208. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16209. * Please note that this option is not available if the hardware does not support it
  16210. */
  16211. get useTextureToStoreBoneMatrices(): boolean;
  16212. set useTextureToStoreBoneMatrices(value: boolean);
  16213. private _animationPropertiesOverride;
  16214. /**
  16215. * Gets or sets the animation properties override
  16216. */
  16217. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16218. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16219. /**
  16220. * List of inspectable custom properties (used by the Inspector)
  16221. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16222. */
  16223. inspectableCustomProperties: IInspectable[];
  16224. /**
  16225. * An observable triggered before computing the skeleton's matrices
  16226. */
  16227. onBeforeComputeObservable: Observable<Skeleton>;
  16228. /**
  16229. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16230. */
  16231. get isUsingTextureForMatrices(): boolean;
  16232. /**
  16233. * Gets the unique ID of this skeleton
  16234. */
  16235. get uniqueId(): number;
  16236. /**
  16237. * Creates a new skeleton
  16238. * @param name defines the skeleton name
  16239. * @param id defines the skeleton Id
  16240. * @param scene defines the hosting scene
  16241. */
  16242. constructor(
  16243. /** defines the skeleton name */
  16244. name: string,
  16245. /** defines the skeleton Id */
  16246. id: string, scene: Scene);
  16247. /**
  16248. * Gets the current object class name.
  16249. * @return the class name
  16250. */
  16251. getClassName(): string;
  16252. /**
  16253. * Returns an array containing the root bones
  16254. * @returns an array containing the root bones
  16255. */
  16256. getChildren(): Array<Bone>;
  16257. /**
  16258. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16259. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16260. * @returns a Float32Array containing matrices data
  16261. */
  16262. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16263. /**
  16264. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16265. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16266. * @returns a raw texture containing the data
  16267. */
  16268. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16269. /**
  16270. * Gets the current hosting scene
  16271. * @returns a scene object
  16272. */
  16273. getScene(): Scene;
  16274. /**
  16275. * Gets a string representing the current skeleton data
  16276. * @param fullDetails defines a boolean indicating if we want a verbose version
  16277. * @returns a string representing the current skeleton data
  16278. */
  16279. toString(fullDetails?: boolean): string;
  16280. /**
  16281. * Get bone's index searching by name
  16282. * @param name defines bone's name to search for
  16283. * @return the indice of the bone. Returns -1 if not found
  16284. */
  16285. getBoneIndexByName(name: string): number;
  16286. /**
  16287. * Creater a new animation range
  16288. * @param name defines the name of the range
  16289. * @param from defines the start key
  16290. * @param to defines the end key
  16291. */
  16292. createAnimationRange(name: string, from: number, to: number): void;
  16293. /**
  16294. * Delete a specific animation range
  16295. * @param name defines the name of the range
  16296. * @param deleteFrames defines if frames must be removed as well
  16297. */
  16298. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16299. /**
  16300. * Gets a specific animation range
  16301. * @param name defines the name of the range to look for
  16302. * @returns the requested animation range or null if not found
  16303. */
  16304. getAnimationRange(name: string): Nullable<AnimationRange>;
  16305. /**
  16306. * Gets the list of all animation ranges defined on this skeleton
  16307. * @returns an array
  16308. */
  16309. getAnimationRanges(): Nullable<AnimationRange>[];
  16310. /**
  16311. * Copy animation range from a source skeleton.
  16312. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16313. * @param source defines the source skeleton
  16314. * @param name defines the name of the range to copy
  16315. * @param rescaleAsRequired defines if rescaling must be applied if required
  16316. * @returns true if operation was successful
  16317. */
  16318. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16319. /**
  16320. * Forces the skeleton to go to rest pose
  16321. */
  16322. returnToRest(): void;
  16323. private _getHighestAnimationFrame;
  16324. /**
  16325. * Begin a specific animation range
  16326. * @param name defines the name of the range to start
  16327. * @param loop defines if looping must be turned on (false by default)
  16328. * @param speedRatio defines the speed ratio to apply (1 by default)
  16329. * @param onAnimationEnd defines a callback which will be called when animation will end
  16330. * @returns a new animatable
  16331. */
  16332. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16333. /**
  16334. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16335. * @param skeleton defines the Skeleton containing the animation range to convert
  16336. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16337. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16338. * @returns the original skeleton
  16339. */
  16340. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16341. /** @hidden */
  16342. _markAsDirty(): void;
  16343. /** @hidden */
  16344. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16345. /** @hidden */
  16346. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16347. private _computeTransformMatrices;
  16348. /**
  16349. * Build all resources required to render a skeleton
  16350. */
  16351. prepare(): void;
  16352. /**
  16353. * Gets the list of animatables currently running for this skeleton
  16354. * @returns an array of animatables
  16355. */
  16356. getAnimatables(): IAnimatable[];
  16357. /**
  16358. * Clone the current skeleton
  16359. * @param name defines the name of the new skeleton
  16360. * @param id defines the id of the new skeleton
  16361. * @returns the new skeleton
  16362. */
  16363. clone(name: string, id?: string): Skeleton;
  16364. /**
  16365. * Enable animation blending for this skeleton
  16366. * @param blendingSpeed defines the blending speed to apply
  16367. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16368. */
  16369. enableBlending(blendingSpeed?: number): void;
  16370. /**
  16371. * Releases all resources associated with the current skeleton
  16372. */
  16373. dispose(): void;
  16374. /**
  16375. * Serialize the skeleton in a JSON object
  16376. * @returns a JSON object
  16377. */
  16378. serialize(): any;
  16379. /**
  16380. * Creates a new skeleton from serialized data
  16381. * @param parsedSkeleton defines the serialized data
  16382. * @param scene defines the hosting scene
  16383. * @returns a new skeleton
  16384. */
  16385. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16386. /**
  16387. * Compute all node absolute transforms
  16388. * @param forceUpdate defines if computation must be done even if cache is up to date
  16389. */
  16390. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16391. /**
  16392. * Gets the root pose matrix
  16393. * @returns a matrix
  16394. */
  16395. getPoseMatrix(): Nullable<Matrix>;
  16396. /**
  16397. * Sorts bones per internal index
  16398. */
  16399. sortBones(): void;
  16400. private _sortBones;
  16401. }
  16402. }
  16403. declare module "babylonjs/Meshes/instancedMesh" {
  16404. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16405. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16406. import { Camera } from "babylonjs/Cameras/camera";
  16407. import { Node } from "babylonjs/node";
  16408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16409. import { Mesh } from "babylonjs/Meshes/mesh";
  16410. import { Material } from "babylonjs/Materials/material";
  16411. import { Skeleton } from "babylonjs/Bones/skeleton";
  16412. import { Light } from "babylonjs/Lights/light";
  16413. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16414. /**
  16415. * Creates an instance based on a source mesh.
  16416. */
  16417. export class InstancedMesh extends AbstractMesh {
  16418. private _sourceMesh;
  16419. private _currentLOD;
  16420. /** @hidden */
  16421. _indexInSourceMeshInstanceArray: number;
  16422. constructor(name: string, source: Mesh);
  16423. /**
  16424. * Returns the string "InstancedMesh".
  16425. */
  16426. getClassName(): string;
  16427. /** Gets the list of lights affecting that mesh */
  16428. get lightSources(): Light[];
  16429. _resyncLightSources(): void;
  16430. _resyncLightSource(light: Light): void;
  16431. _removeLightSource(light: Light, dispose: boolean): void;
  16432. /**
  16433. * If the source mesh receives shadows
  16434. */
  16435. get receiveShadows(): boolean;
  16436. /**
  16437. * The material of the source mesh
  16438. */
  16439. get material(): Nullable<Material>;
  16440. /**
  16441. * Visibility of the source mesh
  16442. */
  16443. get visibility(): number;
  16444. /**
  16445. * Skeleton of the source mesh
  16446. */
  16447. get skeleton(): Nullable<Skeleton>;
  16448. /**
  16449. * Rendering ground id of the source mesh
  16450. */
  16451. get renderingGroupId(): number;
  16452. set renderingGroupId(value: number);
  16453. /**
  16454. * Returns the total number of vertices (integer).
  16455. */
  16456. getTotalVertices(): number;
  16457. /**
  16458. * Returns a positive integer : the total number of indices in this mesh geometry.
  16459. * @returns the numner of indices or zero if the mesh has no geometry.
  16460. */
  16461. getTotalIndices(): number;
  16462. /**
  16463. * The source mesh of the instance
  16464. */
  16465. get sourceMesh(): Mesh;
  16466. /**
  16467. * Creates a new InstancedMesh object from the mesh model.
  16468. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16469. * @param name defines the name of the new instance
  16470. * @returns a new InstancedMesh
  16471. */
  16472. createInstance(name: string): InstancedMesh;
  16473. /**
  16474. * Is this node ready to be used/rendered
  16475. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16476. * @return {boolean} is it ready
  16477. */
  16478. isReady(completeCheck?: boolean): boolean;
  16479. /**
  16480. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16481. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16482. * @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.
  16483. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16484. */
  16485. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16486. /**
  16487. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16488. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16489. * The `data` are either a numeric array either a Float32Array.
  16490. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16491. * 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).
  16492. * Note that a new underlying VertexBuffer object is created each call.
  16493. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16494. *
  16495. * Possible `kind` values :
  16496. * - VertexBuffer.PositionKind
  16497. * - VertexBuffer.UVKind
  16498. * - VertexBuffer.UV2Kind
  16499. * - VertexBuffer.UV3Kind
  16500. * - VertexBuffer.UV4Kind
  16501. * - VertexBuffer.UV5Kind
  16502. * - VertexBuffer.UV6Kind
  16503. * - VertexBuffer.ColorKind
  16504. * - VertexBuffer.MatricesIndicesKind
  16505. * - VertexBuffer.MatricesIndicesExtraKind
  16506. * - VertexBuffer.MatricesWeightsKind
  16507. * - VertexBuffer.MatricesWeightsExtraKind
  16508. *
  16509. * Returns the Mesh.
  16510. */
  16511. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16512. /**
  16513. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16514. * If the mesh has no geometry, it is simply returned as it is.
  16515. * The `data` are either a numeric array either a Float32Array.
  16516. * No new underlying VertexBuffer object is created.
  16517. * 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.
  16518. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16519. *
  16520. * Possible `kind` values :
  16521. * - VertexBuffer.PositionKind
  16522. * - VertexBuffer.UVKind
  16523. * - VertexBuffer.UV2Kind
  16524. * - VertexBuffer.UV3Kind
  16525. * - VertexBuffer.UV4Kind
  16526. * - VertexBuffer.UV5Kind
  16527. * - VertexBuffer.UV6Kind
  16528. * - VertexBuffer.ColorKind
  16529. * - VertexBuffer.MatricesIndicesKind
  16530. * - VertexBuffer.MatricesIndicesExtraKind
  16531. * - VertexBuffer.MatricesWeightsKind
  16532. * - VertexBuffer.MatricesWeightsExtraKind
  16533. *
  16534. * Returns the Mesh.
  16535. */
  16536. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16537. /**
  16538. * Sets the mesh indices.
  16539. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16540. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16541. * This method creates a new index buffer each call.
  16542. * Returns the Mesh.
  16543. */
  16544. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16545. /**
  16546. * Boolean : True if the mesh owns the requested kind of data.
  16547. */
  16548. isVerticesDataPresent(kind: string): boolean;
  16549. /**
  16550. * Returns an array of indices (IndicesArray).
  16551. */
  16552. getIndices(): Nullable<IndicesArray>;
  16553. get _positions(): Nullable<Vector3[]>;
  16554. /**
  16555. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16556. * This means the mesh underlying bounding box and sphere are recomputed.
  16557. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16558. * @returns the current mesh
  16559. */
  16560. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16561. /** @hidden */
  16562. _preActivate(): InstancedMesh;
  16563. /** @hidden */
  16564. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16565. /** @hidden */
  16566. _postActivate(): void;
  16567. getWorldMatrix(): Matrix;
  16568. get isAnInstance(): boolean;
  16569. /**
  16570. * Returns the current associated LOD AbstractMesh.
  16571. */
  16572. getLOD(camera: Camera): AbstractMesh;
  16573. /** @hidden */
  16574. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16575. /** @hidden */
  16576. _syncSubMeshes(): InstancedMesh;
  16577. /** @hidden */
  16578. _generatePointsArray(): boolean;
  16579. /**
  16580. * Creates a new InstancedMesh from the current mesh.
  16581. * - name (string) : the cloned mesh name
  16582. * - newParent (optional Node) : the optional Node to parent the clone to.
  16583. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16584. *
  16585. * Returns the clone.
  16586. */
  16587. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16588. /**
  16589. * Disposes the InstancedMesh.
  16590. * Returns nothing.
  16591. */
  16592. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16593. }
  16594. module "babylonjs/Meshes/mesh" {
  16595. interface Mesh {
  16596. /**
  16597. * Register a custom buffer that will be instanced
  16598. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16599. * @param kind defines the buffer kind
  16600. * @param stride defines the stride in floats
  16601. */
  16602. registerInstancedBuffer(kind: string, stride: number): void;
  16603. /**
  16604. * true to use the edge renderer for all instances of this mesh
  16605. */
  16606. edgesShareWithInstances: boolean;
  16607. /** @hidden */
  16608. _userInstancedBuffersStorage: {
  16609. data: {
  16610. [key: string]: Float32Array;
  16611. };
  16612. sizes: {
  16613. [key: string]: number;
  16614. };
  16615. vertexBuffers: {
  16616. [key: string]: Nullable<VertexBuffer>;
  16617. };
  16618. strides: {
  16619. [key: string]: number;
  16620. };
  16621. };
  16622. }
  16623. }
  16624. module "babylonjs/Meshes/abstractMesh" {
  16625. interface AbstractMesh {
  16626. /**
  16627. * Object used to store instanced buffers defined by user
  16628. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16629. */
  16630. instancedBuffers: {
  16631. [key: string]: any;
  16632. };
  16633. }
  16634. }
  16635. }
  16636. declare module "babylonjs/Materials/shaderMaterial" {
  16637. import { Nullable } from "babylonjs/types";
  16638. import { Scene } from "babylonjs/scene";
  16639. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16641. import { Mesh } from "babylonjs/Meshes/mesh";
  16642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16644. import { Effect } from "babylonjs/Materials/effect";
  16645. import { Material } from "babylonjs/Materials/material";
  16646. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16647. /**
  16648. * Defines the options associated with the creation of a shader material.
  16649. */
  16650. export interface IShaderMaterialOptions {
  16651. /**
  16652. * Does the material work in alpha blend mode
  16653. */
  16654. needAlphaBlending: boolean;
  16655. /**
  16656. * Does the material work in alpha test mode
  16657. */
  16658. needAlphaTesting: boolean;
  16659. /**
  16660. * The list of attribute names used in the shader
  16661. */
  16662. attributes: string[];
  16663. /**
  16664. * The list of unifrom names used in the shader
  16665. */
  16666. uniforms: string[];
  16667. /**
  16668. * The list of UBO names used in the shader
  16669. */
  16670. uniformBuffers: string[];
  16671. /**
  16672. * The list of sampler names used in the shader
  16673. */
  16674. samplers: string[];
  16675. /**
  16676. * The list of defines used in the shader
  16677. */
  16678. defines: string[];
  16679. }
  16680. /**
  16681. * 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.
  16682. *
  16683. * This returned material effects how the mesh will look based on the code in the shaders.
  16684. *
  16685. * @see http://doc.babylonjs.com/how_to/shader_material
  16686. */
  16687. export class ShaderMaterial extends Material {
  16688. private _shaderPath;
  16689. private _options;
  16690. private _textures;
  16691. private _textureArrays;
  16692. private _floats;
  16693. private _ints;
  16694. private _floatsArrays;
  16695. private _colors3;
  16696. private _colors3Arrays;
  16697. private _colors4;
  16698. private _colors4Arrays;
  16699. private _vectors2;
  16700. private _vectors3;
  16701. private _vectors4;
  16702. private _matrices;
  16703. private _matrixArrays;
  16704. private _matrices3x3;
  16705. private _matrices2x2;
  16706. private _vectors2Arrays;
  16707. private _vectors3Arrays;
  16708. private _vectors4Arrays;
  16709. private _cachedWorldViewMatrix;
  16710. private _cachedWorldViewProjectionMatrix;
  16711. private _renderId;
  16712. private _multiview;
  16713. private _cachedDefines;
  16714. /** Define the Url to load snippets */
  16715. static SnippetUrl: string;
  16716. /** Snippet ID if the material was created from the snippet server */
  16717. snippetId: string;
  16718. /**
  16719. * Instantiate a new shader material.
  16720. * 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.
  16721. * This returned material effects how the mesh will look based on the code in the shaders.
  16722. * @see http://doc.babylonjs.com/how_to/shader_material
  16723. * @param name Define the name of the material in the scene
  16724. * @param scene Define the scene the material belongs to
  16725. * @param shaderPath Defines the route to the shader code in one of three ways:
  16726. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16727. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16728. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16729. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16730. * @param options Define the options used to create the shader
  16731. */
  16732. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16733. /**
  16734. * Gets the shader path used to define the shader code
  16735. * It can be modified to trigger a new compilation
  16736. */
  16737. get shaderPath(): any;
  16738. /**
  16739. * Sets the shader path used to define the shader code
  16740. * It can be modified to trigger a new compilation
  16741. */
  16742. set shaderPath(shaderPath: any);
  16743. /**
  16744. * Gets the options used to compile the shader.
  16745. * They can be modified to trigger a new compilation
  16746. */
  16747. get options(): IShaderMaterialOptions;
  16748. /**
  16749. * Gets the current class name of the material e.g. "ShaderMaterial"
  16750. * Mainly use in serialization.
  16751. * @returns the class name
  16752. */
  16753. getClassName(): string;
  16754. /**
  16755. * Specifies if the material will require alpha blending
  16756. * @returns a boolean specifying if alpha blending is needed
  16757. */
  16758. needAlphaBlending(): boolean;
  16759. /**
  16760. * Specifies if this material should be rendered in alpha test mode
  16761. * @returns a boolean specifying if an alpha test is needed.
  16762. */
  16763. needAlphaTesting(): boolean;
  16764. private _checkUniform;
  16765. /**
  16766. * Set a texture in the shader.
  16767. * @param name Define the name of the uniform samplers as defined in the shader
  16768. * @param texture Define the texture to bind to this sampler
  16769. * @return the material itself allowing "fluent" like uniform updates
  16770. */
  16771. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16772. /**
  16773. * Set a texture array in the shader.
  16774. * @param name Define the name of the uniform sampler array as defined in the shader
  16775. * @param textures Define the list of textures to bind to this sampler
  16776. * @return the material itself allowing "fluent" like uniform updates
  16777. */
  16778. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16779. /**
  16780. * Set a float in the shader.
  16781. * @param name Define the name of the uniform as defined in the shader
  16782. * @param value Define the value to give to the uniform
  16783. * @return the material itself allowing "fluent" like uniform updates
  16784. */
  16785. setFloat(name: string, value: number): ShaderMaterial;
  16786. /**
  16787. * Set a int in the shader.
  16788. * @param name Define the name of the uniform as defined in the shader
  16789. * @param value Define the value to give to the uniform
  16790. * @return the material itself allowing "fluent" like uniform updates
  16791. */
  16792. setInt(name: string, value: number): ShaderMaterial;
  16793. /**
  16794. * Set an array of floats in the shader.
  16795. * @param name Define the name of the uniform as defined in the shader
  16796. * @param value Define the value to give to the uniform
  16797. * @return the material itself allowing "fluent" like uniform updates
  16798. */
  16799. setFloats(name: string, value: number[]): ShaderMaterial;
  16800. /**
  16801. * Set a vec3 in the shader from a Color3.
  16802. * @param name Define the name of the uniform as defined in the shader
  16803. * @param value Define the value to give to the uniform
  16804. * @return the material itself allowing "fluent" like uniform updates
  16805. */
  16806. setColor3(name: string, value: Color3): ShaderMaterial;
  16807. /**
  16808. * Set a vec3 array in the shader from a Color3 array.
  16809. * @param name Define the name of the uniform as defined in the shader
  16810. * @param value Define the value to give to the uniform
  16811. * @return the material itself allowing "fluent" like uniform updates
  16812. */
  16813. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16814. /**
  16815. * Set a vec4 in the shader from a Color4.
  16816. * @param name Define the name of the uniform as defined in the shader
  16817. * @param value Define the value to give to the uniform
  16818. * @return the material itself allowing "fluent" like uniform updates
  16819. */
  16820. setColor4(name: string, value: Color4): ShaderMaterial;
  16821. /**
  16822. * Set a vec4 array in the shader from a Color4 array.
  16823. * @param name Define the name of the uniform as defined in the shader
  16824. * @param value Define the value to give to the uniform
  16825. * @return the material itself allowing "fluent" like uniform updates
  16826. */
  16827. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16828. /**
  16829. * Set a vec2 in the shader from a Vector2.
  16830. * @param name Define the name of the uniform as defined in the shader
  16831. * @param value Define the value to give to the uniform
  16832. * @return the material itself allowing "fluent" like uniform updates
  16833. */
  16834. setVector2(name: string, value: Vector2): ShaderMaterial;
  16835. /**
  16836. * Set a vec3 in the shader from a Vector3.
  16837. * @param name Define the name of the uniform as defined in the shader
  16838. * @param value Define the value to give to the uniform
  16839. * @return the material itself allowing "fluent" like uniform updates
  16840. */
  16841. setVector3(name: string, value: Vector3): ShaderMaterial;
  16842. /**
  16843. * Set a vec4 in the shader from a Vector4.
  16844. * @param name Define the name of the uniform as defined in the shader
  16845. * @param value Define the value to give to the uniform
  16846. * @return the material itself allowing "fluent" like uniform updates
  16847. */
  16848. setVector4(name: string, value: Vector4): ShaderMaterial;
  16849. /**
  16850. * Set a mat4 in the shader from a Matrix.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the material itself allowing "fluent" like uniform updates
  16854. */
  16855. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16856. /**
  16857. * Set a float32Array in the shader from a matrix array.
  16858. * @param name Define the name of the uniform as defined in the shader
  16859. * @param value Define the value to give to the uniform
  16860. * @return the material itself allowing "fluent" like uniform updates
  16861. */
  16862. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16863. /**
  16864. * Set a mat3 in the shader from a Float32Array.
  16865. * @param name Define the name of the uniform as defined in the shader
  16866. * @param value Define the value to give to the uniform
  16867. * @return the material itself allowing "fluent" like uniform updates
  16868. */
  16869. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16870. /**
  16871. * Set a mat2 in the shader from a Float32Array.
  16872. * @param name Define the name of the uniform as defined in the shader
  16873. * @param value Define the value to give to the uniform
  16874. * @return the material itself allowing "fluent" like uniform updates
  16875. */
  16876. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16877. /**
  16878. * Set a vec2 array in the shader from a number array.
  16879. * @param name Define the name of the uniform as defined in the shader
  16880. * @param value Define the value to give to the uniform
  16881. * @return the material itself allowing "fluent" like uniform updates
  16882. */
  16883. setArray2(name: string, value: number[]): ShaderMaterial;
  16884. /**
  16885. * Set a vec3 array in the shader from a number array.
  16886. * @param name Define the name of the uniform as defined in the shader
  16887. * @param value Define the value to give to the uniform
  16888. * @return the material itself allowing "fluent" like uniform updates
  16889. */
  16890. setArray3(name: string, value: number[]): ShaderMaterial;
  16891. /**
  16892. * Set a vec4 array in the shader from a number array.
  16893. * @param name Define the name of the uniform as defined in the shader
  16894. * @param value Define the value to give to the uniform
  16895. * @return the material itself allowing "fluent" like uniform updates
  16896. */
  16897. setArray4(name: string, value: number[]): ShaderMaterial;
  16898. private _checkCache;
  16899. /**
  16900. * Specifies that the submesh is ready to be used
  16901. * @param mesh defines the mesh to check
  16902. * @param subMesh defines which submesh to check
  16903. * @param useInstances specifies that instances should be used
  16904. * @returns a boolean indicating that the submesh is ready or not
  16905. */
  16906. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16907. /**
  16908. * Checks if the material is ready to render the requested mesh
  16909. * @param mesh Define the mesh to render
  16910. * @param useInstances Define whether or not the material is used with instances
  16911. * @returns true if ready, otherwise false
  16912. */
  16913. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16914. /**
  16915. * Binds the world matrix to the material
  16916. * @param world defines the world transformation matrix
  16917. * @param effectOverride - If provided, use this effect instead of internal effect
  16918. */
  16919. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16920. /**
  16921. * Binds the submesh to this material by preparing the effect and shader to draw
  16922. * @param world defines the world transformation matrix
  16923. * @param mesh defines the mesh containing the submesh
  16924. * @param subMesh defines the submesh to bind the material to
  16925. */
  16926. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16927. /**
  16928. * Binds the material to the mesh
  16929. * @param world defines the world transformation matrix
  16930. * @param mesh defines the mesh to bind the material to
  16931. * @param effectOverride - If provided, use this effect instead of internal effect
  16932. */
  16933. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16934. protected _afterBind(mesh?: Mesh): void;
  16935. /**
  16936. * Gets the active textures from the material
  16937. * @returns an array of textures
  16938. */
  16939. getActiveTextures(): BaseTexture[];
  16940. /**
  16941. * Specifies if the material uses a texture
  16942. * @param texture defines the texture to check against the material
  16943. * @returns a boolean specifying if the material uses the texture
  16944. */
  16945. hasTexture(texture: BaseTexture): boolean;
  16946. /**
  16947. * Makes a duplicate of the material, and gives it a new name
  16948. * @param name defines the new name for the duplicated material
  16949. * @returns the cloned material
  16950. */
  16951. clone(name: string): ShaderMaterial;
  16952. /**
  16953. * Disposes the material
  16954. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16955. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16956. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16957. */
  16958. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16959. /**
  16960. * Serializes this material in a JSON representation
  16961. * @returns the serialized material object
  16962. */
  16963. serialize(): any;
  16964. /**
  16965. * Creates a shader material from parsed shader material data
  16966. * @param source defines the JSON represnetation of the material
  16967. * @param scene defines the hosting scene
  16968. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16969. * @returns a new material
  16970. */
  16971. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16972. /**
  16973. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16974. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16975. * @param url defines the url to load from
  16976. * @param scene defines the hosting scene
  16977. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16978. * @returns a promise that will resolve to the new ShaderMaterial
  16979. */
  16980. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16981. /**
  16982. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16983. * @param snippetId defines the snippet to load
  16984. * @param scene defines the hosting scene
  16985. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16986. * @returns a promise that will resolve to the new ShaderMaterial
  16987. */
  16988. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16989. }
  16990. }
  16991. declare module "babylonjs/Shaders/color.fragment" {
  16992. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16993. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16994. /** @hidden */
  16995. export var colorPixelShader: {
  16996. name: string;
  16997. shader: string;
  16998. };
  16999. }
  17000. declare module "babylonjs/Shaders/color.vertex" {
  17001. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17002. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17003. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17004. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17005. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17006. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17007. /** @hidden */
  17008. export var colorVertexShader: {
  17009. name: string;
  17010. shader: string;
  17011. };
  17012. }
  17013. declare module "babylonjs/Meshes/linesMesh" {
  17014. import { Nullable } from "babylonjs/types";
  17015. import { Scene } from "babylonjs/scene";
  17016. import { Color3 } from "babylonjs/Maths/math.color";
  17017. import { Node } from "babylonjs/node";
  17018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17019. import { Mesh } from "babylonjs/Meshes/mesh";
  17020. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17021. import { Effect } from "babylonjs/Materials/effect";
  17022. import { Material } from "babylonjs/Materials/material";
  17023. import "babylonjs/Shaders/color.fragment";
  17024. import "babylonjs/Shaders/color.vertex";
  17025. /**
  17026. * Line mesh
  17027. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17028. */
  17029. export class LinesMesh extends Mesh {
  17030. /**
  17031. * If vertex color should be applied to the mesh
  17032. */
  17033. readonly useVertexColor?: boolean | undefined;
  17034. /**
  17035. * If vertex alpha should be applied to the mesh
  17036. */
  17037. readonly useVertexAlpha?: boolean | undefined;
  17038. /**
  17039. * Color of the line (Default: White)
  17040. */
  17041. color: Color3;
  17042. /**
  17043. * Alpha of the line (Default: 1)
  17044. */
  17045. alpha: number;
  17046. /**
  17047. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17048. * This margin is expressed in world space coordinates, so its value may vary.
  17049. * Default value is 0.1
  17050. */
  17051. intersectionThreshold: number;
  17052. private _colorShader;
  17053. private color4;
  17054. /**
  17055. * Creates a new LinesMesh
  17056. * @param name defines the name
  17057. * @param scene defines the hosting scene
  17058. * @param parent defines the parent mesh if any
  17059. * @param source defines the optional source LinesMesh used to clone data from
  17060. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17061. * When false, achieved by calling a clone(), also passing False.
  17062. * This will make creation of children, recursive.
  17063. * @param useVertexColor defines if this LinesMesh supports vertex color
  17064. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17065. */
  17066. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17067. /**
  17068. * If vertex color should be applied to the mesh
  17069. */
  17070. useVertexColor?: boolean | undefined,
  17071. /**
  17072. * If vertex alpha should be applied to the mesh
  17073. */
  17074. useVertexAlpha?: boolean | undefined);
  17075. private _addClipPlaneDefine;
  17076. private _removeClipPlaneDefine;
  17077. isReady(): boolean;
  17078. /**
  17079. * Returns the string "LineMesh"
  17080. */
  17081. getClassName(): string;
  17082. /**
  17083. * @hidden
  17084. */
  17085. get material(): Material;
  17086. /**
  17087. * @hidden
  17088. */
  17089. set material(value: Material);
  17090. /**
  17091. * @hidden
  17092. */
  17093. get checkCollisions(): boolean;
  17094. /** @hidden */
  17095. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17096. /** @hidden */
  17097. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17098. /**
  17099. * Disposes of the line mesh
  17100. * @param doNotRecurse If children should be disposed
  17101. */
  17102. dispose(doNotRecurse?: boolean): void;
  17103. /**
  17104. * Returns a new LineMesh object cloned from the current one.
  17105. */
  17106. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17107. /**
  17108. * Creates a new InstancedLinesMesh object from the mesh model.
  17109. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17110. * @param name defines the name of the new instance
  17111. * @returns a new InstancedLinesMesh
  17112. */
  17113. createInstance(name: string): InstancedLinesMesh;
  17114. }
  17115. /**
  17116. * Creates an instance based on a source LinesMesh
  17117. */
  17118. export class InstancedLinesMesh extends InstancedMesh {
  17119. /**
  17120. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17121. * This margin is expressed in world space coordinates, so its value may vary.
  17122. * Initilized with the intersectionThreshold value of the source LinesMesh
  17123. */
  17124. intersectionThreshold: number;
  17125. constructor(name: string, source: LinesMesh);
  17126. /**
  17127. * Returns the string "InstancedLinesMesh".
  17128. */
  17129. getClassName(): string;
  17130. }
  17131. }
  17132. declare module "babylonjs/Shaders/line.fragment" {
  17133. /** @hidden */
  17134. export var linePixelShader: {
  17135. name: string;
  17136. shader: string;
  17137. };
  17138. }
  17139. declare module "babylonjs/Shaders/line.vertex" {
  17140. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17141. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17142. /** @hidden */
  17143. export var lineVertexShader: {
  17144. name: string;
  17145. shader: string;
  17146. };
  17147. }
  17148. declare module "babylonjs/Rendering/edgesRenderer" {
  17149. import { Nullable } from "babylonjs/types";
  17150. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17152. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17153. import { IDisposable } from "babylonjs/scene";
  17154. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17155. import "babylonjs/Shaders/line.fragment";
  17156. import "babylonjs/Shaders/line.vertex";
  17157. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17158. import { SmartArray } from "babylonjs/Misc/smartArray";
  17159. module "babylonjs/scene" {
  17160. interface Scene {
  17161. /** @hidden */
  17162. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17163. }
  17164. }
  17165. module "babylonjs/Meshes/abstractMesh" {
  17166. interface AbstractMesh {
  17167. /**
  17168. * Gets the edgesRenderer associated with the mesh
  17169. */
  17170. edgesRenderer: Nullable<EdgesRenderer>;
  17171. }
  17172. }
  17173. module "babylonjs/Meshes/linesMesh" {
  17174. interface LinesMesh {
  17175. /**
  17176. * Enables the edge rendering mode on the mesh.
  17177. * This mode makes the mesh edges visible
  17178. * @param epsilon defines the maximal distance between two angles to detect a face
  17179. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17180. * @returns the currentAbstractMesh
  17181. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17182. */
  17183. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17184. }
  17185. }
  17186. module "babylonjs/Meshes/linesMesh" {
  17187. interface InstancedLinesMesh {
  17188. /**
  17189. * Enables the edge rendering mode on the mesh.
  17190. * This mode makes the mesh edges visible
  17191. * @param epsilon defines the maximal distance between two angles to detect a face
  17192. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17193. * @returns the current InstancedLinesMesh
  17194. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17195. */
  17196. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17197. }
  17198. }
  17199. /**
  17200. * Defines the minimum contract an Edges renderer should follow.
  17201. */
  17202. export interface IEdgesRenderer extends IDisposable {
  17203. /**
  17204. * Gets or sets a boolean indicating if the edgesRenderer is active
  17205. */
  17206. isEnabled: boolean;
  17207. /**
  17208. * Renders the edges of the attached mesh,
  17209. */
  17210. render(): void;
  17211. /**
  17212. * Checks wether or not the edges renderer is ready to render.
  17213. * @return true if ready, otherwise false.
  17214. */
  17215. isReady(): boolean;
  17216. /**
  17217. * List of instances to render in case the source mesh has instances
  17218. */
  17219. customInstances: SmartArray<Matrix>;
  17220. }
  17221. /**
  17222. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17223. */
  17224. export class EdgesRenderer implements IEdgesRenderer {
  17225. /**
  17226. * Define the size of the edges with an orthographic camera
  17227. */
  17228. edgesWidthScalerForOrthographic: number;
  17229. /**
  17230. * Define the size of the edges with a perspective camera
  17231. */
  17232. edgesWidthScalerForPerspective: number;
  17233. protected _source: AbstractMesh;
  17234. protected _linesPositions: number[];
  17235. protected _linesNormals: number[];
  17236. protected _linesIndices: number[];
  17237. protected _epsilon: number;
  17238. protected _indicesCount: number;
  17239. protected _lineShader: ShaderMaterial;
  17240. protected _ib: DataBuffer;
  17241. protected _buffers: {
  17242. [key: string]: Nullable<VertexBuffer>;
  17243. };
  17244. protected _buffersForInstances: {
  17245. [key: string]: Nullable<VertexBuffer>;
  17246. };
  17247. protected _checkVerticesInsteadOfIndices: boolean;
  17248. private _meshRebuildObserver;
  17249. private _meshDisposeObserver;
  17250. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17251. isEnabled: boolean;
  17252. /**
  17253. * List of instances to render in case the source mesh has instances
  17254. */
  17255. customInstances: SmartArray<Matrix>;
  17256. private static GetShader;
  17257. /**
  17258. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17259. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17260. * @param source Mesh used to create edges
  17261. * @param epsilon sum of angles in adjacency to check for edge
  17262. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17263. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17264. */
  17265. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17266. protected _prepareRessources(): void;
  17267. /** @hidden */
  17268. _rebuild(): void;
  17269. /**
  17270. * Releases the required resources for the edges renderer
  17271. */
  17272. dispose(): void;
  17273. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17274. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17275. /**
  17276. * Checks if the pair of p0 and p1 is en edge
  17277. * @param faceIndex
  17278. * @param edge
  17279. * @param faceNormals
  17280. * @param p0
  17281. * @param p1
  17282. * @private
  17283. */
  17284. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17285. /**
  17286. * push line into the position, normal and index buffer
  17287. * @protected
  17288. */
  17289. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17290. /**
  17291. * Generates lines edges from adjacencjes
  17292. * @private
  17293. */
  17294. _generateEdgesLines(): void;
  17295. /**
  17296. * Checks wether or not the edges renderer is ready to render.
  17297. * @return true if ready, otherwise false.
  17298. */
  17299. isReady(): boolean;
  17300. /**
  17301. * Renders the edges of the attached mesh,
  17302. */
  17303. render(): void;
  17304. }
  17305. /**
  17306. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17307. */
  17308. export class LineEdgesRenderer extends EdgesRenderer {
  17309. /**
  17310. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17311. * @param source LineMesh used to generate edges
  17312. * @param epsilon not important (specified angle for edge detection)
  17313. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17314. */
  17315. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17316. /**
  17317. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17318. */
  17319. _generateEdgesLines(): void;
  17320. }
  17321. }
  17322. declare module "babylonjs/Rendering/renderingGroup" {
  17323. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17326. import { Nullable } from "babylonjs/types";
  17327. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17328. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17329. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17330. import { Material } from "babylonjs/Materials/material";
  17331. import { Scene } from "babylonjs/scene";
  17332. /**
  17333. * This represents the object necessary to create a rendering group.
  17334. * This is exclusively used and created by the rendering manager.
  17335. * To modify the behavior, you use the available helpers in your scene or meshes.
  17336. * @hidden
  17337. */
  17338. export class RenderingGroup {
  17339. index: number;
  17340. private static _zeroVector;
  17341. private _scene;
  17342. private _opaqueSubMeshes;
  17343. private _transparentSubMeshes;
  17344. private _alphaTestSubMeshes;
  17345. private _depthOnlySubMeshes;
  17346. private _particleSystems;
  17347. private _spriteManagers;
  17348. private _opaqueSortCompareFn;
  17349. private _alphaTestSortCompareFn;
  17350. private _transparentSortCompareFn;
  17351. private _renderOpaque;
  17352. private _renderAlphaTest;
  17353. private _renderTransparent;
  17354. /** @hidden */
  17355. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17356. onBeforeTransparentRendering: () => void;
  17357. /**
  17358. * Set the opaque sort comparison function.
  17359. * If null the sub meshes will be render in the order they were created
  17360. */
  17361. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17362. /**
  17363. * Set the alpha test sort comparison function.
  17364. * If null the sub meshes will be render in the order they were created
  17365. */
  17366. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17367. /**
  17368. * Set the transparent sort comparison function.
  17369. * If null the sub meshes will be render in the order they were created
  17370. */
  17371. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17372. /**
  17373. * Creates a new rendering group.
  17374. * @param index The rendering group index
  17375. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17376. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17377. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17378. */
  17379. 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>);
  17380. /**
  17381. * Render all the sub meshes contained in the group.
  17382. * @param customRenderFunction Used to override the default render behaviour of the group.
  17383. * @returns true if rendered some submeshes.
  17384. */
  17385. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17386. /**
  17387. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17388. * @param subMeshes The submeshes to render
  17389. */
  17390. private renderOpaqueSorted;
  17391. /**
  17392. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17393. * @param subMeshes The submeshes to render
  17394. */
  17395. private renderAlphaTestSorted;
  17396. /**
  17397. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17398. * @param subMeshes The submeshes to render
  17399. */
  17400. private renderTransparentSorted;
  17401. /**
  17402. * Renders the submeshes in a specified order.
  17403. * @param subMeshes The submeshes to sort before render
  17404. * @param sortCompareFn The comparison function use to sort
  17405. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17406. * @param transparent Specifies to activate blending if true
  17407. */
  17408. private static renderSorted;
  17409. /**
  17410. * Renders the submeshes in the order they were dispatched (no sort applied).
  17411. * @param subMeshes The submeshes to render
  17412. */
  17413. private static renderUnsorted;
  17414. /**
  17415. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17416. * are rendered back to front if in the same alpha index.
  17417. *
  17418. * @param a The first submesh
  17419. * @param b The second submesh
  17420. * @returns The result of the comparison
  17421. */
  17422. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17423. /**
  17424. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17425. * are rendered back to front.
  17426. *
  17427. * @param a The first submesh
  17428. * @param b The second submesh
  17429. * @returns The result of the comparison
  17430. */
  17431. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17432. /**
  17433. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17434. * are rendered front to back (prevent overdraw).
  17435. *
  17436. * @param a The first submesh
  17437. * @param b The second submesh
  17438. * @returns The result of the comparison
  17439. */
  17440. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17441. /**
  17442. * Resets the different lists of submeshes to prepare a new frame.
  17443. */
  17444. prepare(): void;
  17445. dispose(): void;
  17446. /**
  17447. * Inserts the submesh in its correct queue depending on its material.
  17448. * @param subMesh The submesh to dispatch
  17449. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17450. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17451. */
  17452. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17453. dispatchSprites(spriteManager: ISpriteManager): void;
  17454. dispatchParticles(particleSystem: IParticleSystem): void;
  17455. private _renderParticles;
  17456. private _renderSprites;
  17457. }
  17458. }
  17459. declare module "babylonjs/Rendering/renderingManager" {
  17460. import { Nullable } from "babylonjs/types";
  17461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17462. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17463. import { SmartArray } from "babylonjs/Misc/smartArray";
  17464. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17465. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17466. import { Material } from "babylonjs/Materials/material";
  17467. import { Scene } from "babylonjs/scene";
  17468. import { Camera } from "babylonjs/Cameras/camera";
  17469. /**
  17470. * Interface describing the different options available in the rendering manager
  17471. * regarding Auto Clear between groups.
  17472. */
  17473. export interface IRenderingManagerAutoClearSetup {
  17474. /**
  17475. * Defines whether or not autoclear is enable.
  17476. */
  17477. autoClear: boolean;
  17478. /**
  17479. * Defines whether or not to autoclear the depth buffer.
  17480. */
  17481. depth: boolean;
  17482. /**
  17483. * Defines whether or not to autoclear the stencil buffer.
  17484. */
  17485. stencil: boolean;
  17486. }
  17487. /**
  17488. * This class is used by the onRenderingGroupObservable
  17489. */
  17490. export class RenderingGroupInfo {
  17491. /**
  17492. * The Scene that being rendered
  17493. */
  17494. scene: Scene;
  17495. /**
  17496. * The camera currently used for the rendering pass
  17497. */
  17498. camera: Nullable<Camera>;
  17499. /**
  17500. * The ID of the renderingGroup being processed
  17501. */
  17502. renderingGroupId: number;
  17503. }
  17504. /**
  17505. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17506. * It is enable to manage the different groups as well as the different necessary sort functions.
  17507. * This should not be used directly aside of the few static configurations
  17508. */
  17509. export class RenderingManager {
  17510. /**
  17511. * The max id used for rendering groups (not included)
  17512. */
  17513. static MAX_RENDERINGGROUPS: number;
  17514. /**
  17515. * The min id used for rendering groups (included)
  17516. */
  17517. static MIN_RENDERINGGROUPS: number;
  17518. /**
  17519. * Used to globally prevent autoclearing scenes.
  17520. */
  17521. static AUTOCLEAR: boolean;
  17522. /**
  17523. * @hidden
  17524. */
  17525. _useSceneAutoClearSetup: boolean;
  17526. private _scene;
  17527. private _renderingGroups;
  17528. private _depthStencilBufferAlreadyCleaned;
  17529. private _autoClearDepthStencil;
  17530. private _customOpaqueSortCompareFn;
  17531. private _customAlphaTestSortCompareFn;
  17532. private _customTransparentSortCompareFn;
  17533. private _renderingGroupInfo;
  17534. /**
  17535. * Instantiates a new rendering group for a particular scene
  17536. * @param scene Defines the scene the groups belongs to
  17537. */
  17538. constructor(scene: Scene);
  17539. private _clearDepthStencilBuffer;
  17540. /**
  17541. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17542. * @hidden
  17543. */
  17544. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17545. /**
  17546. * Resets the different information of the group to prepare a new frame
  17547. * @hidden
  17548. */
  17549. reset(): void;
  17550. /**
  17551. * Dispose and release the group and its associated resources.
  17552. * @hidden
  17553. */
  17554. dispose(): void;
  17555. /**
  17556. * Clear the info related to rendering groups preventing retention points during dispose.
  17557. */
  17558. freeRenderingGroups(): void;
  17559. private _prepareRenderingGroup;
  17560. /**
  17561. * Add a sprite manager to the rendering manager in order to render it this frame.
  17562. * @param spriteManager Define the sprite manager to render
  17563. */
  17564. dispatchSprites(spriteManager: ISpriteManager): void;
  17565. /**
  17566. * Add a particle system to the rendering manager in order to render it this frame.
  17567. * @param particleSystem Define the particle system to render
  17568. */
  17569. dispatchParticles(particleSystem: IParticleSystem): void;
  17570. /**
  17571. * Add a submesh to the manager in order to render it this frame
  17572. * @param subMesh The submesh to dispatch
  17573. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17574. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17575. */
  17576. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17577. /**
  17578. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17579. * This allowed control for front to back rendering or reversly depending of the special needs.
  17580. *
  17581. * @param renderingGroupId The rendering group id corresponding to its index
  17582. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17583. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17584. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17585. */
  17586. 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;
  17587. /**
  17588. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17589. *
  17590. * @param renderingGroupId The rendering group id corresponding to its index
  17591. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17592. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17593. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17594. */
  17595. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17596. /**
  17597. * Gets the current auto clear configuration for one rendering group of the rendering
  17598. * manager.
  17599. * @param index the rendering group index to get the information for
  17600. * @returns The auto clear setup for the requested rendering group
  17601. */
  17602. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17603. }
  17604. }
  17605. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17606. import { SmartArray } from "babylonjs/Misc/smartArray";
  17607. import { Nullable } from "babylonjs/types";
  17608. import { Scene } from "babylonjs/scene";
  17609. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17610. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17611. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17612. import { Mesh } from "babylonjs/Meshes/mesh";
  17613. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17614. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17615. import { Effect } from "babylonjs/Materials/effect";
  17616. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17617. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17618. import "babylonjs/Shaders/shadowMap.fragment";
  17619. import "babylonjs/Shaders/shadowMap.vertex";
  17620. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17621. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17622. import { Observable } from "babylonjs/Misc/observable";
  17623. /**
  17624. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17625. */
  17626. export interface ICustomShaderOptions {
  17627. /**
  17628. * Gets or sets the custom shader name to use
  17629. */
  17630. shaderName: string;
  17631. /**
  17632. * The list of attribute names used in the shader
  17633. */
  17634. attributes?: string[];
  17635. /**
  17636. * The list of unifrom names used in the shader
  17637. */
  17638. uniforms?: string[];
  17639. /**
  17640. * The list of sampler names used in the shader
  17641. */
  17642. samplers?: string[];
  17643. /**
  17644. * The list of defines used in the shader
  17645. */
  17646. defines?: string[];
  17647. }
  17648. /**
  17649. * Interface to implement to create a shadow generator compatible with BJS.
  17650. */
  17651. export interface IShadowGenerator {
  17652. /**
  17653. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17654. * @returns The render target texture if present otherwise, null
  17655. */
  17656. getShadowMap(): Nullable<RenderTargetTexture>;
  17657. /**
  17658. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17659. * @param subMesh The submesh we want to render in the shadow map
  17660. * @param useInstances Defines wether will draw in the map using instances
  17661. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17662. * @returns true if ready otherwise, false
  17663. */
  17664. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17665. /**
  17666. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17667. * @param defines Defines of the material we want to update
  17668. * @param lightIndex Index of the light in the enabled light list of the material
  17669. */
  17670. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17671. /**
  17672. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17673. * defined in the generator but impacting the effect).
  17674. * It implies the unifroms available on the materials are the standard BJS ones.
  17675. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17676. * @param effect The effect we are binfing the information for
  17677. */
  17678. bindShadowLight(lightIndex: string, effect: Effect): void;
  17679. /**
  17680. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17681. * (eq to shadow prjection matrix * light transform matrix)
  17682. * @returns The transform matrix used to create the shadow map
  17683. */
  17684. getTransformMatrix(): Matrix;
  17685. /**
  17686. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17687. * Cube and 2D textures for instance.
  17688. */
  17689. recreateShadowMap(): void;
  17690. /**
  17691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17692. * @param onCompiled Callback triggered at the and of the effects compilation
  17693. * @param options Sets of optional options forcing the compilation with different modes
  17694. */
  17695. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17696. useInstances: boolean;
  17697. }>): void;
  17698. /**
  17699. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17700. * @param options Sets of optional options forcing the compilation with different modes
  17701. * @returns A promise that resolves when the compilation completes
  17702. */
  17703. forceCompilationAsync(options?: Partial<{
  17704. useInstances: boolean;
  17705. }>): Promise<void>;
  17706. /**
  17707. * Serializes the shadow generator setup to a json object.
  17708. * @returns The serialized JSON object
  17709. */
  17710. serialize(): any;
  17711. /**
  17712. * Disposes the Shadow map and related Textures and effects.
  17713. */
  17714. dispose(): void;
  17715. }
  17716. /**
  17717. * Default implementation IShadowGenerator.
  17718. * This is the main object responsible of generating shadows in the framework.
  17719. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17720. */
  17721. export class ShadowGenerator implements IShadowGenerator {
  17722. /**
  17723. * Name of the shadow generator class
  17724. */
  17725. static CLASSNAME: string;
  17726. /**
  17727. * Shadow generator mode None: no filtering applied.
  17728. */
  17729. static readonly FILTER_NONE: number;
  17730. /**
  17731. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17733. */
  17734. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17735. /**
  17736. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17737. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17738. */
  17739. static readonly FILTER_POISSONSAMPLING: number;
  17740. /**
  17741. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17742. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17743. */
  17744. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17745. /**
  17746. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17747. * edge artifacts on steep falloff.
  17748. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17749. */
  17750. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17751. /**
  17752. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17753. * edge artifacts on steep falloff.
  17754. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17755. */
  17756. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17757. /**
  17758. * Shadow generator mode PCF: Percentage Closer Filtering
  17759. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17760. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17761. */
  17762. static readonly FILTER_PCF: number;
  17763. /**
  17764. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17765. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17766. * Contact Hardening
  17767. */
  17768. static readonly FILTER_PCSS: number;
  17769. /**
  17770. * Reserved for PCF and PCSS
  17771. * Highest Quality.
  17772. *
  17773. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17774. *
  17775. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17776. */
  17777. static readonly QUALITY_HIGH: number;
  17778. /**
  17779. * Reserved for PCF and PCSS
  17780. * Good tradeoff for quality/perf cross devices
  17781. *
  17782. * Execute PCF on a 3*3 kernel.
  17783. *
  17784. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17785. */
  17786. static readonly QUALITY_MEDIUM: number;
  17787. /**
  17788. * Reserved for PCF and PCSS
  17789. * The lowest quality but the fastest.
  17790. *
  17791. * Execute PCF on a 1*1 kernel.
  17792. *
  17793. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17794. */
  17795. static readonly QUALITY_LOW: number;
  17796. /** Gets or sets the custom shader name to use */
  17797. customShaderOptions: ICustomShaderOptions;
  17798. /**
  17799. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17800. */
  17801. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17802. /**
  17803. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17804. */
  17805. onAfterShadowMapRenderObservable: Observable<Effect>;
  17806. /**
  17807. * Observable triggered before a mesh is rendered in the shadow map.
  17808. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17809. */
  17810. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17811. /**
  17812. * Observable triggered after a mesh is rendered in the shadow map.
  17813. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17814. */
  17815. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17816. protected _bias: number;
  17817. /**
  17818. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17819. */
  17820. get bias(): number;
  17821. /**
  17822. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17823. */
  17824. set bias(bias: number);
  17825. protected _normalBias: number;
  17826. /**
  17827. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17828. */
  17829. get normalBias(): number;
  17830. /**
  17831. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17832. */
  17833. set normalBias(normalBias: number);
  17834. protected _blurBoxOffset: number;
  17835. /**
  17836. * Gets the blur box offset: offset applied during the blur pass.
  17837. * Only useful if useKernelBlur = false
  17838. */
  17839. get blurBoxOffset(): number;
  17840. /**
  17841. * Sets the blur box offset: offset applied during the blur pass.
  17842. * Only useful if useKernelBlur = false
  17843. */
  17844. set blurBoxOffset(value: number);
  17845. protected _blurScale: number;
  17846. /**
  17847. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17848. * 2 means half of the size.
  17849. */
  17850. get blurScale(): number;
  17851. /**
  17852. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17853. * 2 means half of the size.
  17854. */
  17855. set blurScale(value: number);
  17856. protected _blurKernel: number;
  17857. /**
  17858. * Gets the blur kernel: kernel size of the blur pass.
  17859. * Only useful if useKernelBlur = true
  17860. */
  17861. get blurKernel(): number;
  17862. /**
  17863. * Sets the blur kernel: kernel size of the blur pass.
  17864. * Only useful if useKernelBlur = true
  17865. */
  17866. set blurKernel(value: number);
  17867. protected _useKernelBlur: boolean;
  17868. /**
  17869. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17870. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17871. */
  17872. get useKernelBlur(): boolean;
  17873. /**
  17874. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17875. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17876. */
  17877. set useKernelBlur(value: boolean);
  17878. protected _depthScale: number;
  17879. /**
  17880. * Gets the depth scale used in ESM mode.
  17881. */
  17882. get depthScale(): number;
  17883. /**
  17884. * Sets the depth scale used in ESM mode.
  17885. * This can override the scale stored on the light.
  17886. */
  17887. set depthScale(value: number);
  17888. protected _validateFilter(filter: number): number;
  17889. protected _filter: number;
  17890. /**
  17891. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17892. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17893. */
  17894. get filter(): number;
  17895. /**
  17896. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17897. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17898. */
  17899. set filter(value: number);
  17900. /**
  17901. * Gets if the current filter is set to Poisson Sampling.
  17902. */
  17903. get usePoissonSampling(): boolean;
  17904. /**
  17905. * Sets the current filter to Poisson Sampling.
  17906. */
  17907. set usePoissonSampling(value: boolean);
  17908. /**
  17909. * Gets if the current filter is set to ESM.
  17910. */
  17911. get useExponentialShadowMap(): boolean;
  17912. /**
  17913. * Sets the current filter is to ESM.
  17914. */
  17915. set useExponentialShadowMap(value: boolean);
  17916. /**
  17917. * Gets if the current filter is set to filtered ESM.
  17918. */
  17919. get useBlurExponentialShadowMap(): boolean;
  17920. /**
  17921. * Gets if the current filter is set to filtered ESM.
  17922. */
  17923. set useBlurExponentialShadowMap(value: boolean);
  17924. /**
  17925. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17926. * exponential to prevent steep falloff artifacts).
  17927. */
  17928. get useCloseExponentialShadowMap(): boolean;
  17929. /**
  17930. * Sets the current filter to "close ESM" (using the inverse of the
  17931. * exponential to prevent steep falloff artifacts).
  17932. */
  17933. set useCloseExponentialShadowMap(value: boolean);
  17934. /**
  17935. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17936. * exponential to prevent steep falloff artifacts).
  17937. */
  17938. get useBlurCloseExponentialShadowMap(): boolean;
  17939. /**
  17940. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17941. * exponential to prevent steep falloff artifacts).
  17942. */
  17943. set useBlurCloseExponentialShadowMap(value: boolean);
  17944. /**
  17945. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17946. */
  17947. get usePercentageCloserFiltering(): boolean;
  17948. /**
  17949. * Sets the current filter to "PCF" (percentage closer filtering).
  17950. */
  17951. set usePercentageCloserFiltering(value: boolean);
  17952. protected _filteringQuality: number;
  17953. /**
  17954. * Gets the PCF or PCSS Quality.
  17955. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17956. */
  17957. get filteringQuality(): number;
  17958. /**
  17959. * Sets the PCF or PCSS Quality.
  17960. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17961. */
  17962. set filteringQuality(filteringQuality: number);
  17963. /**
  17964. * Gets if the current filter is set to "PCSS" (contact hardening).
  17965. */
  17966. get useContactHardeningShadow(): boolean;
  17967. /**
  17968. * Sets the current filter to "PCSS" (contact hardening).
  17969. */
  17970. set useContactHardeningShadow(value: boolean);
  17971. protected _contactHardeningLightSizeUVRatio: number;
  17972. /**
  17973. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17974. * Using a ratio helps keeping shape stability independently of the map size.
  17975. *
  17976. * It does not account for the light projection as it was having too much
  17977. * instability during the light setup or during light position changes.
  17978. *
  17979. * Only valid if useContactHardeningShadow is true.
  17980. */
  17981. get contactHardeningLightSizeUVRatio(): number;
  17982. /**
  17983. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17984. * Using a ratio helps keeping shape stability independently of the map size.
  17985. *
  17986. * It does not account for the light projection as it was having too much
  17987. * instability during the light setup or during light position changes.
  17988. *
  17989. * Only valid if useContactHardeningShadow is true.
  17990. */
  17991. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17992. protected _darkness: number;
  17993. /** Gets or sets the actual darkness of a shadow */
  17994. get darkness(): number;
  17995. set darkness(value: number);
  17996. /**
  17997. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17998. * 0 means strongest and 1 would means no shadow.
  17999. * @returns the darkness.
  18000. */
  18001. getDarkness(): number;
  18002. /**
  18003. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18004. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18005. * @returns the shadow generator allowing fluent coding.
  18006. */
  18007. setDarkness(darkness: number): ShadowGenerator;
  18008. protected _transparencyShadow: boolean;
  18009. /** Gets or sets the ability to have transparent shadow */
  18010. get transparencyShadow(): boolean;
  18011. set transparencyShadow(value: boolean);
  18012. /**
  18013. * Sets the ability to have transparent shadow (boolean).
  18014. * @param transparent True if transparent else False
  18015. * @returns the shadow generator allowing fluent coding
  18016. */
  18017. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18018. /**
  18019. * Enables or disables shadows with varying strength based on the transparency
  18020. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18021. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18022. * mesh.visibility * alphaTexture.a
  18023. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18024. */
  18025. enableSoftTransparentShadow: boolean;
  18026. protected _shadowMap: Nullable<RenderTargetTexture>;
  18027. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18028. /**
  18029. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18030. * @returns The render target texture if present otherwise, null
  18031. */
  18032. getShadowMap(): Nullable<RenderTargetTexture>;
  18033. /**
  18034. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18035. * @returns The render target texture if the shadow map is present otherwise, null
  18036. */
  18037. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18038. /**
  18039. * Gets the class name of that object
  18040. * @returns "ShadowGenerator"
  18041. */
  18042. getClassName(): string;
  18043. /**
  18044. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18045. * @param mesh Mesh to add
  18046. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18047. * @returns the Shadow Generator itself
  18048. */
  18049. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18050. /**
  18051. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18052. * @param mesh Mesh to remove
  18053. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18054. * @returns the Shadow Generator itself
  18055. */
  18056. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18057. /**
  18058. * Controls the extent to which the shadows fade out at the edge of the frustum
  18059. */
  18060. frustumEdgeFalloff: number;
  18061. protected _light: IShadowLight;
  18062. /**
  18063. * Returns the associated light object.
  18064. * @returns the light generating the shadow
  18065. */
  18066. getLight(): IShadowLight;
  18067. /**
  18068. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18069. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18070. * It might on the other hand introduce peter panning.
  18071. */
  18072. forceBackFacesOnly: boolean;
  18073. protected _scene: Scene;
  18074. protected _lightDirection: Vector3;
  18075. protected _effect: Effect;
  18076. protected _viewMatrix: Matrix;
  18077. protected _projectionMatrix: Matrix;
  18078. protected _transformMatrix: Matrix;
  18079. protected _cachedPosition: Vector3;
  18080. protected _cachedDirection: Vector3;
  18081. protected _cachedDefines: string;
  18082. protected _currentRenderID: number;
  18083. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18084. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18085. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18086. protected _blurPostProcesses: PostProcess[];
  18087. protected _mapSize: number;
  18088. protected _currentFaceIndex: number;
  18089. protected _currentFaceIndexCache: number;
  18090. protected _textureType: number;
  18091. protected _defaultTextureMatrix: Matrix;
  18092. protected _storedUniqueId: Nullable<number>;
  18093. /** @hidden */
  18094. static _SceneComponentInitialization: (scene: Scene) => void;
  18095. /**
  18096. * Creates a ShadowGenerator object.
  18097. * A ShadowGenerator is the required tool to use the shadows.
  18098. * Each light casting shadows needs to use its own ShadowGenerator.
  18099. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18100. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18101. * @param light The light object generating the shadows.
  18102. * @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.
  18103. */
  18104. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18105. protected _initializeGenerator(): void;
  18106. protected _createTargetRenderTexture(): void;
  18107. protected _initializeShadowMap(): void;
  18108. protected _initializeBlurRTTAndPostProcesses(): void;
  18109. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18110. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18111. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18112. protected _applyFilterValues(): void;
  18113. /**
  18114. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18115. * @param onCompiled Callback triggered at the and of the effects compilation
  18116. * @param options Sets of optional options forcing the compilation with different modes
  18117. */
  18118. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18119. useInstances: boolean;
  18120. }>): void;
  18121. /**
  18122. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18123. * @param options Sets of optional options forcing the compilation with different modes
  18124. * @returns A promise that resolves when the compilation completes
  18125. */
  18126. forceCompilationAsync(options?: Partial<{
  18127. useInstances: boolean;
  18128. }>): Promise<void>;
  18129. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18130. private _prepareShadowDefines;
  18131. /**
  18132. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18133. * @param subMesh The submesh we want to render in the shadow map
  18134. * @param useInstances Defines wether will draw in the map using instances
  18135. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18136. * @returns true if ready otherwise, false
  18137. */
  18138. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18139. /**
  18140. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18141. * @param defines Defines of the material we want to update
  18142. * @param lightIndex Index of the light in the enabled light list of the material
  18143. */
  18144. prepareDefines(defines: any, lightIndex: number): void;
  18145. /**
  18146. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18147. * defined in the generator but impacting the effect).
  18148. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18149. * @param effect The effect we are binfing the information for
  18150. */
  18151. bindShadowLight(lightIndex: string, effect: Effect): void;
  18152. /**
  18153. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18154. * (eq to shadow prjection matrix * light transform matrix)
  18155. * @returns The transform matrix used to create the shadow map
  18156. */
  18157. getTransformMatrix(): Matrix;
  18158. /**
  18159. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18160. * Cube and 2D textures for instance.
  18161. */
  18162. recreateShadowMap(): void;
  18163. protected _disposeBlurPostProcesses(): void;
  18164. protected _disposeRTTandPostProcesses(): void;
  18165. /**
  18166. * Disposes the ShadowGenerator.
  18167. * Returns nothing.
  18168. */
  18169. dispose(): void;
  18170. /**
  18171. * Serializes the shadow generator setup to a json object.
  18172. * @returns The serialized JSON object
  18173. */
  18174. serialize(): any;
  18175. /**
  18176. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18177. * @param parsedShadowGenerator The JSON object to parse
  18178. * @param scene The scene to create the shadow map for
  18179. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18180. * @returns The parsed shadow generator
  18181. */
  18182. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18183. }
  18184. }
  18185. declare module "babylonjs/Lights/light" {
  18186. import { Nullable } from "babylonjs/types";
  18187. import { Scene } from "babylonjs/scene";
  18188. import { Vector3 } from "babylonjs/Maths/math.vector";
  18189. import { Color3 } from "babylonjs/Maths/math.color";
  18190. import { Node } from "babylonjs/node";
  18191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18192. import { Effect } from "babylonjs/Materials/effect";
  18193. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18194. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18195. /**
  18196. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18197. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18198. * 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.
  18199. */
  18200. export abstract class Light extends Node {
  18201. /**
  18202. * Falloff Default: light is falling off following the material specification:
  18203. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18204. */
  18205. static readonly FALLOFF_DEFAULT: number;
  18206. /**
  18207. * Falloff Physical: light is falling off following the inverse squared distance law.
  18208. */
  18209. static readonly FALLOFF_PHYSICAL: number;
  18210. /**
  18211. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18212. * to enhance interoperability with other engines.
  18213. */
  18214. static readonly FALLOFF_GLTF: number;
  18215. /**
  18216. * Falloff Standard: light is falling off like in the standard material
  18217. * to enhance interoperability with other materials.
  18218. */
  18219. static readonly FALLOFF_STANDARD: number;
  18220. /**
  18221. * If every light affecting the material is in this lightmapMode,
  18222. * material.lightmapTexture adds or multiplies
  18223. * (depends on material.useLightmapAsShadowmap)
  18224. * after every other light calculations.
  18225. */
  18226. static readonly LIGHTMAP_DEFAULT: number;
  18227. /**
  18228. * material.lightmapTexture as only diffuse lighting from this light
  18229. * adds only specular lighting from this light
  18230. * adds dynamic shadows
  18231. */
  18232. static readonly LIGHTMAP_SPECULAR: number;
  18233. /**
  18234. * material.lightmapTexture as only lighting
  18235. * no light calculation from this light
  18236. * only adds dynamic shadows from this light
  18237. */
  18238. static readonly LIGHTMAP_SHADOWSONLY: number;
  18239. /**
  18240. * Each light type uses the default quantity according to its type:
  18241. * point/spot lights use luminous intensity
  18242. * directional lights use illuminance
  18243. */
  18244. static readonly INTENSITYMODE_AUTOMATIC: number;
  18245. /**
  18246. * lumen (lm)
  18247. */
  18248. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18249. /**
  18250. * candela (lm/sr)
  18251. */
  18252. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18253. /**
  18254. * lux (lm/m^2)
  18255. */
  18256. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18257. /**
  18258. * nit (cd/m^2)
  18259. */
  18260. static readonly INTENSITYMODE_LUMINANCE: number;
  18261. /**
  18262. * Light type const id of the point light.
  18263. */
  18264. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18265. /**
  18266. * Light type const id of the directional light.
  18267. */
  18268. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18269. /**
  18270. * Light type const id of the spot light.
  18271. */
  18272. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18273. /**
  18274. * Light type const id of the hemispheric light.
  18275. */
  18276. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18277. /**
  18278. * Diffuse gives the basic color to an object.
  18279. */
  18280. diffuse: Color3;
  18281. /**
  18282. * Specular produces a highlight color on an object.
  18283. * Note: This is note affecting PBR materials.
  18284. */
  18285. specular: Color3;
  18286. /**
  18287. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18288. * falling off base on range or angle.
  18289. * This can be set to any values in Light.FALLOFF_x.
  18290. *
  18291. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18292. * other types of materials.
  18293. */
  18294. falloffType: number;
  18295. /**
  18296. * Strength of the light.
  18297. * Note: By default it is define in the framework own unit.
  18298. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18299. */
  18300. intensity: number;
  18301. private _range;
  18302. protected _inverseSquaredRange: number;
  18303. /**
  18304. * Defines how far from the source the light is impacting in scene units.
  18305. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18306. */
  18307. get range(): number;
  18308. /**
  18309. * Defines how far from the source the light is impacting in scene units.
  18310. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18311. */
  18312. set range(value: number);
  18313. /**
  18314. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18315. * of light.
  18316. */
  18317. private _photometricScale;
  18318. private _intensityMode;
  18319. /**
  18320. * Gets the photometric scale used to interpret the intensity.
  18321. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18322. */
  18323. get intensityMode(): number;
  18324. /**
  18325. * Sets the photometric scale used to interpret the intensity.
  18326. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18327. */
  18328. set intensityMode(value: number);
  18329. private _radius;
  18330. /**
  18331. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18332. */
  18333. get radius(): number;
  18334. /**
  18335. * sets the light radius used by PBR Materials to simulate soft area lights.
  18336. */
  18337. set radius(value: number);
  18338. private _renderPriority;
  18339. /**
  18340. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18341. * exceeding the number allowed of the materials.
  18342. */
  18343. renderPriority: number;
  18344. private _shadowEnabled;
  18345. /**
  18346. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18347. * the current shadow generator.
  18348. */
  18349. get shadowEnabled(): boolean;
  18350. /**
  18351. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18352. * the current shadow generator.
  18353. */
  18354. set shadowEnabled(value: boolean);
  18355. private _includedOnlyMeshes;
  18356. /**
  18357. * Gets the only meshes impacted by this light.
  18358. */
  18359. get includedOnlyMeshes(): AbstractMesh[];
  18360. /**
  18361. * Sets the only meshes impacted by this light.
  18362. */
  18363. set includedOnlyMeshes(value: AbstractMesh[]);
  18364. private _excludedMeshes;
  18365. /**
  18366. * Gets the meshes not impacted by this light.
  18367. */
  18368. get excludedMeshes(): AbstractMesh[];
  18369. /**
  18370. * Sets the meshes not impacted by this light.
  18371. */
  18372. set excludedMeshes(value: AbstractMesh[]);
  18373. private _excludeWithLayerMask;
  18374. /**
  18375. * Gets the layer id use to find what meshes are not impacted by the light.
  18376. * Inactive if 0
  18377. */
  18378. get excludeWithLayerMask(): number;
  18379. /**
  18380. * Sets the layer id use to find what meshes are not impacted by the light.
  18381. * Inactive if 0
  18382. */
  18383. set excludeWithLayerMask(value: number);
  18384. private _includeOnlyWithLayerMask;
  18385. /**
  18386. * Gets the layer id use to find what meshes are impacted by the light.
  18387. * Inactive if 0
  18388. */
  18389. get includeOnlyWithLayerMask(): number;
  18390. /**
  18391. * Sets the layer id use to find what meshes are impacted by the light.
  18392. * Inactive if 0
  18393. */
  18394. set includeOnlyWithLayerMask(value: number);
  18395. private _lightmapMode;
  18396. /**
  18397. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18398. */
  18399. get lightmapMode(): number;
  18400. /**
  18401. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18402. */
  18403. set lightmapMode(value: number);
  18404. /**
  18405. * Shadow generator associted to the light.
  18406. * @hidden Internal use only.
  18407. */
  18408. _shadowGenerator: Nullable<IShadowGenerator>;
  18409. /**
  18410. * @hidden Internal use only.
  18411. */
  18412. _excludedMeshesIds: string[];
  18413. /**
  18414. * @hidden Internal use only.
  18415. */
  18416. _includedOnlyMeshesIds: string[];
  18417. /**
  18418. * The current light unifom buffer.
  18419. * @hidden Internal use only.
  18420. */
  18421. _uniformBuffer: UniformBuffer;
  18422. /** @hidden */
  18423. _renderId: number;
  18424. /**
  18425. * Creates a Light object in the scene.
  18426. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18427. * @param name The firendly name of the light
  18428. * @param scene The scene the light belongs too
  18429. */
  18430. constructor(name: string, scene: Scene);
  18431. protected abstract _buildUniformLayout(): void;
  18432. /**
  18433. * Sets the passed Effect "effect" with the Light information.
  18434. * @param effect The effect to update
  18435. * @param lightIndex The index of the light in the effect to update
  18436. * @returns The light
  18437. */
  18438. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18439. /**
  18440. * Sets the passed Effect "effect" with the Light textures.
  18441. * @param effect The effect to update
  18442. * @param lightIndex The index of the light in the effect to update
  18443. * @returns The light
  18444. */
  18445. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18446. /**
  18447. * Binds the lights information from the scene to the effect for the given mesh.
  18448. * @param lightIndex Light index
  18449. * @param scene The scene where the light belongs to
  18450. * @param effect The effect we are binding the data to
  18451. * @param useSpecular Defines if specular is supported
  18452. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18453. */
  18454. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18455. /**
  18456. * Sets the passed Effect "effect" with the Light information.
  18457. * @param effect The effect to update
  18458. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18459. * @returns The light
  18460. */
  18461. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18462. /**
  18463. * Returns the string "Light".
  18464. * @returns the class name
  18465. */
  18466. getClassName(): string;
  18467. /** @hidden */
  18468. readonly _isLight: boolean;
  18469. /**
  18470. * Converts the light information to a readable string for debug purpose.
  18471. * @param fullDetails Supports for multiple levels of logging within scene loading
  18472. * @returns the human readable light info
  18473. */
  18474. toString(fullDetails?: boolean): string;
  18475. /** @hidden */
  18476. protected _syncParentEnabledState(): void;
  18477. /**
  18478. * Set the enabled state of this node.
  18479. * @param value - the new enabled state
  18480. */
  18481. setEnabled(value: boolean): void;
  18482. /**
  18483. * Returns the Light associated shadow generator if any.
  18484. * @return the associated shadow generator.
  18485. */
  18486. getShadowGenerator(): Nullable<IShadowGenerator>;
  18487. /**
  18488. * Returns a Vector3, the absolute light position in the World.
  18489. * @returns the world space position of the light
  18490. */
  18491. getAbsolutePosition(): Vector3;
  18492. /**
  18493. * Specifies if the light will affect the passed mesh.
  18494. * @param mesh The mesh to test against the light
  18495. * @return true the mesh is affected otherwise, false.
  18496. */
  18497. canAffectMesh(mesh: AbstractMesh): boolean;
  18498. /**
  18499. * Sort function to order lights for rendering.
  18500. * @param a First Light object to compare to second.
  18501. * @param b Second Light object to compare first.
  18502. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18503. */
  18504. static CompareLightsPriority(a: Light, b: Light): number;
  18505. /**
  18506. * Releases resources associated with this node.
  18507. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18508. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18509. */
  18510. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18511. /**
  18512. * Returns the light type ID (integer).
  18513. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18514. */
  18515. getTypeID(): number;
  18516. /**
  18517. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18518. * @returns the scaled intensity in intensity mode unit
  18519. */
  18520. getScaledIntensity(): number;
  18521. /**
  18522. * Returns a new Light object, named "name", from the current one.
  18523. * @param name The name of the cloned light
  18524. * @param newParent The parent of this light, if it has one
  18525. * @returns the new created light
  18526. */
  18527. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18528. /**
  18529. * Serializes the current light into a Serialization object.
  18530. * @returns the serialized object.
  18531. */
  18532. serialize(): any;
  18533. /**
  18534. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18535. * This new light is named "name" and added to the passed scene.
  18536. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18537. * @param name The friendly name of the light
  18538. * @param scene The scene the new light will belong to
  18539. * @returns the constructor function
  18540. */
  18541. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18542. /**
  18543. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18544. * @param parsedLight The JSON representation of the light
  18545. * @param scene The scene to create the parsed light in
  18546. * @returns the created light after parsing
  18547. */
  18548. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18549. private _hookArrayForExcluded;
  18550. private _hookArrayForIncludedOnly;
  18551. private _resyncMeshes;
  18552. /**
  18553. * Forces the meshes to update their light related information in their rendering used effects
  18554. * @hidden Internal Use Only
  18555. */
  18556. _markMeshesAsLightDirty(): void;
  18557. /**
  18558. * Recomputes the cached photometric scale if needed.
  18559. */
  18560. private _computePhotometricScale;
  18561. /**
  18562. * Returns the Photometric Scale according to the light type and intensity mode.
  18563. */
  18564. private _getPhotometricScale;
  18565. /**
  18566. * Reorder the light in the scene according to their defined priority.
  18567. * @hidden Internal Use Only
  18568. */
  18569. _reorderLightsInScene(): void;
  18570. /**
  18571. * Prepares the list of defines specific to the light type.
  18572. * @param defines the list of defines
  18573. * @param lightIndex defines the index of the light for the effect
  18574. */
  18575. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18576. }
  18577. }
  18578. declare module "babylonjs/Cameras/targetCamera" {
  18579. import { Nullable } from "babylonjs/types";
  18580. import { Camera } from "babylonjs/Cameras/camera";
  18581. import { Scene } from "babylonjs/scene";
  18582. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18583. /**
  18584. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18585. * This is the base of the follow, arc rotate cameras and Free camera
  18586. * @see http://doc.babylonjs.com/features/cameras
  18587. */
  18588. export class TargetCamera extends Camera {
  18589. private static _RigCamTransformMatrix;
  18590. private static _TargetTransformMatrix;
  18591. private static _TargetFocalPoint;
  18592. private _tmpUpVector;
  18593. private _tmpTargetVector;
  18594. /**
  18595. * Define the current direction the camera is moving to
  18596. */
  18597. cameraDirection: Vector3;
  18598. /**
  18599. * Define the current rotation the camera is rotating to
  18600. */
  18601. cameraRotation: Vector2;
  18602. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18603. ignoreParentScaling: boolean;
  18604. /**
  18605. * When set, the up vector of the camera will be updated by the rotation of the camera
  18606. */
  18607. updateUpVectorFromRotation: boolean;
  18608. private _tmpQuaternion;
  18609. /**
  18610. * Define the current rotation of the camera
  18611. */
  18612. rotation: Vector3;
  18613. /**
  18614. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18615. */
  18616. rotationQuaternion: Quaternion;
  18617. /**
  18618. * Define the current speed of the camera
  18619. */
  18620. speed: number;
  18621. /**
  18622. * Add constraint to the camera to prevent it to move freely in all directions and
  18623. * around all axis.
  18624. */
  18625. noRotationConstraint: boolean;
  18626. /**
  18627. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18628. * panning
  18629. */
  18630. invertRotation: boolean;
  18631. /**
  18632. * Speed multiplier for inverse camera panning
  18633. */
  18634. inverseRotationSpeed: number;
  18635. /**
  18636. * Define the current target of the camera as an object or a position.
  18637. */
  18638. lockedTarget: any;
  18639. /** @hidden */
  18640. _currentTarget: Vector3;
  18641. /** @hidden */
  18642. _initialFocalDistance: number;
  18643. /** @hidden */
  18644. _viewMatrix: Matrix;
  18645. /** @hidden */
  18646. _camMatrix: Matrix;
  18647. /** @hidden */
  18648. _cameraTransformMatrix: Matrix;
  18649. /** @hidden */
  18650. _cameraRotationMatrix: Matrix;
  18651. /** @hidden */
  18652. _referencePoint: Vector3;
  18653. /** @hidden */
  18654. _transformedReferencePoint: Vector3;
  18655. /** @hidden */
  18656. _reset: () => void;
  18657. private _defaultUp;
  18658. /**
  18659. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18660. * This is the base of the follow, arc rotate cameras and Free camera
  18661. * @see http://doc.babylonjs.com/features/cameras
  18662. * @param name Defines the name of the camera in the scene
  18663. * @param position Defines the start position of the camera in the scene
  18664. * @param scene Defines the scene the camera belongs to
  18665. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18666. */
  18667. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18668. /**
  18669. * Gets the position in front of the camera at a given distance.
  18670. * @param distance The distance from the camera we want the position to be
  18671. * @returns the position
  18672. */
  18673. getFrontPosition(distance: number): Vector3;
  18674. /** @hidden */
  18675. _getLockedTargetPosition(): Nullable<Vector3>;
  18676. private _storedPosition;
  18677. private _storedRotation;
  18678. private _storedRotationQuaternion;
  18679. /**
  18680. * Store current camera state of the camera (fov, position, rotation, etc..)
  18681. * @returns the camera
  18682. */
  18683. storeState(): Camera;
  18684. /**
  18685. * Restored camera state. You must call storeState() first
  18686. * @returns whether it was successful or not
  18687. * @hidden
  18688. */
  18689. _restoreStateValues(): boolean;
  18690. /** @hidden */
  18691. _initCache(): void;
  18692. /** @hidden */
  18693. _updateCache(ignoreParentClass?: boolean): void;
  18694. /** @hidden */
  18695. _isSynchronizedViewMatrix(): boolean;
  18696. /** @hidden */
  18697. _computeLocalCameraSpeed(): number;
  18698. /**
  18699. * Defines the target the camera should look at.
  18700. * @param target Defines the new target as a Vector or a mesh
  18701. */
  18702. setTarget(target: Vector3): void;
  18703. /**
  18704. * Return the current target position of the camera. This value is expressed in local space.
  18705. * @returns the target position
  18706. */
  18707. getTarget(): Vector3;
  18708. /** @hidden */
  18709. _decideIfNeedsToMove(): boolean;
  18710. /** @hidden */
  18711. _updatePosition(): void;
  18712. /** @hidden */
  18713. _checkInputs(): void;
  18714. protected _updateCameraRotationMatrix(): void;
  18715. /**
  18716. * 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)
  18717. * @returns the current camera
  18718. */
  18719. private _rotateUpVectorWithCameraRotationMatrix;
  18720. private _cachedRotationZ;
  18721. private _cachedQuaternionRotationZ;
  18722. /** @hidden */
  18723. _getViewMatrix(): Matrix;
  18724. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18725. /**
  18726. * @hidden
  18727. */
  18728. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18729. /**
  18730. * @hidden
  18731. */
  18732. _updateRigCameras(): void;
  18733. private _getRigCamPositionAndTarget;
  18734. /**
  18735. * Gets the current object class name.
  18736. * @return the class name
  18737. */
  18738. getClassName(): string;
  18739. }
  18740. }
  18741. declare module "babylonjs/Events/keyboardEvents" {
  18742. /**
  18743. * Gather the list of keyboard event types as constants.
  18744. */
  18745. export class KeyboardEventTypes {
  18746. /**
  18747. * The keydown event is fired when a key becomes active (pressed).
  18748. */
  18749. static readonly KEYDOWN: number;
  18750. /**
  18751. * The keyup event is fired when a key has been released.
  18752. */
  18753. static readonly KEYUP: number;
  18754. }
  18755. /**
  18756. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18757. */
  18758. export class KeyboardInfo {
  18759. /**
  18760. * Defines the type of event (KeyboardEventTypes)
  18761. */
  18762. type: number;
  18763. /**
  18764. * Defines the related dom event
  18765. */
  18766. event: KeyboardEvent;
  18767. /**
  18768. * Instantiates a new keyboard info.
  18769. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18770. * @param type Defines the type of event (KeyboardEventTypes)
  18771. * @param event Defines the related dom event
  18772. */
  18773. constructor(
  18774. /**
  18775. * Defines the type of event (KeyboardEventTypes)
  18776. */
  18777. type: number,
  18778. /**
  18779. * Defines the related dom event
  18780. */
  18781. event: KeyboardEvent);
  18782. }
  18783. /**
  18784. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18785. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18786. */
  18787. export class KeyboardInfoPre extends KeyboardInfo {
  18788. /**
  18789. * Defines the type of event (KeyboardEventTypes)
  18790. */
  18791. type: number;
  18792. /**
  18793. * Defines the related dom event
  18794. */
  18795. event: KeyboardEvent;
  18796. /**
  18797. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18798. */
  18799. skipOnPointerObservable: boolean;
  18800. /**
  18801. * Instantiates a new keyboard pre info.
  18802. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18803. * @param type Defines the type of event (KeyboardEventTypes)
  18804. * @param event Defines the related dom event
  18805. */
  18806. constructor(
  18807. /**
  18808. * Defines the type of event (KeyboardEventTypes)
  18809. */
  18810. type: number,
  18811. /**
  18812. * Defines the related dom event
  18813. */
  18814. event: KeyboardEvent);
  18815. }
  18816. }
  18817. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18818. import { Nullable } from "babylonjs/types";
  18819. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18820. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18821. /**
  18822. * Manage the keyboard inputs to control the movement of a free camera.
  18823. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18824. */
  18825. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18826. /**
  18827. * Defines the camera the input is attached to.
  18828. */
  18829. camera: FreeCamera;
  18830. /**
  18831. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18832. */
  18833. keysUp: number[];
  18834. /**
  18835. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18836. */
  18837. keysUpward: number[];
  18838. /**
  18839. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18840. */
  18841. keysDown: number[];
  18842. /**
  18843. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18844. */
  18845. keysDownward: number[];
  18846. /**
  18847. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18848. */
  18849. keysLeft: number[];
  18850. /**
  18851. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18852. */
  18853. keysRight: number[];
  18854. private _keys;
  18855. private _onCanvasBlurObserver;
  18856. private _onKeyboardObserver;
  18857. private _engine;
  18858. private _scene;
  18859. /**
  18860. * Attach the input controls to a specific dom element to get the input from.
  18861. * @param element Defines the element the controls should be listened from
  18862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18863. */
  18864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18865. /**
  18866. * Detach the current controls from the specified dom element.
  18867. * @param element Defines the element to stop listening the inputs from
  18868. */
  18869. detachControl(element: Nullable<HTMLElement>): void;
  18870. /**
  18871. * Update the current camera state depending on the inputs that have been used this frame.
  18872. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18873. */
  18874. checkInputs(): void;
  18875. /**
  18876. * Gets the class name of the current intput.
  18877. * @returns the class name
  18878. */
  18879. getClassName(): string;
  18880. /** @hidden */
  18881. _onLostFocus(): void;
  18882. /**
  18883. * Get the friendly name associated with the input class.
  18884. * @returns the input friendly name
  18885. */
  18886. getSimpleName(): string;
  18887. }
  18888. }
  18889. declare module "babylonjs/Events/pointerEvents" {
  18890. import { Nullable } from "babylonjs/types";
  18891. import { Vector2 } from "babylonjs/Maths/math.vector";
  18892. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18893. import { Ray } from "babylonjs/Culling/ray";
  18894. /**
  18895. * Gather the list of pointer event types as constants.
  18896. */
  18897. export class PointerEventTypes {
  18898. /**
  18899. * 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.
  18900. */
  18901. static readonly POINTERDOWN: number;
  18902. /**
  18903. * The pointerup event is fired when a pointer is no longer active.
  18904. */
  18905. static readonly POINTERUP: number;
  18906. /**
  18907. * The pointermove event is fired when a pointer changes coordinates.
  18908. */
  18909. static readonly POINTERMOVE: number;
  18910. /**
  18911. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18912. */
  18913. static readonly POINTERWHEEL: number;
  18914. /**
  18915. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18916. */
  18917. static readonly POINTERPICK: number;
  18918. /**
  18919. * The pointertap event is fired when a the object has been touched and released without drag.
  18920. */
  18921. static readonly POINTERTAP: number;
  18922. /**
  18923. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18924. */
  18925. static readonly POINTERDOUBLETAP: number;
  18926. }
  18927. /**
  18928. * Base class of pointer info types.
  18929. */
  18930. export class PointerInfoBase {
  18931. /**
  18932. * Defines the type of event (PointerEventTypes)
  18933. */
  18934. type: number;
  18935. /**
  18936. * Defines the related dom event
  18937. */
  18938. event: PointerEvent | MouseWheelEvent;
  18939. /**
  18940. * Instantiates the base class of pointers info.
  18941. * @param type Defines the type of event (PointerEventTypes)
  18942. * @param event Defines the related dom event
  18943. */
  18944. constructor(
  18945. /**
  18946. * Defines the type of event (PointerEventTypes)
  18947. */
  18948. type: number,
  18949. /**
  18950. * Defines the related dom event
  18951. */
  18952. event: PointerEvent | MouseWheelEvent);
  18953. }
  18954. /**
  18955. * This class is used to store pointer related info for the onPrePointerObservable event.
  18956. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18957. */
  18958. export class PointerInfoPre extends PointerInfoBase {
  18959. /**
  18960. * Ray from a pointer if availible (eg. 6dof controller)
  18961. */
  18962. ray: Nullable<Ray>;
  18963. /**
  18964. * Defines the local position of the pointer on the canvas.
  18965. */
  18966. localPosition: Vector2;
  18967. /**
  18968. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18969. */
  18970. skipOnPointerObservable: boolean;
  18971. /**
  18972. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18973. * @param type Defines the type of event (PointerEventTypes)
  18974. * @param event Defines the related dom event
  18975. * @param localX Defines the local x coordinates of the pointer when the event occured
  18976. * @param localY Defines the local y coordinates of the pointer when the event occured
  18977. */
  18978. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18979. }
  18980. /**
  18981. * This type contains all the data related to a pointer event in Babylon.js.
  18982. * 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.
  18983. */
  18984. export class PointerInfo extends PointerInfoBase {
  18985. /**
  18986. * Defines the picking info associated to the info (if any)\
  18987. */
  18988. pickInfo: Nullable<PickingInfo>;
  18989. /**
  18990. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18991. * @param type Defines the type of event (PointerEventTypes)
  18992. * @param event Defines the related dom event
  18993. * @param pickInfo Defines the picking info associated to the info (if any)\
  18994. */
  18995. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18996. /**
  18997. * Defines the picking info associated to the info (if any)\
  18998. */
  18999. pickInfo: Nullable<PickingInfo>);
  19000. }
  19001. /**
  19002. * Data relating to a touch event on the screen.
  19003. */
  19004. export interface PointerTouch {
  19005. /**
  19006. * X coordinate of touch.
  19007. */
  19008. x: number;
  19009. /**
  19010. * Y coordinate of touch.
  19011. */
  19012. y: number;
  19013. /**
  19014. * Id of touch. Unique for each finger.
  19015. */
  19016. pointerId: number;
  19017. /**
  19018. * Event type passed from DOM.
  19019. */
  19020. type: any;
  19021. }
  19022. }
  19023. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19024. import { Observable } from "babylonjs/Misc/observable";
  19025. import { Nullable } from "babylonjs/types";
  19026. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19027. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19028. /**
  19029. * Manage the mouse inputs to control the movement of a free camera.
  19030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19031. */
  19032. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19033. /**
  19034. * Define if touch is enabled in the mouse input
  19035. */
  19036. touchEnabled: boolean;
  19037. /**
  19038. * Defines the camera the input is attached to.
  19039. */
  19040. camera: FreeCamera;
  19041. /**
  19042. * Defines the buttons associated with the input to handle camera move.
  19043. */
  19044. buttons: number[];
  19045. /**
  19046. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19047. */
  19048. angularSensibility: number;
  19049. private _pointerInput;
  19050. private _onMouseMove;
  19051. private _observer;
  19052. private previousPosition;
  19053. /**
  19054. * Observable for when a pointer move event occurs containing the move offset
  19055. */
  19056. onPointerMovedObservable: Observable<{
  19057. offsetX: number;
  19058. offsetY: number;
  19059. }>;
  19060. /**
  19061. * @hidden
  19062. * If the camera should be rotated automatically based on pointer movement
  19063. */
  19064. _allowCameraRotation: boolean;
  19065. /**
  19066. * Manage the mouse inputs to control the movement of a free camera.
  19067. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19068. * @param touchEnabled Defines if touch is enabled or not
  19069. */
  19070. constructor(
  19071. /**
  19072. * Define if touch is enabled in the mouse input
  19073. */
  19074. touchEnabled?: boolean);
  19075. /**
  19076. * Attach the input controls to a specific dom element to get the input from.
  19077. * @param element Defines the element the controls should be listened from
  19078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19079. */
  19080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19081. /**
  19082. * Called on JS contextmenu event.
  19083. * Override this method to provide functionality.
  19084. */
  19085. protected onContextMenu(evt: PointerEvent): void;
  19086. /**
  19087. * Detach the current controls from the specified dom element.
  19088. * @param element Defines the element to stop listening the inputs from
  19089. */
  19090. detachControl(element: Nullable<HTMLElement>): void;
  19091. /**
  19092. * Gets the class name of the current intput.
  19093. * @returns the class name
  19094. */
  19095. getClassName(): string;
  19096. /**
  19097. * Get the friendly name associated with the input class.
  19098. * @returns the input friendly name
  19099. */
  19100. getSimpleName(): string;
  19101. }
  19102. }
  19103. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19104. import { Nullable } from "babylonjs/types";
  19105. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19106. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19107. /**
  19108. * Manage the touch inputs to control the movement of a free camera.
  19109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19110. */
  19111. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19112. /**
  19113. * Defines the camera the input is attached to.
  19114. */
  19115. camera: FreeCamera;
  19116. /**
  19117. * Defines the touch sensibility for rotation.
  19118. * The higher the faster.
  19119. */
  19120. touchAngularSensibility: number;
  19121. /**
  19122. * Defines the touch sensibility for move.
  19123. * The higher the faster.
  19124. */
  19125. touchMoveSensibility: number;
  19126. private _offsetX;
  19127. private _offsetY;
  19128. private _pointerPressed;
  19129. private _pointerInput;
  19130. private _observer;
  19131. private _onLostFocus;
  19132. /**
  19133. * Attach the input controls to a specific dom element to get the input from.
  19134. * @param element Defines the element the controls should be listened from
  19135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19136. */
  19137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19138. /**
  19139. * Detach the current controls from the specified dom element.
  19140. * @param element Defines the element to stop listening the inputs from
  19141. */
  19142. detachControl(element: Nullable<HTMLElement>): void;
  19143. /**
  19144. * Update the current camera state depending on the inputs that have been used this frame.
  19145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19146. */
  19147. checkInputs(): void;
  19148. /**
  19149. * Gets the class name of the current intput.
  19150. * @returns the class name
  19151. */
  19152. getClassName(): string;
  19153. /**
  19154. * Get the friendly name associated with the input class.
  19155. * @returns the input friendly name
  19156. */
  19157. getSimpleName(): string;
  19158. }
  19159. }
  19160. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19161. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19162. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19163. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19164. import { Nullable } from "babylonjs/types";
  19165. /**
  19166. * Default Inputs manager for the FreeCamera.
  19167. * It groups all the default supported inputs for ease of use.
  19168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19169. */
  19170. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19171. /**
  19172. * @hidden
  19173. */
  19174. _mouseInput: Nullable<FreeCameraMouseInput>;
  19175. /**
  19176. * Instantiates a new FreeCameraInputsManager.
  19177. * @param camera Defines the camera the inputs belong to
  19178. */
  19179. constructor(camera: FreeCamera);
  19180. /**
  19181. * Add keyboard input support to the input manager.
  19182. * @returns the current input manager
  19183. */
  19184. addKeyboard(): FreeCameraInputsManager;
  19185. /**
  19186. * Add mouse input support to the input manager.
  19187. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19188. * @returns the current input manager
  19189. */
  19190. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19191. /**
  19192. * Removes the mouse input support from the manager
  19193. * @returns the current input manager
  19194. */
  19195. removeMouse(): FreeCameraInputsManager;
  19196. /**
  19197. * Add touch input support to the input manager.
  19198. * @returns the current input manager
  19199. */
  19200. addTouch(): FreeCameraInputsManager;
  19201. /**
  19202. * Remove all attached input methods from a camera
  19203. */
  19204. clear(): void;
  19205. }
  19206. }
  19207. declare module "babylonjs/Cameras/freeCamera" {
  19208. import { Vector3 } from "babylonjs/Maths/math.vector";
  19209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19210. import { Scene } from "babylonjs/scene";
  19211. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19212. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19213. /**
  19214. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19215. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19216. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19217. */
  19218. export class FreeCamera extends TargetCamera {
  19219. /**
  19220. * Define the collision ellipsoid of the camera.
  19221. * This is helpful to simulate a camera body like the player body around the camera
  19222. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19223. */
  19224. ellipsoid: Vector3;
  19225. /**
  19226. * Define an offset for the position of the ellipsoid around the camera.
  19227. * This can be helpful to determine the center of the body near the gravity center of the body
  19228. * instead of its head.
  19229. */
  19230. ellipsoidOffset: Vector3;
  19231. /**
  19232. * Enable or disable collisions of the camera with the rest of the scene objects.
  19233. */
  19234. checkCollisions: boolean;
  19235. /**
  19236. * Enable or disable gravity on the camera.
  19237. */
  19238. applyGravity: boolean;
  19239. /**
  19240. * Define the input manager associated to the camera.
  19241. */
  19242. inputs: FreeCameraInputsManager;
  19243. /**
  19244. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19245. * Higher values reduce sensitivity.
  19246. */
  19247. get angularSensibility(): number;
  19248. /**
  19249. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19250. * Higher values reduce sensitivity.
  19251. */
  19252. set angularSensibility(value: number);
  19253. /**
  19254. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19255. */
  19256. get keysUp(): number[];
  19257. set keysUp(value: number[]);
  19258. /**
  19259. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19260. */
  19261. get keysUpward(): number[];
  19262. set keysUpward(value: number[]);
  19263. /**
  19264. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19265. */
  19266. get keysDown(): number[];
  19267. set keysDown(value: number[]);
  19268. /**
  19269. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19270. */
  19271. get keysDownward(): number[];
  19272. set keysDownward(value: number[]);
  19273. /**
  19274. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19275. */
  19276. get keysLeft(): number[];
  19277. set keysLeft(value: number[]);
  19278. /**
  19279. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19280. */
  19281. get keysRight(): number[];
  19282. set keysRight(value: number[]);
  19283. /**
  19284. * Event raised when the camera collide with a mesh in the scene.
  19285. */
  19286. onCollide: (collidedMesh: AbstractMesh) => void;
  19287. private _collider;
  19288. private _needMoveForGravity;
  19289. private _oldPosition;
  19290. private _diffPosition;
  19291. private _newPosition;
  19292. /** @hidden */
  19293. _localDirection: Vector3;
  19294. /** @hidden */
  19295. _transformedDirection: Vector3;
  19296. /**
  19297. * Instantiates a Free Camera.
  19298. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19299. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19300. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19301. * @param name Define the name of the camera in the scene
  19302. * @param position Define the start position of the camera in the scene
  19303. * @param scene Define the scene the camera belongs to
  19304. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19305. */
  19306. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19307. /**
  19308. * Attached controls to the current camera.
  19309. * @param element Defines the element the controls should be listened from
  19310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19311. */
  19312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19313. /**
  19314. * Detach the current controls from the camera.
  19315. * The camera will stop reacting to inputs.
  19316. * @param element Defines the element to stop listening the inputs from
  19317. */
  19318. detachControl(element: HTMLElement): void;
  19319. private _collisionMask;
  19320. /**
  19321. * Define a collision mask to limit the list of object the camera can collide with
  19322. */
  19323. get collisionMask(): number;
  19324. set collisionMask(mask: number);
  19325. /** @hidden */
  19326. _collideWithWorld(displacement: Vector3): void;
  19327. private _onCollisionPositionChange;
  19328. /** @hidden */
  19329. _checkInputs(): void;
  19330. /** @hidden */
  19331. _decideIfNeedsToMove(): boolean;
  19332. /** @hidden */
  19333. _updatePosition(): void;
  19334. /**
  19335. * Destroy the camera and release the current resources hold by it.
  19336. */
  19337. dispose(): void;
  19338. /**
  19339. * Gets the current object class name.
  19340. * @return the class name
  19341. */
  19342. getClassName(): string;
  19343. }
  19344. }
  19345. declare module "babylonjs/Gamepads/gamepad" {
  19346. import { Observable } from "babylonjs/Misc/observable";
  19347. /**
  19348. * Represents a gamepad control stick position
  19349. */
  19350. export class StickValues {
  19351. /**
  19352. * The x component of the control stick
  19353. */
  19354. x: number;
  19355. /**
  19356. * The y component of the control stick
  19357. */
  19358. y: number;
  19359. /**
  19360. * Initializes the gamepad x and y control stick values
  19361. * @param x The x component of the gamepad control stick value
  19362. * @param y The y component of the gamepad control stick value
  19363. */
  19364. constructor(
  19365. /**
  19366. * The x component of the control stick
  19367. */
  19368. x: number,
  19369. /**
  19370. * The y component of the control stick
  19371. */
  19372. y: number);
  19373. }
  19374. /**
  19375. * An interface which manages callbacks for gamepad button changes
  19376. */
  19377. export interface GamepadButtonChanges {
  19378. /**
  19379. * Called when a gamepad has been changed
  19380. */
  19381. changed: boolean;
  19382. /**
  19383. * Called when a gamepad press event has been triggered
  19384. */
  19385. pressChanged: boolean;
  19386. /**
  19387. * Called when a touch event has been triggered
  19388. */
  19389. touchChanged: boolean;
  19390. /**
  19391. * Called when a value has changed
  19392. */
  19393. valueChanged: boolean;
  19394. }
  19395. /**
  19396. * Represents a gamepad
  19397. */
  19398. export class Gamepad {
  19399. /**
  19400. * The id of the gamepad
  19401. */
  19402. id: string;
  19403. /**
  19404. * The index of the gamepad
  19405. */
  19406. index: number;
  19407. /**
  19408. * The browser gamepad
  19409. */
  19410. browserGamepad: any;
  19411. /**
  19412. * Specifies what type of gamepad this represents
  19413. */
  19414. type: number;
  19415. private _leftStick;
  19416. private _rightStick;
  19417. /** @hidden */
  19418. _isConnected: boolean;
  19419. private _leftStickAxisX;
  19420. private _leftStickAxisY;
  19421. private _rightStickAxisX;
  19422. private _rightStickAxisY;
  19423. /**
  19424. * Triggered when the left control stick has been changed
  19425. */
  19426. private _onleftstickchanged;
  19427. /**
  19428. * Triggered when the right control stick has been changed
  19429. */
  19430. private _onrightstickchanged;
  19431. /**
  19432. * Represents a gamepad controller
  19433. */
  19434. static GAMEPAD: number;
  19435. /**
  19436. * Represents a generic controller
  19437. */
  19438. static GENERIC: number;
  19439. /**
  19440. * Represents an XBox controller
  19441. */
  19442. static XBOX: number;
  19443. /**
  19444. * Represents a pose-enabled controller
  19445. */
  19446. static POSE_ENABLED: number;
  19447. /**
  19448. * Represents an Dual Shock controller
  19449. */
  19450. static DUALSHOCK: number;
  19451. /**
  19452. * Specifies whether the left control stick should be Y-inverted
  19453. */
  19454. protected _invertLeftStickY: boolean;
  19455. /**
  19456. * Specifies if the gamepad has been connected
  19457. */
  19458. get isConnected(): boolean;
  19459. /**
  19460. * Initializes the gamepad
  19461. * @param id The id of the gamepad
  19462. * @param index The index of the gamepad
  19463. * @param browserGamepad The browser gamepad
  19464. * @param leftStickX The x component of the left joystick
  19465. * @param leftStickY The y component of the left joystick
  19466. * @param rightStickX The x component of the right joystick
  19467. * @param rightStickY The y component of the right joystick
  19468. */
  19469. constructor(
  19470. /**
  19471. * The id of the gamepad
  19472. */
  19473. id: string,
  19474. /**
  19475. * The index of the gamepad
  19476. */
  19477. index: number,
  19478. /**
  19479. * The browser gamepad
  19480. */
  19481. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19482. /**
  19483. * Callback triggered when the left joystick has changed
  19484. * @param callback
  19485. */
  19486. onleftstickchanged(callback: (values: StickValues) => void): void;
  19487. /**
  19488. * Callback triggered when the right joystick has changed
  19489. * @param callback
  19490. */
  19491. onrightstickchanged(callback: (values: StickValues) => void): void;
  19492. /**
  19493. * Gets the left joystick
  19494. */
  19495. get leftStick(): StickValues;
  19496. /**
  19497. * Sets the left joystick values
  19498. */
  19499. set leftStick(newValues: StickValues);
  19500. /**
  19501. * Gets the right joystick
  19502. */
  19503. get rightStick(): StickValues;
  19504. /**
  19505. * Sets the right joystick value
  19506. */
  19507. set rightStick(newValues: StickValues);
  19508. /**
  19509. * Updates the gamepad joystick positions
  19510. */
  19511. update(): void;
  19512. /**
  19513. * Disposes the gamepad
  19514. */
  19515. dispose(): void;
  19516. }
  19517. /**
  19518. * Represents a generic gamepad
  19519. */
  19520. export class GenericPad extends Gamepad {
  19521. private _buttons;
  19522. private _onbuttondown;
  19523. private _onbuttonup;
  19524. /**
  19525. * Observable triggered when a button has been pressed
  19526. */
  19527. onButtonDownObservable: Observable<number>;
  19528. /**
  19529. * Observable triggered when a button has been released
  19530. */
  19531. onButtonUpObservable: Observable<number>;
  19532. /**
  19533. * Callback triggered when a button has been pressed
  19534. * @param callback Called when a button has been pressed
  19535. */
  19536. onbuttondown(callback: (buttonPressed: number) => void): void;
  19537. /**
  19538. * Callback triggered when a button has been released
  19539. * @param callback Called when a button has been released
  19540. */
  19541. onbuttonup(callback: (buttonReleased: number) => void): void;
  19542. /**
  19543. * Initializes the generic gamepad
  19544. * @param id The id of the generic gamepad
  19545. * @param index The index of the generic gamepad
  19546. * @param browserGamepad The browser gamepad
  19547. */
  19548. constructor(id: string, index: number, browserGamepad: any);
  19549. private _setButtonValue;
  19550. /**
  19551. * Updates the generic gamepad
  19552. */
  19553. update(): void;
  19554. /**
  19555. * Disposes the generic gamepad
  19556. */
  19557. dispose(): void;
  19558. }
  19559. }
  19560. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19561. import { Observable } from "babylonjs/Misc/observable";
  19562. import { Nullable } from "babylonjs/types";
  19563. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19564. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19566. import { Ray } from "babylonjs/Culling/ray";
  19567. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19568. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19569. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19570. /**
  19571. * Defines the types of pose enabled controllers that are supported
  19572. */
  19573. export enum PoseEnabledControllerType {
  19574. /**
  19575. * HTC Vive
  19576. */
  19577. VIVE = 0,
  19578. /**
  19579. * Oculus Rift
  19580. */
  19581. OCULUS = 1,
  19582. /**
  19583. * Windows mixed reality
  19584. */
  19585. WINDOWS = 2,
  19586. /**
  19587. * Samsung gear VR
  19588. */
  19589. GEAR_VR = 3,
  19590. /**
  19591. * Google Daydream
  19592. */
  19593. DAYDREAM = 4,
  19594. /**
  19595. * Generic
  19596. */
  19597. GENERIC = 5
  19598. }
  19599. /**
  19600. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19601. */
  19602. export interface MutableGamepadButton {
  19603. /**
  19604. * Value of the button/trigger
  19605. */
  19606. value: number;
  19607. /**
  19608. * If the button/trigger is currently touched
  19609. */
  19610. touched: boolean;
  19611. /**
  19612. * If the button/trigger is currently pressed
  19613. */
  19614. pressed: boolean;
  19615. }
  19616. /**
  19617. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19618. * @hidden
  19619. */
  19620. export interface ExtendedGamepadButton extends GamepadButton {
  19621. /**
  19622. * If the button/trigger is currently pressed
  19623. */
  19624. readonly pressed: boolean;
  19625. /**
  19626. * If the button/trigger is currently touched
  19627. */
  19628. readonly touched: boolean;
  19629. /**
  19630. * Value of the button/trigger
  19631. */
  19632. readonly value: number;
  19633. }
  19634. /** @hidden */
  19635. export interface _GamePadFactory {
  19636. /**
  19637. * Returns whether or not the current gamepad can be created for this type of controller.
  19638. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19639. * @returns true if it can be created, otherwise false
  19640. */
  19641. canCreate(gamepadInfo: any): boolean;
  19642. /**
  19643. * Creates a new instance of the Gamepad.
  19644. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19645. * @returns the new gamepad instance
  19646. */
  19647. create(gamepadInfo: any): Gamepad;
  19648. }
  19649. /**
  19650. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19651. */
  19652. export class PoseEnabledControllerHelper {
  19653. /** @hidden */
  19654. static _ControllerFactories: _GamePadFactory[];
  19655. /** @hidden */
  19656. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19657. /**
  19658. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19659. * @param vrGamepad the gamepad to initialized
  19660. * @returns a vr controller of the type the gamepad identified as
  19661. */
  19662. static InitiateController(vrGamepad: any): Gamepad;
  19663. }
  19664. /**
  19665. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19666. */
  19667. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19668. /**
  19669. * If the controller is used in a webXR session
  19670. */
  19671. isXR: boolean;
  19672. private _deviceRoomPosition;
  19673. private _deviceRoomRotationQuaternion;
  19674. /**
  19675. * The device position in babylon space
  19676. */
  19677. devicePosition: Vector3;
  19678. /**
  19679. * The device rotation in babylon space
  19680. */
  19681. deviceRotationQuaternion: Quaternion;
  19682. /**
  19683. * The scale factor of the device in babylon space
  19684. */
  19685. deviceScaleFactor: number;
  19686. /**
  19687. * (Likely devicePosition should be used instead) The device position in its room space
  19688. */
  19689. position: Vector3;
  19690. /**
  19691. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19692. */
  19693. rotationQuaternion: Quaternion;
  19694. /**
  19695. * The type of controller (Eg. Windows mixed reality)
  19696. */
  19697. controllerType: PoseEnabledControllerType;
  19698. protected _calculatedPosition: Vector3;
  19699. private _calculatedRotation;
  19700. /**
  19701. * The raw pose from the device
  19702. */
  19703. rawPose: DevicePose;
  19704. private _trackPosition;
  19705. private _maxRotationDistFromHeadset;
  19706. private _draggedRoomRotation;
  19707. /**
  19708. * @hidden
  19709. */
  19710. _disableTrackPosition(fixedPosition: Vector3): void;
  19711. /**
  19712. * Internal, the mesh attached to the controller
  19713. * @hidden
  19714. */
  19715. _mesh: Nullable<AbstractMesh>;
  19716. private _poseControlledCamera;
  19717. private _leftHandSystemQuaternion;
  19718. /**
  19719. * Internal, matrix used to convert room space to babylon space
  19720. * @hidden
  19721. */
  19722. _deviceToWorld: Matrix;
  19723. /**
  19724. * Node to be used when casting a ray from the controller
  19725. * @hidden
  19726. */
  19727. _pointingPoseNode: Nullable<TransformNode>;
  19728. /**
  19729. * Name of the child mesh that can be used to cast a ray from the controller
  19730. */
  19731. static readonly POINTING_POSE: string;
  19732. /**
  19733. * Creates a new PoseEnabledController from a gamepad
  19734. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19735. */
  19736. constructor(browserGamepad: any);
  19737. private _workingMatrix;
  19738. /**
  19739. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19740. */
  19741. update(): void;
  19742. /**
  19743. * Updates only the pose device and mesh without doing any button event checking
  19744. */
  19745. protected _updatePoseAndMesh(): void;
  19746. /**
  19747. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19748. * @param poseData raw pose fromthe device
  19749. */
  19750. updateFromDevice(poseData: DevicePose): void;
  19751. /**
  19752. * @hidden
  19753. */
  19754. _meshAttachedObservable: Observable<AbstractMesh>;
  19755. /**
  19756. * Attaches a mesh to the controller
  19757. * @param mesh the mesh to be attached
  19758. */
  19759. attachToMesh(mesh: AbstractMesh): void;
  19760. /**
  19761. * Attaches the controllers mesh to a camera
  19762. * @param camera the camera the mesh should be attached to
  19763. */
  19764. attachToPoseControlledCamera(camera: TargetCamera): void;
  19765. /**
  19766. * Disposes of the controller
  19767. */
  19768. dispose(): void;
  19769. /**
  19770. * The mesh that is attached to the controller
  19771. */
  19772. get mesh(): Nullable<AbstractMesh>;
  19773. /**
  19774. * Gets the ray of the controller in the direction the controller is pointing
  19775. * @param length the length the resulting ray should be
  19776. * @returns a ray in the direction the controller is pointing
  19777. */
  19778. getForwardRay(length?: number): Ray;
  19779. }
  19780. }
  19781. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19782. import { Observable } from "babylonjs/Misc/observable";
  19783. import { Scene } from "babylonjs/scene";
  19784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19785. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19786. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19787. import { Nullable } from "babylonjs/types";
  19788. /**
  19789. * Defines the WebVRController object that represents controllers tracked in 3D space
  19790. */
  19791. export abstract class WebVRController extends PoseEnabledController {
  19792. /**
  19793. * Internal, the default controller model for the controller
  19794. */
  19795. protected _defaultModel: Nullable<AbstractMesh>;
  19796. /**
  19797. * Fired when the trigger state has changed
  19798. */
  19799. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19800. /**
  19801. * Fired when the main button state has changed
  19802. */
  19803. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19804. /**
  19805. * Fired when the secondary button state has changed
  19806. */
  19807. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19808. /**
  19809. * Fired when the pad state has changed
  19810. */
  19811. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19812. /**
  19813. * Fired when controllers stick values have changed
  19814. */
  19815. onPadValuesChangedObservable: Observable<StickValues>;
  19816. /**
  19817. * Array of button availible on the controller
  19818. */
  19819. protected _buttons: Array<MutableGamepadButton>;
  19820. private _onButtonStateChange;
  19821. /**
  19822. * Fired when a controller button's state has changed
  19823. * @param callback the callback containing the button that was modified
  19824. */
  19825. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19826. /**
  19827. * X and Y axis corresponding to the controllers joystick
  19828. */
  19829. pad: StickValues;
  19830. /**
  19831. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19832. */
  19833. hand: string;
  19834. /**
  19835. * The default controller model for the controller
  19836. */
  19837. get defaultModel(): Nullable<AbstractMesh>;
  19838. /**
  19839. * Creates a new WebVRController from a gamepad
  19840. * @param vrGamepad the gamepad that the WebVRController should be created from
  19841. */
  19842. constructor(vrGamepad: any);
  19843. /**
  19844. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19845. */
  19846. update(): void;
  19847. /**
  19848. * Function to be called when a button is modified
  19849. */
  19850. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19851. /**
  19852. * Loads a mesh and attaches it to the controller
  19853. * @param scene the scene the mesh should be added to
  19854. * @param meshLoaded callback for when the mesh has been loaded
  19855. */
  19856. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19857. private _setButtonValue;
  19858. private _changes;
  19859. private _checkChanges;
  19860. /**
  19861. * Disposes of th webVRCOntroller
  19862. */
  19863. dispose(): void;
  19864. }
  19865. }
  19866. declare module "babylonjs/Lights/hemisphericLight" {
  19867. import { Nullable } from "babylonjs/types";
  19868. import { Scene } from "babylonjs/scene";
  19869. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19870. import { Color3 } from "babylonjs/Maths/math.color";
  19871. import { Effect } from "babylonjs/Materials/effect";
  19872. import { Light } from "babylonjs/Lights/light";
  19873. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19874. /**
  19875. * The HemisphericLight simulates the ambient environment light,
  19876. * so the passed direction is the light reflection direction, not the incoming direction.
  19877. */
  19878. export class HemisphericLight extends Light {
  19879. /**
  19880. * The groundColor is the light in the opposite direction to the one specified during creation.
  19881. * 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.
  19882. */
  19883. groundColor: Color3;
  19884. /**
  19885. * The light reflection direction, not the incoming direction.
  19886. */
  19887. direction: Vector3;
  19888. /**
  19889. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19890. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19891. * The HemisphericLight can't cast shadows.
  19892. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19893. * @param name The friendly name of the light
  19894. * @param direction The direction of the light reflection
  19895. * @param scene The scene the light belongs to
  19896. */
  19897. constructor(name: string, direction: Vector3, scene: Scene);
  19898. protected _buildUniformLayout(): void;
  19899. /**
  19900. * Returns the string "HemisphericLight".
  19901. * @return The class name
  19902. */
  19903. getClassName(): string;
  19904. /**
  19905. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19906. * Returns the updated direction.
  19907. * @param target The target the direction should point to
  19908. * @return The computed direction
  19909. */
  19910. setDirectionToTarget(target: Vector3): Vector3;
  19911. /**
  19912. * Returns the shadow generator associated to the light.
  19913. * @returns Always null for hemispheric lights because it does not support shadows.
  19914. */
  19915. getShadowGenerator(): Nullable<IShadowGenerator>;
  19916. /**
  19917. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19918. * @param effect The effect to update
  19919. * @param lightIndex The index of the light in the effect to update
  19920. * @returns The hemispheric light
  19921. */
  19922. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19923. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19924. /**
  19925. * Computes the world matrix of the node
  19926. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19927. * @param useWasUpdatedFlag defines a reserved property
  19928. * @returns the world matrix
  19929. */
  19930. computeWorldMatrix(): Matrix;
  19931. /**
  19932. * Returns the integer 3.
  19933. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19934. */
  19935. getTypeID(): number;
  19936. /**
  19937. * Prepares the list of defines specific to the light type.
  19938. * @param defines the list of defines
  19939. * @param lightIndex defines the index of the light for the effect
  19940. */
  19941. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19942. }
  19943. }
  19944. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19945. /** @hidden */
  19946. export var vrMultiviewToSingleviewPixelShader: {
  19947. name: string;
  19948. shader: string;
  19949. };
  19950. }
  19951. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19952. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19953. import { Scene } from "babylonjs/scene";
  19954. /**
  19955. * Renders to multiple views with a single draw call
  19956. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19957. */
  19958. export class MultiviewRenderTarget extends RenderTargetTexture {
  19959. /**
  19960. * Creates a multiview render target
  19961. * @param scene scene used with the render target
  19962. * @param size the size of the render target (used for each view)
  19963. */
  19964. constructor(scene: Scene, size?: number | {
  19965. width: number;
  19966. height: number;
  19967. } | {
  19968. ratio: number;
  19969. });
  19970. /**
  19971. * @hidden
  19972. * @param faceIndex the face index, if its a cube texture
  19973. */
  19974. _bindFrameBuffer(faceIndex?: number): void;
  19975. /**
  19976. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19977. * @returns the view count
  19978. */
  19979. getViewCount(): number;
  19980. }
  19981. }
  19982. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19983. import { Camera } from "babylonjs/Cameras/camera";
  19984. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19985. import { Nullable } from "babylonjs/types";
  19986. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19987. import { Matrix } from "babylonjs/Maths/math.vector";
  19988. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19989. module "babylonjs/Engines/engine" {
  19990. interface Engine {
  19991. /**
  19992. * Creates a new multiview render target
  19993. * @param width defines the width of the texture
  19994. * @param height defines the height of the texture
  19995. * @returns the created multiview texture
  19996. */
  19997. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19998. /**
  19999. * Binds a multiview framebuffer to be drawn to
  20000. * @param multiviewTexture texture to bind
  20001. */
  20002. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20003. }
  20004. }
  20005. module "babylonjs/Cameras/camera" {
  20006. interface Camera {
  20007. /**
  20008. * @hidden
  20009. * 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)
  20010. */
  20011. _useMultiviewToSingleView: boolean;
  20012. /**
  20013. * @hidden
  20014. * 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)
  20015. */
  20016. _multiviewTexture: Nullable<RenderTargetTexture>;
  20017. /**
  20018. * @hidden
  20019. * ensures the multiview texture of the camera exists and has the specified width/height
  20020. * @param width height to set on the multiview texture
  20021. * @param height width to set on the multiview texture
  20022. */
  20023. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20024. }
  20025. }
  20026. module "babylonjs/scene" {
  20027. interface Scene {
  20028. /** @hidden */
  20029. _transformMatrixR: Matrix;
  20030. /** @hidden */
  20031. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20032. /** @hidden */
  20033. _createMultiviewUbo(): void;
  20034. /** @hidden */
  20035. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20036. /** @hidden */
  20037. _renderMultiviewToSingleView(camera: Camera): void;
  20038. }
  20039. }
  20040. }
  20041. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20042. import { Camera } from "babylonjs/Cameras/camera";
  20043. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20044. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20045. import "babylonjs/Engines/Extensions/engine.multiview";
  20046. /**
  20047. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20048. * This will not be used for webXR as it supports displaying texture arrays directly
  20049. */
  20050. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20051. /**
  20052. * Initializes a VRMultiviewToSingleview
  20053. * @param name name of the post process
  20054. * @param camera camera to be applied to
  20055. * @param scaleFactor scaling factor to the size of the output texture
  20056. */
  20057. constructor(name: string, camera: Camera, scaleFactor: number);
  20058. }
  20059. }
  20060. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20061. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20062. import { Nullable } from "babylonjs/types";
  20063. import { Size } from "babylonjs/Maths/math.size";
  20064. import { Observable } from "babylonjs/Misc/observable";
  20065. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20066. /**
  20067. * Interface used to define additional presentation attributes
  20068. */
  20069. export interface IVRPresentationAttributes {
  20070. /**
  20071. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20072. */
  20073. highRefreshRate: boolean;
  20074. /**
  20075. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20076. */
  20077. foveationLevel: number;
  20078. }
  20079. module "babylonjs/Engines/engine" {
  20080. interface Engine {
  20081. /** @hidden */
  20082. _vrDisplay: any;
  20083. /** @hidden */
  20084. _vrSupported: boolean;
  20085. /** @hidden */
  20086. _oldSize: Size;
  20087. /** @hidden */
  20088. _oldHardwareScaleFactor: number;
  20089. /** @hidden */
  20090. _vrExclusivePointerMode: boolean;
  20091. /** @hidden */
  20092. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20093. /** @hidden */
  20094. _onVRDisplayPointerRestricted: () => void;
  20095. /** @hidden */
  20096. _onVRDisplayPointerUnrestricted: () => void;
  20097. /** @hidden */
  20098. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20099. /** @hidden */
  20100. _onVrDisplayDisconnect: Nullable<() => void>;
  20101. /** @hidden */
  20102. _onVrDisplayPresentChange: Nullable<() => void>;
  20103. /**
  20104. * Observable signaled when VR display mode changes
  20105. */
  20106. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20107. /**
  20108. * Observable signaled when VR request present is complete
  20109. */
  20110. onVRRequestPresentComplete: Observable<boolean>;
  20111. /**
  20112. * Observable signaled when VR request present starts
  20113. */
  20114. onVRRequestPresentStart: Observable<Engine>;
  20115. /**
  20116. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20117. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20118. */
  20119. isInVRExclusivePointerMode: boolean;
  20120. /**
  20121. * Gets a boolean indicating if a webVR device was detected
  20122. * @returns true if a webVR device was detected
  20123. */
  20124. isVRDevicePresent(): boolean;
  20125. /**
  20126. * Gets the current webVR device
  20127. * @returns the current webVR device (or null)
  20128. */
  20129. getVRDevice(): any;
  20130. /**
  20131. * Initializes a webVR display and starts listening to display change events
  20132. * The onVRDisplayChangedObservable will be notified upon these changes
  20133. * @returns A promise containing a VRDisplay and if vr is supported
  20134. */
  20135. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20136. /** @hidden */
  20137. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20138. /**
  20139. * Gets or sets the presentation attributes used to configure VR rendering
  20140. */
  20141. vrPresentationAttributes?: IVRPresentationAttributes;
  20142. /**
  20143. * Call this function to switch to webVR mode
  20144. * Will do nothing if webVR is not supported or if there is no webVR device
  20145. * @param options the webvr options provided to the camera. mainly used for multiview
  20146. * @see http://doc.babylonjs.com/how_to/webvr_camera
  20147. */
  20148. enableVR(options: WebVROptions): void;
  20149. /** @hidden */
  20150. _onVRFullScreenTriggered(): void;
  20151. }
  20152. }
  20153. }
  20154. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20155. import { Nullable } from "babylonjs/types";
  20156. import { Observable } from "babylonjs/Misc/observable";
  20157. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20158. import { Scene } from "babylonjs/scene";
  20159. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20160. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20161. import { Node } from "babylonjs/node";
  20162. import { Ray } from "babylonjs/Culling/ray";
  20163. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20164. import "babylonjs/Engines/Extensions/engine.webVR";
  20165. /**
  20166. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20167. * IMPORTANT!! The data is right-hand data.
  20168. * @export
  20169. * @interface DevicePose
  20170. */
  20171. export interface DevicePose {
  20172. /**
  20173. * The position of the device, values in array are [x,y,z].
  20174. */
  20175. readonly position: Nullable<Float32Array>;
  20176. /**
  20177. * The linearVelocity of the device, values in array are [x,y,z].
  20178. */
  20179. readonly linearVelocity: Nullable<Float32Array>;
  20180. /**
  20181. * The linearAcceleration of the device, values in array are [x,y,z].
  20182. */
  20183. readonly linearAcceleration: Nullable<Float32Array>;
  20184. /**
  20185. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20186. */
  20187. readonly orientation: Nullable<Float32Array>;
  20188. /**
  20189. * The angularVelocity of the device, values in array are [x,y,z].
  20190. */
  20191. readonly angularVelocity: Nullable<Float32Array>;
  20192. /**
  20193. * The angularAcceleration of the device, values in array are [x,y,z].
  20194. */
  20195. readonly angularAcceleration: Nullable<Float32Array>;
  20196. }
  20197. /**
  20198. * Interface representing a pose controlled object in Babylon.
  20199. * A pose controlled object has both regular pose values as well as pose values
  20200. * from an external device such as a VR head mounted display
  20201. */
  20202. export interface PoseControlled {
  20203. /**
  20204. * The position of the object in babylon space.
  20205. */
  20206. position: Vector3;
  20207. /**
  20208. * The rotation quaternion of the object in babylon space.
  20209. */
  20210. rotationQuaternion: Quaternion;
  20211. /**
  20212. * The position of the device in babylon space.
  20213. */
  20214. devicePosition?: Vector3;
  20215. /**
  20216. * The rotation quaternion of the device in babylon space.
  20217. */
  20218. deviceRotationQuaternion: Quaternion;
  20219. /**
  20220. * The raw pose coming from the device.
  20221. */
  20222. rawPose: Nullable<DevicePose>;
  20223. /**
  20224. * The scale of the device to be used when translating from device space to babylon space.
  20225. */
  20226. deviceScaleFactor: number;
  20227. /**
  20228. * Updates the poseControlled values based on the input device pose.
  20229. * @param poseData the pose data to update the object with
  20230. */
  20231. updateFromDevice(poseData: DevicePose): void;
  20232. }
  20233. /**
  20234. * Set of options to customize the webVRCamera
  20235. */
  20236. export interface WebVROptions {
  20237. /**
  20238. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20239. */
  20240. trackPosition?: boolean;
  20241. /**
  20242. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20243. */
  20244. positionScale?: number;
  20245. /**
  20246. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20247. */
  20248. displayName?: string;
  20249. /**
  20250. * Should the native controller meshes be initialized. (default: true)
  20251. */
  20252. controllerMeshes?: boolean;
  20253. /**
  20254. * Creating a default HemiLight only on controllers. (default: true)
  20255. */
  20256. defaultLightingOnControllers?: boolean;
  20257. /**
  20258. * If you don't want to use the default VR button of the helper. (default: false)
  20259. */
  20260. useCustomVRButton?: boolean;
  20261. /**
  20262. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20263. */
  20264. customVRButton?: HTMLButtonElement;
  20265. /**
  20266. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20267. */
  20268. rayLength?: number;
  20269. /**
  20270. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20271. */
  20272. defaultHeight?: number;
  20273. /**
  20274. * If multiview should be used if availible (default: false)
  20275. */
  20276. useMultiview?: boolean;
  20277. }
  20278. /**
  20279. * This represents a WebVR camera.
  20280. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20281. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20282. */
  20283. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20284. private webVROptions;
  20285. /**
  20286. * @hidden
  20287. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20288. */
  20289. _vrDevice: any;
  20290. /**
  20291. * The rawPose of the vrDevice.
  20292. */
  20293. rawPose: Nullable<DevicePose>;
  20294. private _onVREnabled;
  20295. private _specsVersion;
  20296. private _attached;
  20297. private _frameData;
  20298. protected _descendants: Array<Node>;
  20299. private _deviceRoomPosition;
  20300. /** @hidden */
  20301. _deviceRoomRotationQuaternion: Quaternion;
  20302. private _standingMatrix;
  20303. /**
  20304. * Represents device position in babylon space.
  20305. */
  20306. devicePosition: Vector3;
  20307. /**
  20308. * Represents device rotation in babylon space.
  20309. */
  20310. deviceRotationQuaternion: Quaternion;
  20311. /**
  20312. * The scale of the device to be used when translating from device space to babylon space.
  20313. */
  20314. deviceScaleFactor: number;
  20315. private _deviceToWorld;
  20316. private _worldToDevice;
  20317. /**
  20318. * References to the webVR controllers for the vrDevice.
  20319. */
  20320. controllers: Array<WebVRController>;
  20321. /**
  20322. * Emits an event when a controller is attached.
  20323. */
  20324. onControllersAttachedObservable: Observable<WebVRController[]>;
  20325. /**
  20326. * Emits an event when a controller's mesh has been loaded;
  20327. */
  20328. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20329. /**
  20330. * Emits an event when the HMD's pose has been updated.
  20331. */
  20332. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20333. private _poseSet;
  20334. /**
  20335. * If the rig cameras be used as parent instead of this camera.
  20336. */
  20337. rigParenting: boolean;
  20338. private _lightOnControllers;
  20339. private _defaultHeight?;
  20340. /**
  20341. * Instantiates a WebVRFreeCamera.
  20342. * @param name The name of the WebVRFreeCamera
  20343. * @param position The starting anchor position for the camera
  20344. * @param scene The scene the camera belongs to
  20345. * @param webVROptions a set of customizable options for the webVRCamera
  20346. */
  20347. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20348. /**
  20349. * Gets the device distance from the ground in meters.
  20350. * @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.
  20351. */
  20352. deviceDistanceToRoomGround(): number;
  20353. /**
  20354. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20355. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20356. */
  20357. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20358. /**
  20359. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20360. * @returns A promise with a boolean set to if the standing matrix is supported.
  20361. */
  20362. useStandingMatrixAsync(): Promise<boolean>;
  20363. /**
  20364. * Disposes the camera
  20365. */
  20366. dispose(): void;
  20367. /**
  20368. * Gets a vrController by name.
  20369. * @param name The name of the controller to retreive
  20370. * @returns the controller matching the name specified or null if not found
  20371. */
  20372. getControllerByName(name: string): Nullable<WebVRController>;
  20373. private _leftController;
  20374. /**
  20375. * The controller corresponding to the users left hand.
  20376. */
  20377. get leftController(): Nullable<WebVRController>;
  20378. private _rightController;
  20379. /**
  20380. * The controller corresponding to the users right hand.
  20381. */
  20382. get rightController(): Nullable<WebVRController>;
  20383. /**
  20384. * Casts a ray forward from the vrCamera's gaze.
  20385. * @param length Length of the ray (default: 100)
  20386. * @returns the ray corresponding to the gaze
  20387. */
  20388. getForwardRay(length?: number): Ray;
  20389. /**
  20390. * @hidden
  20391. * Updates the camera based on device's frame data
  20392. */
  20393. _checkInputs(): void;
  20394. /**
  20395. * Updates the poseControlled values based on the input device pose.
  20396. * @param poseData Pose coming from the device
  20397. */
  20398. updateFromDevice(poseData: DevicePose): void;
  20399. private _htmlElementAttached;
  20400. private _detachIfAttached;
  20401. /**
  20402. * WebVR's attach control will start broadcasting frames to the device.
  20403. * Note that in certain browsers (chrome for example) this function must be called
  20404. * within a user-interaction callback. Example:
  20405. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20406. *
  20407. * @param element html element to attach the vrDevice to
  20408. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20409. */
  20410. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20411. /**
  20412. * Detaches the camera from the html element and disables VR
  20413. *
  20414. * @param element html element to detach from
  20415. */
  20416. detachControl(element: HTMLElement): void;
  20417. /**
  20418. * @returns the name of this class
  20419. */
  20420. getClassName(): string;
  20421. /**
  20422. * Calls resetPose on the vrDisplay
  20423. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20424. */
  20425. resetToCurrentRotation(): void;
  20426. /**
  20427. * @hidden
  20428. * Updates the rig cameras (left and right eye)
  20429. */
  20430. _updateRigCameras(): void;
  20431. private _workingVector;
  20432. private _oneVector;
  20433. private _workingMatrix;
  20434. private updateCacheCalled;
  20435. private _correctPositionIfNotTrackPosition;
  20436. /**
  20437. * @hidden
  20438. * Updates the cached values of the camera
  20439. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20440. */
  20441. _updateCache(ignoreParentClass?: boolean): void;
  20442. /**
  20443. * @hidden
  20444. * Get current device position in babylon world
  20445. */
  20446. _computeDevicePosition(): void;
  20447. /**
  20448. * Updates the current device position and rotation in the babylon world
  20449. */
  20450. update(): void;
  20451. /**
  20452. * @hidden
  20453. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20454. * @returns an identity matrix
  20455. */
  20456. _getViewMatrix(): Matrix;
  20457. private _tmpMatrix;
  20458. /**
  20459. * This function is called by the two RIG cameras.
  20460. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20461. * @hidden
  20462. */
  20463. _getWebVRViewMatrix(): Matrix;
  20464. /** @hidden */
  20465. _getWebVRProjectionMatrix(): Matrix;
  20466. private _onGamepadConnectedObserver;
  20467. private _onGamepadDisconnectedObserver;
  20468. private _updateCacheWhenTrackingDisabledObserver;
  20469. /**
  20470. * Initializes the controllers and their meshes
  20471. */
  20472. initControllers(): void;
  20473. }
  20474. }
  20475. declare module "babylonjs/Materials/materialHelper" {
  20476. import { Nullable } from "babylonjs/types";
  20477. import { Scene } from "babylonjs/scene";
  20478. import { Engine } from "babylonjs/Engines/engine";
  20479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20480. import { Light } from "babylonjs/Lights/light";
  20481. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20482. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20483. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20484. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20485. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20486. /**
  20487. * "Static Class" containing the most commonly used helper while dealing with material for
  20488. * rendering purpose.
  20489. *
  20490. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20491. *
  20492. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20493. */
  20494. export class MaterialHelper {
  20495. /**
  20496. * Bind the current view position to an effect.
  20497. * @param effect The effect to be bound
  20498. * @param scene The scene the eyes position is used from
  20499. * @param variableName name of the shader variable that will hold the eye position
  20500. */
  20501. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20502. /**
  20503. * Helps preparing the defines values about the UVs in used in the effect.
  20504. * UVs are shared as much as we can accross channels in the shaders.
  20505. * @param texture The texture we are preparing the UVs for
  20506. * @param defines The defines to update
  20507. * @param key The channel key "diffuse", "specular"... used in the shader
  20508. */
  20509. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20510. /**
  20511. * Binds a texture matrix value to its corrsponding uniform
  20512. * @param texture The texture to bind the matrix for
  20513. * @param uniformBuffer The uniform buffer receivin the data
  20514. * @param key The channel key "diffuse", "specular"... used in the shader
  20515. */
  20516. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20517. /**
  20518. * Gets the current status of the fog (should it be enabled?)
  20519. * @param mesh defines the mesh to evaluate for fog support
  20520. * @param scene defines the hosting scene
  20521. * @returns true if fog must be enabled
  20522. */
  20523. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20524. /**
  20525. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20526. * @param mesh defines the current mesh
  20527. * @param scene defines the current scene
  20528. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20529. * @param pointsCloud defines if point cloud rendering has to be turned on
  20530. * @param fogEnabled defines if fog has to be turned on
  20531. * @param alphaTest defines if alpha testing has to be turned on
  20532. * @param defines defines the current list of defines
  20533. */
  20534. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20535. /**
  20536. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20537. * @param scene defines the current scene
  20538. * @param engine defines the current engine
  20539. * @param defines specifies the list of active defines
  20540. * @param useInstances defines if instances have to be turned on
  20541. * @param useClipPlane defines if clip plane have to be turned on
  20542. * @param useInstances defines if instances have to be turned on
  20543. * @param useThinInstances defines if thin instances have to be turned on
  20544. */
  20545. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20546. /**
  20547. * Prepares the defines for bones
  20548. * @param mesh The mesh containing the geometry data we will draw
  20549. * @param defines The defines to update
  20550. */
  20551. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20552. /**
  20553. * Prepares the defines for morph targets
  20554. * @param mesh The mesh containing the geometry data we will draw
  20555. * @param defines The defines to update
  20556. */
  20557. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20558. /**
  20559. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20560. * @param mesh The mesh containing the geometry data we will draw
  20561. * @param defines The defines to update
  20562. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20563. * @param useBones Precise whether bones should be used or not (override mesh info)
  20564. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20565. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20566. * @returns false if defines are considered not dirty and have not been checked
  20567. */
  20568. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20569. /**
  20570. * Prepares the defines related to multiview
  20571. * @param scene The scene we are intending to draw
  20572. * @param defines The defines to update
  20573. */
  20574. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20575. /**
  20576. * Prepares the defines related to the light information passed in parameter
  20577. * @param scene The scene we are intending to draw
  20578. * @param mesh The mesh the effect is compiling for
  20579. * @param light The light the effect is compiling for
  20580. * @param lightIndex The index of the light
  20581. * @param defines The defines to update
  20582. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20583. * @param state Defines the current state regarding what is needed (normals, etc...)
  20584. */
  20585. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20586. needNormals: boolean;
  20587. needRebuild: boolean;
  20588. shadowEnabled: boolean;
  20589. specularEnabled: boolean;
  20590. lightmapMode: boolean;
  20591. }): void;
  20592. /**
  20593. * Prepares the defines related to the light information passed in parameter
  20594. * @param scene The scene we are intending to draw
  20595. * @param mesh The mesh the effect is compiling for
  20596. * @param defines The defines to update
  20597. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20598. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20599. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20600. * @returns true if normals will be required for the rest of the effect
  20601. */
  20602. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20603. /**
  20604. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20605. * @param lightIndex defines the light index
  20606. * @param uniformsList The uniform list
  20607. * @param samplersList The sampler list
  20608. * @param projectedLightTexture defines if projected texture must be used
  20609. * @param uniformBuffersList defines an optional list of uniform buffers
  20610. */
  20611. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20612. /**
  20613. * Prepares the uniforms and samplers list to be used in the effect
  20614. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20615. * @param samplersList The sampler list
  20616. * @param defines The defines helping in the list generation
  20617. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20618. */
  20619. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20620. /**
  20621. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20622. * @param defines The defines to update while falling back
  20623. * @param fallbacks The authorized effect fallbacks
  20624. * @param maxSimultaneousLights The maximum number of lights allowed
  20625. * @param rank the current rank of the Effect
  20626. * @returns The newly affected rank
  20627. */
  20628. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20629. private static _TmpMorphInfluencers;
  20630. /**
  20631. * Prepares the list of attributes required for morph targets according to the effect defines.
  20632. * @param attribs The current list of supported attribs
  20633. * @param mesh The mesh to prepare the morph targets attributes for
  20634. * @param influencers The number of influencers
  20635. */
  20636. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20637. /**
  20638. * Prepares the list of attributes required for morph targets according to the effect defines.
  20639. * @param attribs The current list of supported attribs
  20640. * @param mesh The mesh to prepare the morph targets attributes for
  20641. * @param defines The current Defines of the effect
  20642. */
  20643. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20644. /**
  20645. * Prepares the list of attributes required for bones according to the effect defines.
  20646. * @param attribs The current list of supported attribs
  20647. * @param mesh The mesh to prepare the bones attributes for
  20648. * @param defines The current Defines of the effect
  20649. * @param fallbacks The current efffect fallback strategy
  20650. */
  20651. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20652. /**
  20653. * Check and prepare the list of attributes required for instances according to the effect defines.
  20654. * @param attribs The current list of supported attribs
  20655. * @param defines The current MaterialDefines of the effect
  20656. */
  20657. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20658. /**
  20659. * Add the list of attributes required for instances to the attribs array.
  20660. * @param attribs The current list of supported attribs
  20661. */
  20662. static PushAttributesForInstances(attribs: string[]): void;
  20663. /**
  20664. * Binds the light information to the effect.
  20665. * @param light The light containing the generator
  20666. * @param effect The effect we are binding the data to
  20667. * @param lightIndex The light index in the effect used to render
  20668. */
  20669. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20670. /**
  20671. * Binds the lights information from the scene to the effect for the given mesh.
  20672. * @param light Light to bind
  20673. * @param lightIndex Light index
  20674. * @param scene The scene where the light belongs to
  20675. * @param effect The effect we are binding the data to
  20676. * @param useSpecular Defines if specular is supported
  20677. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20678. */
  20679. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20680. /**
  20681. * Binds the lights information from the scene to the effect for the given mesh.
  20682. * @param scene The scene the lights belongs to
  20683. * @param mesh The mesh we are binding the information to render
  20684. * @param effect The effect we are binding the data to
  20685. * @param defines The generated defines for the effect
  20686. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20687. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20688. */
  20689. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20690. private static _tempFogColor;
  20691. /**
  20692. * Binds the fog information from the scene to the effect for the given mesh.
  20693. * @param scene The scene the lights belongs to
  20694. * @param mesh The mesh we are binding the information to render
  20695. * @param effect The effect we are binding the data to
  20696. * @param linearSpace Defines if the fog effect is applied in linear space
  20697. */
  20698. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20699. /**
  20700. * Binds the bones information from the mesh to the effect.
  20701. * @param mesh The mesh we are binding the information to render
  20702. * @param effect The effect we are binding the data to
  20703. */
  20704. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20705. /**
  20706. * Binds the morph targets information from the mesh to the effect.
  20707. * @param abstractMesh The mesh we are binding the information to render
  20708. * @param effect The effect we are binding the data to
  20709. */
  20710. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20711. /**
  20712. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20713. * @param defines The generated defines used in the effect
  20714. * @param effect The effect we are binding the data to
  20715. * @param scene The scene we are willing to render with logarithmic scale for
  20716. */
  20717. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20718. /**
  20719. * Binds the clip plane information from the scene to the effect.
  20720. * @param scene The scene the clip plane information are extracted from
  20721. * @param effect The effect we are binding the data to
  20722. */
  20723. static BindClipPlane(effect: Effect, scene: Scene): void;
  20724. }
  20725. }
  20726. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20727. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20728. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20729. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20730. import { Nullable } from "babylonjs/types";
  20731. import { Effect } from "babylonjs/Materials/effect";
  20732. import { Matrix } from "babylonjs/Maths/math.vector";
  20733. import { Scene } from "babylonjs/scene";
  20734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20736. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20737. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20738. import { Observable } from "babylonjs/Misc/observable";
  20739. /**
  20740. * Block used to expose an input value
  20741. */
  20742. export class InputBlock extends NodeMaterialBlock {
  20743. private _mode;
  20744. private _associatedVariableName;
  20745. private _storedValue;
  20746. private _valueCallback;
  20747. private _type;
  20748. private _animationType;
  20749. /** Gets or set a value used to limit the range of float values */
  20750. min: number;
  20751. /** Gets or set a value used to limit the range of float values */
  20752. max: number;
  20753. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20754. isBoolean: boolean;
  20755. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20756. matrixMode: number;
  20757. /** @hidden */
  20758. _systemValue: Nullable<NodeMaterialSystemValues>;
  20759. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20760. visibleInInspector: boolean;
  20761. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20762. isConstant: boolean;
  20763. /** Gets or sets the group to use to display this block in the Inspector */
  20764. groupInInspector: string;
  20765. /** Gets an observable raised when the value is changed */
  20766. onValueChangedObservable: Observable<InputBlock>;
  20767. /**
  20768. * Gets or sets the connection point type (default is float)
  20769. */
  20770. get type(): NodeMaterialBlockConnectionPointTypes;
  20771. /**
  20772. * Creates a new InputBlock
  20773. * @param name defines the block name
  20774. * @param target defines the target of that block (Vertex by default)
  20775. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20776. */
  20777. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20778. /**
  20779. * Gets the output component
  20780. */
  20781. get output(): NodeMaterialConnectionPoint;
  20782. /**
  20783. * Set the source of this connection point to a vertex attribute
  20784. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20785. * @returns the current connection point
  20786. */
  20787. setAsAttribute(attributeName?: string): InputBlock;
  20788. /**
  20789. * Set the source of this connection point to a system value
  20790. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20791. * @returns the current connection point
  20792. */
  20793. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20794. /**
  20795. * Gets or sets the value of that point.
  20796. * Please note that this value will be ignored if valueCallback is defined
  20797. */
  20798. get value(): any;
  20799. set value(value: any);
  20800. /**
  20801. * Gets or sets a callback used to get the value of that point.
  20802. * Please note that setting this value will force the connection point to ignore the value property
  20803. */
  20804. get valueCallback(): () => any;
  20805. set valueCallback(value: () => any);
  20806. /**
  20807. * Gets or sets the associated variable name in the shader
  20808. */
  20809. get associatedVariableName(): string;
  20810. set associatedVariableName(value: string);
  20811. /** Gets or sets the type of animation applied to the input */
  20812. get animationType(): AnimatedInputBlockTypes;
  20813. set animationType(value: AnimatedInputBlockTypes);
  20814. /**
  20815. * Gets a boolean indicating that this connection point not defined yet
  20816. */
  20817. get isUndefined(): boolean;
  20818. /**
  20819. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20820. * In this case the connection point name must be the name of the uniform to use.
  20821. * Can only be set on inputs
  20822. */
  20823. get isUniform(): boolean;
  20824. set isUniform(value: boolean);
  20825. /**
  20826. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20827. * In this case the connection point name must be the name of the attribute to use
  20828. * Can only be set on inputs
  20829. */
  20830. get isAttribute(): boolean;
  20831. set isAttribute(value: boolean);
  20832. /**
  20833. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20834. * Can only be set on exit points
  20835. */
  20836. get isVarying(): boolean;
  20837. set isVarying(value: boolean);
  20838. /**
  20839. * Gets a boolean indicating that the current connection point is a system value
  20840. */
  20841. get isSystemValue(): boolean;
  20842. /**
  20843. * Gets or sets the current well known value or null if not defined as a system value
  20844. */
  20845. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20846. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20847. /**
  20848. * Gets the current class name
  20849. * @returns the class name
  20850. */
  20851. getClassName(): string;
  20852. /**
  20853. * Animate the input if animationType !== None
  20854. * @param scene defines the rendering scene
  20855. */
  20856. animate(scene: Scene): void;
  20857. private _emitDefine;
  20858. initialize(state: NodeMaterialBuildState): void;
  20859. /**
  20860. * Set the input block to its default value (based on its type)
  20861. */
  20862. setDefaultValue(): void;
  20863. private _emitConstant;
  20864. /** @hidden */
  20865. get _noContextSwitch(): boolean;
  20866. private _emit;
  20867. /** @hidden */
  20868. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20869. /** @hidden */
  20870. _transmit(effect: Effect, scene: Scene): void;
  20871. protected _buildBlock(state: NodeMaterialBuildState): void;
  20872. protected _dumpPropertiesCode(): string;
  20873. dispose(): void;
  20874. serialize(): any;
  20875. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20876. }
  20877. }
  20878. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20879. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20880. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20881. import { Nullable } from "babylonjs/types";
  20882. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20883. import { Observable } from "babylonjs/Misc/observable";
  20884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20885. /**
  20886. * Enum used to define the compatibility state between two connection points
  20887. */
  20888. export enum NodeMaterialConnectionPointCompatibilityStates {
  20889. /** Points are compatibles */
  20890. Compatible = 0,
  20891. /** Points are incompatible because of their types */
  20892. TypeIncompatible = 1,
  20893. /** Points are incompatible because of their targets (vertex vs fragment) */
  20894. TargetIncompatible = 2
  20895. }
  20896. /**
  20897. * Defines the direction of a connection point
  20898. */
  20899. export enum NodeMaterialConnectionPointDirection {
  20900. /** Input */
  20901. Input = 0,
  20902. /** Output */
  20903. Output = 1
  20904. }
  20905. /**
  20906. * Defines a connection point for a block
  20907. */
  20908. export class NodeMaterialConnectionPoint {
  20909. /** @hidden */
  20910. _ownerBlock: NodeMaterialBlock;
  20911. /** @hidden */
  20912. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20913. private _endpoints;
  20914. private _associatedVariableName;
  20915. private _direction;
  20916. /** @hidden */
  20917. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20918. /** @hidden */
  20919. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20920. private _type;
  20921. /** @hidden */
  20922. _enforceAssociatedVariableName: boolean;
  20923. /** Gets the direction of the point */
  20924. get direction(): NodeMaterialConnectionPointDirection;
  20925. /** Indicates that this connection point needs dual validation before being connected to another point */
  20926. needDualDirectionValidation: boolean;
  20927. /**
  20928. * Gets or sets the additional types supported by this connection point
  20929. */
  20930. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20931. /**
  20932. * Gets or sets the additional types excluded by this connection point
  20933. */
  20934. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20935. /**
  20936. * Observable triggered when this point is connected
  20937. */
  20938. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20939. /**
  20940. * Gets or sets the associated variable name in the shader
  20941. */
  20942. get associatedVariableName(): string;
  20943. set associatedVariableName(value: string);
  20944. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20945. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20946. /**
  20947. * Gets or sets the connection point type (default is float)
  20948. */
  20949. get type(): NodeMaterialBlockConnectionPointTypes;
  20950. set type(value: NodeMaterialBlockConnectionPointTypes);
  20951. /**
  20952. * Gets or sets the connection point name
  20953. */
  20954. name: string;
  20955. /**
  20956. * Gets or sets the connection point name
  20957. */
  20958. displayName: string;
  20959. /**
  20960. * Gets or sets a boolean indicating that this connection point can be omitted
  20961. */
  20962. isOptional: boolean;
  20963. /**
  20964. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20965. */
  20966. isExposedOnFrame: boolean;
  20967. /**
  20968. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20969. */
  20970. define: string;
  20971. /** @hidden */
  20972. _prioritizeVertex: boolean;
  20973. private _target;
  20974. /** Gets or sets the target of that connection point */
  20975. get target(): NodeMaterialBlockTargets;
  20976. set target(value: NodeMaterialBlockTargets);
  20977. /**
  20978. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20979. */
  20980. get isConnected(): boolean;
  20981. /**
  20982. * Gets a boolean indicating that the current point is connected to an input block
  20983. */
  20984. get isConnectedToInputBlock(): boolean;
  20985. /**
  20986. * Gets a the connected input block (if any)
  20987. */
  20988. get connectInputBlock(): Nullable<InputBlock>;
  20989. /** Get the other side of the connection (if any) */
  20990. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20991. /** Get the block that owns this connection point */
  20992. get ownerBlock(): NodeMaterialBlock;
  20993. /** Get the block connected on the other side of this connection (if any) */
  20994. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20995. /** Get the block connected on the endpoints of this connection (if any) */
  20996. get connectedBlocks(): Array<NodeMaterialBlock>;
  20997. /** Gets the list of connected endpoints */
  20998. get endpoints(): NodeMaterialConnectionPoint[];
  20999. /** Gets a boolean indicating if that output point is connected to at least one input */
  21000. get hasEndpoints(): boolean;
  21001. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21002. get isConnectedInVertexShader(): boolean;
  21003. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21004. get isConnectedInFragmentShader(): boolean;
  21005. /**
  21006. * Creates a block suitable to be used as an input for this input point.
  21007. * If null is returned, a block based on the point type will be created.
  21008. * @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
  21009. */
  21010. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21011. /**
  21012. * Creates a new connection point
  21013. * @param name defines the connection point name
  21014. * @param ownerBlock defines the block hosting this connection point
  21015. * @param direction defines the direction of the connection point
  21016. */
  21017. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21018. /**
  21019. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21020. * @returns the class name
  21021. */
  21022. getClassName(): string;
  21023. /**
  21024. * Gets a boolean indicating if the current point can be connected to another point
  21025. * @param connectionPoint defines the other connection point
  21026. * @returns a boolean
  21027. */
  21028. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21029. /**
  21030. * Gets a number indicating if the current point can be connected to another point
  21031. * @param connectionPoint defines the other connection point
  21032. * @returns a number defining the compatibility state
  21033. */
  21034. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21035. /**
  21036. * Connect this point to another connection point
  21037. * @param connectionPoint defines the other connection point
  21038. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21039. * @returns the current connection point
  21040. */
  21041. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21042. /**
  21043. * Disconnect this point from one of his endpoint
  21044. * @param endpoint defines the other connection point
  21045. * @returns the current connection point
  21046. */
  21047. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21048. /**
  21049. * Serializes this point in a JSON representation
  21050. * @param isInput defines if the connection point is an input (default is true)
  21051. * @returns the serialized point object
  21052. */
  21053. serialize(isInput?: boolean): any;
  21054. /**
  21055. * Release resources
  21056. */
  21057. dispose(): void;
  21058. }
  21059. }
  21060. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21061. /**
  21062. * Enum used to define the material modes
  21063. */
  21064. export enum NodeMaterialModes {
  21065. /** Regular material */
  21066. Material = 0,
  21067. /** For post process */
  21068. PostProcess = 1,
  21069. /** For particle system */
  21070. Particle = 2
  21071. }
  21072. }
  21073. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21076. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21079. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21080. import { Effect } from "babylonjs/Materials/effect";
  21081. import { Mesh } from "babylonjs/Meshes/mesh";
  21082. import { Nullable } from "babylonjs/types";
  21083. import { Texture } from "babylonjs/Materials/Textures/texture";
  21084. import { Scene } from "babylonjs/scene";
  21085. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21086. /**
  21087. * Block used to read a texture from a sampler
  21088. */
  21089. export class TextureBlock extends NodeMaterialBlock {
  21090. private _defineName;
  21091. private _linearDefineName;
  21092. private _gammaDefineName;
  21093. private _tempTextureRead;
  21094. private _samplerName;
  21095. private _transformedUVName;
  21096. private _textureTransformName;
  21097. private _textureInfoName;
  21098. private _mainUVName;
  21099. private _mainUVDefineName;
  21100. private _fragmentOnly;
  21101. /**
  21102. * Gets or sets the texture associated with the node
  21103. */
  21104. texture: Nullable<Texture>;
  21105. /**
  21106. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21107. */
  21108. convertToGammaSpace: boolean;
  21109. /**
  21110. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21111. */
  21112. convertToLinearSpace: boolean;
  21113. /**
  21114. * Create a new TextureBlock
  21115. * @param name defines the block name
  21116. */
  21117. constructor(name: string, fragmentOnly?: boolean);
  21118. /**
  21119. * Gets the current class name
  21120. * @returns the class name
  21121. */
  21122. getClassName(): string;
  21123. /**
  21124. * Gets the uv input component
  21125. */
  21126. get uv(): NodeMaterialConnectionPoint;
  21127. /**
  21128. * Gets the rgba output component
  21129. */
  21130. get rgba(): NodeMaterialConnectionPoint;
  21131. /**
  21132. * Gets the rgb output component
  21133. */
  21134. get rgb(): NodeMaterialConnectionPoint;
  21135. /**
  21136. * Gets the r output component
  21137. */
  21138. get r(): NodeMaterialConnectionPoint;
  21139. /**
  21140. * Gets the g output component
  21141. */
  21142. get g(): NodeMaterialConnectionPoint;
  21143. /**
  21144. * Gets the b output component
  21145. */
  21146. get b(): NodeMaterialConnectionPoint;
  21147. /**
  21148. * Gets the a output component
  21149. */
  21150. get a(): NodeMaterialConnectionPoint;
  21151. get target(): NodeMaterialBlockTargets;
  21152. autoConfigure(material: NodeMaterial): void;
  21153. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21154. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21155. isReady(): boolean;
  21156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21157. private get _isMixed();
  21158. private _injectVertexCode;
  21159. private _writeTextureRead;
  21160. private _writeOutput;
  21161. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21162. protected _dumpPropertiesCode(): string;
  21163. serialize(): any;
  21164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21165. }
  21166. }
  21167. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21168. /** @hidden */
  21169. export var reflectionFunction: {
  21170. name: string;
  21171. shader: string;
  21172. };
  21173. }
  21174. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21180. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21181. import { Effect } from "babylonjs/Materials/effect";
  21182. import { Mesh } from "babylonjs/Meshes/mesh";
  21183. import { Nullable } from "babylonjs/types";
  21184. import { Scene } from "babylonjs/scene";
  21185. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21186. /**
  21187. * Base block used to read a reflection texture from a sampler
  21188. */
  21189. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21190. /** @hidden */
  21191. _define3DName: string;
  21192. /** @hidden */
  21193. _defineCubicName: string;
  21194. /** @hidden */
  21195. _defineExplicitName: string;
  21196. /** @hidden */
  21197. _defineProjectionName: string;
  21198. /** @hidden */
  21199. _defineLocalCubicName: string;
  21200. /** @hidden */
  21201. _defineSphericalName: string;
  21202. /** @hidden */
  21203. _definePlanarName: string;
  21204. /** @hidden */
  21205. _defineEquirectangularName: string;
  21206. /** @hidden */
  21207. _defineMirroredEquirectangularFixedName: string;
  21208. /** @hidden */
  21209. _defineEquirectangularFixedName: string;
  21210. /** @hidden */
  21211. _defineSkyboxName: string;
  21212. /** @hidden */
  21213. _defineOppositeZ: string;
  21214. /** @hidden */
  21215. _cubeSamplerName: string;
  21216. /** @hidden */
  21217. _2DSamplerName: string;
  21218. protected _positionUVWName: string;
  21219. protected _directionWName: string;
  21220. protected _reflectionVectorName: string;
  21221. /** @hidden */
  21222. _reflectionCoordsName: string;
  21223. /** @hidden */
  21224. _reflectionMatrixName: string;
  21225. protected _reflectionColorName: string;
  21226. /**
  21227. * Gets or sets the texture associated with the node
  21228. */
  21229. texture: Nullable<BaseTexture>;
  21230. /**
  21231. * Create a new ReflectionTextureBaseBlock
  21232. * @param name defines the block name
  21233. */
  21234. constructor(name: string);
  21235. /**
  21236. * Gets the current class name
  21237. * @returns the class name
  21238. */
  21239. getClassName(): string;
  21240. /**
  21241. * Gets the world position input component
  21242. */
  21243. abstract get position(): NodeMaterialConnectionPoint;
  21244. /**
  21245. * Gets the world position input component
  21246. */
  21247. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21248. /**
  21249. * Gets the world normal input component
  21250. */
  21251. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21252. /**
  21253. * Gets the world input component
  21254. */
  21255. abstract get world(): NodeMaterialConnectionPoint;
  21256. /**
  21257. * Gets the camera (or eye) position component
  21258. */
  21259. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21260. /**
  21261. * Gets the view input component
  21262. */
  21263. abstract get view(): NodeMaterialConnectionPoint;
  21264. protected _getTexture(): Nullable<BaseTexture>;
  21265. autoConfigure(material: NodeMaterial): void;
  21266. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21267. isReady(): boolean;
  21268. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21269. /**
  21270. * Gets the code to inject in the vertex shader
  21271. * @param state current state of the node material building
  21272. * @returns the shader code
  21273. */
  21274. handleVertexSide(state: NodeMaterialBuildState): string;
  21275. /**
  21276. * Handles the inits for the fragment code path
  21277. * @param state node material build state
  21278. */
  21279. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21280. /**
  21281. * Generates the reflection coords code for the fragment code path
  21282. * @param worldNormalVarName name of the world normal variable
  21283. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21284. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21285. * @returns the shader code
  21286. */
  21287. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21288. /**
  21289. * Generates the reflection color code for the fragment code path
  21290. * @param lodVarName name of the lod variable
  21291. * @param swizzleLookupTexture swizzle to use for the final color variable
  21292. * @returns the shader code
  21293. */
  21294. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21295. /**
  21296. * Generates the code corresponding to the connected output points
  21297. * @param state node material build state
  21298. * @param varName name of the variable to output
  21299. * @returns the shader code
  21300. */
  21301. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21302. protected _buildBlock(state: NodeMaterialBuildState): this;
  21303. protected _dumpPropertiesCode(): string;
  21304. serialize(): any;
  21305. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21306. }
  21307. }
  21308. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21309. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21310. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21311. import { Nullable } from "babylonjs/types";
  21312. /**
  21313. * Defines a connection point to be used for points with a custom object type
  21314. */
  21315. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21316. private _blockType;
  21317. private _blockName;
  21318. private _nameForCheking?;
  21319. /**
  21320. * Creates a new connection point
  21321. * @param name defines the connection point name
  21322. * @param ownerBlock defines the block hosting this connection point
  21323. * @param direction defines the direction of the connection point
  21324. */
  21325. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21326. /**
  21327. * Gets a number indicating if the current point can be connected to another point
  21328. * @param connectionPoint defines the other connection point
  21329. * @returns a number defining the compatibility state
  21330. */
  21331. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21332. /**
  21333. * Creates a block suitable to be used as an input for this input point.
  21334. * If null is returned, a block based on the point type will be created.
  21335. * @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
  21336. */
  21337. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21338. }
  21339. }
  21340. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21341. /**
  21342. * Enum defining the type of properties that can be edited in the property pages in the NME
  21343. */
  21344. export enum PropertyTypeForEdition {
  21345. /** property is a boolean */
  21346. Boolean = 0,
  21347. /** property is a float */
  21348. Float = 1,
  21349. /** property is a Vector2 */
  21350. Vector2 = 2,
  21351. /** property is a list of values */
  21352. List = 3
  21353. }
  21354. /**
  21355. * Interface that defines an option in a variable of type list
  21356. */
  21357. export interface IEditablePropertyListOption {
  21358. /** label of the option */
  21359. "label": string;
  21360. /** value of the option */
  21361. "value": number;
  21362. }
  21363. /**
  21364. * Interface that defines the options available for an editable property
  21365. */
  21366. export interface IEditablePropertyOption {
  21367. /** min value */
  21368. "min"?: number;
  21369. /** max value */
  21370. "max"?: number;
  21371. /** notifiers: indicates which actions to take when the property is changed */
  21372. "notifiers"?: {
  21373. /** the material should be rebuilt */
  21374. "rebuild"?: boolean;
  21375. /** the preview should be updated */
  21376. "update"?: boolean;
  21377. };
  21378. /** list of the options for a variable of type list */
  21379. "options"?: IEditablePropertyListOption[];
  21380. }
  21381. /**
  21382. * Interface that describes an editable property
  21383. */
  21384. export interface IPropertyDescriptionForEdition {
  21385. /** name of the property */
  21386. "propertyName": string;
  21387. /** display name of the property */
  21388. "displayName": string;
  21389. /** type of the property */
  21390. "type": PropertyTypeForEdition;
  21391. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21392. "groupName": string;
  21393. /** options for the property */
  21394. "options": IEditablePropertyOption;
  21395. }
  21396. /**
  21397. * Decorator that flags a property in a node material block as being editable
  21398. */
  21399. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21400. }
  21401. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21404. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21406. import { Nullable } from "babylonjs/types";
  21407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21408. import { Mesh } from "babylonjs/Meshes/mesh";
  21409. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21410. import { Effect } from "babylonjs/Materials/effect";
  21411. import { Scene } from "babylonjs/scene";
  21412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21413. /**
  21414. * Block used to implement the refraction part of the sub surface module of the PBR material
  21415. */
  21416. export class RefractionBlock extends NodeMaterialBlock {
  21417. /** @hidden */
  21418. _define3DName: string;
  21419. /** @hidden */
  21420. _refractionMatrixName: string;
  21421. /** @hidden */
  21422. _defineLODRefractionAlpha: string;
  21423. /** @hidden */
  21424. _defineLinearSpecularRefraction: string;
  21425. /** @hidden */
  21426. _defineOppositeZ: string;
  21427. /** @hidden */
  21428. _cubeSamplerName: string;
  21429. /** @hidden */
  21430. _2DSamplerName: string;
  21431. /** @hidden */
  21432. _vRefractionMicrosurfaceInfosName: string;
  21433. /** @hidden */
  21434. _vRefractionInfosName: string;
  21435. private _scene;
  21436. /**
  21437. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21438. * Materials half opaque for instance using refraction could benefit from this control.
  21439. */
  21440. linkRefractionWithTransparency: boolean;
  21441. /**
  21442. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21443. */
  21444. invertRefractionY: boolean;
  21445. /**
  21446. * Gets or sets the texture associated with the node
  21447. */
  21448. texture: Nullable<BaseTexture>;
  21449. /**
  21450. * Create a new RefractionBlock
  21451. * @param name defines the block name
  21452. */
  21453. constructor(name: string);
  21454. /**
  21455. * Gets the current class name
  21456. * @returns the class name
  21457. */
  21458. getClassName(): string;
  21459. /**
  21460. * Gets the intensity input component
  21461. */
  21462. get intensity(): NodeMaterialConnectionPoint;
  21463. /**
  21464. * Gets the index of refraction input component
  21465. */
  21466. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21467. /**
  21468. * Gets the tint at distance input component
  21469. */
  21470. get tintAtDistance(): NodeMaterialConnectionPoint;
  21471. /**
  21472. * Gets the view input component
  21473. */
  21474. get view(): NodeMaterialConnectionPoint;
  21475. /**
  21476. * Gets the refraction object output component
  21477. */
  21478. get refraction(): NodeMaterialConnectionPoint;
  21479. /**
  21480. * Returns true if the block has a texture
  21481. */
  21482. get hasTexture(): boolean;
  21483. protected _getTexture(): Nullable<BaseTexture>;
  21484. autoConfigure(material: NodeMaterial): void;
  21485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21486. isReady(): boolean;
  21487. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21488. /**
  21489. * Gets the main code of the block (fragment side)
  21490. * @param state current state of the node material building
  21491. * @returns the shader code
  21492. */
  21493. getCode(state: NodeMaterialBuildState): string;
  21494. protected _buildBlock(state: NodeMaterialBuildState): this;
  21495. protected _dumpPropertiesCode(): string;
  21496. serialize(): any;
  21497. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21498. }
  21499. }
  21500. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21501. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21502. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21503. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21506. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21508. import { Nullable } from "babylonjs/types";
  21509. import { Scene } from "babylonjs/scene";
  21510. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21511. /**
  21512. * Base block used as input for post process
  21513. */
  21514. export class CurrentScreenBlock extends NodeMaterialBlock {
  21515. private _samplerName;
  21516. private _linearDefineName;
  21517. private _gammaDefineName;
  21518. private _mainUVName;
  21519. private _tempTextureRead;
  21520. /**
  21521. * Gets or sets the texture associated with the node
  21522. */
  21523. texture: Nullable<BaseTexture>;
  21524. /**
  21525. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21526. */
  21527. convertToGammaSpace: boolean;
  21528. /**
  21529. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21530. */
  21531. convertToLinearSpace: boolean;
  21532. /**
  21533. * Create a new CurrentScreenBlock
  21534. * @param name defines the block name
  21535. */
  21536. constructor(name: string);
  21537. /**
  21538. * Gets the current class name
  21539. * @returns the class name
  21540. */
  21541. getClassName(): string;
  21542. /**
  21543. * Gets the uv input component
  21544. */
  21545. get uv(): NodeMaterialConnectionPoint;
  21546. /**
  21547. * Gets the rgba output component
  21548. */
  21549. get rgba(): NodeMaterialConnectionPoint;
  21550. /**
  21551. * Gets the rgb output component
  21552. */
  21553. get rgb(): NodeMaterialConnectionPoint;
  21554. /**
  21555. * Gets the r output component
  21556. */
  21557. get r(): NodeMaterialConnectionPoint;
  21558. /**
  21559. * Gets the g output component
  21560. */
  21561. get g(): NodeMaterialConnectionPoint;
  21562. /**
  21563. * Gets the b output component
  21564. */
  21565. get b(): NodeMaterialConnectionPoint;
  21566. /**
  21567. * Gets the a output component
  21568. */
  21569. get a(): NodeMaterialConnectionPoint;
  21570. /**
  21571. * Initialize the block and prepare the context for build
  21572. * @param state defines the state that will be used for the build
  21573. */
  21574. initialize(state: NodeMaterialBuildState): void;
  21575. get target(): NodeMaterialBlockTargets;
  21576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21577. isReady(): boolean;
  21578. private _injectVertexCode;
  21579. private _writeTextureRead;
  21580. private _writeOutput;
  21581. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21582. serialize(): any;
  21583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21584. }
  21585. }
  21586. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21590. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21591. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21592. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21593. import { Nullable } from "babylonjs/types";
  21594. import { Scene } from "babylonjs/scene";
  21595. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21596. /**
  21597. * Base block used for the particle texture
  21598. */
  21599. export class ParticleTextureBlock extends NodeMaterialBlock {
  21600. private _samplerName;
  21601. private _linearDefineName;
  21602. private _gammaDefineName;
  21603. private _tempTextureRead;
  21604. /**
  21605. * Gets or sets the texture associated with the node
  21606. */
  21607. texture: Nullable<BaseTexture>;
  21608. /**
  21609. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21610. */
  21611. convertToGammaSpace: boolean;
  21612. /**
  21613. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21614. */
  21615. convertToLinearSpace: boolean;
  21616. /**
  21617. * Create a new ParticleTextureBlock
  21618. * @param name defines the block name
  21619. */
  21620. constructor(name: string);
  21621. /**
  21622. * Gets the current class name
  21623. * @returns the class name
  21624. */
  21625. getClassName(): string;
  21626. /**
  21627. * Gets the uv input component
  21628. */
  21629. get uv(): NodeMaterialConnectionPoint;
  21630. /**
  21631. * Gets the rgba output component
  21632. */
  21633. get rgba(): NodeMaterialConnectionPoint;
  21634. /**
  21635. * Gets the rgb output component
  21636. */
  21637. get rgb(): NodeMaterialConnectionPoint;
  21638. /**
  21639. * Gets the r output component
  21640. */
  21641. get r(): NodeMaterialConnectionPoint;
  21642. /**
  21643. * Gets the g output component
  21644. */
  21645. get g(): NodeMaterialConnectionPoint;
  21646. /**
  21647. * Gets the b output component
  21648. */
  21649. get b(): NodeMaterialConnectionPoint;
  21650. /**
  21651. * Gets the a output component
  21652. */
  21653. get a(): NodeMaterialConnectionPoint;
  21654. /**
  21655. * Initialize the block and prepare the context for build
  21656. * @param state defines the state that will be used for the build
  21657. */
  21658. initialize(state: NodeMaterialBuildState): void;
  21659. autoConfigure(material: NodeMaterial): void;
  21660. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21661. isReady(): boolean;
  21662. private _writeOutput;
  21663. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21664. serialize(): any;
  21665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21666. }
  21667. }
  21668. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21669. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21671. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21672. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21673. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21674. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21675. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21676. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21677. import { Scene } from "babylonjs/scene";
  21678. /**
  21679. * Class used to store shared data between 2 NodeMaterialBuildState
  21680. */
  21681. export class NodeMaterialBuildStateSharedData {
  21682. /**
  21683. * Gets the list of emitted varyings
  21684. */
  21685. temps: string[];
  21686. /**
  21687. * Gets the list of emitted varyings
  21688. */
  21689. varyings: string[];
  21690. /**
  21691. * Gets the varying declaration string
  21692. */
  21693. varyingDeclaration: string;
  21694. /**
  21695. * Input blocks
  21696. */
  21697. inputBlocks: InputBlock[];
  21698. /**
  21699. * Input blocks
  21700. */
  21701. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21702. /**
  21703. * Bindable blocks (Blocks that need to set data to the effect)
  21704. */
  21705. bindableBlocks: NodeMaterialBlock[];
  21706. /**
  21707. * List of blocks that can provide a compilation fallback
  21708. */
  21709. blocksWithFallbacks: NodeMaterialBlock[];
  21710. /**
  21711. * List of blocks that can provide a define update
  21712. */
  21713. blocksWithDefines: NodeMaterialBlock[];
  21714. /**
  21715. * List of blocks that can provide a repeatable content
  21716. */
  21717. repeatableContentBlocks: NodeMaterialBlock[];
  21718. /**
  21719. * List of blocks that can provide a dynamic list of uniforms
  21720. */
  21721. dynamicUniformBlocks: NodeMaterialBlock[];
  21722. /**
  21723. * List of blocks that can block the isReady function for the material
  21724. */
  21725. blockingBlocks: NodeMaterialBlock[];
  21726. /**
  21727. * Gets the list of animated inputs
  21728. */
  21729. animatedInputs: InputBlock[];
  21730. /**
  21731. * Build Id used to avoid multiple recompilations
  21732. */
  21733. buildId: number;
  21734. /** List of emitted variables */
  21735. variableNames: {
  21736. [key: string]: number;
  21737. };
  21738. /** List of emitted defines */
  21739. defineNames: {
  21740. [key: string]: number;
  21741. };
  21742. /** Should emit comments? */
  21743. emitComments: boolean;
  21744. /** Emit build activity */
  21745. verbose: boolean;
  21746. /** Gets or sets the hosting scene */
  21747. scene: Scene;
  21748. /**
  21749. * Gets the compilation hints emitted at compilation time
  21750. */
  21751. hints: {
  21752. needWorldViewMatrix: boolean;
  21753. needWorldViewProjectionMatrix: boolean;
  21754. needAlphaBlending: boolean;
  21755. needAlphaTesting: boolean;
  21756. };
  21757. /**
  21758. * List of compilation checks
  21759. */
  21760. checks: {
  21761. emitVertex: boolean;
  21762. emitFragment: boolean;
  21763. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21764. };
  21765. /**
  21766. * Is vertex program allowed to be empty?
  21767. */
  21768. allowEmptyVertexProgram: boolean;
  21769. /** Creates a new shared data */
  21770. constructor();
  21771. /**
  21772. * Emits console errors and exceptions if there is a failing check
  21773. */
  21774. emitErrors(): void;
  21775. }
  21776. }
  21777. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21778. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21779. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21780. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21781. /**
  21782. * Class used to store node based material build state
  21783. */
  21784. export class NodeMaterialBuildState {
  21785. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21786. supportUniformBuffers: boolean;
  21787. /**
  21788. * Gets the list of emitted attributes
  21789. */
  21790. attributes: string[];
  21791. /**
  21792. * Gets the list of emitted uniforms
  21793. */
  21794. uniforms: string[];
  21795. /**
  21796. * Gets the list of emitted constants
  21797. */
  21798. constants: string[];
  21799. /**
  21800. * Gets the list of emitted samplers
  21801. */
  21802. samplers: string[];
  21803. /**
  21804. * Gets the list of emitted functions
  21805. */
  21806. functions: {
  21807. [key: string]: string;
  21808. };
  21809. /**
  21810. * Gets the list of emitted extensions
  21811. */
  21812. extensions: {
  21813. [key: string]: string;
  21814. };
  21815. /**
  21816. * Gets the target of the compilation state
  21817. */
  21818. target: NodeMaterialBlockTargets;
  21819. /**
  21820. * Gets the list of emitted counters
  21821. */
  21822. counters: {
  21823. [key: string]: number;
  21824. };
  21825. /**
  21826. * Shared data between multiple NodeMaterialBuildState instances
  21827. */
  21828. sharedData: NodeMaterialBuildStateSharedData;
  21829. /** @hidden */
  21830. _vertexState: NodeMaterialBuildState;
  21831. /** @hidden */
  21832. _attributeDeclaration: string;
  21833. /** @hidden */
  21834. _uniformDeclaration: string;
  21835. /** @hidden */
  21836. _constantDeclaration: string;
  21837. /** @hidden */
  21838. _samplerDeclaration: string;
  21839. /** @hidden */
  21840. _varyingTransfer: string;
  21841. /** @hidden */
  21842. _injectAtEnd: string;
  21843. private _repeatableContentAnchorIndex;
  21844. /** @hidden */
  21845. _builtCompilationString: string;
  21846. /**
  21847. * Gets the emitted compilation strings
  21848. */
  21849. compilationString: string;
  21850. /**
  21851. * Finalize the compilation strings
  21852. * @param state defines the current compilation state
  21853. */
  21854. finalize(state: NodeMaterialBuildState): void;
  21855. /** @hidden */
  21856. get _repeatableContentAnchor(): string;
  21857. /** @hidden */
  21858. _getFreeVariableName(prefix: string): string;
  21859. /** @hidden */
  21860. _getFreeDefineName(prefix: string): string;
  21861. /** @hidden */
  21862. _excludeVariableName(name: string): void;
  21863. /** @hidden */
  21864. _emit2DSampler(name: string): void;
  21865. /** @hidden */
  21866. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21867. /** @hidden */
  21868. _emitExtension(name: string, extension: string, define?: string): void;
  21869. /** @hidden */
  21870. _emitFunction(name: string, code: string, comments: string): void;
  21871. /** @hidden */
  21872. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21873. replaceStrings?: {
  21874. search: RegExp;
  21875. replace: string;
  21876. }[];
  21877. repeatKey?: string;
  21878. }): string;
  21879. /** @hidden */
  21880. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21881. repeatKey?: string;
  21882. removeAttributes?: boolean;
  21883. removeUniforms?: boolean;
  21884. removeVaryings?: boolean;
  21885. removeIfDef?: boolean;
  21886. replaceStrings?: {
  21887. search: RegExp;
  21888. replace: string;
  21889. }[];
  21890. }, storeKey?: string): void;
  21891. /** @hidden */
  21892. _registerTempVariable(name: string): boolean;
  21893. /** @hidden */
  21894. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21895. /** @hidden */
  21896. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21897. /** @hidden */
  21898. _emitFloat(value: number): string;
  21899. }
  21900. }
  21901. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21902. /**
  21903. * Helper class used to generate session unique ID
  21904. */
  21905. export class UniqueIdGenerator {
  21906. private static _UniqueIdCounter;
  21907. /**
  21908. * Gets an unique (relatively to the current scene) Id
  21909. */
  21910. static get UniqueId(): number;
  21911. }
  21912. }
  21913. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21914. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21915. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21916. import { Nullable } from "babylonjs/types";
  21917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21918. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21919. import { Effect } from "babylonjs/Materials/effect";
  21920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21921. import { Mesh } from "babylonjs/Meshes/mesh";
  21922. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21923. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21924. import { Scene } from "babylonjs/scene";
  21925. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21926. /**
  21927. * Defines a block that can be used inside a node based material
  21928. */
  21929. export class NodeMaterialBlock {
  21930. private _buildId;
  21931. private _buildTarget;
  21932. private _target;
  21933. private _isFinalMerger;
  21934. private _isInput;
  21935. protected _isUnique: boolean;
  21936. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21937. inputsAreExclusive: boolean;
  21938. /** @hidden */
  21939. _codeVariableName: string;
  21940. /** @hidden */
  21941. _inputs: NodeMaterialConnectionPoint[];
  21942. /** @hidden */
  21943. _outputs: NodeMaterialConnectionPoint[];
  21944. /** @hidden */
  21945. _preparationId: number;
  21946. /**
  21947. * Gets or sets the name of the block
  21948. */
  21949. name: string;
  21950. /**
  21951. * Gets or sets the unique id of the node
  21952. */
  21953. uniqueId: number;
  21954. /**
  21955. * Gets or sets the comments associated with this block
  21956. */
  21957. comments: string;
  21958. /**
  21959. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21960. */
  21961. get isUnique(): boolean;
  21962. /**
  21963. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21964. */
  21965. get isFinalMerger(): boolean;
  21966. /**
  21967. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21968. */
  21969. get isInput(): boolean;
  21970. /**
  21971. * Gets or sets the build Id
  21972. */
  21973. get buildId(): number;
  21974. set buildId(value: number);
  21975. /**
  21976. * Gets or sets the target of the block
  21977. */
  21978. get target(): NodeMaterialBlockTargets;
  21979. set target(value: NodeMaterialBlockTargets);
  21980. /**
  21981. * Gets the list of input points
  21982. */
  21983. get inputs(): NodeMaterialConnectionPoint[];
  21984. /** Gets the list of output points */
  21985. get outputs(): NodeMaterialConnectionPoint[];
  21986. /**
  21987. * Find an input by its name
  21988. * @param name defines the name of the input to look for
  21989. * @returns the input or null if not found
  21990. */
  21991. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21992. /**
  21993. * Find an output by its name
  21994. * @param name defines the name of the outputto look for
  21995. * @returns the output or null if not found
  21996. */
  21997. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21998. /**
  21999. * Creates a new NodeMaterialBlock
  22000. * @param name defines the block name
  22001. * @param target defines the target of that block (Vertex by default)
  22002. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22003. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22004. */
  22005. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22006. /**
  22007. * Initialize the block and prepare the context for build
  22008. * @param state defines the state that will be used for the build
  22009. */
  22010. initialize(state: NodeMaterialBuildState): void;
  22011. /**
  22012. * Bind data to effect. Will only be called for blocks with isBindable === true
  22013. * @param effect defines the effect to bind data to
  22014. * @param nodeMaterial defines the hosting NodeMaterial
  22015. * @param mesh defines the mesh that will be rendered
  22016. * @param subMesh defines the submesh that will be rendered
  22017. */
  22018. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22019. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22020. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22021. protected _writeFloat(value: number): string;
  22022. /**
  22023. * Gets the current class name e.g. "NodeMaterialBlock"
  22024. * @returns the class name
  22025. */
  22026. getClassName(): string;
  22027. /**
  22028. * Register a new input. Must be called inside a block constructor
  22029. * @param name defines the connection point name
  22030. * @param type defines the connection point type
  22031. * @param isOptional defines a boolean indicating that this input can be omitted
  22032. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22033. * @param point an already created connection point. If not provided, create a new one
  22034. * @returns the current block
  22035. */
  22036. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22037. /**
  22038. * Register a new output. Must be called inside a block constructor
  22039. * @param name defines the connection point name
  22040. * @param type defines the connection point type
  22041. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22042. * @param point an already created connection point. If not provided, create a new one
  22043. * @returns the current block
  22044. */
  22045. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22046. /**
  22047. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22048. * @param forOutput defines an optional connection point to check compatibility with
  22049. * @returns the first available input or null
  22050. */
  22051. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22052. /**
  22053. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22054. * @param forBlock defines an optional block to check compatibility with
  22055. * @returns the first available input or null
  22056. */
  22057. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22058. /**
  22059. * Gets the sibling of the given output
  22060. * @param current defines the current output
  22061. * @returns the next output in the list or null
  22062. */
  22063. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22064. /**
  22065. * Connect current block with another block
  22066. * @param other defines the block to connect with
  22067. * @param options define the various options to help pick the right connections
  22068. * @returns the current block
  22069. */
  22070. connectTo(other: NodeMaterialBlock, options?: {
  22071. input?: string;
  22072. output?: string;
  22073. outputSwizzle?: string;
  22074. }): this | undefined;
  22075. protected _buildBlock(state: NodeMaterialBuildState): void;
  22076. /**
  22077. * Add uniforms, samplers and uniform buffers at compilation time
  22078. * @param state defines the state to update
  22079. * @param nodeMaterial defines the node material requesting the update
  22080. * @param defines defines the material defines to update
  22081. * @param uniformBuffers defines the list of uniform buffer names
  22082. */
  22083. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22084. /**
  22085. * Add potential fallbacks if shader compilation fails
  22086. * @param mesh defines the mesh to be rendered
  22087. * @param fallbacks defines the current prioritized list of fallbacks
  22088. */
  22089. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22090. /**
  22091. * Initialize defines for shader compilation
  22092. * @param mesh defines the mesh to be rendered
  22093. * @param nodeMaterial defines the node material requesting the update
  22094. * @param defines defines the material defines to update
  22095. * @param useInstances specifies that instances should be used
  22096. */
  22097. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22098. /**
  22099. * Update defines for shader compilation
  22100. * @param mesh defines the mesh to be rendered
  22101. * @param nodeMaterial defines the node material requesting the update
  22102. * @param defines defines the material defines to update
  22103. * @param useInstances specifies that instances should be used
  22104. * @param subMesh defines which submesh to render
  22105. */
  22106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22107. /**
  22108. * Lets the block try to connect some inputs automatically
  22109. * @param material defines the hosting NodeMaterial
  22110. */
  22111. autoConfigure(material: NodeMaterial): void;
  22112. /**
  22113. * Function called when a block is declared as repeatable content generator
  22114. * @param vertexShaderState defines the current compilation state for the vertex shader
  22115. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22116. * @param mesh defines the mesh to be rendered
  22117. * @param defines defines the material defines to update
  22118. */
  22119. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22120. /**
  22121. * Checks if the block is ready
  22122. * @param mesh defines the mesh to be rendered
  22123. * @param nodeMaterial defines the node material requesting the update
  22124. * @param defines defines the material defines to update
  22125. * @param useInstances specifies that instances should be used
  22126. * @returns true if the block is ready
  22127. */
  22128. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22129. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22130. private _processBuild;
  22131. /**
  22132. * Compile the current node and generate the shader code
  22133. * @param state defines the current compilation state (uniforms, samplers, current string)
  22134. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22135. * @returns true if already built
  22136. */
  22137. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22138. protected _inputRename(name: string): string;
  22139. protected _outputRename(name: string): string;
  22140. protected _dumpPropertiesCode(): string;
  22141. /** @hidden */
  22142. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22143. /** @hidden */
  22144. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22145. /**
  22146. * Clone the current block to a new identical block
  22147. * @param scene defines the hosting scene
  22148. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22149. * @returns a copy of the current block
  22150. */
  22151. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22152. /**
  22153. * Serializes this block in a JSON representation
  22154. * @returns the serialized block object
  22155. */
  22156. serialize(): any;
  22157. /** @hidden */
  22158. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22159. private _deserializePortDisplayNamesAndExposedOnFrame;
  22160. /**
  22161. * Release resources
  22162. */
  22163. dispose(): void;
  22164. }
  22165. }
  22166. declare module "babylonjs/Materials/pushMaterial" {
  22167. import { Nullable } from "babylonjs/types";
  22168. import { Scene } from "babylonjs/scene";
  22169. import { Matrix } from "babylonjs/Maths/math.vector";
  22170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22171. import { Mesh } from "babylonjs/Meshes/mesh";
  22172. import { Material } from "babylonjs/Materials/material";
  22173. import { Effect } from "babylonjs/Materials/effect";
  22174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22175. /**
  22176. * Base class of materials working in push mode in babylon JS
  22177. * @hidden
  22178. */
  22179. export class PushMaterial extends Material {
  22180. protected _activeEffect: Effect;
  22181. protected _normalMatrix: Matrix;
  22182. constructor(name: string, scene: Scene);
  22183. getEffect(): Effect;
  22184. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22185. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22186. /**
  22187. * Binds the given world matrix to the active effect
  22188. *
  22189. * @param world the matrix to bind
  22190. */
  22191. bindOnlyWorldMatrix(world: Matrix): void;
  22192. /**
  22193. * Binds the given normal matrix to the active effect
  22194. *
  22195. * @param normalMatrix the matrix to bind
  22196. */
  22197. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22198. bind(world: Matrix, mesh?: Mesh): void;
  22199. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22200. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22201. }
  22202. }
  22203. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22204. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22205. /**
  22206. * Root class for all node material optimizers
  22207. */
  22208. export class NodeMaterialOptimizer {
  22209. /**
  22210. * Function used to optimize a NodeMaterial graph
  22211. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22212. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22213. */
  22214. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22215. }
  22216. }
  22217. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22219. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22220. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22221. import { Scene } from "babylonjs/scene";
  22222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22223. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22224. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22225. /**
  22226. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22227. */
  22228. export class TransformBlock extends NodeMaterialBlock {
  22229. /**
  22230. * Defines the value to use to complement W value to transform it to a Vector4
  22231. */
  22232. complementW: number;
  22233. /**
  22234. * Defines the value to use to complement z value to transform it to a Vector4
  22235. */
  22236. complementZ: number;
  22237. /**
  22238. * Creates a new TransformBlock
  22239. * @param name defines the block name
  22240. */
  22241. constructor(name: string);
  22242. /**
  22243. * Gets the current class name
  22244. * @returns the class name
  22245. */
  22246. getClassName(): string;
  22247. /**
  22248. * Gets the vector input
  22249. */
  22250. get vector(): NodeMaterialConnectionPoint;
  22251. /**
  22252. * Gets the output component
  22253. */
  22254. get output(): NodeMaterialConnectionPoint;
  22255. /**
  22256. * Gets the xyz output component
  22257. */
  22258. get xyz(): NodeMaterialConnectionPoint;
  22259. /**
  22260. * Gets the matrix transform input
  22261. */
  22262. get transform(): NodeMaterialConnectionPoint;
  22263. protected _buildBlock(state: NodeMaterialBuildState): this;
  22264. /**
  22265. * Update defines for shader compilation
  22266. * @param mesh defines the mesh to be rendered
  22267. * @param nodeMaterial defines the node material requesting the update
  22268. * @param defines defines the material defines to update
  22269. * @param useInstances specifies that instances should be used
  22270. * @param subMesh defines which submesh to render
  22271. */
  22272. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22273. serialize(): any;
  22274. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22275. protected _dumpPropertiesCode(): string;
  22276. }
  22277. }
  22278. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22282. /**
  22283. * Block used to output the vertex position
  22284. */
  22285. export class VertexOutputBlock extends NodeMaterialBlock {
  22286. /**
  22287. * Creates a new VertexOutputBlock
  22288. * @param name defines the block name
  22289. */
  22290. constructor(name: string);
  22291. /**
  22292. * Gets the current class name
  22293. * @returns the class name
  22294. */
  22295. getClassName(): string;
  22296. /**
  22297. * Gets the vector input component
  22298. */
  22299. get vector(): NodeMaterialConnectionPoint;
  22300. protected _buildBlock(state: NodeMaterialBuildState): this;
  22301. }
  22302. }
  22303. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22304. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22305. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22306. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22307. /**
  22308. * Block used to output the final color
  22309. */
  22310. export class FragmentOutputBlock extends NodeMaterialBlock {
  22311. /**
  22312. * Create a new FragmentOutputBlock
  22313. * @param name defines the block name
  22314. */
  22315. constructor(name: string);
  22316. /**
  22317. * Gets the current class name
  22318. * @returns the class name
  22319. */
  22320. getClassName(): string;
  22321. /**
  22322. * Gets the rgba input component
  22323. */
  22324. get rgba(): NodeMaterialConnectionPoint;
  22325. /**
  22326. * Gets the rgb input component
  22327. */
  22328. get rgb(): NodeMaterialConnectionPoint;
  22329. /**
  22330. * Gets the a input component
  22331. */
  22332. get a(): NodeMaterialConnectionPoint;
  22333. protected _buildBlock(state: NodeMaterialBuildState): this;
  22334. }
  22335. }
  22336. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22340. /**
  22341. * Block used for the particle ramp gradient section
  22342. */
  22343. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22344. /**
  22345. * Create a new ParticleRampGradientBlock
  22346. * @param name defines the block name
  22347. */
  22348. constructor(name: string);
  22349. /**
  22350. * Gets the current class name
  22351. * @returns the class name
  22352. */
  22353. getClassName(): string;
  22354. /**
  22355. * Gets the color input component
  22356. */
  22357. get color(): NodeMaterialConnectionPoint;
  22358. /**
  22359. * Gets the rampColor output component
  22360. */
  22361. get rampColor(): NodeMaterialConnectionPoint;
  22362. /**
  22363. * Initialize the block and prepare the context for build
  22364. * @param state defines the state that will be used for the build
  22365. */
  22366. initialize(state: NodeMaterialBuildState): void;
  22367. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22368. }
  22369. }
  22370. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22374. /**
  22375. * Block used for the particle blend multiply section
  22376. */
  22377. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22378. /**
  22379. * Create a new ParticleBlendMultiplyBlock
  22380. * @param name defines the block name
  22381. */
  22382. constructor(name: string);
  22383. /**
  22384. * Gets the current class name
  22385. * @returns the class name
  22386. */
  22387. getClassName(): string;
  22388. /**
  22389. * Gets the color input component
  22390. */
  22391. get color(): NodeMaterialConnectionPoint;
  22392. /**
  22393. * Gets the alphaTexture input component
  22394. */
  22395. get alphaTexture(): NodeMaterialConnectionPoint;
  22396. /**
  22397. * Gets the alphaColor input component
  22398. */
  22399. get alphaColor(): NodeMaterialConnectionPoint;
  22400. /**
  22401. * Gets the blendColor output component
  22402. */
  22403. get blendColor(): NodeMaterialConnectionPoint;
  22404. /**
  22405. * Initialize the block and prepare the context for build
  22406. * @param state defines the state that will be used for the build
  22407. */
  22408. initialize(state: NodeMaterialBuildState): void;
  22409. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22410. }
  22411. }
  22412. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22416. /**
  22417. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22418. */
  22419. export class VectorMergerBlock extends NodeMaterialBlock {
  22420. /**
  22421. * Create a new VectorMergerBlock
  22422. * @param name defines the block name
  22423. */
  22424. constructor(name: string);
  22425. /**
  22426. * Gets the current class name
  22427. * @returns the class name
  22428. */
  22429. getClassName(): string;
  22430. /**
  22431. * Gets the xyz component (input)
  22432. */
  22433. get xyzIn(): NodeMaterialConnectionPoint;
  22434. /**
  22435. * Gets the xy component (input)
  22436. */
  22437. get xyIn(): NodeMaterialConnectionPoint;
  22438. /**
  22439. * Gets the x component (input)
  22440. */
  22441. get x(): NodeMaterialConnectionPoint;
  22442. /**
  22443. * Gets the y component (input)
  22444. */
  22445. get y(): NodeMaterialConnectionPoint;
  22446. /**
  22447. * Gets the z component (input)
  22448. */
  22449. get z(): NodeMaterialConnectionPoint;
  22450. /**
  22451. * Gets the w component (input)
  22452. */
  22453. get w(): NodeMaterialConnectionPoint;
  22454. /**
  22455. * Gets the xyzw component (output)
  22456. */
  22457. get xyzw(): NodeMaterialConnectionPoint;
  22458. /**
  22459. * Gets the xyz component (output)
  22460. */
  22461. get xyzOut(): NodeMaterialConnectionPoint;
  22462. /**
  22463. * Gets the xy component (output)
  22464. */
  22465. get xyOut(): NodeMaterialConnectionPoint;
  22466. /**
  22467. * Gets the xy component (output)
  22468. * @deprecated Please use xyOut instead.
  22469. */
  22470. get xy(): NodeMaterialConnectionPoint;
  22471. /**
  22472. * Gets the xyz component (output)
  22473. * @deprecated Please use xyzOut instead.
  22474. */
  22475. get xyz(): NodeMaterialConnectionPoint;
  22476. protected _buildBlock(state: NodeMaterialBuildState): this;
  22477. }
  22478. }
  22479. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22480. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22481. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22482. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22483. import { Vector2 } from "babylonjs/Maths/math.vector";
  22484. import { Scene } from "babylonjs/scene";
  22485. /**
  22486. * Block used to remap a float from a range to a new one
  22487. */
  22488. export class RemapBlock extends NodeMaterialBlock {
  22489. /**
  22490. * Gets or sets the source range
  22491. */
  22492. sourceRange: Vector2;
  22493. /**
  22494. * Gets or sets the target range
  22495. */
  22496. targetRange: Vector2;
  22497. /**
  22498. * Creates a new RemapBlock
  22499. * @param name defines the block name
  22500. */
  22501. constructor(name: string);
  22502. /**
  22503. * Gets the current class name
  22504. * @returns the class name
  22505. */
  22506. getClassName(): string;
  22507. /**
  22508. * Gets the input component
  22509. */
  22510. get input(): NodeMaterialConnectionPoint;
  22511. /**
  22512. * Gets the source min input component
  22513. */
  22514. get sourceMin(): NodeMaterialConnectionPoint;
  22515. /**
  22516. * Gets the source max input component
  22517. */
  22518. get sourceMax(): NodeMaterialConnectionPoint;
  22519. /**
  22520. * Gets the target min input component
  22521. */
  22522. get targetMin(): NodeMaterialConnectionPoint;
  22523. /**
  22524. * Gets the target max input component
  22525. */
  22526. get targetMax(): NodeMaterialConnectionPoint;
  22527. /**
  22528. * Gets the output component
  22529. */
  22530. get output(): NodeMaterialConnectionPoint;
  22531. protected _buildBlock(state: NodeMaterialBuildState): this;
  22532. protected _dumpPropertiesCode(): string;
  22533. serialize(): any;
  22534. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22535. }
  22536. }
  22537. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22541. /**
  22542. * Block used to multiply 2 values
  22543. */
  22544. export class MultiplyBlock extends NodeMaterialBlock {
  22545. /**
  22546. * Creates a new MultiplyBlock
  22547. * @param name defines the block name
  22548. */
  22549. constructor(name: string);
  22550. /**
  22551. * Gets the current class name
  22552. * @returns the class name
  22553. */
  22554. getClassName(): string;
  22555. /**
  22556. * Gets the left operand input component
  22557. */
  22558. get left(): NodeMaterialConnectionPoint;
  22559. /**
  22560. * Gets the right operand input component
  22561. */
  22562. get right(): NodeMaterialConnectionPoint;
  22563. /**
  22564. * Gets the output component
  22565. */
  22566. get output(): NodeMaterialConnectionPoint;
  22567. protected _buildBlock(state: NodeMaterialBuildState): this;
  22568. }
  22569. }
  22570. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22574. /**
  22575. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22576. */
  22577. export class ColorSplitterBlock extends NodeMaterialBlock {
  22578. /**
  22579. * Create a new ColorSplitterBlock
  22580. * @param name defines the block name
  22581. */
  22582. constructor(name: string);
  22583. /**
  22584. * Gets the current class name
  22585. * @returns the class name
  22586. */
  22587. getClassName(): string;
  22588. /**
  22589. * Gets the rgba component (input)
  22590. */
  22591. get rgba(): NodeMaterialConnectionPoint;
  22592. /**
  22593. * Gets the rgb component (input)
  22594. */
  22595. get rgbIn(): NodeMaterialConnectionPoint;
  22596. /**
  22597. * Gets the rgb component (output)
  22598. */
  22599. get rgbOut(): NodeMaterialConnectionPoint;
  22600. /**
  22601. * Gets the r component (output)
  22602. */
  22603. get r(): NodeMaterialConnectionPoint;
  22604. /**
  22605. * Gets the g component (output)
  22606. */
  22607. get g(): NodeMaterialConnectionPoint;
  22608. /**
  22609. * Gets the b component (output)
  22610. */
  22611. get b(): NodeMaterialConnectionPoint;
  22612. /**
  22613. * Gets the a component (output)
  22614. */
  22615. get a(): NodeMaterialConnectionPoint;
  22616. protected _inputRename(name: string): string;
  22617. protected _outputRename(name: string): string;
  22618. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22619. }
  22620. }
  22621. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22622. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22623. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22624. import { Scene } from "babylonjs/scene";
  22625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22626. import { Matrix } from "babylonjs/Maths/math.vector";
  22627. import { Mesh } from "babylonjs/Meshes/mesh";
  22628. import { Engine } from "babylonjs/Engines/engine";
  22629. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22630. import { Observable } from "babylonjs/Misc/observable";
  22631. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22632. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22633. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22634. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22635. import { Nullable } from "babylonjs/types";
  22636. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22637. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22638. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22639. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22640. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22641. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22642. import { Effect } from "babylonjs/Materials/effect";
  22643. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22644. import { Camera } from "babylonjs/Cameras/camera";
  22645. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22646. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22647. /**
  22648. * Interface used to configure the node material editor
  22649. */
  22650. export interface INodeMaterialEditorOptions {
  22651. /** Define the URl to load node editor script */
  22652. editorURL?: string;
  22653. }
  22654. /** @hidden */
  22655. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22656. NORMAL: boolean;
  22657. TANGENT: boolean;
  22658. UV1: boolean;
  22659. /** BONES */
  22660. NUM_BONE_INFLUENCERS: number;
  22661. BonesPerMesh: number;
  22662. BONETEXTURE: boolean;
  22663. /** MORPH TARGETS */
  22664. MORPHTARGETS: boolean;
  22665. MORPHTARGETS_NORMAL: boolean;
  22666. MORPHTARGETS_TANGENT: boolean;
  22667. MORPHTARGETS_UV: boolean;
  22668. NUM_MORPH_INFLUENCERS: number;
  22669. /** IMAGE PROCESSING */
  22670. IMAGEPROCESSING: boolean;
  22671. VIGNETTE: boolean;
  22672. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22673. VIGNETTEBLENDMODEOPAQUE: boolean;
  22674. TONEMAPPING: boolean;
  22675. TONEMAPPING_ACES: boolean;
  22676. CONTRAST: boolean;
  22677. EXPOSURE: boolean;
  22678. COLORCURVES: boolean;
  22679. COLORGRADING: boolean;
  22680. COLORGRADING3D: boolean;
  22681. SAMPLER3DGREENDEPTH: boolean;
  22682. SAMPLER3DBGRMAP: boolean;
  22683. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22684. /** MISC. */
  22685. BUMPDIRECTUV: number;
  22686. constructor();
  22687. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22688. }
  22689. /**
  22690. * Class used to configure NodeMaterial
  22691. */
  22692. export interface INodeMaterialOptions {
  22693. /**
  22694. * Defines if blocks should emit comments
  22695. */
  22696. emitComments: boolean;
  22697. }
  22698. /**
  22699. * Class used to create a node based material built by assembling shader blocks
  22700. */
  22701. export class NodeMaterial extends PushMaterial {
  22702. private static _BuildIdGenerator;
  22703. private _options;
  22704. private _vertexCompilationState;
  22705. private _fragmentCompilationState;
  22706. private _sharedData;
  22707. private _buildId;
  22708. private _buildWasSuccessful;
  22709. private _cachedWorldViewMatrix;
  22710. private _cachedWorldViewProjectionMatrix;
  22711. private _optimizers;
  22712. private _animationFrame;
  22713. /** Define the Url to load node editor script */
  22714. static EditorURL: string;
  22715. /** Define the Url to load snippets */
  22716. static SnippetUrl: string;
  22717. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22718. static IgnoreTexturesAtLoadTime: boolean;
  22719. private BJSNODEMATERIALEDITOR;
  22720. /** Get the inspector from bundle or global */
  22721. private _getGlobalNodeMaterialEditor;
  22722. /**
  22723. * Snippet ID if the material was created from the snippet server
  22724. */
  22725. snippetId: string;
  22726. /**
  22727. * Gets or sets data used by visual editor
  22728. * @see https://nme.babylonjs.com
  22729. */
  22730. editorData: any;
  22731. /**
  22732. * 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)
  22733. */
  22734. ignoreAlpha: boolean;
  22735. /**
  22736. * Defines the maximum number of lights that can be used in the material
  22737. */
  22738. maxSimultaneousLights: number;
  22739. /**
  22740. * Observable raised when the material is built
  22741. */
  22742. onBuildObservable: Observable<NodeMaterial>;
  22743. /**
  22744. * Gets or sets the root nodes of the material vertex shader
  22745. */
  22746. _vertexOutputNodes: NodeMaterialBlock[];
  22747. /**
  22748. * Gets or sets the root nodes of the material fragment (pixel) shader
  22749. */
  22750. _fragmentOutputNodes: NodeMaterialBlock[];
  22751. /** Gets or sets options to control the node material overall behavior */
  22752. get options(): INodeMaterialOptions;
  22753. set options(options: INodeMaterialOptions);
  22754. /**
  22755. * Default configuration related to image processing available in the standard Material.
  22756. */
  22757. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22758. /**
  22759. * Gets the image processing configuration used either in this material.
  22760. */
  22761. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22762. /**
  22763. * Sets the Default image processing configuration used either in the this material.
  22764. *
  22765. * If sets to null, the scene one is in use.
  22766. */
  22767. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22768. /**
  22769. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22770. */
  22771. attachedBlocks: NodeMaterialBlock[];
  22772. /**
  22773. * Specifies the mode of the node material
  22774. * @hidden
  22775. */
  22776. _mode: NodeMaterialModes;
  22777. /**
  22778. * Gets the mode property
  22779. */
  22780. get mode(): NodeMaterialModes;
  22781. /**
  22782. * Create a new node based material
  22783. * @param name defines the material name
  22784. * @param scene defines the hosting scene
  22785. * @param options defines creation option
  22786. */
  22787. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22788. /**
  22789. * Gets the current class name of the material e.g. "NodeMaterial"
  22790. * @returns the class name
  22791. */
  22792. getClassName(): string;
  22793. /**
  22794. * Keep track of the image processing observer to allow dispose and replace.
  22795. */
  22796. private _imageProcessingObserver;
  22797. /**
  22798. * Attaches a new image processing configuration to the Standard Material.
  22799. * @param configuration
  22800. */
  22801. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22802. /**
  22803. * Get a block by its name
  22804. * @param name defines the name of the block to retrieve
  22805. * @returns the required block or null if not found
  22806. */
  22807. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22808. /**
  22809. * Get a block by its name
  22810. * @param predicate defines the predicate used to find the good candidate
  22811. * @returns the required block or null if not found
  22812. */
  22813. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22814. /**
  22815. * Get an input block by its name
  22816. * @param predicate defines the predicate used to find the good candidate
  22817. * @returns the required input block or null if not found
  22818. */
  22819. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22820. /**
  22821. * Gets the list of input blocks attached to this material
  22822. * @returns an array of InputBlocks
  22823. */
  22824. getInputBlocks(): InputBlock[];
  22825. /**
  22826. * Adds a new optimizer to the list of optimizers
  22827. * @param optimizer defines the optimizers to add
  22828. * @returns the current material
  22829. */
  22830. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22831. /**
  22832. * Remove an optimizer from the list of optimizers
  22833. * @param optimizer defines the optimizers to remove
  22834. * @returns the current material
  22835. */
  22836. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22837. /**
  22838. * Add a new block to the list of output nodes
  22839. * @param node defines the node to add
  22840. * @returns the current material
  22841. */
  22842. addOutputNode(node: NodeMaterialBlock): this;
  22843. /**
  22844. * Remove a block from the list of root nodes
  22845. * @param node defines the node to remove
  22846. * @returns the current material
  22847. */
  22848. removeOutputNode(node: NodeMaterialBlock): this;
  22849. private _addVertexOutputNode;
  22850. private _removeVertexOutputNode;
  22851. private _addFragmentOutputNode;
  22852. private _removeFragmentOutputNode;
  22853. /**
  22854. * Specifies if the material will require alpha blending
  22855. * @returns a boolean specifying if alpha blending is needed
  22856. */
  22857. needAlphaBlending(): boolean;
  22858. /**
  22859. * Specifies if this material should be rendered in alpha test mode
  22860. * @returns a boolean specifying if an alpha test is needed.
  22861. */
  22862. needAlphaTesting(): boolean;
  22863. private _initializeBlock;
  22864. private _resetDualBlocks;
  22865. /**
  22866. * Remove a block from the current node material
  22867. * @param block defines the block to remove
  22868. */
  22869. removeBlock(block: NodeMaterialBlock): void;
  22870. /**
  22871. * Build the material and generates the inner effect
  22872. * @param verbose defines if the build should log activity
  22873. */
  22874. build(verbose?: boolean): void;
  22875. /**
  22876. * Runs an otpimization phase to try to improve the shader code
  22877. */
  22878. optimize(): void;
  22879. private _prepareDefinesForAttributes;
  22880. /**
  22881. * Create a post process from the material
  22882. * @param camera The camera to apply the render pass to.
  22883. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22885. * @param engine The engine which the post process will be applied. (default: current engine)
  22886. * @param reusable If the post process can be reused on the same frame. (default: false)
  22887. * @param textureType Type of textures used when performing the post process. (default: 0)
  22888. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22889. * @returns the post process created
  22890. */
  22891. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22892. /**
  22893. * Create the post process effect from the material
  22894. * @param postProcess The post process to create the effect for
  22895. */
  22896. createEffectForPostProcess(postProcess: PostProcess): void;
  22897. private _createEffectOrPostProcess;
  22898. private _createEffectForParticles;
  22899. /**
  22900. * Create the effect to be used as the custom effect for a particle system
  22901. * @param particleSystem Particle system to create the effect for
  22902. * @param onCompiled defines a function to call when the effect creation is successful
  22903. * @param onError defines a function to call when the effect creation has failed
  22904. */
  22905. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22906. private _processDefines;
  22907. /**
  22908. * Get if the submesh is ready to be used and all its information available.
  22909. * Child classes can use it to update shaders
  22910. * @param mesh defines the mesh to check
  22911. * @param subMesh defines which submesh to check
  22912. * @param useInstances specifies that instances should be used
  22913. * @returns a boolean indicating that the submesh is ready or not
  22914. */
  22915. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22916. /**
  22917. * Get a string representing the shaders built by the current node graph
  22918. */
  22919. get compiledShaders(): string;
  22920. /**
  22921. * Binds the world matrix to the material
  22922. * @param world defines the world transformation matrix
  22923. */
  22924. bindOnlyWorldMatrix(world: Matrix): void;
  22925. /**
  22926. * Binds the submesh to this material by preparing the effect and shader to draw
  22927. * @param world defines the world transformation matrix
  22928. * @param mesh defines the mesh containing the submesh
  22929. * @param subMesh defines the submesh to bind the material to
  22930. */
  22931. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22932. /**
  22933. * Gets the active textures from the material
  22934. * @returns an array of textures
  22935. */
  22936. getActiveTextures(): BaseTexture[];
  22937. /**
  22938. * Gets the list of texture blocks
  22939. * @returns an array of texture blocks
  22940. */
  22941. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22942. /**
  22943. * Specifies if the material uses a texture
  22944. * @param texture defines the texture to check against the material
  22945. * @returns a boolean specifying if the material uses the texture
  22946. */
  22947. hasTexture(texture: BaseTexture): boolean;
  22948. /**
  22949. * Disposes the material
  22950. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22951. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22952. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22953. */
  22954. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22955. /** Creates the node editor window. */
  22956. private _createNodeEditor;
  22957. /**
  22958. * Launch the node material editor
  22959. * @param config Define the configuration of the editor
  22960. * @return a promise fulfilled when the node editor is visible
  22961. */
  22962. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22963. /**
  22964. * Clear the current material
  22965. */
  22966. clear(): void;
  22967. /**
  22968. * Clear the current material and set it to a default state
  22969. */
  22970. setToDefault(): void;
  22971. /**
  22972. * Clear the current material and set it to a default state for post process
  22973. */
  22974. setToDefaultPostProcess(): void;
  22975. /**
  22976. * Clear the current material and set it to a default state for particle
  22977. */
  22978. setToDefaultParticle(): void;
  22979. /**
  22980. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22981. * @param url defines the url to load from
  22982. * @returns a promise that will fullfil when the material is fully loaded
  22983. */
  22984. loadAsync(url: string): Promise<void>;
  22985. private _gatherBlocks;
  22986. /**
  22987. * Generate a string containing the code declaration required to create an equivalent of this material
  22988. * @returns a string
  22989. */
  22990. generateCode(): string;
  22991. /**
  22992. * Serializes this material in a JSON representation
  22993. * @returns the serialized material object
  22994. */
  22995. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22996. private _restoreConnections;
  22997. /**
  22998. * Clear the current graph and load a new one from a serialization object
  22999. * @param source defines the JSON representation of the material
  23000. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23001. * @param merge defines whether or not the source must be merged or replace the current content
  23002. */
  23003. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23004. /**
  23005. * Makes a duplicate of the current material.
  23006. * @param name - name to use for the new material.
  23007. */
  23008. clone(name: string): NodeMaterial;
  23009. /**
  23010. * Creates a node material from parsed material data
  23011. * @param source defines the JSON representation of the material
  23012. * @param scene defines the hosting scene
  23013. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23014. * @returns a new node material
  23015. */
  23016. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23017. /**
  23018. * Creates a node material from a snippet saved in a remote file
  23019. * @param name defines the name of the material to create
  23020. * @param url defines the url to load from
  23021. * @param scene defines the hosting scene
  23022. * @returns a promise that will resolve to the new node material
  23023. */
  23024. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23025. /**
  23026. * Creates a node material from a snippet saved by the node material editor
  23027. * @param snippetId defines the snippet to load
  23028. * @param scene defines the hosting scene
  23029. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23030. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23031. * @returns a promise that will resolve to the new node material
  23032. */
  23033. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23034. /**
  23035. * Creates a new node material set to default basic configuration
  23036. * @param name defines the name of the material
  23037. * @param scene defines the hosting scene
  23038. * @returns a new NodeMaterial
  23039. */
  23040. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23041. }
  23042. }
  23043. declare module "babylonjs/PostProcesses/postProcess" {
  23044. import { Nullable } from "babylonjs/types";
  23045. import { SmartArray } from "babylonjs/Misc/smartArray";
  23046. import { Observable } from "babylonjs/Misc/observable";
  23047. import { Vector2 } from "babylonjs/Maths/math.vector";
  23048. import { Camera } from "babylonjs/Cameras/camera";
  23049. import { Effect } from "babylonjs/Materials/effect";
  23050. import "babylonjs/Shaders/postprocess.vertex";
  23051. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23052. import { Engine } from "babylonjs/Engines/engine";
  23053. import { Color4 } from "babylonjs/Maths/math.color";
  23054. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23055. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23056. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23057. /**
  23058. * Size options for a post process
  23059. */
  23060. export type PostProcessOptions = {
  23061. width: number;
  23062. height: number;
  23063. };
  23064. /**
  23065. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23066. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23067. */
  23068. export class PostProcess {
  23069. /** Name of the PostProcess. */
  23070. name: string;
  23071. /**
  23072. * Gets or sets the unique id of the post process
  23073. */
  23074. uniqueId: number;
  23075. /**
  23076. * Width of the texture to apply the post process on
  23077. */
  23078. width: number;
  23079. /**
  23080. * Height of the texture to apply the post process on
  23081. */
  23082. height: number;
  23083. /**
  23084. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23085. */
  23086. nodeMaterialSource: Nullable<NodeMaterial>;
  23087. /**
  23088. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23089. * @hidden
  23090. */
  23091. _outputTexture: Nullable<InternalTexture>;
  23092. /**
  23093. * Sampling mode used by the shader
  23094. * See https://doc.babylonjs.com/classes/3.1/texture
  23095. */
  23096. renderTargetSamplingMode: number;
  23097. /**
  23098. * Clear color to use when screen clearing
  23099. */
  23100. clearColor: Color4;
  23101. /**
  23102. * If the buffer needs to be cleared before applying the post process. (default: true)
  23103. * Should be set to false if shader will overwrite all previous pixels.
  23104. */
  23105. autoClear: boolean;
  23106. /**
  23107. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23108. */
  23109. alphaMode: number;
  23110. /**
  23111. * Sets the setAlphaBlendConstants of the babylon engine
  23112. */
  23113. alphaConstants: Color4;
  23114. /**
  23115. * Animations to be used for the post processing
  23116. */
  23117. animations: import("babylonjs/Animations/animation").Animation[];
  23118. /**
  23119. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23120. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23121. */
  23122. enablePixelPerfectMode: boolean;
  23123. /**
  23124. * Force the postprocess to be applied without taking in account viewport
  23125. */
  23126. forceFullscreenViewport: boolean;
  23127. /**
  23128. * List of inspectable custom properties (used by the Inspector)
  23129. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23130. */
  23131. inspectableCustomProperties: IInspectable[];
  23132. /**
  23133. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23134. *
  23135. * | Value | Type | Description |
  23136. * | ----- | ----------------------------------- | ----------- |
  23137. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23138. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23139. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23140. *
  23141. */
  23142. scaleMode: number;
  23143. /**
  23144. * Force textures to be a power of two (default: false)
  23145. */
  23146. alwaysForcePOT: boolean;
  23147. private _samples;
  23148. /**
  23149. * Number of sample textures (default: 1)
  23150. */
  23151. get samples(): number;
  23152. set samples(n: number);
  23153. /**
  23154. * Modify the scale of the post process to be the same as the viewport (default: false)
  23155. */
  23156. adaptScaleToCurrentViewport: boolean;
  23157. private _camera;
  23158. private _scene;
  23159. private _engine;
  23160. private _options;
  23161. private _reusable;
  23162. private _textureType;
  23163. private _textureFormat;
  23164. /**
  23165. * Smart array of input and output textures for the post process.
  23166. * @hidden
  23167. */
  23168. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23169. /**
  23170. * The index in _textures that corresponds to the output texture.
  23171. * @hidden
  23172. */
  23173. _currentRenderTextureInd: number;
  23174. private _effect;
  23175. private _samplers;
  23176. private _fragmentUrl;
  23177. private _vertexUrl;
  23178. private _parameters;
  23179. private _scaleRatio;
  23180. protected _indexParameters: any;
  23181. private _shareOutputWithPostProcess;
  23182. private _texelSize;
  23183. private _forcedOutputTexture;
  23184. /**
  23185. * Returns the fragment url or shader name used in the post process.
  23186. * @returns the fragment url or name in the shader store.
  23187. */
  23188. getEffectName(): string;
  23189. /**
  23190. * An event triggered when the postprocess is activated.
  23191. */
  23192. onActivateObservable: Observable<Camera>;
  23193. private _onActivateObserver;
  23194. /**
  23195. * A function that is added to the onActivateObservable
  23196. */
  23197. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23198. /**
  23199. * An event triggered when the postprocess changes its size.
  23200. */
  23201. onSizeChangedObservable: Observable<PostProcess>;
  23202. private _onSizeChangedObserver;
  23203. /**
  23204. * A function that is added to the onSizeChangedObservable
  23205. */
  23206. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23207. /**
  23208. * An event triggered when the postprocess applies its effect.
  23209. */
  23210. onApplyObservable: Observable<Effect>;
  23211. private _onApplyObserver;
  23212. /**
  23213. * A function that is added to the onApplyObservable
  23214. */
  23215. set onApply(callback: (effect: Effect) => void);
  23216. /**
  23217. * An event triggered before rendering the postprocess
  23218. */
  23219. onBeforeRenderObservable: Observable<Effect>;
  23220. private _onBeforeRenderObserver;
  23221. /**
  23222. * A function that is added to the onBeforeRenderObservable
  23223. */
  23224. set onBeforeRender(callback: (effect: Effect) => void);
  23225. /**
  23226. * An event triggered after rendering the postprocess
  23227. */
  23228. onAfterRenderObservable: Observable<Effect>;
  23229. private _onAfterRenderObserver;
  23230. /**
  23231. * A function that is added to the onAfterRenderObservable
  23232. */
  23233. set onAfterRender(callback: (efect: Effect) => void);
  23234. /**
  23235. * 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
  23236. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23237. */
  23238. get inputTexture(): InternalTexture;
  23239. set inputTexture(value: InternalTexture);
  23240. /**
  23241. * Gets the camera which post process is applied to.
  23242. * @returns The camera the post process is applied to.
  23243. */
  23244. getCamera(): Camera;
  23245. /**
  23246. * Gets the texel size of the postprocess.
  23247. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23248. */
  23249. get texelSize(): Vector2;
  23250. /**
  23251. * Creates a new instance PostProcess
  23252. * @param name The name of the PostProcess.
  23253. * @param fragmentUrl The url of the fragment shader to be used.
  23254. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23255. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23256. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23257. * @param camera The camera to apply the render pass to.
  23258. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23259. * @param engine The engine which the post process will be applied. (default: current engine)
  23260. * @param reusable If the post process can be reused on the same frame. (default: false)
  23261. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23262. * @param textureType Type of textures used when performing the post process. (default: 0)
  23263. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23264. * @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
  23265. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23266. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23267. */
  23268. constructor(
  23269. /** Name of the PostProcess. */
  23270. 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);
  23271. /**
  23272. * Gets a string idenfifying the name of the class
  23273. * @returns "PostProcess" string
  23274. */
  23275. getClassName(): string;
  23276. /**
  23277. * Gets the engine which this post process belongs to.
  23278. * @returns The engine the post process was enabled with.
  23279. */
  23280. getEngine(): Engine;
  23281. /**
  23282. * The effect that is created when initializing the post process.
  23283. * @returns The created effect corresponding the the postprocess.
  23284. */
  23285. getEffect(): Effect;
  23286. /**
  23287. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23288. * @param postProcess The post process to share the output with.
  23289. * @returns This post process.
  23290. */
  23291. shareOutputWith(postProcess: PostProcess): PostProcess;
  23292. /**
  23293. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23294. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23295. */
  23296. useOwnOutput(): void;
  23297. /**
  23298. * Updates the effect with the current post process compile time values and recompiles the shader.
  23299. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23300. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23301. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23302. * @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
  23303. * @param onCompiled Called when the shader has been compiled.
  23304. * @param onError Called if there is an error when compiling a shader.
  23305. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23306. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23307. */
  23308. 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;
  23309. /**
  23310. * The post process is reusable if it can be used multiple times within one frame.
  23311. * @returns If the post process is reusable
  23312. */
  23313. isReusable(): boolean;
  23314. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23315. markTextureDirty(): void;
  23316. /**
  23317. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23318. * 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.
  23319. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23320. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23321. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23322. * @returns The target texture that was bound to be written to.
  23323. */
  23324. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23325. /**
  23326. * If the post process is supported.
  23327. */
  23328. get isSupported(): boolean;
  23329. /**
  23330. * The aspect ratio of the output texture.
  23331. */
  23332. get aspectRatio(): number;
  23333. /**
  23334. * Get a value indicating if the post-process is ready to be used
  23335. * @returns true if the post-process is ready (shader is compiled)
  23336. */
  23337. isReady(): boolean;
  23338. /**
  23339. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23340. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23341. */
  23342. apply(): Nullable<Effect>;
  23343. private _disposeTextures;
  23344. /**
  23345. * Disposes the post process.
  23346. * @param camera The camera to dispose the post process on.
  23347. */
  23348. dispose(camera?: Camera): void;
  23349. }
  23350. }
  23351. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23352. /** @hidden */
  23353. export var kernelBlurVaryingDeclaration: {
  23354. name: string;
  23355. shader: string;
  23356. };
  23357. }
  23358. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23359. /** @hidden */
  23360. export var kernelBlurFragment: {
  23361. name: string;
  23362. shader: string;
  23363. };
  23364. }
  23365. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23366. /** @hidden */
  23367. export var kernelBlurFragment2: {
  23368. name: string;
  23369. shader: string;
  23370. };
  23371. }
  23372. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23373. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23374. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23375. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23376. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23377. /** @hidden */
  23378. export var kernelBlurPixelShader: {
  23379. name: string;
  23380. shader: string;
  23381. };
  23382. }
  23383. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23384. /** @hidden */
  23385. export var kernelBlurVertex: {
  23386. name: string;
  23387. shader: string;
  23388. };
  23389. }
  23390. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23391. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23392. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23393. /** @hidden */
  23394. export var kernelBlurVertexShader: {
  23395. name: string;
  23396. shader: string;
  23397. };
  23398. }
  23399. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23400. import { Vector2 } from "babylonjs/Maths/math.vector";
  23401. import { Nullable } from "babylonjs/types";
  23402. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23403. import { Camera } from "babylonjs/Cameras/camera";
  23404. import { Effect } from "babylonjs/Materials/effect";
  23405. import { Engine } from "babylonjs/Engines/engine";
  23406. import "babylonjs/Shaders/kernelBlur.fragment";
  23407. import "babylonjs/Shaders/kernelBlur.vertex";
  23408. /**
  23409. * The Blur Post Process which blurs an image based on a kernel and direction.
  23410. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23411. */
  23412. export class BlurPostProcess extends PostProcess {
  23413. /** The direction in which to blur the image. */
  23414. direction: Vector2;
  23415. private blockCompilation;
  23416. protected _kernel: number;
  23417. protected _idealKernel: number;
  23418. protected _packedFloat: boolean;
  23419. private _staticDefines;
  23420. /**
  23421. * Sets the length in pixels of the blur sample region
  23422. */
  23423. set kernel(v: number);
  23424. /**
  23425. * Gets the length in pixels of the blur sample region
  23426. */
  23427. get kernel(): number;
  23428. /**
  23429. * Sets wether or not the blur needs to unpack/repack floats
  23430. */
  23431. set packedFloat(v: boolean);
  23432. /**
  23433. * Gets wether or not the blur is unpacking/repacking floats
  23434. */
  23435. get packedFloat(): boolean;
  23436. /**
  23437. * Creates a new instance BlurPostProcess
  23438. * @param name The name of the effect.
  23439. * @param direction The direction in which to blur the image.
  23440. * @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.
  23441. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23442. * @param camera The camera to apply the render pass to.
  23443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23444. * @param engine The engine which the post process will be applied. (default: current engine)
  23445. * @param reusable If the post process can be reused on the same frame. (default: false)
  23446. * @param textureType Type of textures used when performing the post process. (default: 0)
  23447. * @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)
  23448. */
  23449. constructor(name: string,
  23450. /** The direction in which to blur the image. */
  23451. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23452. /**
  23453. * Updates the effect with the current post process compile time values and recompiles the shader.
  23454. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23455. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23456. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23457. * @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
  23458. * @param onCompiled Called when the shader has been compiled.
  23459. * @param onError Called if there is an error when compiling a shader.
  23460. */
  23461. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23462. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23463. /**
  23464. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23465. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23466. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23467. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23468. * The gaps between physical kernels are compensated for in the weighting of the samples
  23469. * @param idealKernel Ideal blur kernel.
  23470. * @return Nearest best kernel.
  23471. */
  23472. protected _nearestBestKernel(idealKernel: number): number;
  23473. /**
  23474. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23475. * @param x The point on the Gaussian distribution to sample.
  23476. * @return the value of the Gaussian function at x.
  23477. */
  23478. protected _gaussianWeight(x: number): number;
  23479. /**
  23480. * Generates a string that can be used as a floating point number in GLSL.
  23481. * @param x Value to print.
  23482. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23483. * @return GLSL float string.
  23484. */
  23485. protected _glslFloat(x: number, decimalFigures?: number): string;
  23486. }
  23487. }
  23488. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23489. import { Scene } from "babylonjs/scene";
  23490. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23491. import { Plane } from "babylonjs/Maths/math.plane";
  23492. /**
  23493. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23494. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23495. * You can then easily use it as a reflectionTexture on a flat surface.
  23496. * In case the surface is not a plane, please consider relying on reflection probes.
  23497. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23498. */
  23499. export class MirrorTexture extends RenderTargetTexture {
  23500. private scene;
  23501. /**
  23502. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23503. * 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.
  23504. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23505. */
  23506. mirrorPlane: Plane;
  23507. /**
  23508. * Define the blur ratio used to blur the reflection if needed.
  23509. */
  23510. set blurRatio(value: number);
  23511. get blurRatio(): number;
  23512. /**
  23513. * Define the adaptive blur kernel used to blur the reflection if needed.
  23514. * This will autocompute the closest best match for the `blurKernel`
  23515. */
  23516. set adaptiveBlurKernel(value: number);
  23517. /**
  23518. * Define the blur kernel used to blur the reflection if needed.
  23519. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23520. */
  23521. set blurKernel(value: number);
  23522. /**
  23523. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23524. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23525. */
  23526. set blurKernelX(value: number);
  23527. get blurKernelX(): number;
  23528. /**
  23529. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23530. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23531. */
  23532. set blurKernelY(value: number);
  23533. get blurKernelY(): number;
  23534. private _autoComputeBlurKernel;
  23535. protected _onRatioRescale(): void;
  23536. private _updateGammaSpace;
  23537. private _imageProcessingConfigChangeObserver;
  23538. private _transformMatrix;
  23539. private _mirrorMatrix;
  23540. private _savedViewMatrix;
  23541. private _blurX;
  23542. private _blurY;
  23543. private _adaptiveBlurKernel;
  23544. private _blurKernelX;
  23545. private _blurKernelY;
  23546. private _blurRatio;
  23547. /**
  23548. * Instantiates a Mirror Texture.
  23549. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23550. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23551. * You can then easily use it as a reflectionTexture on a flat surface.
  23552. * In case the surface is not a plane, please consider relying on reflection probes.
  23553. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23554. * @param name
  23555. * @param size
  23556. * @param scene
  23557. * @param generateMipMaps
  23558. * @param type
  23559. * @param samplingMode
  23560. * @param generateDepthBuffer
  23561. */
  23562. constructor(name: string, size: number | {
  23563. width: number;
  23564. height: number;
  23565. } | {
  23566. ratio: number;
  23567. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23568. private _preparePostProcesses;
  23569. /**
  23570. * Clone the mirror texture.
  23571. * @returns the cloned texture
  23572. */
  23573. clone(): MirrorTexture;
  23574. /**
  23575. * Serialize the texture to a JSON representation you could use in Parse later on
  23576. * @returns the serialized JSON representation
  23577. */
  23578. serialize(): any;
  23579. /**
  23580. * Dispose the texture and release its associated resources.
  23581. */
  23582. dispose(): void;
  23583. }
  23584. }
  23585. declare module "babylonjs/Materials/Textures/texture" {
  23586. import { Observable } from "babylonjs/Misc/observable";
  23587. import { Nullable } from "babylonjs/types";
  23588. import { Matrix } from "babylonjs/Maths/math.vector";
  23589. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23590. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23591. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23592. import { Scene } from "babylonjs/scene";
  23593. /**
  23594. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23595. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23596. */
  23597. export class Texture extends BaseTexture {
  23598. /**
  23599. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23600. */
  23601. static SerializeBuffers: boolean;
  23602. /** @hidden */
  23603. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  23604. /** @hidden */
  23605. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  23606. /** @hidden */
  23607. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  23608. /** nearest is mag = nearest and min = nearest and mip = linear */
  23609. static readonly NEAREST_SAMPLINGMODE: number;
  23610. /** nearest is mag = nearest and min = nearest and mip = linear */
  23611. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23613. static readonly BILINEAR_SAMPLINGMODE: number;
  23614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23615. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23616. /** Trilinear is mag = linear and min = linear and mip = linear */
  23617. static readonly TRILINEAR_SAMPLINGMODE: number;
  23618. /** Trilinear is mag = linear and min = linear and mip = linear */
  23619. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23620. /** mag = nearest and min = nearest and mip = nearest */
  23621. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23622. /** mag = nearest and min = linear and mip = nearest */
  23623. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23624. /** mag = nearest and min = linear and mip = linear */
  23625. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23626. /** mag = nearest and min = linear and mip = none */
  23627. static readonly NEAREST_LINEAR: number;
  23628. /** mag = nearest and min = nearest and mip = none */
  23629. static readonly NEAREST_NEAREST: number;
  23630. /** mag = linear and min = nearest and mip = nearest */
  23631. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23632. /** mag = linear and min = nearest and mip = linear */
  23633. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23634. /** mag = linear and min = linear and mip = none */
  23635. static readonly LINEAR_LINEAR: number;
  23636. /** mag = linear and min = nearest and mip = none */
  23637. static readonly LINEAR_NEAREST: number;
  23638. /** Explicit coordinates mode */
  23639. static readonly EXPLICIT_MODE: number;
  23640. /** Spherical coordinates mode */
  23641. static readonly SPHERICAL_MODE: number;
  23642. /** Planar coordinates mode */
  23643. static readonly PLANAR_MODE: number;
  23644. /** Cubic coordinates mode */
  23645. static readonly CUBIC_MODE: number;
  23646. /** Projection coordinates mode */
  23647. static readonly PROJECTION_MODE: number;
  23648. /** Inverse Cubic coordinates mode */
  23649. static readonly SKYBOX_MODE: number;
  23650. /** Inverse Cubic coordinates mode */
  23651. static readonly INVCUBIC_MODE: number;
  23652. /** Equirectangular coordinates mode */
  23653. static readonly EQUIRECTANGULAR_MODE: number;
  23654. /** Equirectangular Fixed coordinates mode */
  23655. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23656. /** Equirectangular Fixed Mirrored coordinates mode */
  23657. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23658. /** Texture is not repeating outside of 0..1 UVs */
  23659. static readonly CLAMP_ADDRESSMODE: number;
  23660. /** Texture is repeating outside of 0..1 UVs */
  23661. static readonly WRAP_ADDRESSMODE: number;
  23662. /** Texture is repeating and mirrored */
  23663. static readonly MIRROR_ADDRESSMODE: number;
  23664. /**
  23665. * 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
  23666. */
  23667. static UseSerializedUrlIfAny: boolean;
  23668. /**
  23669. * Define the url of the texture.
  23670. */
  23671. url: Nullable<string>;
  23672. /**
  23673. * Define an offset on the texture to offset the u coordinates of the UVs
  23674. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23675. */
  23676. uOffset: number;
  23677. /**
  23678. * Define an offset on the texture to offset the v coordinates of the UVs
  23679. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  23680. */
  23681. vOffset: number;
  23682. /**
  23683. * Define an offset on the texture to scale the u coordinates of the UVs
  23684. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23685. */
  23686. uScale: number;
  23687. /**
  23688. * Define an offset on the texture to scale the v coordinates of the UVs
  23689. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23690. */
  23691. vScale: number;
  23692. /**
  23693. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23694. * @see http://doc.babylonjs.com/how_to/more_materials
  23695. */
  23696. uAng: number;
  23697. /**
  23698. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23699. * @see http://doc.babylonjs.com/how_to/more_materials
  23700. */
  23701. vAng: number;
  23702. /**
  23703. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23704. * @see http://doc.babylonjs.com/how_to/more_materials
  23705. */
  23706. wAng: number;
  23707. /**
  23708. * Defines the center of rotation (U)
  23709. */
  23710. uRotationCenter: number;
  23711. /**
  23712. * Defines the center of rotation (V)
  23713. */
  23714. vRotationCenter: number;
  23715. /**
  23716. * Defines the center of rotation (W)
  23717. */
  23718. wRotationCenter: number;
  23719. /**
  23720. * Are mip maps generated for this texture or not.
  23721. */
  23722. get noMipmap(): boolean;
  23723. /**
  23724. * List of inspectable custom properties (used by the Inspector)
  23725. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23726. */
  23727. inspectableCustomProperties: Nullable<IInspectable[]>;
  23728. private _noMipmap;
  23729. /** @hidden */
  23730. _invertY: boolean;
  23731. private _rowGenerationMatrix;
  23732. private _cachedTextureMatrix;
  23733. private _projectionModeMatrix;
  23734. private _t0;
  23735. private _t1;
  23736. private _t2;
  23737. private _cachedUOffset;
  23738. private _cachedVOffset;
  23739. private _cachedUScale;
  23740. private _cachedVScale;
  23741. private _cachedUAng;
  23742. private _cachedVAng;
  23743. private _cachedWAng;
  23744. private _cachedProjectionMatrixId;
  23745. private _cachedCoordinatesMode;
  23746. /** @hidden */
  23747. protected _initialSamplingMode: number;
  23748. /** @hidden */
  23749. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23750. private _deleteBuffer;
  23751. protected _format: Nullable<number>;
  23752. private _delayedOnLoad;
  23753. private _delayedOnError;
  23754. private _mimeType?;
  23755. /**
  23756. * Observable triggered once the texture has been loaded.
  23757. */
  23758. onLoadObservable: Observable<Texture>;
  23759. protected _isBlocking: boolean;
  23760. /**
  23761. * Is the texture preventing material to render while loading.
  23762. * If false, a default texture will be used instead of the loading one during the preparation step.
  23763. */
  23764. set isBlocking(value: boolean);
  23765. get isBlocking(): boolean;
  23766. /**
  23767. * Get the current sampling mode associated with the texture.
  23768. */
  23769. get samplingMode(): number;
  23770. /**
  23771. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23772. */
  23773. get invertY(): boolean;
  23774. /**
  23775. * Instantiates a new texture.
  23776. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23777. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23778. * @param url defines the url of the picture to load as a texture
  23779. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23780. * @param noMipmap defines if the texture will require mip maps or not
  23781. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23782. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23783. * @param onLoad defines a callback triggered when the texture has been loaded
  23784. * @param onError defines a callback triggered when an error occurred during the loading session
  23785. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23786. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23787. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23788. * @param mimeType defines an optional mime type information
  23789. */
  23790. 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);
  23791. /**
  23792. * Update the url (and optional buffer) of this texture if url was null during construction.
  23793. * @param url the url of the texture
  23794. * @param buffer the buffer of the texture (defaults to null)
  23795. * @param onLoad callback called when the texture is loaded (defaults to null)
  23796. */
  23797. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23798. /**
  23799. * Finish the loading sequence of a texture flagged as delayed load.
  23800. * @hidden
  23801. */
  23802. delayLoad(): void;
  23803. private _prepareRowForTextureGeneration;
  23804. /**
  23805. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23806. * @returns the transform matrix of the texture.
  23807. */
  23808. getTextureMatrix(uBase?: number): Matrix;
  23809. /**
  23810. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23811. * @returns The reflection texture transform
  23812. */
  23813. getReflectionTextureMatrix(): Matrix;
  23814. /**
  23815. * Clones the texture.
  23816. * @returns the cloned texture
  23817. */
  23818. clone(): Texture;
  23819. /**
  23820. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23821. * @returns The JSON representation of the texture
  23822. */
  23823. serialize(): any;
  23824. /**
  23825. * Get the current class name of the texture useful for serialization or dynamic coding.
  23826. * @returns "Texture"
  23827. */
  23828. getClassName(): string;
  23829. /**
  23830. * Dispose the texture and release its associated resources.
  23831. */
  23832. dispose(): void;
  23833. /**
  23834. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23835. * @param parsedTexture Define the JSON representation of the texture
  23836. * @param scene Define the scene the parsed texture should be instantiated in
  23837. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23838. * @returns The parsed texture if successful
  23839. */
  23840. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23841. /**
  23842. * Creates a texture from its base 64 representation.
  23843. * @param data Define the base64 payload without the data: prefix
  23844. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23845. * @param scene Define the scene the texture should belong to
  23846. * @param noMipmap Forces the texture to not create mip map information if true
  23847. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23848. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23849. * @param onLoad define a callback triggered when the texture has been loaded
  23850. * @param onError define a callback triggered when an error occurred during the loading session
  23851. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23852. * @returns the created texture
  23853. */
  23854. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23855. /**
  23856. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23857. * @param data Define the base64 payload without the data: prefix
  23858. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23859. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23860. * @param scene Define the scene the texture should belong to
  23861. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23862. * @param noMipmap Forces the texture to not create mip map information if true
  23863. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23864. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23865. * @param onLoad define a callback triggered when the texture has been loaded
  23866. * @param onError define a callback triggered when an error occurred during the loading session
  23867. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23868. * @returns the created texture
  23869. */
  23870. 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;
  23871. }
  23872. }
  23873. declare module "babylonjs/PostProcesses/postProcessManager" {
  23874. import { Nullable } from "babylonjs/types";
  23875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23876. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23877. import { Scene } from "babylonjs/scene";
  23878. /**
  23879. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23880. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23881. */
  23882. export class PostProcessManager {
  23883. private _scene;
  23884. private _indexBuffer;
  23885. private _vertexBuffers;
  23886. /**
  23887. * Creates a new instance PostProcess
  23888. * @param scene The scene that the post process is associated with.
  23889. */
  23890. constructor(scene: Scene);
  23891. private _prepareBuffers;
  23892. private _buildIndexBuffer;
  23893. /**
  23894. * Rebuilds the vertex buffers of the manager.
  23895. * @hidden
  23896. */
  23897. _rebuild(): void;
  23898. /**
  23899. * Prepares a frame to be run through a post process.
  23900. * @param sourceTexture The input texture to the post procesess. (default: null)
  23901. * @param postProcesses An array of post processes to be run. (default: null)
  23902. * @returns True if the post processes were able to be run.
  23903. * @hidden
  23904. */
  23905. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23906. /**
  23907. * Manually render a set of post processes to a texture.
  23908. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23909. * @param postProcesses An array of post processes to be run.
  23910. * @param targetTexture The target texture to render to.
  23911. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23912. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23913. * @param lodLevel defines which lod of the texture to render to
  23914. */
  23915. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23916. /**
  23917. * Finalize the result of the output of the postprocesses.
  23918. * @param doNotPresent If true the result will not be displayed to the screen.
  23919. * @param targetTexture The target texture to render to.
  23920. * @param faceIndex The index of the face to bind the target texture to.
  23921. * @param postProcesses The array of post processes to render.
  23922. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23923. * @hidden
  23924. */
  23925. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23926. /**
  23927. * Disposes of the post process manager.
  23928. */
  23929. dispose(): void;
  23930. }
  23931. }
  23932. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  23933. import { Observable } from "babylonjs/Misc/observable";
  23934. import { SmartArray } from "babylonjs/Misc/smartArray";
  23935. import { Nullable, Immutable } from "babylonjs/types";
  23936. import { Camera } from "babylonjs/Cameras/camera";
  23937. import { Scene } from "babylonjs/scene";
  23938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  23939. import { Color4 } from "babylonjs/Maths/math.color";
  23940. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  23941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23942. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23943. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23944. import { Texture } from "babylonjs/Materials/Textures/texture";
  23945. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23946. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  23947. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23948. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  23949. import { Engine } from "babylonjs/Engines/engine";
  23950. /**
  23951. * This Helps creating a texture that will be created from a camera in your scene.
  23952. * It is basically a dynamic texture that could be used to create special effects for instance.
  23953. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23954. */
  23955. export class RenderTargetTexture extends Texture {
  23956. isCube: boolean;
  23957. /**
  23958. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23959. */
  23960. static readonly REFRESHRATE_RENDER_ONCE: number;
  23961. /**
  23962. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23963. */
  23964. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23965. /**
  23966. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23967. * the central point of your effect and can save a lot of performances.
  23968. */
  23969. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23970. /**
  23971. * Use this predicate to dynamically define the list of mesh you want to render.
  23972. * If set, the renderList property will be overwritten.
  23973. */
  23974. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23975. private _renderList;
  23976. /**
  23977. * Use this list to define the list of mesh you want to render.
  23978. */
  23979. get renderList(): Nullable<Array<AbstractMesh>>;
  23980. set renderList(value: Nullable<Array<AbstractMesh>>);
  23981. /**
  23982. * Use this function to overload the renderList array at rendering time.
  23983. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23984. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23985. * the cube (if the RTT is a cube, else layerOrFace=0).
  23986. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23987. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23988. * hold dummy elements!
  23989. */
  23990. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23991. private _hookArray;
  23992. /**
  23993. * Define if particles should be rendered in your texture.
  23994. */
  23995. renderParticles: boolean;
  23996. /**
  23997. * Define if sprites should be rendered in your texture.
  23998. */
  23999. renderSprites: boolean;
  24000. /**
  24001. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24002. */
  24003. coordinatesMode: number;
  24004. /**
  24005. * Define the camera used to render the texture.
  24006. */
  24007. activeCamera: Nullable<Camera>;
  24008. /**
  24009. * Override the mesh isReady function with your own one.
  24010. */
  24011. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24012. /**
  24013. * Override the render function of the texture with your own one.
  24014. */
  24015. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24016. /**
  24017. * Define if camera post processes should be use while rendering the texture.
  24018. */
  24019. useCameraPostProcesses: boolean;
  24020. /**
  24021. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24022. */
  24023. ignoreCameraViewport: boolean;
  24024. private _postProcessManager;
  24025. private _postProcesses;
  24026. private _resizeObserver;
  24027. /**
  24028. * An event triggered when the texture is unbind.
  24029. */
  24030. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24031. /**
  24032. * An event triggered when the texture is unbind.
  24033. */
  24034. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24035. private _onAfterUnbindObserver;
  24036. /**
  24037. * Set a after unbind callback in the texture.
  24038. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24039. */
  24040. set onAfterUnbind(callback: () => void);
  24041. /**
  24042. * An event triggered before rendering the texture
  24043. */
  24044. onBeforeRenderObservable: Observable<number>;
  24045. private _onBeforeRenderObserver;
  24046. /**
  24047. * Set a before render callback in the texture.
  24048. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24049. */
  24050. set onBeforeRender(callback: (faceIndex: number) => void);
  24051. /**
  24052. * An event triggered after rendering the texture
  24053. */
  24054. onAfterRenderObservable: Observable<number>;
  24055. private _onAfterRenderObserver;
  24056. /**
  24057. * Set a after render callback in the texture.
  24058. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24059. */
  24060. set onAfterRender(callback: (faceIndex: number) => void);
  24061. /**
  24062. * An event triggered after the texture clear
  24063. */
  24064. onClearObservable: Observable<Engine>;
  24065. private _onClearObserver;
  24066. /**
  24067. * Set a clear callback in the texture.
  24068. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24069. */
  24070. set onClear(callback: (Engine: Engine) => void);
  24071. /**
  24072. * An event triggered when the texture is resized.
  24073. */
  24074. onResizeObservable: Observable<RenderTargetTexture>;
  24075. /**
  24076. * Define the clear color of the Render Target if it should be different from the scene.
  24077. */
  24078. clearColor: Color4;
  24079. protected _size: number | {
  24080. width: number;
  24081. height: number;
  24082. layers?: number;
  24083. };
  24084. protected _initialSizeParameter: number | {
  24085. width: number;
  24086. height: number;
  24087. } | {
  24088. ratio: number;
  24089. };
  24090. protected _sizeRatio: Nullable<number>;
  24091. /** @hidden */
  24092. _generateMipMaps: boolean;
  24093. protected _renderingManager: RenderingManager;
  24094. /** @hidden */
  24095. _waitingRenderList: string[];
  24096. protected _doNotChangeAspectRatio: boolean;
  24097. protected _currentRefreshId: number;
  24098. protected _refreshRate: number;
  24099. protected _textureMatrix: Matrix;
  24100. protected _samples: number;
  24101. protected _renderTargetOptions: RenderTargetCreationOptions;
  24102. /**
  24103. * Gets render target creation options that were used.
  24104. */
  24105. get renderTargetOptions(): RenderTargetCreationOptions;
  24106. protected _onRatioRescale(): void;
  24107. /**
  24108. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24109. * It must define where the camera used to render the texture is set
  24110. */
  24111. boundingBoxPosition: Vector3;
  24112. private _boundingBoxSize;
  24113. /**
  24114. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24115. * When defined, the cubemap will switch to local mode
  24116. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24117. * @example https://www.babylonjs-playground.com/#RNASML
  24118. */
  24119. set boundingBoxSize(value: Vector3);
  24120. get boundingBoxSize(): Vector3;
  24121. /**
  24122. * In case the RTT has been created with a depth texture, get the associated
  24123. * depth texture.
  24124. * Otherwise, return null.
  24125. */
  24126. get depthStencilTexture(): Nullable<InternalTexture>;
  24127. /**
  24128. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24129. * or used a shadow, depth texture...
  24130. * @param name The friendly name of the texture
  24131. * @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)
  24132. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24133. * @param generateMipMaps True if mip maps need to be generated after render.
  24134. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24135. * @param type The type of the buffer in the RTT (int, half float, float...)
  24136. * @param isCube True if a cube texture needs to be created
  24137. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24138. * @param generateDepthBuffer True to generate a depth buffer
  24139. * @param generateStencilBuffer True to generate a stencil buffer
  24140. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24141. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24142. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24143. */
  24144. constructor(name: string, size: number | {
  24145. width: number;
  24146. height: number;
  24147. layers?: number;
  24148. } | {
  24149. ratio: number;
  24150. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24151. /**
  24152. * Creates a depth stencil texture.
  24153. * This is only available in WebGL 2 or with the depth texture extension available.
  24154. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24155. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24156. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24157. */
  24158. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24159. private _processSizeParameter;
  24160. /**
  24161. * Define the number of samples to use in case of MSAA.
  24162. * It defaults to one meaning no MSAA has been enabled.
  24163. */
  24164. get samples(): number;
  24165. set samples(value: number);
  24166. /**
  24167. * Resets the refresh counter of the texture and start bak from scratch.
  24168. * Could be useful to regenerate the texture if it is setup to render only once.
  24169. */
  24170. resetRefreshCounter(): void;
  24171. /**
  24172. * Define the refresh rate of the texture or the rendering frequency.
  24173. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24174. */
  24175. get refreshRate(): number;
  24176. set refreshRate(value: number);
  24177. /**
  24178. * Adds a post process to the render target rendering passes.
  24179. * @param postProcess define the post process to add
  24180. */
  24181. addPostProcess(postProcess: PostProcess): void;
  24182. /**
  24183. * Clear all the post processes attached to the render target
  24184. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24185. */
  24186. clearPostProcesses(dispose?: boolean): void;
  24187. /**
  24188. * Remove one of the post process from the list of attached post processes to the texture
  24189. * @param postProcess define the post process to remove from the list
  24190. */
  24191. removePostProcess(postProcess: PostProcess): void;
  24192. /** @hidden */
  24193. _shouldRender(): boolean;
  24194. /**
  24195. * Gets the actual render size of the texture.
  24196. * @returns the width of the render size
  24197. */
  24198. getRenderSize(): number;
  24199. /**
  24200. * Gets the actual render width of the texture.
  24201. * @returns the width of the render size
  24202. */
  24203. getRenderWidth(): number;
  24204. /**
  24205. * Gets the actual render height of the texture.
  24206. * @returns the height of the render size
  24207. */
  24208. getRenderHeight(): number;
  24209. /**
  24210. * Gets the actual number of layers of the texture.
  24211. * @returns the number of layers
  24212. */
  24213. getRenderLayers(): number;
  24214. /**
  24215. * Get if the texture can be rescaled or not.
  24216. */
  24217. get canRescale(): boolean;
  24218. /**
  24219. * Resize the texture using a ratio.
  24220. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24221. */
  24222. scale(ratio: number): void;
  24223. /**
  24224. * Get the texture reflection matrix used to rotate/transform the reflection.
  24225. * @returns the reflection matrix
  24226. */
  24227. getReflectionTextureMatrix(): Matrix;
  24228. /**
  24229. * Resize the texture to a new desired size.
  24230. * Be carrefull as it will recreate all the data in the new texture.
  24231. * @param size Define the new size. It can be:
  24232. * - a number for squared texture,
  24233. * - an object containing { width: number, height: number }
  24234. * - or an object containing a ratio { ratio: number }
  24235. */
  24236. resize(size: number | {
  24237. width: number;
  24238. height: number;
  24239. } | {
  24240. ratio: number;
  24241. }): void;
  24242. private _defaultRenderListPrepared;
  24243. /**
  24244. * Renders all the objects from the render list into the texture.
  24245. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24246. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24247. */
  24248. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24249. private _bestReflectionRenderTargetDimension;
  24250. private _prepareRenderingManager;
  24251. /**
  24252. * @hidden
  24253. * @param faceIndex face index to bind to if this is a cubetexture
  24254. * @param layer defines the index of the texture to bind in the array
  24255. */
  24256. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24257. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24258. private renderToTarget;
  24259. /**
  24260. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24261. * This allowed control for front to back rendering or reversly depending of the special needs.
  24262. *
  24263. * @param renderingGroupId The rendering group id corresponding to its index
  24264. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24265. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24266. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24267. */
  24268. 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;
  24269. /**
  24270. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24271. *
  24272. * @param renderingGroupId The rendering group id corresponding to its index
  24273. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24274. */
  24275. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24276. /**
  24277. * Clones the texture.
  24278. * @returns the cloned texture
  24279. */
  24280. clone(): RenderTargetTexture;
  24281. /**
  24282. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24283. * @returns The JSON representation of the texture
  24284. */
  24285. serialize(): any;
  24286. /**
  24287. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24288. */
  24289. disposeFramebufferObjects(): void;
  24290. /**
  24291. * Dispose the texture and release its associated resources.
  24292. */
  24293. dispose(): void;
  24294. /** @hidden */
  24295. _rebuild(): void;
  24296. /**
  24297. * Clear the info related to rendering groups preventing retention point in material dispose.
  24298. */
  24299. freeRenderingGroups(): void;
  24300. /**
  24301. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24302. * @returns the view count
  24303. */
  24304. getViewCount(): number;
  24305. }
  24306. }
  24307. declare module "babylonjs/Misc/guid" {
  24308. /**
  24309. * Class used to manipulate GUIDs
  24310. */
  24311. export class GUID {
  24312. /**
  24313. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24314. * Be aware Math.random() could cause collisions, but:
  24315. * "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"
  24316. * @returns a pseudo random id
  24317. */
  24318. static RandomId(): string;
  24319. }
  24320. }
  24321. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24322. import { Nullable } from "babylonjs/types";
  24323. import { Scene } from "babylonjs/scene";
  24324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24325. import { Material } from "babylonjs/Materials/material";
  24326. import { Effect } from "babylonjs/Materials/effect";
  24327. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24328. /**
  24329. * Options to be used when creating a shadow depth material
  24330. */
  24331. export interface IIOptionShadowDepthMaterial {
  24332. /** Variables in the vertex shader code that need to have their names remapped.
  24333. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24334. * "var_name" should be either: worldPos or vNormalW
  24335. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24336. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24337. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24338. */
  24339. remappedVariables?: string[];
  24340. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24341. standalone?: boolean;
  24342. }
  24343. /**
  24344. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24345. */
  24346. export class ShadowDepthWrapper {
  24347. private _scene;
  24348. private _options?;
  24349. private _baseMaterial;
  24350. private _onEffectCreatedObserver;
  24351. private _subMeshToEffect;
  24352. private _subMeshToDepthEffect;
  24353. private _meshes;
  24354. /** @hidden */
  24355. _matriceNames: any;
  24356. /** Gets the standalone status of the wrapper */
  24357. get standalone(): boolean;
  24358. /** Gets the base material the wrapper is built upon */
  24359. get baseMaterial(): Material;
  24360. /**
  24361. * Instantiate a new shadow depth wrapper.
  24362. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24363. * generate the shadow depth map. For more information, please refer to the documentation:
  24364. * https://doc.babylonjs.com/babylon101/shadows
  24365. * @param baseMaterial Material to wrap
  24366. * @param scene Define the scene the material belongs to
  24367. * @param options Options used to create the wrapper
  24368. */
  24369. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24370. /**
  24371. * Gets the effect to use to generate the depth map
  24372. * @param subMesh subMesh to get the effect for
  24373. * @param shadowGenerator shadow generator to get the effect for
  24374. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24375. */
  24376. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24377. /**
  24378. * Specifies that the submesh is ready to be used for depth rendering
  24379. * @param subMesh submesh to check
  24380. * @param defines the list of defines to take into account when checking the effect
  24381. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24382. * @param useInstances specifies that instances should be used
  24383. * @returns a boolean indicating that the submesh is ready or not
  24384. */
  24385. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24386. /**
  24387. * Disposes the resources
  24388. */
  24389. dispose(): void;
  24390. private _makeEffect;
  24391. }
  24392. }
  24393. declare module "babylonjs/Materials/material" {
  24394. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24395. import { SmartArray } from "babylonjs/Misc/smartArray";
  24396. import { Observable } from "babylonjs/Misc/observable";
  24397. import { Nullable } from "babylonjs/types";
  24398. import { Scene } from "babylonjs/scene";
  24399. import { Matrix } from "babylonjs/Maths/math.vector";
  24400. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24402. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24403. import { Effect } from "babylonjs/Materials/effect";
  24404. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24405. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24406. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24407. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24408. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24409. import { Mesh } from "babylonjs/Meshes/mesh";
  24410. import { Animation } from "babylonjs/Animations/animation";
  24411. /**
  24412. * Options for compiling materials.
  24413. */
  24414. export interface IMaterialCompilationOptions {
  24415. /**
  24416. * Defines whether clip planes are enabled.
  24417. */
  24418. clipPlane: boolean;
  24419. /**
  24420. * Defines whether instances are enabled.
  24421. */
  24422. useInstances: boolean;
  24423. }
  24424. /**
  24425. * Options passed when calling customShaderNameResolve
  24426. */
  24427. export interface ICustomShaderNameResolveOptions {
  24428. /**
  24429. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  24430. */
  24431. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24432. }
  24433. /**
  24434. * Base class for the main features of a material in Babylon.js
  24435. */
  24436. export class Material implements IAnimatable {
  24437. /**
  24438. * Returns the triangle fill mode
  24439. */
  24440. static readonly TriangleFillMode: number;
  24441. /**
  24442. * Returns the wireframe mode
  24443. */
  24444. static readonly WireFrameFillMode: number;
  24445. /**
  24446. * Returns the point fill mode
  24447. */
  24448. static readonly PointFillMode: number;
  24449. /**
  24450. * Returns the point list draw mode
  24451. */
  24452. static readonly PointListDrawMode: number;
  24453. /**
  24454. * Returns the line list draw mode
  24455. */
  24456. static readonly LineListDrawMode: number;
  24457. /**
  24458. * Returns the line loop draw mode
  24459. */
  24460. static readonly LineLoopDrawMode: number;
  24461. /**
  24462. * Returns the line strip draw mode
  24463. */
  24464. static readonly LineStripDrawMode: number;
  24465. /**
  24466. * Returns the triangle strip draw mode
  24467. */
  24468. static readonly TriangleStripDrawMode: number;
  24469. /**
  24470. * Returns the triangle fan draw mode
  24471. */
  24472. static readonly TriangleFanDrawMode: number;
  24473. /**
  24474. * Stores the clock-wise side orientation
  24475. */
  24476. static readonly ClockWiseSideOrientation: number;
  24477. /**
  24478. * Stores the counter clock-wise side orientation
  24479. */
  24480. static readonly CounterClockWiseSideOrientation: number;
  24481. /**
  24482. * The dirty texture flag value
  24483. */
  24484. static readonly TextureDirtyFlag: number;
  24485. /**
  24486. * The dirty light flag value
  24487. */
  24488. static readonly LightDirtyFlag: number;
  24489. /**
  24490. * The dirty fresnel flag value
  24491. */
  24492. static readonly FresnelDirtyFlag: number;
  24493. /**
  24494. * The dirty attribute flag value
  24495. */
  24496. static readonly AttributesDirtyFlag: number;
  24497. /**
  24498. * The dirty misc flag value
  24499. */
  24500. static readonly MiscDirtyFlag: number;
  24501. /**
  24502. * The all dirty flag value
  24503. */
  24504. static readonly AllDirtyFlag: number;
  24505. /**
  24506. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24507. */
  24508. static readonly MATERIAL_OPAQUE: number;
  24509. /**
  24510. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24511. */
  24512. static readonly MATERIAL_ALPHATEST: number;
  24513. /**
  24514. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24515. */
  24516. static readonly MATERIAL_ALPHABLEND: number;
  24517. /**
  24518. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24519. * They are also discarded below the alpha cutoff threshold to improve performances.
  24520. */
  24521. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24522. /**
  24523. * The Whiteout method is used to blend normals.
  24524. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24525. */
  24526. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24527. /**
  24528. * The Reoriented Normal Mapping method is used to blend normals.
  24529. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24530. */
  24531. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24532. /**
  24533. * Custom callback helping to override the default shader used in the material.
  24534. */
  24535. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24536. /**
  24537. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24538. */
  24539. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24540. /**
  24541. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24542. * This means that the material can keep using a previous shader while a new one is being compiled.
  24543. * This is mostly used when shader parallel compilation is supported (true by default)
  24544. */
  24545. allowShaderHotSwapping: boolean;
  24546. /**
  24547. * The ID of the material
  24548. */
  24549. id: string;
  24550. /**
  24551. * Gets or sets the unique id of the material
  24552. */
  24553. uniqueId: number;
  24554. /**
  24555. * The name of the material
  24556. */
  24557. name: string;
  24558. /**
  24559. * Gets or sets user defined metadata
  24560. */
  24561. metadata: any;
  24562. /**
  24563. * For internal use only. Please do not use.
  24564. */
  24565. reservedDataStore: any;
  24566. /**
  24567. * Specifies if the ready state should be checked on each call
  24568. */
  24569. checkReadyOnEveryCall: boolean;
  24570. /**
  24571. * Specifies if the ready state should be checked once
  24572. */
  24573. checkReadyOnlyOnce: boolean;
  24574. /**
  24575. * The state of the material
  24576. */
  24577. state: string;
  24578. /**
  24579. * The alpha value of the material
  24580. */
  24581. protected _alpha: number;
  24582. /**
  24583. * List of inspectable custom properties (used by the Inspector)
  24584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24585. */
  24586. inspectableCustomProperties: IInspectable[];
  24587. /**
  24588. * Sets the alpha value of the material
  24589. */
  24590. set alpha(value: number);
  24591. /**
  24592. * Gets the alpha value of the material
  24593. */
  24594. get alpha(): number;
  24595. /**
  24596. * Specifies if back face culling is enabled
  24597. */
  24598. protected _backFaceCulling: boolean;
  24599. /**
  24600. * Sets the back-face culling state
  24601. */
  24602. set backFaceCulling(value: boolean);
  24603. /**
  24604. * Gets the back-face culling state
  24605. */
  24606. get backFaceCulling(): boolean;
  24607. /**
  24608. * Stores the value for side orientation
  24609. */
  24610. sideOrientation: number;
  24611. /**
  24612. * Callback triggered when the material is compiled
  24613. */
  24614. onCompiled: Nullable<(effect: Effect) => void>;
  24615. /**
  24616. * Callback triggered when an error occurs
  24617. */
  24618. onError: Nullable<(effect: Effect, errors: string) => void>;
  24619. /**
  24620. * Callback triggered to get the render target textures
  24621. */
  24622. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24623. /**
  24624. * Gets a boolean indicating that current material needs to register RTT
  24625. */
  24626. get hasRenderTargetTextures(): boolean;
  24627. /**
  24628. * Specifies if the material should be serialized
  24629. */
  24630. doNotSerialize: boolean;
  24631. /**
  24632. * @hidden
  24633. */
  24634. _storeEffectOnSubMeshes: boolean;
  24635. /**
  24636. * Stores the animations for the material
  24637. */
  24638. animations: Nullable<Array<Animation>>;
  24639. /**
  24640. * An event triggered when the material is disposed
  24641. */
  24642. onDisposeObservable: Observable<Material>;
  24643. /**
  24644. * An observer which watches for dispose events
  24645. */
  24646. private _onDisposeObserver;
  24647. private _onUnBindObservable;
  24648. /**
  24649. * Called during a dispose event
  24650. */
  24651. set onDispose(callback: () => void);
  24652. private _onBindObservable;
  24653. /**
  24654. * An event triggered when the material is bound
  24655. */
  24656. get onBindObservable(): Observable<AbstractMesh>;
  24657. /**
  24658. * An observer which watches for bind events
  24659. */
  24660. private _onBindObserver;
  24661. /**
  24662. * Called during a bind event
  24663. */
  24664. set onBind(callback: (Mesh: AbstractMesh) => void);
  24665. /**
  24666. * An event triggered when the material is unbound
  24667. */
  24668. get onUnBindObservable(): Observable<Material>;
  24669. protected _onEffectCreatedObservable: Nullable<Observable<{
  24670. effect: Effect;
  24671. subMesh: Nullable<SubMesh>;
  24672. }>>;
  24673. /**
  24674. * An event triggered when the effect is (re)created
  24675. */
  24676. get onEffectCreatedObservable(): Observable<{
  24677. effect: Effect;
  24678. subMesh: Nullable<SubMesh>;
  24679. }>;
  24680. /**
  24681. * Stores the value of the alpha mode
  24682. */
  24683. private _alphaMode;
  24684. /**
  24685. * Sets the value of the alpha mode.
  24686. *
  24687. * | Value | Type | Description |
  24688. * | --- | --- | --- |
  24689. * | 0 | ALPHA_DISABLE | |
  24690. * | 1 | ALPHA_ADD | |
  24691. * | 2 | ALPHA_COMBINE | |
  24692. * | 3 | ALPHA_SUBTRACT | |
  24693. * | 4 | ALPHA_MULTIPLY | |
  24694. * | 5 | ALPHA_MAXIMIZED | |
  24695. * | 6 | ALPHA_ONEONE | |
  24696. * | 7 | ALPHA_PREMULTIPLIED | |
  24697. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24698. * | 9 | ALPHA_INTERPOLATE | |
  24699. * | 10 | ALPHA_SCREENMODE | |
  24700. *
  24701. */
  24702. set alphaMode(value: number);
  24703. /**
  24704. * Gets the value of the alpha mode
  24705. */
  24706. get alphaMode(): number;
  24707. /**
  24708. * Stores the state of the need depth pre-pass value
  24709. */
  24710. private _needDepthPrePass;
  24711. /**
  24712. * Sets the need depth pre-pass value
  24713. */
  24714. set needDepthPrePass(value: boolean);
  24715. /**
  24716. * Gets the depth pre-pass value
  24717. */
  24718. get needDepthPrePass(): boolean;
  24719. /**
  24720. * Specifies if depth writing should be disabled
  24721. */
  24722. disableDepthWrite: boolean;
  24723. /**
  24724. * Specifies if color writing should be disabled
  24725. */
  24726. disableColorWrite: boolean;
  24727. /**
  24728. * Specifies if depth writing should be forced
  24729. */
  24730. forceDepthWrite: boolean;
  24731. /**
  24732. * Specifies the depth function that should be used. 0 means the default engine function
  24733. */
  24734. depthFunction: number;
  24735. /**
  24736. * Specifies if there should be a separate pass for culling
  24737. */
  24738. separateCullingPass: boolean;
  24739. /**
  24740. * Stores the state specifing if fog should be enabled
  24741. */
  24742. private _fogEnabled;
  24743. /**
  24744. * Sets the state for enabling fog
  24745. */
  24746. set fogEnabled(value: boolean);
  24747. /**
  24748. * Gets the value of the fog enabled state
  24749. */
  24750. get fogEnabled(): boolean;
  24751. /**
  24752. * Stores the size of points
  24753. */
  24754. pointSize: number;
  24755. /**
  24756. * Stores the z offset value
  24757. */
  24758. zOffset: number;
  24759. get wireframe(): boolean;
  24760. /**
  24761. * Sets the state of wireframe mode
  24762. */
  24763. set wireframe(value: boolean);
  24764. /**
  24765. * Gets the value specifying if point clouds are enabled
  24766. */
  24767. get pointsCloud(): boolean;
  24768. /**
  24769. * Sets the state of point cloud mode
  24770. */
  24771. set pointsCloud(value: boolean);
  24772. /**
  24773. * Gets the material fill mode
  24774. */
  24775. get fillMode(): number;
  24776. /**
  24777. * Sets the material fill mode
  24778. */
  24779. set fillMode(value: number);
  24780. /**
  24781. * @hidden
  24782. * Stores the effects for the material
  24783. */
  24784. _effect: Nullable<Effect>;
  24785. /**
  24786. * Specifies if uniform buffers should be used
  24787. */
  24788. private _useUBO;
  24789. /**
  24790. * Stores a reference to the scene
  24791. */
  24792. private _scene;
  24793. /**
  24794. * Stores the fill mode state
  24795. */
  24796. private _fillMode;
  24797. /**
  24798. * Specifies if the depth write state should be cached
  24799. */
  24800. private _cachedDepthWriteState;
  24801. /**
  24802. * Specifies if the color write state should be cached
  24803. */
  24804. private _cachedColorWriteState;
  24805. /**
  24806. * Specifies if the depth function state should be cached
  24807. */
  24808. private _cachedDepthFunctionState;
  24809. /**
  24810. * Stores the uniform buffer
  24811. */
  24812. protected _uniformBuffer: UniformBuffer;
  24813. /** @hidden */
  24814. _indexInSceneMaterialArray: number;
  24815. /** @hidden */
  24816. meshMap: Nullable<{
  24817. [id: string]: AbstractMesh | undefined;
  24818. }>;
  24819. /**
  24820. * Creates a material instance
  24821. * @param name defines the name of the material
  24822. * @param scene defines the scene to reference
  24823. * @param doNotAdd specifies if the material should be added to the scene
  24824. */
  24825. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24826. /**
  24827. * Returns a string representation of the current material
  24828. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24829. * @returns a string with material information
  24830. */
  24831. toString(fullDetails?: boolean): string;
  24832. /**
  24833. * Gets the class name of the material
  24834. * @returns a string with the class name of the material
  24835. */
  24836. getClassName(): string;
  24837. /**
  24838. * Specifies if updates for the material been locked
  24839. */
  24840. get isFrozen(): boolean;
  24841. /**
  24842. * Locks updates for the material
  24843. */
  24844. freeze(): void;
  24845. /**
  24846. * Unlocks updates for the material
  24847. */
  24848. unfreeze(): void;
  24849. /**
  24850. * Specifies if the material is ready to be used
  24851. * @param mesh defines the mesh to check
  24852. * @param useInstances specifies if instances should be used
  24853. * @returns a boolean indicating if the material is ready to be used
  24854. */
  24855. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24856. /**
  24857. * Specifies that the submesh is ready to be used
  24858. * @param mesh defines the mesh to check
  24859. * @param subMesh defines which submesh to check
  24860. * @param useInstances specifies that instances should be used
  24861. * @returns a boolean indicating that the submesh is ready or not
  24862. */
  24863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24864. /**
  24865. * Returns the material effect
  24866. * @returns the effect associated with the material
  24867. */
  24868. getEffect(): Nullable<Effect>;
  24869. /**
  24870. * Returns the current scene
  24871. * @returns a Scene
  24872. */
  24873. getScene(): Scene;
  24874. /**
  24875. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24876. */
  24877. protected _forceAlphaTest: boolean;
  24878. /**
  24879. * The transparency mode of the material.
  24880. */
  24881. protected _transparencyMode: Nullable<number>;
  24882. /**
  24883. * Gets the current transparency mode.
  24884. */
  24885. get transparencyMode(): Nullable<number>;
  24886. /**
  24887. * Sets the transparency mode of the material.
  24888. *
  24889. * | Value | Type | Description |
  24890. * | ----- | ----------------------------------- | ----------- |
  24891. * | 0 | OPAQUE | |
  24892. * | 1 | ALPHATEST | |
  24893. * | 2 | ALPHABLEND | |
  24894. * | 3 | ALPHATESTANDBLEND | |
  24895. *
  24896. */
  24897. set transparencyMode(value: Nullable<number>);
  24898. /**
  24899. * Returns true if alpha blending should be disabled.
  24900. */
  24901. protected get _disableAlphaBlending(): boolean;
  24902. /**
  24903. * Specifies whether or not this material should be rendered in alpha blend mode.
  24904. * @returns a boolean specifying if alpha blending is needed
  24905. */
  24906. needAlphaBlending(): boolean;
  24907. /**
  24908. * Specifies if the mesh will require alpha blending
  24909. * @param mesh defines the mesh to check
  24910. * @returns a boolean specifying if alpha blending is needed for the mesh
  24911. */
  24912. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24913. /**
  24914. * Specifies whether or not this material should be rendered in alpha test mode.
  24915. * @returns a boolean specifying if an alpha test is needed.
  24916. */
  24917. needAlphaTesting(): boolean;
  24918. /**
  24919. * Specifies if material alpha testing should be turned on for the mesh
  24920. * @param mesh defines the mesh to check
  24921. */
  24922. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24923. /**
  24924. * Gets the texture used for the alpha test
  24925. * @returns the texture to use for alpha testing
  24926. */
  24927. getAlphaTestTexture(): Nullable<BaseTexture>;
  24928. /**
  24929. * Marks the material to indicate that it needs to be re-calculated
  24930. */
  24931. markDirty(): void;
  24932. /** @hidden */
  24933. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24934. /**
  24935. * Binds the material to the mesh
  24936. * @param world defines the world transformation matrix
  24937. * @param mesh defines the mesh to bind the material to
  24938. */
  24939. bind(world: Matrix, mesh?: Mesh): void;
  24940. /**
  24941. * Binds the submesh to the material
  24942. * @param world defines the world transformation matrix
  24943. * @param mesh defines the mesh containing the submesh
  24944. * @param subMesh defines the submesh to bind the material to
  24945. */
  24946. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24947. /**
  24948. * Binds the world matrix to the material
  24949. * @param world defines the world transformation matrix
  24950. */
  24951. bindOnlyWorldMatrix(world: Matrix): void;
  24952. /**
  24953. * Binds the scene's uniform buffer to the effect.
  24954. * @param effect defines the effect to bind to the scene uniform buffer
  24955. * @param sceneUbo defines the uniform buffer storing scene data
  24956. */
  24957. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24958. /**
  24959. * Binds the view matrix to the effect
  24960. * @param effect defines the effect to bind the view matrix to
  24961. */
  24962. bindView(effect: Effect): void;
  24963. /**
  24964. * Binds the view projection matrix to the effect
  24965. * @param effect defines the effect to bind the view projection matrix to
  24966. */
  24967. bindViewProjection(effect: Effect): void;
  24968. /**
  24969. * Processes to execute after binding the material to a mesh
  24970. * @param mesh defines the rendered mesh
  24971. */
  24972. protected _afterBind(mesh?: Mesh): void;
  24973. /**
  24974. * Unbinds the material from the mesh
  24975. */
  24976. unbind(): void;
  24977. /**
  24978. * Gets the active textures from the material
  24979. * @returns an array of textures
  24980. */
  24981. getActiveTextures(): BaseTexture[];
  24982. /**
  24983. * Specifies if the material uses a texture
  24984. * @param texture defines the texture to check against the material
  24985. * @returns a boolean specifying if the material uses the texture
  24986. */
  24987. hasTexture(texture: BaseTexture): boolean;
  24988. /**
  24989. * Makes a duplicate of the material, and gives it a new name
  24990. * @param name defines the new name for the duplicated material
  24991. * @returns the cloned material
  24992. */
  24993. clone(name: string): Nullable<Material>;
  24994. /**
  24995. * Gets the meshes bound to the material
  24996. * @returns an array of meshes bound to the material
  24997. */
  24998. getBindedMeshes(): AbstractMesh[];
  24999. /**
  25000. * Force shader compilation
  25001. * @param mesh defines the mesh associated with this material
  25002. * @param onCompiled defines a function to execute once the material is compiled
  25003. * @param options defines the options to configure the compilation
  25004. * @param onError defines a function to execute if the material fails compiling
  25005. */
  25006. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25007. /**
  25008. * Force shader compilation
  25009. * @param mesh defines the mesh that will use this material
  25010. * @param options defines additional options for compiling the shaders
  25011. * @returns a promise that resolves when the compilation completes
  25012. */
  25013. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25014. private static readonly _AllDirtyCallBack;
  25015. private static readonly _ImageProcessingDirtyCallBack;
  25016. private static readonly _TextureDirtyCallBack;
  25017. private static readonly _FresnelDirtyCallBack;
  25018. private static readonly _MiscDirtyCallBack;
  25019. private static readonly _LightsDirtyCallBack;
  25020. private static readonly _AttributeDirtyCallBack;
  25021. private static _FresnelAndMiscDirtyCallBack;
  25022. private static _TextureAndMiscDirtyCallBack;
  25023. private static readonly _DirtyCallbackArray;
  25024. private static readonly _RunDirtyCallBacks;
  25025. /**
  25026. * Marks a define in the material to indicate that it needs to be re-computed
  25027. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25028. */
  25029. markAsDirty(flag: number): void;
  25030. /**
  25031. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25032. * @param func defines a function which checks material defines against the submeshes
  25033. */
  25034. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25035. /**
  25036. * Indicates that we need to re-calculated for all submeshes
  25037. */
  25038. protected _markAllSubMeshesAsAllDirty(): void;
  25039. /**
  25040. * Indicates that image processing needs to be re-calculated for all submeshes
  25041. */
  25042. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25043. /**
  25044. * Indicates that textures need to be re-calculated for all submeshes
  25045. */
  25046. protected _markAllSubMeshesAsTexturesDirty(): void;
  25047. /**
  25048. * Indicates that fresnel needs to be re-calculated for all submeshes
  25049. */
  25050. protected _markAllSubMeshesAsFresnelDirty(): void;
  25051. /**
  25052. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25053. */
  25054. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25055. /**
  25056. * Indicates that lights need to be re-calculated for all submeshes
  25057. */
  25058. protected _markAllSubMeshesAsLightsDirty(): void;
  25059. /**
  25060. * Indicates that attributes need to be re-calculated for all submeshes
  25061. */
  25062. protected _markAllSubMeshesAsAttributesDirty(): void;
  25063. /**
  25064. * Indicates that misc needs to be re-calculated for all submeshes
  25065. */
  25066. protected _markAllSubMeshesAsMiscDirty(): void;
  25067. /**
  25068. * Indicates that textures and misc need to be re-calculated for all submeshes
  25069. */
  25070. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25071. /**
  25072. * Disposes the material
  25073. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25074. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25075. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25076. */
  25077. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25078. /** @hidden */
  25079. private releaseVertexArrayObject;
  25080. /**
  25081. * Serializes this material
  25082. * @returns the serialized material object
  25083. */
  25084. serialize(): any;
  25085. /**
  25086. * Creates a material from parsed material data
  25087. * @param parsedMaterial defines parsed material data
  25088. * @param scene defines the hosting scene
  25089. * @param rootUrl defines the root URL to use to load textures
  25090. * @returns a new material
  25091. */
  25092. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25093. }
  25094. }
  25095. declare module "babylonjs/Materials/multiMaterial" {
  25096. import { Nullable } from "babylonjs/types";
  25097. import { Scene } from "babylonjs/scene";
  25098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25099. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25100. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25101. import { Material } from "babylonjs/Materials/material";
  25102. /**
  25103. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25104. * separate meshes. This can be use to improve performances.
  25105. * @see http://doc.babylonjs.com/how_to/multi_materials
  25106. */
  25107. export class MultiMaterial extends Material {
  25108. private _subMaterials;
  25109. /**
  25110. * Gets or Sets the list of Materials used within the multi material.
  25111. * They need to be ordered according to the submeshes order in the associated mesh
  25112. */
  25113. get subMaterials(): Nullable<Material>[];
  25114. set subMaterials(value: Nullable<Material>[]);
  25115. /**
  25116. * Function used to align with Node.getChildren()
  25117. * @returns the list of Materials used within the multi material
  25118. */
  25119. getChildren(): Nullable<Material>[];
  25120. /**
  25121. * Instantiates a new Multi Material
  25122. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25123. * separate meshes. This can be use to improve performances.
  25124. * @see http://doc.babylonjs.com/how_to/multi_materials
  25125. * @param name Define the name in the scene
  25126. * @param scene Define the scene the material belongs to
  25127. */
  25128. constructor(name: string, scene: Scene);
  25129. private _hookArray;
  25130. /**
  25131. * Get one of the submaterial by its index in the submaterials array
  25132. * @param index The index to look the sub material at
  25133. * @returns The Material if the index has been defined
  25134. */
  25135. getSubMaterial(index: number): Nullable<Material>;
  25136. /**
  25137. * Get the list of active textures for the whole sub materials list.
  25138. * @returns All the textures that will be used during the rendering
  25139. */
  25140. getActiveTextures(): BaseTexture[];
  25141. /**
  25142. * Gets the current class name of the material e.g. "MultiMaterial"
  25143. * Mainly use in serialization.
  25144. * @returns the class name
  25145. */
  25146. getClassName(): string;
  25147. /**
  25148. * Checks if the material is ready to render the requested sub mesh
  25149. * @param mesh Define the mesh the submesh belongs to
  25150. * @param subMesh Define the sub mesh to look readyness for
  25151. * @param useInstances Define whether or not the material is used with instances
  25152. * @returns true if ready, otherwise false
  25153. */
  25154. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25155. /**
  25156. * Clones the current material and its related sub materials
  25157. * @param name Define the name of the newly cloned material
  25158. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25159. * @returns the cloned material
  25160. */
  25161. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25162. /**
  25163. * Serializes the materials into a JSON representation.
  25164. * @returns the JSON representation
  25165. */
  25166. serialize(): any;
  25167. /**
  25168. * Dispose the material and release its associated resources
  25169. * @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)
  25170. * @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)
  25171. * @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)
  25172. */
  25173. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25174. /**
  25175. * Creates a MultiMaterial from parsed MultiMaterial data.
  25176. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25177. * @param scene defines the hosting scene
  25178. * @returns a new MultiMaterial
  25179. */
  25180. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25181. }
  25182. }
  25183. declare module "babylonjs/Meshes/subMesh" {
  25184. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25185. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25186. import { Engine } from "babylonjs/Engines/engine";
  25187. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25188. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25189. import { Effect } from "babylonjs/Materials/effect";
  25190. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25191. import { Plane } from "babylonjs/Maths/math.plane";
  25192. import { Collider } from "babylonjs/Collisions/collider";
  25193. import { Material } from "babylonjs/Materials/material";
  25194. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25196. import { Mesh } from "babylonjs/Meshes/mesh";
  25197. import { Ray } from "babylonjs/Culling/ray";
  25198. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25199. /**
  25200. * Defines a subdivision inside a mesh
  25201. */
  25202. export class SubMesh implements ICullable {
  25203. /** the material index to use */
  25204. materialIndex: number;
  25205. /** vertex index start */
  25206. verticesStart: number;
  25207. /** vertices count */
  25208. verticesCount: number;
  25209. /** index start */
  25210. indexStart: number;
  25211. /** indices count */
  25212. indexCount: number;
  25213. /** @hidden */
  25214. _materialDefines: Nullable<MaterialDefines>;
  25215. /** @hidden */
  25216. _materialEffect: Nullable<Effect>;
  25217. /** @hidden */
  25218. _effectOverride: Nullable<Effect>;
  25219. /**
  25220. * Gets material defines used by the effect associated to the sub mesh
  25221. */
  25222. get materialDefines(): Nullable<MaterialDefines>;
  25223. /**
  25224. * Sets material defines used by the effect associated to the sub mesh
  25225. */
  25226. set materialDefines(defines: Nullable<MaterialDefines>);
  25227. /**
  25228. * Gets associated effect
  25229. */
  25230. get effect(): Nullable<Effect>;
  25231. /**
  25232. * Sets associated effect (effect used to render this submesh)
  25233. * @param effect defines the effect to associate with
  25234. * @param defines defines the set of defines used to compile this effect
  25235. */
  25236. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25237. /** @hidden */
  25238. _linesIndexCount: number;
  25239. private _mesh;
  25240. private _renderingMesh;
  25241. private _boundingInfo;
  25242. private _linesIndexBuffer;
  25243. /** @hidden */
  25244. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25245. /** @hidden */
  25246. _trianglePlanes: Plane[];
  25247. /** @hidden */
  25248. _lastColliderTransformMatrix: Nullable<Matrix>;
  25249. /** @hidden */
  25250. _renderId: number;
  25251. /** @hidden */
  25252. _alphaIndex: number;
  25253. /** @hidden */
  25254. _distanceToCamera: number;
  25255. /** @hidden */
  25256. _id: number;
  25257. private _currentMaterial;
  25258. /**
  25259. * Add a new submesh to a mesh
  25260. * @param materialIndex defines the material index to use
  25261. * @param verticesStart defines vertex index start
  25262. * @param verticesCount defines vertices count
  25263. * @param indexStart defines index start
  25264. * @param indexCount defines indices count
  25265. * @param mesh defines the parent mesh
  25266. * @param renderingMesh defines an optional rendering mesh
  25267. * @param createBoundingBox defines if bounding box should be created for this submesh
  25268. * @returns the new submesh
  25269. */
  25270. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25271. /**
  25272. * Creates a new submesh
  25273. * @param materialIndex defines the material index to use
  25274. * @param verticesStart defines vertex index start
  25275. * @param verticesCount defines vertices count
  25276. * @param indexStart defines index start
  25277. * @param indexCount defines indices count
  25278. * @param mesh defines the parent mesh
  25279. * @param renderingMesh defines an optional rendering mesh
  25280. * @param createBoundingBox defines if bounding box should be created for this submesh
  25281. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25282. */
  25283. constructor(
  25284. /** the material index to use */
  25285. materialIndex: number,
  25286. /** vertex index start */
  25287. verticesStart: number,
  25288. /** vertices count */
  25289. verticesCount: number,
  25290. /** index start */
  25291. indexStart: number,
  25292. /** indices count */
  25293. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25294. /**
  25295. * Returns true if this submesh covers the entire parent mesh
  25296. * @ignorenaming
  25297. */
  25298. get IsGlobal(): boolean;
  25299. /**
  25300. * Returns the submesh BoudingInfo object
  25301. * @returns current bounding info (or mesh's one if the submesh is global)
  25302. */
  25303. getBoundingInfo(): BoundingInfo;
  25304. /**
  25305. * Sets the submesh BoundingInfo
  25306. * @param boundingInfo defines the new bounding info to use
  25307. * @returns the SubMesh
  25308. */
  25309. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25310. /**
  25311. * Returns the mesh of the current submesh
  25312. * @return the parent mesh
  25313. */
  25314. getMesh(): AbstractMesh;
  25315. /**
  25316. * Returns the rendering mesh of the submesh
  25317. * @returns the rendering mesh (could be different from parent mesh)
  25318. */
  25319. getRenderingMesh(): Mesh;
  25320. /**
  25321. * Returns the replacement mesh of the submesh
  25322. * @returns the replacement mesh (could be different from parent mesh)
  25323. */
  25324. getReplacementMesh(): Nullable<AbstractMesh>;
  25325. /**
  25326. * Returns the effective mesh of the submesh
  25327. * @returns the effective mesh (could be different from parent mesh)
  25328. */
  25329. getEffectiveMesh(): AbstractMesh;
  25330. /**
  25331. * Returns the submesh material
  25332. * @returns null or the current material
  25333. */
  25334. getMaterial(): Nullable<Material>;
  25335. private _IsMultiMaterial;
  25336. /**
  25337. * Sets a new updated BoundingInfo object to the submesh
  25338. * @param data defines an optional position array to use to determine the bounding info
  25339. * @returns the SubMesh
  25340. */
  25341. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25342. /** @hidden */
  25343. _checkCollision(collider: Collider): boolean;
  25344. /**
  25345. * Updates the submesh BoundingInfo
  25346. * @param world defines the world matrix to use to update the bounding info
  25347. * @returns the submesh
  25348. */
  25349. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25350. /**
  25351. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25352. * @param frustumPlanes defines the frustum planes
  25353. * @returns true if the submesh is intersecting with the frustum
  25354. */
  25355. isInFrustum(frustumPlanes: Plane[]): boolean;
  25356. /**
  25357. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25358. * @param frustumPlanes defines the frustum planes
  25359. * @returns true if the submesh is inside the frustum
  25360. */
  25361. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25362. /**
  25363. * Renders the submesh
  25364. * @param enableAlphaMode defines if alpha needs to be used
  25365. * @returns the submesh
  25366. */
  25367. render(enableAlphaMode: boolean): SubMesh;
  25368. /**
  25369. * @hidden
  25370. */
  25371. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25372. /**
  25373. * Checks if the submesh intersects with a ray
  25374. * @param ray defines the ray to test
  25375. * @returns true is the passed ray intersects the submesh bounding box
  25376. */
  25377. canIntersects(ray: Ray): boolean;
  25378. /**
  25379. * Intersects current submesh with a ray
  25380. * @param ray defines the ray to test
  25381. * @param positions defines mesh's positions array
  25382. * @param indices defines mesh's indices array
  25383. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25384. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25385. * @returns intersection info or null if no intersection
  25386. */
  25387. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25388. /** @hidden */
  25389. private _intersectLines;
  25390. /** @hidden */
  25391. private _intersectUnIndexedLines;
  25392. /** @hidden */
  25393. private _intersectTriangles;
  25394. /** @hidden */
  25395. private _intersectUnIndexedTriangles;
  25396. /** @hidden */
  25397. _rebuild(): void;
  25398. /**
  25399. * Creates a new submesh from the passed mesh
  25400. * @param newMesh defines the new hosting mesh
  25401. * @param newRenderingMesh defines an optional rendering mesh
  25402. * @returns the new submesh
  25403. */
  25404. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25405. /**
  25406. * Release associated resources
  25407. */
  25408. dispose(): void;
  25409. /**
  25410. * Gets the class name
  25411. * @returns the string "SubMesh".
  25412. */
  25413. getClassName(): string;
  25414. /**
  25415. * Creates a new submesh from indices data
  25416. * @param materialIndex the index of the main mesh material
  25417. * @param startIndex the index where to start the copy in the mesh indices array
  25418. * @param indexCount the number of indices to copy then from the startIndex
  25419. * @param mesh the main mesh to create the submesh from
  25420. * @param renderingMesh the optional rendering mesh
  25421. * @returns a new submesh
  25422. */
  25423. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25424. }
  25425. }
  25426. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25427. /**
  25428. * Class used to represent data loading progression
  25429. */
  25430. export class SceneLoaderFlags {
  25431. private static _ForceFullSceneLoadingForIncremental;
  25432. private static _ShowLoadingScreen;
  25433. private static _CleanBoneMatrixWeights;
  25434. private static _loggingLevel;
  25435. /**
  25436. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25437. */
  25438. static get ForceFullSceneLoadingForIncremental(): boolean;
  25439. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25440. /**
  25441. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25442. */
  25443. static get ShowLoadingScreen(): boolean;
  25444. static set ShowLoadingScreen(value: boolean);
  25445. /**
  25446. * Defines the current logging level (while loading the scene)
  25447. * @ignorenaming
  25448. */
  25449. static get loggingLevel(): number;
  25450. static set loggingLevel(value: number);
  25451. /**
  25452. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25453. */
  25454. static get CleanBoneMatrixWeights(): boolean;
  25455. static set CleanBoneMatrixWeights(value: boolean);
  25456. }
  25457. }
  25458. declare module "babylonjs/Meshes/geometry" {
  25459. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25460. import { Scene } from "babylonjs/scene";
  25461. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25462. import { Engine } from "babylonjs/Engines/engine";
  25463. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25464. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25465. import { Effect } from "babylonjs/Materials/effect";
  25466. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25467. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25468. import { Mesh } from "babylonjs/Meshes/mesh";
  25469. /**
  25470. * Class used to store geometry data (vertex buffers + index buffer)
  25471. */
  25472. export class Geometry implements IGetSetVerticesData {
  25473. /**
  25474. * Gets or sets the ID of the geometry
  25475. */
  25476. id: string;
  25477. /**
  25478. * Gets or sets the unique ID of the geometry
  25479. */
  25480. uniqueId: number;
  25481. /**
  25482. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25483. */
  25484. delayLoadState: number;
  25485. /**
  25486. * Gets the file containing the data to load when running in delay load state
  25487. */
  25488. delayLoadingFile: Nullable<string>;
  25489. /**
  25490. * Callback called when the geometry is updated
  25491. */
  25492. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25493. private _scene;
  25494. private _engine;
  25495. private _meshes;
  25496. private _totalVertices;
  25497. /** @hidden */
  25498. _indices: IndicesArray;
  25499. /** @hidden */
  25500. _vertexBuffers: {
  25501. [key: string]: VertexBuffer;
  25502. };
  25503. private _isDisposed;
  25504. private _extend;
  25505. private _boundingBias;
  25506. /** @hidden */
  25507. _delayInfo: Array<string>;
  25508. private _indexBuffer;
  25509. private _indexBufferIsUpdatable;
  25510. /** @hidden */
  25511. _boundingInfo: Nullable<BoundingInfo>;
  25512. /** @hidden */
  25513. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25514. /** @hidden */
  25515. _softwareSkinningFrameId: number;
  25516. private _vertexArrayObjects;
  25517. private _updatable;
  25518. /** @hidden */
  25519. _positions: Nullable<Vector3[]>;
  25520. /**
  25521. * 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
  25522. */
  25523. get boundingBias(): Vector2;
  25524. /**
  25525. * 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
  25526. */
  25527. set boundingBias(value: Vector2);
  25528. /**
  25529. * Static function used to attach a new empty geometry to a mesh
  25530. * @param mesh defines the mesh to attach the geometry to
  25531. * @returns the new Geometry
  25532. */
  25533. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25534. /** Get the list of meshes using this geometry */
  25535. get meshes(): Mesh[];
  25536. /**
  25537. * Creates a new geometry
  25538. * @param id defines the unique ID
  25539. * @param scene defines the hosting scene
  25540. * @param vertexData defines the VertexData used to get geometry data
  25541. * @param updatable defines if geometry must be updatable (false by default)
  25542. * @param mesh defines the mesh that will be associated with the geometry
  25543. */
  25544. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25545. /**
  25546. * Gets the current extend of the geometry
  25547. */
  25548. get extend(): {
  25549. minimum: Vector3;
  25550. maximum: Vector3;
  25551. };
  25552. /**
  25553. * Gets the hosting scene
  25554. * @returns the hosting Scene
  25555. */
  25556. getScene(): Scene;
  25557. /**
  25558. * Gets the hosting engine
  25559. * @returns the hosting Engine
  25560. */
  25561. getEngine(): Engine;
  25562. /**
  25563. * Defines if the geometry is ready to use
  25564. * @returns true if the geometry is ready to be used
  25565. */
  25566. isReady(): boolean;
  25567. /**
  25568. * Gets a value indicating that the geometry should not be serialized
  25569. */
  25570. get doNotSerialize(): boolean;
  25571. /** @hidden */
  25572. _rebuild(): void;
  25573. /**
  25574. * Affects all geometry data in one call
  25575. * @param vertexData defines the geometry data
  25576. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25577. */
  25578. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25579. /**
  25580. * Set specific vertex data
  25581. * @param kind defines the data kind (Position, normal, etc...)
  25582. * @param data defines the vertex data to use
  25583. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25584. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25585. */
  25586. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25587. /**
  25588. * Removes a specific vertex data
  25589. * @param kind defines the data kind (Position, normal, etc...)
  25590. */
  25591. removeVerticesData(kind: string): void;
  25592. /**
  25593. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25594. * @param buffer defines the vertex buffer to use
  25595. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25596. */
  25597. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25598. /**
  25599. * Update a specific vertex buffer
  25600. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25601. * It will do nothing if the buffer is not updatable
  25602. * @param kind defines the data kind (Position, normal, etc...)
  25603. * @param data defines the data to use
  25604. * @param offset defines the offset in the target buffer where to store the data
  25605. * @param useBytes set to true if the offset is in bytes
  25606. */
  25607. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25608. /**
  25609. * Update a specific vertex buffer
  25610. * This function will create a new buffer if the current one is not updatable
  25611. * @param kind defines the data kind (Position, normal, etc...)
  25612. * @param data defines the data to use
  25613. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25614. */
  25615. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25616. private _updateBoundingInfo;
  25617. /** @hidden */
  25618. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25619. /**
  25620. * Gets total number of vertices
  25621. * @returns the total number of vertices
  25622. */
  25623. getTotalVertices(): number;
  25624. /**
  25625. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25626. * @param kind defines the data kind (Position, normal, etc...)
  25627. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25628. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25629. * @returns a float array containing vertex data
  25630. */
  25631. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25632. /**
  25633. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25634. * @param kind defines the data kind (Position, normal, etc...)
  25635. * @returns true if the vertex buffer with the specified kind is updatable
  25636. */
  25637. isVertexBufferUpdatable(kind: string): boolean;
  25638. /**
  25639. * Gets a specific vertex buffer
  25640. * @param kind defines the data kind (Position, normal, etc...)
  25641. * @returns a VertexBuffer
  25642. */
  25643. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25644. /**
  25645. * Returns all vertex buffers
  25646. * @return an object holding all vertex buffers indexed by kind
  25647. */
  25648. getVertexBuffers(): Nullable<{
  25649. [key: string]: VertexBuffer;
  25650. }>;
  25651. /**
  25652. * Gets a boolean indicating if specific vertex buffer is present
  25653. * @param kind defines the data kind (Position, normal, etc...)
  25654. * @returns true if data is present
  25655. */
  25656. isVerticesDataPresent(kind: string): boolean;
  25657. /**
  25658. * Gets a list of all attached data kinds (Position, normal, etc...)
  25659. * @returns a list of string containing all kinds
  25660. */
  25661. getVerticesDataKinds(): string[];
  25662. /**
  25663. * Update index buffer
  25664. * @param indices defines the indices to store in the index buffer
  25665. * @param offset defines the offset in the target buffer where to store the data
  25666. * @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)
  25667. */
  25668. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25669. /**
  25670. * Creates a new index buffer
  25671. * @param indices defines the indices to store in the index buffer
  25672. * @param totalVertices defines the total number of vertices (could be null)
  25673. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25674. */
  25675. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25676. /**
  25677. * Return the total number of indices
  25678. * @returns the total number of indices
  25679. */
  25680. getTotalIndices(): number;
  25681. /**
  25682. * Gets the index buffer array
  25683. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25684. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25685. * @returns the index buffer array
  25686. */
  25687. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25688. /**
  25689. * Gets the index buffer
  25690. * @return the index buffer
  25691. */
  25692. getIndexBuffer(): Nullable<DataBuffer>;
  25693. /** @hidden */
  25694. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25695. /**
  25696. * Release the associated resources for a specific mesh
  25697. * @param mesh defines the source mesh
  25698. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25699. */
  25700. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25701. /**
  25702. * Apply current geometry to a given mesh
  25703. * @param mesh defines the mesh to apply geometry to
  25704. */
  25705. applyToMesh(mesh: Mesh): void;
  25706. private _updateExtend;
  25707. private _applyToMesh;
  25708. private notifyUpdate;
  25709. /**
  25710. * Load the geometry if it was flagged as delay loaded
  25711. * @param scene defines the hosting scene
  25712. * @param onLoaded defines a callback called when the geometry is loaded
  25713. */
  25714. load(scene: Scene, onLoaded?: () => void): void;
  25715. private _queueLoad;
  25716. /**
  25717. * Invert the geometry to move from a right handed system to a left handed one.
  25718. */
  25719. toLeftHanded(): void;
  25720. /** @hidden */
  25721. _resetPointsArrayCache(): void;
  25722. /** @hidden */
  25723. _generatePointsArray(): boolean;
  25724. /**
  25725. * Gets a value indicating if the geometry is disposed
  25726. * @returns true if the geometry was disposed
  25727. */
  25728. isDisposed(): boolean;
  25729. private _disposeVertexArrayObjects;
  25730. /**
  25731. * Free all associated resources
  25732. */
  25733. dispose(): void;
  25734. /**
  25735. * Clone the current geometry into a new geometry
  25736. * @param id defines the unique ID of the new geometry
  25737. * @returns a new geometry object
  25738. */
  25739. copy(id: string): Geometry;
  25740. /**
  25741. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25742. * @return a JSON representation of the current geometry data (without the vertices data)
  25743. */
  25744. serialize(): any;
  25745. private toNumberArray;
  25746. /**
  25747. * Serialize all vertices data into a JSON oject
  25748. * @returns a JSON representation of the current geometry data
  25749. */
  25750. serializeVerticeData(): any;
  25751. /**
  25752. * Extracts a clone of a mesh geometry
  25753. * @param mesh defines the source mesh
  25754. * @param id defines the unique ID of the new geometry object
  25755. * @returns the new geometry object
  25756. */
  25757. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25758. /**
  25759. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25760. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25761. * Be aware Math.random() could cause collisions, but:
  25762. * "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"
  25763. * @returns a string containing a new GUID
  25764. */
  25765. static RandomId(): string;
  25766. /** @hidden */
  25767. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25768. private static _CleanMatricesWeights;
  25769. /**
  25770. * Create a new geometry from persisted data (Using .babylon file format)
  25771. * @param parsedVertexData defines the persisted data
  25772. * @param scene defines the hosting scene
  25773. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25774. * @returns the new geometry object
  25775. */
  25776. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25777. }
  25778. }
  25779. declare module "babylonjs/Meshes/mesh.vertexData" {
  25780. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25781. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25782. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25783. import { Geometry } from "babylonjs/Meshes/geometry";
  25784. import { Mesh } from "babylonjs/Meshes/mesh";
  25785. /**
  25786. * Define an interface for all classes that will get and set the data on vertices
  25787. */
  25788. export interface IGetSetVerticesData {
  25789. /**
  25790. * Gets a boolean indicating if specific vertex data is present
  25791. * @param kind defines the vertex data kind to use
  25792. * @returns true is data kind is present
  25793. */
  25794. isVerticesDataPresent(kind: string): boolean;
  25795. /**
  25796. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25797. * @param kind defines the data kind (Position, normal, etc...)
  25798. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25799. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25800. * @returns a float array containing vertex data
  25801. */
  25802. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25803. /**
  25804. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25805. * @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.
  25806. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25807. * @returns the indices array or an empty array if the mesh has no geometry
  25808. */
  25809. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25810. /**
  25811. * Set specific vertex data
  25812. * @param kind defines the data kind (Position, normal, etc...)
  25813. * @param data defines the vertex data to use
  25814. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25815. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25816. */
  25817. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25818. /**
  25819. * Update a specific associated vertex buffer
  25820. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25821. * - VertexBuffer.PositionKind
  25822. * - VertexBuffer.UVKind
  25823. * - VertexBuffer.UV2Kind
  25824. * - VertexBuffer.UV3Kind
  25825. * - VertexBuffer.UV4Kind
  25826. * - VertexBuffer.UV5Kind
  25827. * - VertexBuffer.UV6Kind
  25828. * - VertexBuffer.ColorKind
  25829. * - VertexBuffer.MatricesIndicesKind
  25830. * - VertexBuffer.MatricesIndicesExtraKind
  25831. * - VertexBuffer.MatricesWeightsKind
  25832. * - VertexBuffer.MatricesWeightsExtraKind
  25833. * @param data defines the data source
  25834. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25835. * @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)
  25836. */
  25837. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25838. /**
  25839. * Creates a new index buffer
  25840. * @param indices defines the indices to store in the index buffer
  25841. * @param totalVertices defines the total number of vertices (could be null)
  25842. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25843. */
  25844. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25845. }
  25846. /**
  25847. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25848. */
  25849. export class VertexData {
  25850. /**
  25851. * Mesh side orientation : usually the external or front surface
  25852. */
  25853. static readonly FRONTSIDE: number;
  25854. /**
  25855. * Mesh side orientation : usually the internal or back surface
  25856. */
  25857. static readonly BACKSIDE: number;
  25858. /**
  25859. * Mesh side orientation : both internal and external or front and back surfaces
  25860. */
  25861. static readonly DOUBLESIDE: number;
  25862. /**
  25863. * Mesh side orientation : by default, `FRONTSIDE`
  25864. */
  25865. static readonly DEFAULTSIDE: number;
  25866. /**
  25867. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25868. */
  25869. positions: Nullable<FloatArray>;
  25870. /**
  25871. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25872. */
  25873. normals: Nullable<FloatArray>;
  25874. /**
  25875. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25876. */
  25877. tangents: Nullable<FloatArray>;
  25878. /**
  25879. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25880. */
  25881. uvs: Nullable<FloatArray>;
  25882. /**
  25883. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25884. */
  25885. uvs2: Nullable<FloatArray>;
  25886. /**
  25887. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25888. */
  25889. uvs3: Nullable<FloatArray>;
  25890. /**
  25891. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25892. */
  25893. uvs4: Nullable<FloatArray>;
  25894. /**
  25895. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25896. */
  25897. uvs5: Nullable<FloatArray>;
  25898. /**
  25899. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25900. */
  25901. uvs6: Nullable<FloatArray>;
  25902. /**
  25903. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25904. */
  25905. colors: Nullable<FloatArray>;
  25906. /**
  25907. * 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).
  25908. */
  25909. matricesIndices: Nullable<FloatArray>;
  25910. /**
  25911. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25912. */
  25913. matricesWeights: Nullable<FloatArray>;
  25914. /**
  25915. * An array extending the number of possible indices
  25916. */
  25917. matricesIndicesExtra: Nullable<FloatArray>;
  25918. /**
  25919. * An array extending the number of possible weights when the number of indices is extended
  25920. */
  25921. matricesWeightsExtra: Nullable<FloatArray>;
  25922. /**
  25923. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25924. */
  25925. indices: Nullable<IndicesArray>;
  25926. /**
  25927. * Uses the passed data array to set the set the values for the specified kind of data
  25928. * @param data a linear array of floating numbers
  25929. * @param kind the type of data that is being set, eg positions, colors etc
  25930. */
  25931. set(data: FloatArray, kind: string): void;
  25932. /**
  25933. * Associates the vertexData to the passed Mesh.
  25934. * Sets it as updatable or not (default `false`)
  25935. * @param mesh the mesh the vertexData is applied to
  25936. * @param updatable when used and having the value true allows new data to update the vertexData
  25937. * @returns the VertexData
  25938. */
  25939. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25940. /**
  25941. * Associates the vertexData to the passed Geometry.
  25942. * Sets it as updatable or not (default `false`)
  25943. * @param geometry the geometry the vertexData is applied to
  25944. * @param updatable when used and having the value true allows new data to update the vertexData
  25945. * @returns VertexData
  25946. */
  25947. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25948. /**
  25949. * Updates the associated mesh
  25950. * @param mesh the mesh to be updated
  25951. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25952. * @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
  25953. * @returns VertexData
  25954. */
  25955. updateMesh(mesh: Mesh): VertexData;
  25956. /**
  25957. * Updates the associated geometry
  25958. * @param geometry the geometry to be updated
  25959. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25960. * @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
  25961. * @returns VertexData.
  25962. */
  25963. updateGeometry(geometry: Geometry): VertexData;
  25964. private _applyTo;
  25965. private _update;
  25966. /**
  25967. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25968. * @param matrix the transforming matrix
  25969. * @returns the VertexData
  25970. */
  25971. transform(matrix: Matrix): VertexData;
  25972. /**
  25973. * Merges the passed VertexData into the current one
  25974. * @param other the VertexData to be merged into the current one
  25975. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25976. * @returns the modified VertexData
  25977. */
  25978. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25979. private _mergeElement;
  25980. private _validate;
  25981. /**
  25982. * Serializes the VertexData
  25983. * @returns a serialized object
  25984. */
  25985. serialize(): any;
  25986. /**
  25987. * Extracts the vertexData from a mesh
  25988. * @param mesh the mesh from which to extract the VertexData
  25989. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25990. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25991. * @returns the object VertexData associated to the passed mesh
  25992. */
  25993. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25994. /**
  25995. * Extracts the vertexData from the geometry
  25996. * @param geometry the geometry from which to extract the VertexData
  25997. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25998. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25999. * @returns the object VertexData associated to the passed mesh
  26000. */
  26001. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26002. private static _ExtractFrom;
  26003. /**
  26004. * Creates the VertexData for a Ribbon
  26005. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26006. * * pathArray array of paths, each of which an array of successive Vector3
  26007. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26008. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26009. * * 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
  26010. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26011. * * 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)
  26012. * * 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)
  26013. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26014. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26015. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26016. * @returns the VertexData of the ribbon
  26017. */
  26018. static CreateRibbon(options: {
  26019. pathArray: Vector3[][];
  26020. closeArray?: boolean;
  26021. closePath?: boolean;
  26022. offset?: number;
  26023. sideOrientation?: number;
  26024. frontUVs?: Vector4;
  26025. backUVs?: Vector4;
  26026. invertUV?: boolean;
  26027. uvs?: Vector2[];
  26028. colors?: Color4[];
  26029. }): VertexData;
  26030. /**
  26031. * Creates the VertexData for a box
  26032. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26033. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26034. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26035. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26036. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26037. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26038. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26039. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26040. * * 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)
  26041. * * 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)
  26042. * @returns the VertexData of the box
  26043. */
  26044. static CreateBox(options: {
  26045. size?: number;
  26046. width?: number;
  26047. height?: number;
  26048. depth?: number;
  26049. faceUV?: Vector4[];
  26050. faceColors?: Color4[];
  26051. sideOrientation?: number;
  26052. frontUVs?: Vector4;
  26053. backUVs?: Vector4;
  26054. }): VertexData;
  26055. /**
  26056. * Creates the VertexData for a tiled box
  26057. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26058. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26059. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26060. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26061. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26062. * @returns the VertexData of the box
  26063. */
  26064. static CreateTiledBox(options: {
  26065. pattern?: number;
  26066. width?: number;
  26067. height?: number;
  26068. depth?: number;
  26069. tileSize?: number;
  26070. tileWidth?: number;
  26071. tileHeight?: number;
  26072. alignHorizontal?: number;
  26073. alignVertical?: number;
  26074. faceUV?: Vector4[];
  26075. faceColors?: Color4[];
  26076. sideOrientation?: number;
  26077. }): VertexData;
  26078. /**
  26079. * Creates the VertexData for a tiled plane
  26080. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26081. * * pattern a limited pattern arrangement depending on the number
  26082. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26083. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26084. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26085. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26086. * * 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)
  26087. * * 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)
  26088. * @returns the VertexData of the tiled plane
  26089. */
  26090. static CreateTiledPlane(options: {
  26091. pattern?: number;
  26092. tileSize?: number;
  26093. tileWidth?: number;
  26094. tileHeight?: number;
  26095. size?: number;
  26096. width?: number;
  26097. height?: number;
  26098. alignHorizontal?: number;
  26099. alignVertical?: number;
  26100. sideOrientation?: number;
  26101. frontUVs?: Vector4;
  26102. backUVs?: Vector4;
  26103. }): VertexData;
  26104. /**
  26105. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26106. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26107. * * segments sets the number of horizontal strips optional, default 32
  26108. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26109. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26110. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26111. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26112. * * 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
  26113. * * 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
  26114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26115. * * 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)
  26116. * * 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)
  26117. * @returns the VertexData of the ellipsoid
  26118. */
  26119. static CreateSphere(options: {
  26120. segments?: number;
  26121. diameter?: number;
  26122. diameterX?: number;
  26123. diameterY?: number;
  26124. diameterZ?: number;
  26125. arc?: number;
  26126. slice?: number;
  26127. sideOrientation?: number;
  26128. frontUVs?: Vector4;
  26129. backUVs?: Vector4;
  26130. }): VertexData;
  26131. /**
  26132. * Creates the VertexData for a cylinder, cone or prism
  26133. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26134. * * height sets the height (y direction) of the cylinder, optional, default 2
  26135. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26136. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26137. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26138. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26139. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26140. * * 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
  26141. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26142. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26143. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26144. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26146. * * 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)
  26147. * * 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)
  26148. * @returns the VertexData of the cylinder, cone or prism
  26149. */
  26150. static CreateCylinder(options: {
  26151. height?: number;
  26152. diameterTop?: number;
  26153. diameterBottom?: number;
  26154. diameter?: number;
  26155. tessellation?: number;
  26156. subdivisions?: number;
  26157. arc?: number;
  26158. faceColors?: Color4[];
  26159. faceUV?: Vector4[];
  26160. hasRings?: boolean;
  26161. enclose?: boolean;
  26162. sideOrientation?: number;
  26163. frontUVs?: Vector4;
  26164. backUVs?: Vector4;
  26165. }): VertexData;
  26166. /**
  26167. * Creates the VertexData for a torus
  26168. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26169. * * diameter the diameter of the torus, optional default 1
  26170. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26171. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26173. * * 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)
  26174. * * 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)
  26175. * @returns the VertexData of the torus
  26176. */
  26177. static CreateTorus(options: {
  26178. diameter?: number;
  26179. thickness?: number;
  26180. tessellation?: number;
  26181. sideOrientation?: number;
  26182. frontUVs?: Vector4;
  26183. backUVs?: Vector4;
  26184. }): VertexData;
  26185. /**
  26186. * Creates the VertexData of the LineSystem
  26187. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26188. * - lines an array of lines, each line being an array of successive Vector3
  26189. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26190. * @returns the VertexData of the LineSystem
  26191. */
  26192. static CreateLineSystem(options: {
  26193. lines: Vector3[][];
  26194. colors?: Nullable<Color4[][]>;
  26195. }): VertexData;
  26196. /**
  26197. * Create the VertexData for a DashedLines
  26198. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26199. * - points an array successive Vector3
  26200. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26201. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26202. * - dashNb the intended total number of dashes, optional, default 200
  26203. * @returns the VertexData for the DashedLines
  26204. */
  26205. static CreateDashedLines(options: {
  26206. points: Vector3[];
  26207. dashSize?: number;
  26208. gapSize?: number;
  26209. dashNb?: number;
  26210. }): VertexData;
  26211. /**
  26212. * Creates the VertexData for a Ground
  26213. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26214. * - width the width (x direction) of the ground, optional, default 1
  26215. * - height the height (z direction) of the ground, optional, default 1
  26216. * - subdivisions the number of subdivisions per side, optional, default 1
  26217. * @returns the VertexData of the Ground
  26218. */
  26219. static CreateGround(options: {
  26220. width?: number;
  26221. height?: number;
  26222. subdivisions?: number;
  26223. subdivisionsX?: number;
  26224. subdivisionsY?: number;
  26225. }): VertexData;
  26226. /**
  26227. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26228. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26229. * * xmin the ground minimum X coordinate, optional, default -1
  26230. * * zmin the ground minimum Z coordinate, optional, default -1
  26231. * * xmax the ground maximum X coordinate, optional, default 1
  26232. * * zmax the ground maximum Z coordinate, optional, default 1
  26233. * * 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}
  26234. * * 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}
  26235. * @returns the VertexData of the TiledGround
  26236. */
  26237. static CreateTiledGround(options: {
  26238. xmin: number;
  26239. zmin: number;
  26240. xmax: number;
  26241. zmax: number;
  26242. subdivisions?: {
  26243. w: number;
  26244. h: number;
  26245. };
  26246. precision?: {
  26247. w: number;
  26248. h: number;
  26249. };
  26250. }): VertexData;
  26251. /**
  26252. * Creates the VertexData of the Ground designed from a heightmap
  26253. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26254. * * width the width (x direction) of the ground
  26255. * * height the height (z direction) of the ground
  26256. * * subdivisions the number of subdivisions per side
  26257. * * minHeight the minimum altitude on the ground, optional, default 0
  26258. * * maxHeight the maximum altitude on the ground, optional default 1
  26259. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26260. * * buffer the array holding the image color data
  26261. * * bufferWidth the width of image
  26262. * * bufferHeight the height of image
  26263. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26264. * @returns the VertexData of the Ground designed from a heightmap
  26265. */
  26266. static CreateGroundFromHeightMap(options: {
  26267. width: number;
  26268. height: number;
  26269. subdivisions: number;
  26270. minHeight: number;
  26271. maxHeight: number;
  26272. colorFilter: Color3;
  26273. buffer: Uint8Array;
  26274. bufferWidth: number;
  26275. bufferHeight: number;
  26276. alphaFilter: number;
  26277. }): VertexData;
  26278. /**
  26279. * Creates the VertexData for a Plane
  26280. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26281. * * size sets the width and height of the plane to the value of size, optional default 1
  26282. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26283. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26284. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26285. * * 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)
  26286. * * 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)
  26287. * @returns the VertexData of the box
  26288. */
  26289. static CreatePlane(options: {
  26290. size?: number;
  26291. width?: number;
  26292. height?: number;
  26293. sideOrientation?: number;
  26294. frontUVs?: Vector4;
  26295. backUVs?: Vector4;
  26296. }): VertexData;
  26297. /**
  26298. * Creates the VertexData of the Disc or regular Polygon
  26299. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26300. * * radius the radius of the disc, optional default 0.5
  26301. * * tessellation the number of polygon sides, optional, default 64
  26302. * * 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
  26303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26304. * * 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)
  26305. * * 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)
  26306. * @returns the VertexData of the box
  26307. */
  26308. static CreateDisc(options: {
  26309. radius?: number;
  26310. tessellation?: number;
  26311. arc?: number;
  26312. sideOrientation?: number;
  26313. frontUVs?: Vector4;
  26314. backUVs?: Vector4;
  26315. }): VertexData;
  26316. /**
  26317. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26318. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26319. * @param polygon a mesh built from polygonTriangulation.build()
  26320. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26321. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26322. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26323. * @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)
  26324. * @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)
  26325. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26326. * @returns the VertexData of the Polygon
  26327. */
  26328. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26329. /**
  26330. * Creates the VertexData of the IcoSphere
  26331. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26332. * * radius the radius of the IcoSphere, optional default 1
  26333. * * radiusX allows stretching in the x direction, optional, default radius
  26334. * * radiusY allows stretching in the y direction, optional, default radius
  26335. * * radiusZ allows stretching in the z direction, optional, default radius
  26336. * * flat when true creates a flat shaded mesh, optional, default true
  26337. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26338. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26339. * * 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)
  26340. * * 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)
  26341. * @returns the VertexData of the IcoSphere
  26342. */
  26343. static CreateIcoSphere(options: {
  26344. radius?: number;
  26345. radiusX?: number;
  26346. radiusY?: number;
  26347. radiusZ?: number;
  26348. flat?: boolean;
  26349. subdivisions?: number;
  26350. sideOrientation?: number;
  26351. frontUVs?: Vector4;
  26352. backUVs?: Vector4;
  26353. }): VertexData;
  26354. /**
  26355. * Creates the VertexData for a Polyhedron
  26356. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26357. * * type provided types are:
  26358. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26359. * * 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)
  26360. * * size the size of the IcoSphere, optional default 1
  26361. * * sizeX allows stretching in the x direction, optional, default size
  26362. * * sizeY allows stretching in the y direction, optional, default size
  26363. * * sizeZ allows stretching in the z direction, optional, default size
  26364. * * 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
  26365. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26366. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26367. * * flat when true creates a flat shaded mesh, optional, default true
  26368. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26369. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26370. * * 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)
  26371. * * 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)
  26372. * @returns the VertexData of the Polyhedron
  26373. */
  26374. static CreatePolyhedron(options: {
  26375. type?: number;
  26376. size?: number;
  26377. sizeX?: number;
  26378. sizeY?: number;
  26379. sizeZ?: number;
  26380. custom?: any;
  26381. faceUV?: Vector4[];
  26382. faceColors?: Color4[];
  26383. flat?: boolean;
  26384. sideOrientation?: number;
  26385. frontUVs?: Vector4;
  26386. backUVs?: Vector4;
  26387. }): VertexData;
  26388. /**
  26389. * Creates the VertexData for a TorusKnot
  26390. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26391. * * radius the radius of the torus knot, optional, default 2
  26392. * * tube the thickness of the tube, optional, default 0.5
  26393. * * radialSegments the number of sides on each tube segments, optional, default 32
  26394. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26395. * * p the number of windings around the z axis, optional, default 2
  26396. * * q the number of windings around the x axis, optional, default 3
  26397. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26398. * * 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)
  26399. * * 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)
  26400. * @returns the VertexData of the Torus Knot
  26401. */
  26402. static CreateTorusKnot(options: {
  26403. radius?: number;
  26404. tube?: number;
  26405. radialSegments?: number;
  26406. tubularSegments?: number;
  26407. p?: number;
  26408. q?: number;
  26409. sideOrientation?: number;
  26410. frontUVs?: Vector4;
  26411. backUVs?: Vector4;
  26412. }): VertexData;
  26413. /**
  26414. * Compute normals for given positions and indices
  26415. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26416. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26417. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26418. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26419. * * facetNormals : optional array of facet normals (vector3)
  26420. * * facetPositions : optional array of facet positions (vector3)
  26421. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26422. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26423. * * bInfo : optional bounding info, required for facetPartitioning computation
  26424. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26425. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26426. * * useRightHandedSystem: optional boolean to for right handed system computation
  26427. * * depthSort : optional boolean to enable the facet depth sort computation
  26428. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26429. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26430. */
  26431. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26432. facetNormals?: any;
  26433. facetPositions?: any;
  26434. facetPartitioning?: any;
  26435. ratio?: number;
  26436. bInfo?: any;
  26437. bbSize?: Vector3;
  26438. subDiv?: any;
  26439. useRightHandedSystem?: boolean;
  26440. depthSort?: boolean;
  26441. distanceTo?: Vector3;
  26442. depthSortedFacets?: any;
  26443. }): void;
  26444. /** @hidden */
  26445. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26446. /**
  26447. * Applies VertexData created from the imported parameters to the geometry
  26448. * @param parsedVertexData the parsed data from an imported file
  26449. * @param geometry the geometry to apply the VertexData to
  26450. */
  26451. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26452. }
  26453. }
  26454. declare module "babylonjs/Morph/morphTarget" {
  26455. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26456. import { Observable } from "babylonjs/Misc/observable";
  26457. import { Nullable, FloatArray } from "babylonjs/types";
  26458. import { Scene } from "babylonjs/scene";
  26459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26460. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26461. /**
  26462. * Defines a target to use with MorphTargetManager
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26464. */
  26465. export class MorphTarget implements IAnimatable {
  26466. /** defines the name of the target */
  26467. name: string;
  26468. /**
  26469. * Gets or sets the list of animations
  26470. */
  26471. animations: import("babylonjs/Animations/animation").Animation[];
  26472. private _scene;
  26473. private _positions;
  26474. private _normals;
  26475. private _tangents;
  26476. private _uvs;
  26477. private _influence;
  26478. private _uniqueId;
  26479. /**
  26480. * Observable raised when the influence changes
  26481. */
  26482. onInfluenceChanged: Observable<boolean>;
  26483. /** @hidden */
  26484. _onDataLayoutChanged: Observable<void>;
  26485. /**
  26486. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26487. */
  26488. get influence(): number;
  26489. set influence(influence: number);
  26490. /**
  26491. * Gets or sets the id of the morph Target
  26492. */
  26493. id: string;
  26494. private _animationPropertiesOverride;
  26495. /**
  26496. * Gets or sets the animation properties override
  26497. */
  26498. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26499. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26500. /**
  26501. * Creates a new MorphTarget
  26502. * @param name defines the name of the target
  26503. * @param influence defines the influence to use
  26504. * @param scene defines the scene the morphtarget belongs to
  26505. */
  26506. constructor(
  26507. /** defines the name of the target */
  26508. name: string, influence?: number, scene?: Nullable<Scene>);
  26509. /**
  26510. * Gets the unique ID of this manager
  26511. */
  26512. get uniqueId(): number;
  26513. /**
  26514. * Gets a boolean defining if the target contains position data
  26515. */
  26516. get hasPositions(): boolean;
  26517. /**
  26518. * Gets a boolean defining if the target contains normal data
  26519. */
  26520. get hasNormals(): boolean;
  26521. /**
  26522. * Gets a boolean defining if the target contains tangent data
  26523. */
  26524. get hasTangents(): boolean;
  26525. /**
  26526. * Gets a boolean defining if the target contains texture coordinates data
  26527. */
  26528. get hasUVs(): boolean;
  26529. /**
  26530. * Affects position data to this target
  26531. * @param data defines the position data to use
  26532. */
  26533. setPositions(data: Nullable<FloatArray>): void;
  26534. /**
  26535. * Gets the position data stored in this target
  26536. * @returns a FloatArray containing the position data (or null if not present)
  26537. */
  26538. getPositions(): Nullable<FloatArray>;
  26539. /**
  26540. * Affects normal data to this target
  26541. * @param data defines the normal data to use
  26542. */
  26543. setNormals(data: Nullable<FloatArray>): void;
  26544. /**
  26545. * Gets the normal data stored in this target
  26546. * @returns a FloatArray containing the normal data (or null if not present)
  26547. */
  26548. getNormals(): Nullable<FloatArray>;
  26549. /**
  26550. * Affects tangent data to this target
  26551. * @param data defines the tangent data to use
  26552. */
  26553. setTangents(data: Nullable<FloatArray>): void;
  26554. /**
  26555. * Gets the tangent data stored in this target
  26556. * @returns a FloatArray containing the tangent data (or null if not present)
  26557. */
  26558. getTangents(): Nullable<FloatArray>;
  26559. /**
  26560. * Affects texture coordinates data to this target
  26561. * @param data defines the texture coordinates data to use
  26562. */
  26563. setUVs(data: Nullable<FloatArray>): void;
  26564. /**
  26565. * Gets the texture coordinates data stored in this target
  26566. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26567. */
  26568. getUVs(): Nullable<FloatArray>;
  26569. /**
  26570. * Clone the current target
  26571. * @returns a new MorphTarget
  26572. */
  26573. clone(): MorphTarget;
  26574. /**
  26575. * Serializes the current target into a Serialization object
  26576. * @returns the serialized object
  26577. */
  26578. serialize(): any;
  26579. /**
  26580. * Returns the string "MorphTarget"
  26581. * @returns "MorphTarget"
  26582. */
  26583. getClassName(): string;
  26584. /**
  26585. * Creates a new target from serialized data
  26586. * @param serializationObject defines the serialized data to use
  26587. * @returns a new MorphTarget
  26588. */
  26589. static Parse(serializationObject: any): MorphTarget;
  26590. /**
  26591. * Creates a MorphTarget from mesh data
  26592. * @param mesh defines the source mesh
  26593. * @param name defines the name to use for the new target
  26594. * @param influence defines the influence to attach to the target
  26595. * @returns a new MorphTarget
  26596. */
  26597. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26598. }
  26599. }
  26600. declare module "babylonjs/Morph/morphTargetManager" {
  26601. import { Nullable } from "babylonjs/types";
  26602. import { Scene } from "babylonjs/scene";
  26603. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26604. /**
  26605. * This class is used to deform meshes using morphing between different targets
  26606. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26607. */
  26608. export class MorphTargetManager {
  26609. private _targets;
  26610. private _targetInfluenceChangedObservers;
  26611. private _targetDataLayoutChangedObservers;
  26612. private _activeTargets;
  26613. private _scene;
  26614. private _influences;
  26615. private _supportsNormals;
  26616. private _supportsTangents;
  26617. private _supportsUVs;
  26618. private _vertexCount;
  26619. private _uniqueId;
  26620. private _tempInfluences;
  26621. /**
  26622. * Gets or sets a boolean indicating if normals must be morphed
  26623. */
  26624. enableNormalMorphing: boolean;
  26625. /**
  26626. * Gets or sets a boolean indicating if tangents must be morphed
  26627. */
  26628. enableTangentMorphing: boolean;
  26629. /**
  26630. * Gets or sets a boolean indicating if UV must be morphed
  26631. */
  26632. enableUVMorphing: boolean;
  26633. /**
  26634. * Creates a new MorphTargetManager
  26635. * @param scene defines the current scene
  26636. */
  26637. constructor(scene?: Nullable<Scene>);
  26638. /**
  26639. * Gets the unique ID of this manager
  26640. */
  26641. get uniqueId(): number;
  26642. /**
  26643. * Gets the number of vertices handled by this manager
  26644. */
  26645. get vertexCount(): number;
  26646. /**
  26647. * Gets a boolean indicating if this manager supports morphing of normals
  26648. */
  26649. get supportsNormals(): boolean;
  26650. /**
  26651. * Gets a boolean indicating if this manager supports morphing of tangents
  26652. */
  26653. get supportsTangents(): boolean;
  26654. /**
  26655. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26656. */
  26657. get supportsUVs(): boolean;
  26658. /**
  26659. * Gets the number of targets stored in this manager
  26660. */
  26661. get numTargets(): number;
  26662. /**
  26663. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26664. */
  26665. get numInfluencers(): number;
  26666. /**
  26667. * Gets the list of influences (one per target)
  26668. */
  26669. get influences(): Float32Array;
  26670. /**
  26671. * Gets the active target at specified index. An active target is a target with an influence > 0
  26672. * @param index defines the index to check
  26673. * @returns the requested target
  26674. */
  26675. getActiveTarget(index: number): MorphTarget;
  26676. /**
  26677. * Gets the target at specified index
  26678. * @param index defines the index to check
  26679. * @returns the requested target
  26680. */
  26681. getTarget(index: number): MorphTarget;
  26682. /**
  26683. * Add a new target to this manager
  26684. * @param target defines the target to add
  26685. */
  26686. addTarget(target: MorphTarget): void;
  26687. /**
  26688. * Removes a target from the manager
  26689. * @param target defines the target to remove
  26690. */
  26691. removeTarget(target: MorphTarget): void;
  26692. /**
  26693. * Clone the current manager
  26694. * @returns a new MorphTargetManager
  26695. */
  26696. clone(): MorphTargetManager;
  26697. /**
  26698. * Serializes the current manager into a Serialization object
  26699. * @returns the serialized object
  26700. */
  26701. serialize(): any;
  26702. private _syncActiveTargets;
  26703. /**
  26704. * Syncrhonize the targets with all the meshes using this morph target manager
  26705. */
  26706. synchronize(): void;
  26707. /**
  26708. * Creates a new MorphTargetManager from serialized data
  26709. * @param serializationObject defines the serialized data
  26710. * @param scene defines the hosting scene
  26711. * @returns the new MorphTargetManager
  26712. */
  26713. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26714. }
  26715. }
  26716. declare module "babylonjs/Meshes/meshLODLevel" {
  26717. import { Mesh } from "babylonjs/Meshes/mesh";
  26718. import { Nullable } from "babylonjs/types";
  26719. /**
  26720. * Class used to represent a specific level of detail of a mesh
  26721. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26722. */
  26723. export class MeshLODLevel {
  26724. /** Defines the distance where this level should start being displayed */
  26725. distance: number;
  26726. /** Defines the mesh to use to render this level */
  26727. mesh: Nullable<Mesh>;
  26728. /**
  26729. * Creates a new LOD level
  26730. * @param distance defines the distance where this level should star being displayed
  26731. * @param mesh defines the mesh to use to render this level
  26732. */
  26733. constructor(
  26734. /** Defines the distance where this level should start being displayed */
  26735. distance: number,
  26736. /** Defines the mesh to use to render this level */
  26737. mesh: Nullable<Mesh>);
  26738. }
  26739. }
  26740. declare module "babylonjs/Misc/canvasGenerator" {
  26741. /**
  26742. * Helper class used to generate a canvas to manipulate images
  26743. */
  26744. export class CanvasGenerator {
  26745. /**
  26746. * Create a new canvas (or offscreen canvas depending on the context)
  26747. * @param width defines the expected width
  26748. * @param height defines the expected height
  26749. * @return a new canvas or offscreen canvas
  26750. */
  26751. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26752. }
  26753. }
  26754. declare module "babylonjs/Meshes/groundMesh" {
  26755. import { Scene } from "babylonjs/scene";
  26756. import { Vector3 } from "babylonjs/Maths/math.vector";
  26757. import { Mesh } from "babylonjs/Meshes/mesh";
  26758. /**
  26759. * Mesh representing the gorund
  26760. */
  26761. export class GroundMesh extends Mesh {
  26762. /** If octree should be generated */
  26763. generateOctree: boolean;
  26764. private _heightQuads;
  26765. /** @hidden */
  26766. _subdivisionsX: number;
  26767. /** @hidden */
  26768. _subdivisionsY: number;
  26769. /** @hidden */
  26770. _width: number;
  26771. /** @hidden */
  26772. _height: number;
  26773. /** @hidden */
  26774. _minX: number;
  26775. /** @hidden */
  26776. _maxX: number;
  26777. /** @hidden */
  26778. _minZ: number;
  26779. /** @hidden */
  26780. _maxZ: number;
  26781. constructor(name: string, scene: Scene);
  26782. /**
  26783. * "GroundMesh"
  26784. * @returns "GroundMesh"
  26785. */
  26786. getClassName(): string;
  26787. /**
  26788. * The minimum of x and y subdivisions
  26789. */
  26790. get subdivisions(): number;
  26791. /**
  26792. * X subdivisions
  26793. */
  26794. get subdivisionsX(): number;
  26795. /**
  26796. * Y subdivisions
  26797. */
  26798. get subdivisionsY(): number;
  26799. /**
  26800. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26801. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26802. * @param chunksCount the number of subdivisions for x and y
  26803. * @param octreeBlocksSize (Default: 32)
  26804. */
  26805. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26806. /**
  26807. * Returns a height (y) value in the Worl system :
  26808. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26809. * @param x x coordinate
  26810. * @param z z coordinate
  26811. * @returns the ground y position if (x, z) are outside the ground surface.
  26812. */
  26813. getHeightAtCoordinates(x: number, z: number): number;
  26814. /**
  26815. * Returns a normalized vector (Vector3) orthogonal to the ground
  26816. * at the ground coordinates (x, z) expressed in the World system.
  26817. * @param x x coordinate
  26818. * @param z z coordinate
  26819. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26820. */
  26821. getNormalAtCoordinates(x: number, z: number): Vector3;
  26822. /**
  26823. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26824. * at the ground coordinates (x, z) expressed in the World system.
  26825. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26826. * @param x x coordinate
  26827. * @param z z coordinate
  26828. * @param ref vector to store the result
  26829. * @returns the GroundMesh.
  26830. */
  26831. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26832. /**
  26833. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26834. * if the ground has been updated.
  26835. * This can be used in the render loop.
  26836. * @returns the GroundMesh.
  26837. */
  26838. updateCoordinateHeights(): GroundMesh;
  26839. private _getFacetAt;
  26840. private _initHeightQuads;
  26841. private _computeHeightQuads;
  26842. /**
  26843. * Serializes this ground mesh
  26844. * @param serializationObject object to write serialization to
  26845. */
  26846. serialize(serializationObject: any): void;
  26847. /**
  26848. * Parses a serialized ground mesh
  26849. * @param parsedMesh the serialized mesh
  26850. * @param scene the scene to create the ground mesh in
  26851. * @returns the created ground mesh
  26852. */
  26853. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26854. }
  26855. }
  26856. declare module "babylonjs/Physics/physicsJoint" {
  26857. import { Vector3 } from "babylonjs/Maths/math.vector";
  26858. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26859. /**
  26860. * Interface for Physics-Joint data
  26861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26862. */
  26863. export interface PhysicsJointData {
  26864. /**
  26865. * The main pivot of the joint
  26866. */
  26867. mainPivot?: Vector3;
  26868. /**
  26869. * The connected pivot of the joint
  26870. */
  26871. connectedPivot?: Vector3;
  26872. /**
  26873. * The main axis of the joint
  26874. */
  26875. mainAxis?: Vector3;
  26876. /**
  26877. * The connected axis of the joint
  26878. */
  26879. connectedAxis?: Vector3;
  26880. /**
  26881. * The collision of the joint
  26882. */
  26883. collision?: boolean;
  26884. /**
  26885. * Native Oimo/Cannon/Energy data
  26886. */
  26887. nativeParams?: any;
  26888. }
  26889. /**
  26890. * This is a holder class for the physics joint created by the physics plugin
  26891. * It holds a set of functions to control the underlying joint
  26892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26893. */
  26894. export class PhysicsJoint {
  26895. /**
  26896. * The type of the physics joint
  26897. */
  26898. type: number;
  26899. /**
  26900. * The data for the physics joint
  26901. */
  26902. jointData: PhysicsJointData;
  26903. private _physicsJoint;
  26904. protected _physicsPlugin: IPhysicsEnginePlugin;
  26905. /**
  26906. * Initializes the physics joint
  26907. * @param type The type of the physics joint
  26908. * @param jointData The data for the physics joint
  26909. */
  26910. constructor(
  26911. /**
  26912. * The type of the physics joint
  26913. */
  26914. type: number,
  26915. /**
  26916. * The data for the physics joint
  26917. */
  26918. jointData: PhysicsJointData);
  26919. /**
  26920. * Gets the physics joint
  26921. */
  26922. get physicsJoint(): any;
  26923. /**
  26924. * Sets the physics joint
  26925. */
  26926. set physicsJoint(newJoint: any);
  26927. /**
  26928. * Sets the physics plugin
  26929. */
  26930. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26931. /**
  26932. * Execute a function that is physics-plugin specific.
  26933. * @param {Function} func the function that will be executed.
  26934. * It accepts two parameters: the physics world and the physics joint
  26935. */
  26936. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26937. /**
  26938. * Distance-Joint type
  26939. */
  26940. static DistanceJoint: number;
  26941. /**
  26942. * Hinge-Joint type
  26943. */
  26944. static HingeJoint: number;
  26945. /**
  26946. * Ball-and-Socket joint type
  26947. */
  26948. static BallAndSocketJoint: number;
  26949. /**
  26950. * Wheel-Joint type
  26951. */
  26952. static WheelJoint: number;
  26953. /**
  26954. * Slider-Joint type
  26955. */
  26956. static SliderJoint: number;
  26957. /**
  26958. * Prismatic-Joint type
  26959. */
  26960. static PrismaticJoint: number;
  26961. /**
  26962. * Universal-Joint type
  26963. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26964. */
  26965. static UniversalJoint: number;
  26966. /**
  26967. * Hinge-Joint 2 type
  26968. */
  26969. static Hinge2Joint: number;
  26970. /**
  26971. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26972. */
  26973. static PointToPointJoint: number;
  26974. /**
  26975. * Spring-Joint type
  26976. */
  26977. static SpringJoint: number;
  26978. /**
  26979. * Lock-Joint type
  26980. */
  26981. static LockJoint: number;
  26982. }
  26983. /**
  26984. * A class representing a physics distance joint
  26985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26986. */
  26987. export class DistanceJoint extends PhysicsJoint {
  26988. /**
  26989. *
  26990. * @param jointData The data for the Distance-Joint
  26991. */
  26992. constructor(jointData: DistanceJointData);
  26993. /**
  26994. * Update the predefined distance.
  26995. * @param maxDistance The maximum preferred distance
  26996. * @param minDistance The minimum preferred distance
  26997. */
  26998. updateDistance(maxDistance: number, minDistance?: number): void;
  26999. }
  27000. /**
  27001. * Represents a Motor-Enabled Joint
  27002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27003. */
  27004. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27005. /**
  27006. * Initializes the Motor-Enabled Joint
  27007. * @param type The type of the joint
  27008. * @param jointData The physica joint data for the joint
  27009. */
  27010. constructor(type: number, jointData: PhysicsJointData);
  27011. /**
  27012. * Set the motor values.
  27013. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27014. * @param force the force to apply
  27015. * @param maxForce max force for this motor.
  27016. */
  27017. setMotor(force?: number, maxForce?: number): void;
  27018. /**
  27019. * Set the motor's limits.
  27020. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27021. * @param upperLimit The upper limit of the motor
  27022. * @param lowerLimit The lower limit of the motor
  27023. */
  27024. setLimit(upperLimit: number, lowerLimit?: number): void;
  27025. }
  27026. /**
  27027. * This class represents a single physics Hinge-Joint
  27028. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27029. */
  27030. export class HingeJoint extends MotorEnabledJoint {
  27031. /**
  27032. * Initializes the Hinge-Joint
  27033. * @param jointData The joint data for the Hinge-Joint
  27034. */
  27035. constructor(jointData: PhysicsJointData);
  27036. /**
  27037. * Set the motor values.
  27038. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27039. * @param {number} force the force to apply
  27040. * @param {number} maxForce max force for this motor.
  27041. */
  27042. setMotor(force?: number, maxForce?: number): void;
  27043. /**
  27044. * Set the motor's limits.
  27045. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27046. * @param upperLimit The upper limit of the motor
  27047. * @param lowerLimit The lower limit of the motor
  27048. */
  27049. setLimit(upperLimit: number, lowerLimit?: number): void;
  27050. }
  27051. /**
  27052. * This class represents a dual hinge physics joint (same as wheel joint)
  27053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27054. */
  27055. export class Hinge2Joint extends MotorEnabledJoint {
  27056. /**
  27057. * Initializes the Hinge2-Joint
  27058. * @param jointData The joint data for the Hinge2-Joint
  27059. */
  27060. constructor(jointData: PhysicsJointData);
  27061. /**
  27062. * Set the motor values.
  27063. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27064. * @param {number} targetSpeed the speed the motor is to reach
  27065. * @param {number} maxForce max force for this motor.
  27066. * @param {motorIndex} the motor's index, 0 or 1.
  27067. */
  27068. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27069. /**
  27070. * Set the motor limits.
  27071. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27072. * @param {number} upperLimit the upper limit
  27073. * @param {number} lowerLimit lower limit
  27074. * @param {motorIndex} the motor's index, 0 or 1.
  27075. */
  27076. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27077. }
  27078. /**
  27079. * Interface for a motor enabled joint
  27080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27081. */
  27082. export interface IMotorEnabledJoint {
  27083. /**
  27084. * Physics joint
  27085. */
  27086. physicsJoint: any;
  27087. /**
  27088. * Sets the motor of the motor-enabled joint
  27089. * @param force The force of the motor
  27090. * @param maxForce The maximum force of the motor
  27091. * @param motorIndex The index of the motor
  27092. */
  27093. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27094. /**
  27095. * Sets the limit of the motor
  27096. * @param upperLimit The upper limit of the motor
  27097. * @param lowerLimit The lower limit of the motor
  27098. * @param motorIndex The index of the motor
  27099. */
  27100. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27101. }
  27102. /**
  27103. * Joint data for a Distance-Joint
  27104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27105. */
  27106. export interface DistanceJointData extends PhysicsJointData {
  27107. /**
  27108. * Max distance the 2 joint objects can be apart
  27109. */
  27110. maxDistance: number;
  27111. }
  27112. /**
  27113. * Joint data from a spring joint
  27114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27115. */
  27116. export interface SpringJointData extends PhysicsJointData {
  27117. /**
  27118. * Length of the spring
  27119. */
  27120. length: number;
  27121. /**
  27122. * Stiffness of the spring
  27123. */
  27124. stiffness: number;
  27125. /**
  27126. * Damping of the spring
  27127. */
  27128. damping: number;
  27129. /** this callback will be called when applying the force to the impostors. */
  27130. forceApplicationCallback: () => void;
  27131. }
  27132. }
  27133. declare module "babylonjs/Physics/physicsRaycastResult" {
  27134. import { Vector3 } from "babylonjs/Maths/math.vector";
  27135. /**
  27136. * Holds the data for the raycast result
  27137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27138. */
  27139. export class PhysicsRaycastResult {
  27140. private _hasHit;
  27141. private _hitDistance;
  27142. private _hitNormalWorld;
  27143. private _hitPointWorld;
  27144. private _rayFromWorld;
  27145. private _rayToWorld;
  27146. /**
  27147. * Gets if there was a hit
  27148. */
  27149. get hasHit(): boolean;
  27150. /**
  27151. * Gets the distance from the hit
  27152. */
  27153. get hitDistance(): number;
  27154. /**
  27155. * Gets the hit normal/direction in the world
  27156. */
  27157. get hitNormalWorld(): Vector3;
  27158. /**
  27159. * Gets the hit point in the world
  27160. */
  27161. get hitPointWorld(): Vector3;
  27162. /**
  27163. * Gets the ray "start point" of the ray in the world
  27164. */
  27165. get rayFromWorld(): Vector3;
  27166. /**
  27167. * Gets the ray "end point" of the ray in the world
  27168. */
  27169. get rayToWorld(): Vector3;
  27170. /**
  27171. * Sets the hit data (normal & point in world space)
  27172. * @param hitNormalWorld defines the normal in world space
  27173. * @param hitPointWorld defines the point in world space
  27174. */
  27175. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27176. /**
  27177. * Sets the distance from the start point to the hit point
  27178. * @param distance
  27179. */
  27180. setHitDistance(distance: number): void;
  27181. /**
  27182. * Calculates the distance manually
  27183. */
  27184. calculateHitDistance(): void;
  27185. /**
  27186. * Resets all the values to default
  27187. * @param from The from point on world space
  27188. * @param to The to point on world space
  27189. */
  27190. reset(from?: Vector3, to?: Vector3): void;
  27191. }
  27192. /**
  27193. * Interface for the size containing width and height
  27194. */
  27195. interface IXYZ {
  27196. /**
  27197. * X
  27198. */
  27199. x: number;
  27200. /**
  27201. * Y
  27202. */
  27203. y: number;
  27204. /**
  27205. * Z
  27206. */
  27207. z: number;
  27208. }
  27209. }
  27210. declare module "babylonjs/Physics/IPhysicsEngine" {
  27211. import { Nullable } from "babylonjs/types";
  27212. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27214. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27215. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27216. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27217. /**
  27218. * Interface used to describe a physics joint
  27219. */
  27220. export interface PhysicsImpostorJoint {
  27221. /** Defines the main impostor to which the joint is linked */
  27222. mainImpostor: PhysicsImpostor;
  27223. /** Defines the impostor that is connected to the main impostor using this joint */
  27224. connectedImpostor: PhysicsImpostor;
  27225. /** Defines the joint itself */
  27226. joint: PhysicsJoint;
  27227. }
  27228. /** @hidden */
  27229. export interface IPhysicsEnginePlugin {
  27230. world: any;
  27231. name: string;
  27232. setGravity(gravity: Vector3): void;
  27233. setTimeStep(timeStep: number): void;
  27234. getTimeStep(): number;
  27235. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27236. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27237. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27238. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27239. removePhysicsBody(impostor: PhysicsImpostor): void;
  27240. generateJoint(joint: PhysicsImpostorJoint): void;
  27241. removeJoint(joint: PhysicsImpostorJoint): void;
  27242. isSupported(): boolean;
  27243. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27244. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27245. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27246. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27247. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27248. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27249. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27250. getBodyMass(impostor: PhysicsImpostor): number;
  27251. getBodyFriction(impostor: PhysicsImpostor): number;
  27252. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27253. getBodyRestitution(impostor: PhysicsImpostor): number;
  27254. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27255. getBodyPressure?(impostor: PhysicsImpostor): number;
  27256. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27257. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27258. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27259. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27260. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27261. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27262. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27263. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27264. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27265. sleepBody(impostor: PhysicsImpostor): void;
  27266. wakeUpBody(impostor: PhysicsImpostor): void;
  27267. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27268. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27269. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27270. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27271. getRadius(impostor: PhysicsImpostor): number;
  27272. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27273. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27274. dispose(): void;
  27275. }
  27276. /**
  27277. * Interface used to define a physics engine
  27278. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  27279. */
  27280. export interface IPhysicsEngine {
  27281. /**
  27282. * Gets the gravity vector used by the simulation
  27283. */
  27284. gravity: Vector3;
  27285. /**
  27286. * Sets the gravity vector used by the simulation
  27287. * @param gravity defines the gravity vector to use
  27288. */
  27289. setGravity(gravity: Vector3): void;
  27290. /**
  27291. * Set the time step of the physics engine.
  27292. * Default is 1/60.
  27293. * To slow it down, enter 1/600 for example.
  27294. * To speed it up, 1/30
  27295. * @param newTimeStep the new timestep to apply to this world.
  27296. */
  27297. setTimeStep(newTimeStep: number): void;
  27298. /**
  27299. * Get the time step of the physics engine.
  27300. * @returns the current time step
  27301. */
  27302. getTimeStep(): number;
  27303. /**
  27304. * Set the sub time step of the physics engine.
  27305. * Default is 0 meaning there is no sub steps
  27306. * To increase physics resolution precision, set a small value (like 1 ms)
  27307. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27308. */
  27309. setSubTimeStep(subTimeStep: number): void;
  27310. /**
  27311. * Get the sub time step of the physics engine.
  27312. * @returns the current sub time step
  27313. */
  27314. getSubTimeStep(): number;
  27315. /**
  27316. * Release all resources
  27317. */
  27318. dispose(): void;
  27319. /**
  27320. * Gets the name of the current physics plugin
  27321. * @returns the name of the plugin
  27322. */
  27323. getPhysicsPluginName(): string;
  27324. /**
  27325. * Adding a new impostor for the impostor tracking.
  27326. * This will be done by the impostor itself.
  27327. * @param impostor the impostor to add
  27328. */
  27329. addImpostor(impostor: PhysicsImpostor): void;
  27330. /**
  27331. * Remove an impostor from the engine.
  27332. * This impostor and its mesh will not longer be updated by the physics engine.
  27333. * @param impostor the impostor to remove
  27334. */
  27335. removeImpostor(impostor: PhysicsImpostor): void;
  27336. /**
  27337. * Add a joint to the physics engine
  27338. * @param mainImpostor defines the main impostor to which the joint is added.
  27339. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27340. * @param joint defines the joint that will connect both impostors.
  27341. */
  27342. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27343. /**
  27344. * Removes a joint from the simulation
  27345. * @param mainImpostor defines the impostor used with the joint
  27346. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27347. * @param joint defines the joint to remove
  27348. */
  27349. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27350. /**
  27351. * Gets the current plugin used to run the simulation
  27352. * @returns current plugin
  27353. */
  27354. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27355. /**
  27356. * Gets the list of physic impostors
  27357. * @returns an array of PhysicsImpostor
  27358. */
  27359. getImpostors(): Array<PhysicsImpostor>;
  27360. /**
  27361. * Gets the impostor for a physics enabled object
  27362. * @param object defines the object impersonated by the impostor
  27363. * @returns the PhysicsImpostor or null if not found
  27364. */
  27365. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27366. /**
  27367. * Gets the impostor for a physics body object
  27368. * @param body defines physics body used by the impostor
  27369. * @returns the PhysicsImpostor or null if not found
  27370. */
  27371. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27372. /**
  27373. * Does a raycast in the physics world
  27374. * @param from when should the ray start?
  27375. * @param to when should the ray end?
  27376. * @returns PhysicsRaycastResult
  27377. */
  27378. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27379. /**
  27380. * Called by the scene. No need to call it.
  27381. * @param delta defines the timespam between frames
  27382. */
  27383. _step(delta: number): void;
  27384. }
  27385. }
  27386. declare module "babylonjs/Physics/physicsImpostor" {
  27387. import { Nullable, IndicesArray } from "babylonjs/types";
  27388. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27389. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27391. import { Scene } from "babylonjs/scene";
  27392. import { Bone } from "babylonjs/Bones/bone";
  27393. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27394. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27395. import { Space } from "babylonjs/Maths/math.axis";
  27396. /**
  27397. * The interface for the physics imposter parameters
  27398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27399. */
  27400. export interface PhysicsImpostorParameters {
  27401. /**
  27402. * The mass of the physics imposter
  27403. */
  27404. mass: number;
  27405. /**
  27406. * The friction of the physics imposter
  27407. */
  27408. friction?: number;
  27409. /**
  27410. * The coefficient of restitution of the physics imposter
  27411. */
  27412. restitution?: number;
  27413. /**
  27414. * The native options of the physics imposter
  27415. */
  27416. nativeOptions?: any;
  27417. /**
  27418. * Specifies if the parent should be ignored
  27419. */
  27420. ignoreParent?: boolean;
  27421. /**
  27422. * Specifies if bi-directional transformations should be disabled
  27423. */
  27424. disableBidirectionalTransformation?: boolean;
  27425. /**
  27426. * The pressure inside the physics imposter, soft object only
  27427. */
  27428. pressure?: number;
  27429. /**
  27430. * The stiffness the physics imposter, soft object only
  27431. */
  27432. stiffness?: number;
  27433. /**
  27434. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27435. */
  27436. velocityIterations?: number;
  27437. /**
  27438. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27439. */
  27440. positionIterations?: number;
  27441. /**
  27442. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27443. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27444. * Add to fix multiple points
  27445. */
  27446. fixedPoints?: number;
  27447. /**
  27448. * The collision margin around a soft object
  27449. */
  27450. margin?: number;
  27451. /**
  27452. * The collision margin around a soft object
  27453. */
  27454. damping?: number;
  27455. /**
  27456. * The path for a rope based on an extrusion
  27457. */
  27458. path?: any;
  27459. /**
  27460. * The shape of an extrusion used for a rope based on an extrusion
  27461. */
  27462. shape?: any;
  27463. }
  27464. /**
  27465. * Interface for a physics-enabled object
  27466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27467. */
  27468. export interface IPhysicsEnabledObject {
  27469. /**
  27470. * The position of the physics-enabled object
  27471. */
  27472. position: Vector3;
  27473. /**
  27474. * The rotation of the physics-enabled object
  27475. */
  27476. rotationQuaternion: Nullable<Quaternion>;
  27477. /**
  27478. * The scale of the physics-enabled object
  27479. */
  27480. scaling: Vector3;
  27481. /**
  27482. * The rotation of the physics-enabled object
  27483. */
  27484. rotation?: Vector3;
  27485. /**
  27486. * The parent of the physics-enabled object
  27487. */
  27488. parent?: any;
  27489. /**
  27490. * The bounding info of the physics-enabled object
  27491. * @returns The bounding info of the physics-enabled object
  27492. */
  27493. getBoundingInfo(): BoundingInfo;
  27494. /**
  27495. * Computes the world matrix
  27496. * @param force Specifies if the world matrix should be computed by force
  27497. * @returns A world matrix
  27498. */
  27499. computeWorldMatrix(force: boolean): Matrix;
  27500. /**
  27501. * Gets the world matrix
  27502. * @returns A world matrix
  27503. */
  27504. getWorldMatrix?(): Matrix;
  27505. /**
  27506. * Gets the child meshes
  27507. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27508. * @returns An array of abstract meshes
  27509. */
  27510. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27511. /**
  27512. * Gets the vertex data
  27513. * @param kind The type of vertex data
  27514. * @returns A nullable array of numbers, or a float32 array
  27515. */
  27516. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27517. /**
  27518. * Gets the indices from the mesh
  27519. * @returns A nullable array of index arrays
  27520. */
  27521. getIndices?(): Nullable<IndicesArray>;
  27522. /**
  27523. * Gets the scene from the mesh
  27524. * @returns the indices array or null
  27525. */
  27526. getScene?(): Scene;
  27527. /**
  27528. * Gets the absolute position from the mesh
  27529. * @returns the absolute position
  27530. */
  27531. getAbsolutePosition(): Vector3;
  27532. /**
  27533. * Gets the absolute pivot point from the mesh
  27534. * @returns the absolute pivot point
  27535. */
  27536. getAbsolutePivotPoint(): Vector3;
  27537. /**
  27538. * Rotates the mesh
  27539. * @param axis The axis of rotation
  27540. * @param amount The amount of rotation
  27541. * @param space The space of the rotation
  27542. * @returns The rotation transform node
  27543. */
  27544. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27545. /**
  27546. * Translates the mesh
  27547. * @param axis The axis of translation
  27548. * @param distance The distance of translation
  27549. * @param space The space of the translation
  27550. * @returns The transform node
  27551. */
  27552. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27553. /**
  27554. * Sets the absolute position of the mesh
  27555. * @param absolutePosition The absolute position of the mesh
  27556. * @returns The transform node
  27557. */
  27558. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27559. /**
  27560. * Gets the class name of the mesh
  27561. * @returns The class name
  27562. */
  27563. getClassName(): string;
  27564. }
  27565. /**
  27566. * Represents a physics imposter
  27567. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27568. */
  27569. export class PhysicsImpostor {
  27570. /**
  27571. * The physics-enabled object used as the physics imposter
  27572. */
  27573. object: IPhysicsEnabledObject;
  27574. /**
  27575. * The type of the physics imposter
  27576. */
  27577. type: number;
  27578. private _options;
  27579. private _scene?;
  27580. /**
  27581. * The default object size of the imposter
  27582. */
  27583. static DEFAULT_OBJECT_SIZE: Vector3;
  27584. /**
  27585. * The identity quaternion of the imposter
  27586. */
  27587. static IDENTITY_QUATERNION: Quaternion;
  27588. /** @hidden */
  27589. _pluginData: any;
  27590. private _physicsEngine;
  27591. private _physicsBody;
  27592. private _bodyUpdateRequired;
  27593. private _onBeforePhysicsStepCallbacks;
  27594. private _onAfterPhysicsStepCallbacks;
  27595. /** @hidden */
  27596. _onPhysicsCollideCallbacks: Array<{
  27597. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27598. otherImpostors: Array<PhysicsImpostor>;
  27599. }>;
  27600. private _deltaPosition;
  27601. private _deltaRotation;
  27602. private _deltaRotationConjugated;
  27603. /** @hidden */
  27604. _isFromLine: boolean;
  27605. private _parent;
  27606. private _isDisposed;
  27607. private static _tmpVecs;
  27608. private static _tmpQuat;
  27609. /**
  27610. * Specifies if the physics imposter is disposed
  27611. */
  27612. get isDisposed(): boolean;
  27613. /**
  27614. * Gets the mass of the physics imposter
  27615. */
  27616. get mass(): number;
  27617. set mass(value: number);
  27618. /**
  27619. * Gets the coefficient of friction
  27620. */
  27621. get friction(): number;
  27622. /**
  27623. * Sets the coefficient of friction
  27624. */
  27625. set friction(value: number);
  27626. /**
  27627. * Gets the coefficient of restitution
  27628. */
  27629. get restitution(): number;
  27630. /**
  27631. * Sets the coefficient of restitution
  27632. */
  27633. set restitution(value: number);
  27634. /**
  27635. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27636. */
  27637. get pressure(): number;
  27638. /**
  27639. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27640. */
  27641. set pressure(value: number);
  27642. /**
  27643. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27644. */
  27645. get stiffness(): number;
  27646. /**
  27647. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27648. */
  27649. set stiffness(value: number);
  27650. /**
  27651. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27652. */
  27653. get velocityIterations(): number;
  27654. /**
  27655. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27656. */
  27657. set velocityIterations(value: number);
  27658. /**
  27659. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27660. */
  27661. get positionIterations(): number;
  27662. /**
  27663. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27664. */
  27665. set positionIterations(value: number);
  27666. /**
  27667. * The unique id of the physics imposter
  27668. * set by the physics engine when adding this impostor to the array
  27669. */
  27670. uniqueId: number;
  27671. /**
  27672. * @hidden
  27673. */
  27674. soft: boolean;
  27675. /**
  27676. * @hidden
  27677. */
  27678. segments: number;
  27679. private _joints;
  27680. /**
  27681. * Initializes the physics imposter
  27682. * @param object The physics-enabled object used as the physics imposter
  27683. * @param type The type of the physics imposter
  27684. * @param _options The options for the physics imposter
  27685. * @param _scene The Babylon scene
  27686. */
  27687. constructor(
  27688. /**
  27689. * The physics-enabled object used as the physics imposter
  27690. */
  27691. object: IPhysicsEnabledObject,
  27692. /**
  27693. * The type of the physics imposter
  27694. */
  27695. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27696. /**
  27697. * This function will completly initialize this impostor.
  27698. * It will create a new body - but only if this mesh has no parent.
  27699. * If it has, this impostor will not be used other than to define the impostor
  27700. * of the child mesh.
  27701. * @hidden
  27702. */
  27703. _init(): void;
  27704. private _getPhysicsParent;
  27705. /**
  27706. * Should a new body be generated.
  27707. * @returns boolean specifying if body initialization is required
  27708. */
  27709. isBodyInitRequired(): boolean;
  27710. /**
  27711. * Sets the updated scaling
  27712. * @param updated Specifies if the scaling is updated
  27713. */
  27714. setScalingUpdated(): void;
  27715. /**
  27716. * Force a regeneration of this or the parent's impostor's body.
  27717. * Use under cautious - This will remove all joints already implemented.
  27718. */
  27719. forceUpdate(): void;
  27720. /**
  27721. * Gets the body that holds this impostor. Either its own, or its parent.
  27722. */
  27723. get physicsBody(): any;
  27724. /**
  27725. * Get the parent of the physics imposter
  27726. * @returns Physics imposter or null
  27727. */
  27728. get parent(): Nullable<PhysicsImpostor>;
  27729. /**
  27730. * Sets the parent of the physics imposter
  27731. */
  27732. set parent(value: Nullable<PhysicsImpostor>);
  27733. /**
  27734. * Set the physics body. Used mainly by the physics engine/plugin
  27735. */
  27736. set physicsBody(physicsBody: any);
  27737. /**
  27738. * Resets the update flags
  27739. */
  27740. resetUpdateFlags(): void;
  27741. /**
  27742. * Gets the object extend size
  27743. * @returns the object extend size
  27744. */
  27745. getObjectExtendSize(): Vector3;
  27746. /**
  27747. * Gets the object center
  27748. * @returns The object center
  27749. */
  27750. getObjectCenter(): Vector3;
  27751. /**
  27752. * Get a specific parameter from the options parameters
  27753. * @param paramName The object parameter name
  27754. * @returns The object parameter
  27755. */
  27756. getParam(paramName: string): any;
  27757. /**
  27758. * Sets a specific parameter in the options given to the physics plugin
  27759. * @param paramName The parameter name
  27760. * @param value The value of the parameter
  27761. */
  27762. setParam(paramName: string, value: number): void;
  27763. /**
  27764. * Specifically change the body's mass option. Won't recreate the physics body object
  27765. * @param mass The mass of the physics imposter
  27766. */
  27767. setMass(mass: number): void;
  27768. /**
  27769. * Gets the linear velocity
  27770. * @returns linear velocity or null
  27771. */
  27772. getLinearVelocity(): Nullable<Vector3>;
  27773. /**
  27774. * Sets the linear velocity
  27775. * @param velocity linear velocity or null
  27776. */
  27777. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27778. /**
  27779. * Gets the angular velocity
  27780. * @returns angular velocity or null
  27781. */
  27782. getAngularVelocity(): Nullable<Vector3>;
  27783. /**
  27784. * Sets the angular velocity
  27785. * @param velocity The velocity or null
  27786. */
  27787. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27788. /**
  27789. * Execute a function with the physics plugin native code
  27790. * Provide a function the will have two variables - the world object and the physics body object
  27791. * @param func The function to execute with the physics plugin native code
  27792. */
  27793. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27794. /**
  27795. * Register a function that will be executed before the physics world is stepping forward
  27796. * @param func The function to execute before the physics world is stepped forward
  27797. */
  27798. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27799. /**
  27800. * Unregister a function that will be executed before the physics world is stepping forward
  27801. * @param func The function to execute before the physics world is stepped forward
  27802. */
  27803. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27804. /**
  27805. * Register a function that will be executed after the physics step
  27806. * @param func The function to execute after physics step
  27807. */
  27808. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27809. /**
  27810. * Unregisters a function that will be executed after the physics step
  27811. * @param func The function to execute after physics step
  27812. */
  27813. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27814. /**
  27815. * register a function that will be executed when this impostor collides against a different body
  27816. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27817. * @param func Callback that is executed on collision
  27818. */
  27819. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27820. /**
  27821. * Unregisters the physics imposter on contact
  27822. * @param collideAgainst The physics object to collide against
  27823. * @param func Callback to execute on collision
  27824. */
  27825. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27826. private _tmpQuat;
  27827. private _tmpQuat2;
  27828. /**
  27829. * Get the parent rotation
  27830. * @returns The parent rotation
  27831. */
  27832. getParentsRotation(): Quaternion;
  27833. /**
  27834. * this function is executed by the physics engine.
  27835. */
  27836. beforeStep: () => void;
  27837. /**
  27838. * this function is executed by the physics engine
  27839. */
  27840. afterStep: () => void;
  27841. /**
  27842. * Legacy collision detection event support
  27843. */
  27844. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27845. /**
  27846. * event and body object due to cannon's event-based architecture.
  27847. */
  27848. onCollide: (e: {
  27849. body: any;
  27850. }) => void;
  27851. /**
  27852. * Apply a force
  27853. * @param force The force to apply
  27854. * @param contactPoint The contact point for the force
  27855. * @returns The physics imposter
  27856. */
  27857. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27858. /**
  27859. * Apply an impulse
  27860. * @param force The impulse force
  27861. * @param contactPoint The contact point for the impulse force
  27862. * @returns The physics imposter
  27863. */
  27864. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27865. /**
  27866. * A help function to create a joint
  27867. * @param otherImpostor A physics imposter used to create a joint
  27868. * @param jointType The type of joint
  27869. * @param jointData The data for the joint
  27870. * @returns The physics imposter
  27871. */
  27872. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27873. /**
  27874. * Add a joint to this impostor with a different impostor
  27875. * @param otherImpostor A physics imposter used to add a joint
  27876. * @param joint The joint to add
  27877. * @returns The physics imposter
  27878. */
  27879. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27880. /**
  27881. * Add an anchor to a cloth impostor
  27882. * @param otherImpostor rigid impostor to anchor to
  27883. * @param width ratio across width from 0 to 1
  27884. * @param height ratio up height from 0 to 1
  27885. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27886. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27887. * @returns impostor the soft imposter
  27888. */
  27889. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27890. /**
  27891. * Add a hook to a rope impostor
  27892. * @param otherImpostor rigid impostor to anchor to
  27893. * @param length ratio across rope from 0 to 1
  27894. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27895. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27896. * @returns impostor the rope imposter
  27897. */
  27898. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27899. /**
  27900. * Will keep this body still, in a sleep mode.
  27901. * @returns the physics imposter
  27902. */
  27903. sleep(): PhysicsImpostor;
  27904. /**
  27905. * Wake the body up.
  27906. * @returns The physics imposter
  27907. */
  27908. wakeUp(): PhysicsImpostor;
  27909. /**
  27910. * Clones the physics imposter
  27911. * @param newObject The physics imposter clones to this physics-enabled object
  27912. * @returns A nullable physics imposter
  27913. */
  27914. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27915. /**
  27916. * Disposes the physics imposter
  27917. */
  27918. dispose(): void;
  27919. /**
  27920. * Sets the delta position
  27921. * @param position The delta position amount
  27922. */
  27923. setDeltaPosition(position: Vector3): void;
  27924. /**
  27925. * Sets the delta rotation
  27926. * @param rotation The delta rotation amount
  27927. */
  27928. setDeltaRotation(rotation: Quaternion): void;
  27929. /**
  27930. * Gets the box size of the physics imposter and stores the result in the input parameter
  27931. * @param result Stores the box size
  27932. * @returns The physics imposter
  27933. */
  27934. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27935. /**
  27936. * Gets the radius of the physics imposter
  27937. * @returns Radius of the physics imposter
  27938. */
  27939. getRadius(): number;
  27940. /**
  27941. * Sync a bone with this impostor
  27942. * @param bone The bone to sync to the impostor.
  27943. * @param boneMesh The mesh that the bone is influencing.
  27944. * @param jointPivot The pivot of the joint / bone in local space.
  27945. * @param distToJoint Optional distance from the impostor to the joint.
  27946. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27947. */
  27948. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27949. /**
  27950. * Sync impostor to a bone
  27951. * @param bone The bone that the impostor will be synced to.
  27952. * @param boneMesh The mesh that the bone is influencing.
  27953. * @param jointPivot The pivot of the joint / bone in local space.
  27954. * @param distToJoint Optional distance from the impostor to the joint.
  27955. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27956. * @param boneAxis Optional vector3 axis the bone is aligned with
  27957. */
  27958. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27959. /**
  27960. * No-Imposter type
  27961. */
  27962. static NoImpostor: number;
  27963. /**
  27964. * Sphere-Imposter type
  27965. */
  27966. static SphereImpostor: number;
  27967. /**
  27968. * Box-Imposter type
  27969. */
  27970. static BoxImpostor: number;
  27971. /**
  27972. * Plane-Imposter type
  27973. */
  27974. static PlaneImpostor: number;
  27975. /**
  27976. * Mesh-imposter type
  27977. */
  27978. static MeshImpostor: number;
  27979. /**
  27980. * Capsule-Impostor type (Ammo.js plugin only)
  27981. */
  27982. static CapsuleImpostor: number;
  27983. /**
  27984. * Cylinder-Imposter type
  27985. */
  27986. static CylinderImpostor: number;
  27987. /**
  27988. * Particle-Imposter type
  27989. */
  27990. static ParticleImpostor: number;
  27991. /**
  27992. * Heightmap-Imposter type
  27993. */
  27994. static HeightmapImpostor: number;
  27995. /**
  27996. * ConvexHull-Impostor type (Ammo.js plugin only)
  27997. */
  27998. static ConvexHullImpostor: number;
  27999. /**
  28000. * Custom-Imposter type (Ammo.js plugin only)
  28001. */
  28002. static CustomImpostor: number;
  28003. /**
  28004. * Rope-Imposter type
  28005. */
  28006. static RopeImpostor: number;
  28007. /**
  28008. * Cloth-Imposter type
  28009. */
  28010. static ClothImpostor: number;
  28011. /**
  28012. * Softbody-Imposter type
  28013. */
  28014. static SoftbodyImpostor: number;
  28015. }
  28016. }
  28017. declare module "babylonjs/Meshes/mesh" {
  28018. import { Observable } from "babylonjs/Misc/observable";
  28019. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28020. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28021. import { Camera } from "babylonjs/Cameras/camera";
  28022. import { Scene } from "babylonjs/scene";
  28023. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28024. import { Color4 } from "babylonjs/Maths/math.color";
  28025. import { Engine } from "babylonjs/Engines/engine";
  28026. import { Node } from "babylonjs/node";
  28027. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28028. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28029. import { Buffer } from "babylonjs/Meshes/buffer";
  28030. import { Geometry } from "babylonjs/Meshes/geometry";
  28031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28033. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28034. import { Effect } from "babylonjs/Materials/effect";
  28035. import { Material } from "babylonjs/Materials/material";
  28036. import { Skeleton } from "babylonjs/Bones/skeleton";
  28037. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28038. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28039. import { Path3D } from "babylonjs/Maths/math.path";
  28040. import { Plane } from "babylonjs/Maths/math.plane";
  28041. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28042. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28043. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28044. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28045. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28046. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28047. /**
  28048. * @hidden
  28049. **/
  28050. export class _CreationDataStorage {
  28051. closePath?: boolean;
  28052. closeArray?: boolean;
  28053. idx: number[];
  28054. dashSize: number;
  28055. gapSize: number;
  28056. path3D: Path3D;
  28057. pathArray: Vector3[][];
  28058. arc: number;
  28059. radius: number;
  28060. cap: number;
  28061. tessellation: number;
  28062. }
  28063. /**
  28064. * @hidden
  28065. **/
  28066. class _InstanceDataStorage {
  28067. visibleInstances: any;
  28068. batchCache: _InstancesBatch;
  28069. instancesBufferSize: number;
  28070. instancesBuffer: Nullable<Buffer>;
  28071. instancesData: Float32Array;
  28072. overridenInstanceCount: number;
  28073. isFrozen: boolean;
  28074. previousBatch: Nullable<_InstancesBatch>;
  28075. hardwareInstancedRendering: boolean;
  28076. sideOrientation: number;
  28077. manualUpdate: boolean;
  28078. }
  28079. /**
  28080. * @hidden
  28081. **/
  28082. export class _InstancesBatch {
  28083. mustReturn: boolean;
  28084. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28085. renderSelf: boolean[];
  28086. hardwareInstancedRendering: boolean[];
  28087. }
  28088. /**
  28089. * @hidden
  28090. **/
  28091. class _ThinInstanceDataStorage {
  28092. instancesCount: number;
  28093. matrixBuffer: Nullable<Buffer>;
  28094. matrixBufferSize: number;
  28095. matrixData: Nullable<Float32Array>;
  28096. boundingVectors: Array<Vector3>;
  28097. }
  28098. /**
  28099. * Class used to represent renderable models
  28100. */
  28101. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28102. /**
  28103. * Mesh side orientation : usually the external or front surface
  28104. */
  28105. static readonly FRONTSIDE: number;
  28106. /**
  28107. * Mesh side orientation : usually the internal or back surface
  28108. */
  28109. static readonly BACKSIDE: number;
  28110. /**
  28111. * Mesh side orientation : both internal and external or front and back surfaces
  28112. */
  28113. static readonly DOUBLESIDE: number;
  28114. /**
  28115. * Mesh side orientation : by default, `FRONTSIDE`
  28116. */
  28117. static readonly DEFAULTSIDE: number;
  28118. /**
  28119. * Mesh cap setting : no cap
  28120. */
  28121. static readonly NO_CAP: number;
  28122. /**
  28123. * Mesh cap setting : one cap at the beginning of the mesh
  28124. */
  28125. static readonly CAP_START: number;
  28126. /**
  28127. * Mesh cap setting : one cap at the end of the mesh
  28128. */
  28129. static readonly CAP_END: number;
  28130. /**
  28131. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28132. */
  28133. static readonly CAP_ALL: number;
  28134. /**
  28135. * Mesh pattern setting : no flip or rotate
  28136. */
  28137. static readonly NO_FLIP: number;
  28138. /**
  28139. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28140. */
  28141. static readonly FLIP_TILE: number;
  28142. /**
  28143. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28144. */
  28145. static readonly ROTATE_TILE: number;
  28146. /**
  28147. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28148. */
  28149. static readonly FLIP_ROW: number;
  28150. /**
  28151. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28152. */
  28153. static readonly ROTATE_ROW: number;
  28154. /**
  28155. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28156. */
  28157. static readonly FLIP_N_ROTATE_TILE: number;
  28158. /**
  28159. * Mesh pattern setting : rotate pattern and rotate
  28160. */
  28161. static readonly FLIP_N_ROTATE_ROW: number;
  28162. /**
  28163. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28164. */
  28165. static readonly CENTER: number;
  28166. /**
  28167. * Mesh tile positioning : part tiles on left
  28168. */
  28169. static readonly LEFT: number;
  28170. /**
  28171. * Mesh tile positioning : part tiles on right
  28172. */
  28173. static readonly RIGHT: number;
  28174. /**
  28175. * Mesh tile positioning : part tiles on top
  28176. */
  28177. static readonly TOP: number;
  28178. /**
  28179. * Mesh tile positioning : part tiles on bottom
  28180. */
  28181. static readonly BOTTOM: number;
  28182. /**
  28183. * Gets the default side orientation.
  28184. * @param orientation the orientation to value to attempt to get
  28185. * @returns the default orientation
  28186. * @hidden
  28187. */
  28188. static _GetDefaultSideOrientation(orientation?: number): number;
  28189. private _internalMeshDataInfo;
  28190. /**
  28191. * An event triggered before rendering the mesh
  28192. */
  28193. get onBeforeRenderObservable(): Observable<Mesh>;
  28194. /**
  28195. * An event triggered before binding the mesh
  28196. */
  28197. get onBeforeBindObservable(): Observable<Mesh>;
  28198. /**
  28199. * An event triggered after rendering the mesh
  28200. */
  28201. get onAfterRenderObservable(): Observable<Mesh>;
  28202. /**
  28203. * An event triggered before drawing the mesh
  28204. */
  28205. get onBeforeDrawObservable(): Observable<Mesh>;
  28206. private _onBeforeDrawObserver;
  28207. /**
  28208. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28209. */
  28210. set onBeforeDraw(callback: () => void);
  28211. get hasInstances(): boolean;
  28212. get hasThinInstances(): boolean;
  28213. /**
  28214. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28215. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28216. */
  28217. delayLoadState: number;
  28218. /**
  28219. * Gets the list of instances created from this mesh
  28220. * it is not supposed to be modified manually.
  28221. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28222. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28223. */
  28224. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28225. /**
  28226. * Gets the file containing delay loading data for this mesh
  28227. */
  28228. delayLoadingFile: string;
  28229. /** @hidden */
  28230. _binaryInfo: any;
  28231. /**
  28232. * User defined function used to change how LOD level selection is done
  28233. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28234. */
  28235. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28236. /**
  28237. * Gets or sets the morph target manager
  28238. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28239. */
  28240. get morphTargetManager(): Nullable<MorphTargetManager>;
  28241. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28242. /** @hidden */
  28243. _creationDataStorage: Nullable<_CreationDataStorage>;
  28244. /** @hidden */
  28245. _geometry: Nullable<Geometry>;
  28246. /** @hidden */
  28247. _delayInfo: Array<string>;
  28248. /** @hidden */
  28249. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28250. /** @hidden */
  28251. _instanceDataStorage: _InstanceDataStorage;
  28252. /** @hidden */
  28253. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28254. private _effectiveMaterial;
  28255. /** @hidden */
  28256. _shouldGenerateFlatShading: boolean;
  28257. /** @hidden */
  28258. _originalBuilderSideOrientation: number;
  28259. /**
  28260. * Use this property to change the original side orientation defined at construction time
  28261. */
  28262. overrideMaterialSideOrientation: Nullable<number>;
  28263. /**
  28264. * Gets the source mesh (the one used to clone this one from)
  28265. */
  28266. get source(): Nullable<Mesh>;
  28267. /**
  28268. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28269. */
  28270. get isUnIndexed(): boolean;
  28271. set isUnIndexed(value: boolean);
  28272. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28273. get worldMatrixInstancedBuffer(): Float32Array;
  28274. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28275. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28276. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28277. /**
  28278. * @constructor
  28279. * @param name The value used by scene.getMeshByName() to do a lookup.
  28280. * @param scene The scene to add this mesh to.
  28281. * @param parent The parent of this mesh, if it has one
  28282. * @param source An optional Mesh from which geometry is shared, cloned.
  28283. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28284. * When false, achieved by calling a clone(), also passing False.
  28285. * This will make creation of children, recursive.
  28286. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28287. */
  28288. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28289. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28290. doNotInstantiate: boolean;
  28291. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28292. /**
  28293. * Gets the class name
  28294. * @returns the string "Mesh".
  28295. */
  28296. getClassName(): string;
  28297. /** @hidden */
  28298. get _isMesh(): boolean;
  28299. /**
  28300. * Returns a description of this mesh
  28301. * @param fullDetails define if full details about this mesh must be used
  28302. * @returns a descriptive string representing this mesh
  28303. */
  28304. toString(fullDetails?: boolean): string;
  28305. /** @hidden */
  28306. _unBindEffect(): void;
  28307. /**
  28308. * Gets a boolean indicating if this mesh has LOD
  28309. */
  28310. get hasLODLevels(): boolean;
  28311. /**
  28312. * Gets the list of MeshLODLevel associated with the current mesh
  28313. * @returns an array of MeshLODLevel
  28314. */
  28315. getLODLevels(): MeshLODLevel[];
  28316. private _sortLODLevels;
  28317. /**
  28318. * Add a mesh as LOD level triggered at the given distance.
  28319. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28320. * @param distance The distance from the center of the object to show this level
  28321. * @param mesh The mesh to be added as LOD level (can be null)
  28322. * @return This mesh (for chaining)
  28323. */
  28324. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28325. /**
  28326. * Returns the LOD level mesh at the passed distance or null if not found.
  28327. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28328. * @param distance The distance from the center of the object to show this level
  28329. * @returns a Mesh or `null`
  28330. */
  28331. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28332. /**
  28333. * Remove a mesh from the LOD array
  28334. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28335. * @param mesh defines the mesh to be removed
  28336. * @return This mesh (for chaining)
  28337. */
  28338. removeLODLevel(mesh: Mesh): Mesh;
  28339. /**
  28340. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28341. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28342. * @param camera defines the camera to use to compute distance
  28343. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28344. * @return This mesh (for chaining)
  28345. */
  28346. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28347. /**
  28348. * Gets the mesh internal Geometry object
  28349. */
  28350. get geometry(): Nullable<Geometry>;
  28351. /**
  28352. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28353. * @returns the total number of vertices
  28354. */
  28355. getTotalVertices(): number;
  28356. /**
  28357. * Returns the content of an associated vertex buffer
  28358. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28359. * - VertexBuffer.PositionKind
  28360. * - VertexBuffer.UVKind
  28361. * - VertexBuffer.UV2Kind
  28362. * - VertexBuffer.UV3Kind
  28363. * - VertexBuffer.UV4Kind
  28364. * - VertexBuffer.UV5Kind
  28365. * - VertexBuffer.UV6Kind
  28366. * - VertexBuffer.ColorKind
  28367. * - VertexBuffer.MatricesIndicesKind
  28368. * - VertexBuffer.MatricesIndicesExtraKind
  28369. * - VertexBuffer.MatricesWeightsKind
  28370. * - VertexBuffer.MatricesWeightsExtraKind
  28371. * @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
  28372. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28373. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28374. */
  28375. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28376. /**
  28377. * Returns the mesh VertexBuffer object from the requested `kind`
  28378. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28379. * - VertexBuffer.PositionKind
  28380. * - VertexBuffer.NormalKind
  28381. * - VertexBuffer.UVKind
  28382. * - VertexBuffer.UV2Kind
  28383. * - VertexBuffer.UV3Kind
  28384. * - VertexBuffer.UV4Kind
  28385. * - VertexBuffer.UV5Kind
  28386. * - VertexBuffer.UV6Kind
  28387. * - VertexBuffer.ColorKind
  28388. * - VertexBuffer.MatricesIndicesKind
  28389. * - VertexBuffer.MatricesIndicesExtraKind
  28390. * - VertexBuffer.MatricesWeightsKind
  28391. * - VertexBuffer.MatricesWeightsExtraKind
  28392. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28393. */
  28394. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28395. /**
  28396. * Tests if a specific vertex buffer is associated with this mesh
  28397. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28398. * - VertexBuffer.PositionKind
  28399. * - VertexBuffer.NormalKind
  28400. * - VertexBuffer.UVKind
  28401. * - VertexBuffer.UV2Kind
  28402. * - VertexBuffer.UV3Kind
  28403. * - VertexBuffer.UV4Kind
  28404. * - VertexBuffer.UV5Kind
  28405. * - VertexBuffer.UV6Kind
  28406. * - VertexBuffer.ColorKind
  28407. * - VertexBuffer.MatricesIndicesKind
  28408. * - VertexBuffer.MatricesIndicesExtraKind
  28409. * - VertexBuffer.MatricesWeightsKind
  28410. * - VertexBuffer.MatricesWeightsExtraKind
  28411. * @returns a boolean
  28412. */
  28413. isVerticesDataPresent(kind: string): boolean;
  28414. /**
  28415. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28416. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28417. * - VertexBuffer.PositionKind
  28418. * - VertexBuffer.UVKind
  28419. * - VertexBuffer.UV2Kind
  28420. * - VertexBuffer.UV3Kind
  28421. * - VertexBuffer.UV4Kind
  28422. * - VertexBuffer.UV5Kind
  28423. * - VertexBuffer.UV6Kind
  28424. * - VertexBuffer.ColorKind
  28425. * - VertexBuffer.MatricesIndicesKind
  28426. * - VertexBuffer.MatricesIndicesExtraKind
  28427. * - VertexBuffer.MatricesWeightsKind
  28428. * - VertexBuffer.MatricesWeightsExtraKind
  28429. * @returns a boolean
  28430. */
  28431. isVertexBufferUpdatable(kind: string): boolean;
  28432. /**
  28433. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28434. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28435. * - VertexBuffer.PositionKind
  28436. * - VertexBuffer.NormalKind
  28437. * - VertexBuffer.UVKind
  28438. * - VertexBuffer.UV2Kind
  28439. * - VertexBuffer.UV3Kind
  28440. * - VertexBuffer.UV4Kind
  28441. * - VertexBuffer.UV5Kind
  28442. * - VertexBuffer.UV6Kind
  28443. * - VertexBuffer.ColorKind
  28444. * - VertexBuffer.MatricesIndicesKind
  28445. * - VertexBuffer.MatricesIndicesExtraKind
  28446. * - VertexBuffer.MatricesWeightsKind
  28447. * - VertexBuffer.MatricesWeightsExtraKind
  28448. * @returns an array of strings
  28449. */
  28450. getVerticesDataKinds(): string[];
  28451. /**
  28452. * Returns a positive integer : the total number of indices in this mesh geometry.
  28453. * @returns the numner of indices or zero if the mesh has no geometry.
  28454. */
  28455. getTotalIndices(): number;
  28456. /**
  28457. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28458. * @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.
  28459. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28460. * @returns the indices array or an empty array if the mesh has no geometry
  28461. */
  28462. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28463. get isBlocked(): boolean;
  28464. /**
  28465. * Determine if the current mesh is ready to be rendered
  28466. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28467. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28468. * @returns true if all associated assets are ready (material, textures, shaders)
  28469. */
  28470. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28471. /**
  28472. * 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.
  28473. */
  28474. get areNormalsFrozen(): boolean;
  28475. /**
  28476. * 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.
  28477. * @returns the current mesh
  28478. */
  28479. freezeNormals(): Mesh;
  28480. /**
  28481. * 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
  28482. * @returns the current mesh
  28483. */
  28484. unfreezeNormals(): Mesh;
  28485. /**
  28486. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28487. */
  28488. set overridenInstanceCount(count: number);
  28489. /** @hidden */
  28490. _preActivate(): Mesh;
  28491. /** @hidden */
  28492. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28493. /** @hidden */
  28494. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28495. protected _afterComputeWorldMatrix(): void;
  28496. /** @hidden */
  28497. _postActivate(): void;
  28498. /**
  28499. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28500. * This means the mesh underlying bounding box and sphere are recomputed.
  28501. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28502. * @returns the current mesh
  28503. */
  28504. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28505. /** @hidden */
  28506. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28507. /**
  28508. * This function will subdivide the mesh into multiple submeshes
  28509. * @param count defines the expected number of submeshes
  28510. */
  28511. subdivide(count: number): void;
  28512. /**
  28513. * Copy a FloatArray into a specific associated vertex buffer
  28514. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28515. * - VertexBuffer.PositionKind
  28516. * - VertexBuffer.UVKind
  28517. * - VertexBuffer.UV2Kind
  28518. * - VertexBuffer.UV3Kind
  28519. * - VertexBuffer.UV4Kind
  28520. * - VertexBuffer.UV5Kind
  28521. * - VertexBuffer.UV6Kind
  28522. * - VertexBuffer.ColorKind
  28523. * - VertexBuffer.MatricesIndicesKind
  28524. * - VertexBuffer.MatricesIndicesExtraKind
  28525. * - VertexBuffer.MatricesWeightsKind
  28526. * - VertexBuffer.MatricesWeightsExtraKind
  28527. * @param data defines the data source
  28528. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28529. * @param stride defines the data stride size (can be null)
  28530. * @returns the current mesh
  28531. */
  28532. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28533. /**
  28534. * Delete a vertex buffer associated with this mesh
  28535. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28536. * - VertexBuffer.PositionKind
  28537. * - VertexBuffer.UVKind
  28538. * - VertexBuffer.UV2Kind
  28539. * - VertexBuffer.UV3Kind
  28540. * - VertexBuffer.UV4Kind
  28541. * - VertexBuffer.UV5Kind
  28542. * - VertexBuffer.UV6Kind
  28543. * - VertexBuffer.ColorKind
  28544. * - VertexBuffer.MatricesIndicesKind
  28545. * - VertexBuffer.MatricesIndicesExtraKind
  28546. * - VertexBuffer.MatricesWeightsKind
  28547. * - VertexBuffer.MatricesWeightsExtraKind
  28548. */
  28549. removeVerticesData(kind: string): void;
  28550. /**
  28551. * Flags an associated vertex buffer as updatable
  28552. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28553. * - VertexBuffer.PositionKind
  28554. * - VertexBuffer.UVKind
  28555. * - VertexBuffer.UV2Kind
  28556. * - VertexBuffer.UV3Kind
  28557. * - VertexBuffer.UV4Kind
  28558. * - VertexBuffer.UV5Kind
  28559. * - VertexBuffer.UV6Kind
  28560. * - VertexBuffer.ColorKind
  28561. * - VertexBuffer.MatricesIndicesKind
  28562. * - VertexBuffer.MatricesIndicesExtraKind
  28563. * - VertexBuffer.MatricesWeightsKind
  28564. * - VertexBuffer.MatricesWeightsExtraKind
  28565. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28566. */
  28567. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28568. /**
  28569. * Sets the mesh global Vertex Buffer
  28570. * @param buffer defines the buffer to use
  28571. * @returns the current mesh
  28572. */
  28573. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28574. /**
  28575. * Update a specific associated vertex buffer
  28576. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28577. * - VertexBuffer.PositionKind
  28578. * - VertexBuffer.UVKind
  28579. * - VertexBuffer.UV2Kind
  28580. * - VertexBuffer.UV3Kind
  28581. * - VertexBuffer.UV4Kind
  28582. * - VertexBuffer.UV5Kind
  28583. * - VertexBuffer.UV6Kind
  28584. * - VertexBuffer.ColorKind
  28585. * - VertexBuffer.MatricesIndicesKind
  28586. * - VertexBuffer.MatricesIndicesExtraKind
  28587. * - VertexBuffer.MatricesWeightsKind
  28588. * - VertexBuffer.MatricesWeightsExtraKind
  28589. * @param data defines the data source
  28590. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28591. * @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)
  28592. * @returns the current mesh
  28593. */
  28594. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28595. /**
  28596. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28597. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28598. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28599. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28600. * @returns the current mesh
  28601. */
  28602. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28603. /**
  28604. * Creates a un-shared specific occurence of the geometry for the mesh.
  28605. * @returns the current mesh
  28606. */
  28607. makeGeometryUnique(): Mesh;
  28608. /**
  28609. * Set the index buffer of this mesh
  28610. * @param indices defines the source data
  28611. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28612. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28613. * @returns the current mesh
  28614. */
  28615. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28616. /**
  28617. * Update the current index buffer
  28618. * @param indices defines the source data
  28619. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28620. * @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)
  28621. * @returns the current mesh
  28622. */
  28623. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28624. /**
  28625. * Invert the geometry to move from a right handed system to a left handed one.
  28626. * @returns the current mesh
  28627. */
  28628. toLeftHanded(): Mesh;
  28629. /** @hidden */
  28630. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28631. /** @hidden */
  28632. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28633. /**
  28634. * Registers for this mesh a javascript function called just before the rendering process
  28635. * @param func defines the function to call before rendering this mesh
  28636. * @returns the current mesh
  28637. */
  28638. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28639. /**
  28640. * Disposes a previously registered javascript function called before the rendering
  28641. * @param func defines the function to remove
  28642. * @returns the current mesh
  28643. */
  28644. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28645. /**
  28646. * Registers for this mesh a javascript function called just after the rendering is complete
  28647. * @param func defines the function to call after rendering this mesh
  28648. * @returns the current mesh
  28649. */
  28650. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28651. /**
  28652. * Disposes a previously registered javascript function called after the rendering.
  28653. * @param func defines the function to remove
  28654. * @returns the current mesh
  28655. */
  28656. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28657. /** @hidden */
  28658. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28659. /** @hidden */
  28660. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28661. /** @hidden */
  28662. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28663. /** @hidden */
  28664. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28665. /** @hidden */
  28666. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28667. /** @hidden */
  28668. _rebuild(): void;
  28669. /** @hidden */
  28670. _freeze(): void;
  28671. /** @hidden */
  28672. _unFreeze(): void;
  28673. /**
  28674. * 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
  28675. * @param subMesh defines the subMesh to render
  28676. * @param enableAlphaMode defines if alpha mode can be changed
  28677. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28678. * @returns the current mesh
  28679. */
  28680. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28681. private _onBeforeDraw;
  28682. /**
  28683. * Renormalize the mesh and patch it up if there are no weights
  28684. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28685. * However in the case of zero weights then we set just a single influence to 1.
  28686. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28687. */
  28688. cleanMatrixWeights(): void;
  28689. private normalizeSkinFourWeights;
  28690. private normalizeSkinWeightsAndExtra;
  28691. /**
  28692. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28693. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28694. * the user know there was an issue with importing the mesh
  28695. * @returns a validation object with skinned, valid and report string
  28696. */
  28697. validateSkinning(): {
  28698. skinned: boolean;
  28699. valid: boolean;
  28700. report: string;
  28701. };
  28702. /** @hidden */
  28703. _checkDelayState(): Mesh;
  28704. private _queueLoad;
  28705. /**
  28706. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28707. * A mesh is in the frustum if its bounding box intersects the frustum
  28708. * @param frustumPlanes defines the frustum to test
  28709. * @returns true if the mesh is in the frustum planes
  28710. */
  28711. isInFrustum(frustumPlanes: Plane[]): boolean;
  28712. /**
  28713. * Sets the mesh material by the material or multiMaterial `id` property
  28714. * @param id is a string identifying the material or the multiMaterial
  28715. * @returns the current mesh
  28716. */
  28717. setMaterialByID(id: string): Mesh;
  28718. /**
  28719. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28720. * @returns an array of IAnimatable
  28721. */
  28722. getAnimatables(): IAnimatable[];
  28723. /**
  28724. * Modifies the mesh geometry according to the passed transformation matrix.
  28725. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28726. * The mesh normals are modified using the same transformation.
  28727. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28728. * @param transform defines the transform matrix to use
  28729. * @see http://doc.babylonjs.com/resources/baking_transformations
  28730. * @returns the current mesh
  28731. */
  28732. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28733. /**
  28734. * Modifies the mesh geometry according to its own current World Matrix.
  28735. * The mesh World Matrix is then reset.
  28736. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28737. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28738. * @see http://doc.babylonjs.com/resources/baking_transformations
  28739. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28740. * @returns the current mesh
  28741. */
  28742. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28743. /** @hidden */
  28744. get _positions(): Nullable<Vector3[]>;
  28745. /** @hidden */
  28746. _resetPointsArrayCache(): Mesh;
  28747. /** @hidden */
  28748. _generatePointsArray(): boolean;
  28749. /**
  28750. * Returns a new Mesh object generated from the current mesh properties.
  28751. * This method must not get confused with createInstance()
  28752. * @param name is a string, the name given to the new mesh
  28753. * @param newParent can be any Node object (default `null`)
  28754. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28755. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28756. * @returns a new mesh
  28757. */
  28758. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28759. /**
  28760. * Releases resources associated with this mesh.
  28761. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28762. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28763. */
  28764. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28765. /** @hidden */
  28766. _disposeInstanceSpecificData(): void;
  28767. /** @hidden */
  28768. _disposeThinInstanceSpecificData(): void;
  28769. /**
  28770. * Modifies the mesh geometry according to a displacement map.
  28771. * 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.
  28772. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28773. * @param url is a string, the URL from the image file is to be downloaded.
  28774. * @param minHeight is the lower limit of the displacement.
  28775. * @param maxHeight is the upper limit of the displacement.
  28776. * @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.
  28777. * @param uvOffset is an optional vector2 used to offset UV.
  28778. * @param uvScale is an optional vector2 used to scale UV.
  28779. * @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.
  28780. * @returns the Mesh.
  28781. */
  28782. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28783. /**
  28784. * Modifies the mesh geometry according to a displacementMap buffer.
  28785. * 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.
  28786. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28787. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28788. * @param heightMapWidth is the width of the buffer image.
  28789. * @param heightMapHeight is the height of the buffer image.
  28790. * @param minHeight is the lower limit of the displacement.
  28791. * @param maxHeight is the upper limit of the displacement.
  28792. * @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.
  28793. * @param uvOffset is an optional vector2 used to offset UV.
  28794. * @param uvScale is an optional vector2 used to scale UV.
  28795. * @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.
  28796. * @returns the Mesh.
  28797. */
  28798. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28799. /**
  28800. * Modify the mesh to get a flat shading rendering.
  28801. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28802. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28803. * @returns current mesh
  28804. */
  28805. convertToFlatShadedMesh(): Mesh;
  28806. /**
  28807. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28808. * In other words, more vertices, no more indices and a single bigger VBO.
  28809. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28810. * @returns current mesh
  28811. */
  28812. convertToUnIndexedMesh(): Mesh;
  28813. /**
  28814. * Inverses facet orientations.
  28815. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28816. * @param flipNormals will also inverts the normals
  28817. * @returns current mesh
  28818. */
  28819. flipFaces(flipNormals?: boolean): Mesh;
  28820. /**
  28821. * Increase the number of facets and hence vertices in a mesh
  28822. * Vertex normals are interpolated from existing vertex normals
  28823. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28824. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28825. */
  28826. increaseVertices(numberPerEdge: number): void;
  28827. /**
  28828. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28829. * This will undo any application of covertToFlatShadedMesh
  28830. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28831. */
  28832. forceSharedVertices(): void;
  28833. /** @hidden */
  28834. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28835. /** @hidden */
  28836. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28837. /**
  28838. * Creates a new InstancedMesh object from the mesh model.
  28839. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  28840. * @param name defines the name of the new instance
  28841. * @returns a new InstancedMesh
  28842. */
  28843. createInstance(name: string): InstancedMesh;
  28844. /**
  28845. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28846. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28847. * @returns the current mesh
  28848. */
  28849. synchronizeInstances(): Mesh;
  28850. /**
  28851. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28852. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28853. * This should be used together with the simplification to avoid disappearing triangles.
  28854. * @param successCallback an optional success callback to be called after the optimization finished.
  28855. * @returns the current mesh
  28856. */
  28857. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28858. /**
  28859. * Serialize current mesh
  28860. * @param serializationObject defines the object which will receive the serialization data
  28861. */
  28862. serialize(serializationObject: any): void;
  28863. /** @hidden */
  28864. _syncGeometryWithMorphTargetManager(): void;
  28865. /** @hidden */
  28866. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28867. /**
  28868. * Returns a new Mesh object parsed from the source provided.
  28869. * @param parsedMesh is the source
  28870. * @param scene defines the hosting scene
  28871. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28872. * @returns a new Mesh
  28873. */
  28874. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28875. /**
  28876. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28877. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28878. * @param name defines the name of the mesh to create
  28879. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28880. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28881. * @param closePath creates a seam between the first and the last points of each path of the path array
  28882. * @param offset is taken in account only if the `pathArray` is containing a single path
  28883. * @param scene defines the hosting scene
  28884. * @param updatable defines if the mesh must be flagged as updatable
  28885. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28886. * @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)
  28887. * @returns a new Mesh
  28888. */
  28889. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28890. /**
  28891. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28892. * @param name defines the name of the mesh to create
  28893. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28894. * @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
  28895. * @param scene defines the hosting scene
  28896. * @param updatable defines if the mesh must be flagged as updatable
  28897. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28898. * @returns a new Mesh
  28899. */
  28900. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28901. /**
  28902. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28903. * @param name defines the name of the mesh to create
  28904. * @param size sets the size (float) of each box side (default 1)
  28905. * @param scene defines the hosting scene
  28906. * @param updatable defines if the mesh must be flagged as updatable
  28907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28908. * @returns a new Mesh
  28909. */
  28910. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28911. /**
  28912. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28913. * @param name defines the name of the mesh to create
  28914. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28915. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28916. * @param scene defines the hosting scene
  28917. * @param updatable defines if the mesh must be flagged as updatable
  28918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28919. * @returns a new Mesh
  28920. */
  28921. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28922. /**
  28923. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28924. * @param name defines the name of the mesh to create
  28925. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28926. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28927. * @param scene defines the hosting scene
  28928. * @returns a new Mesh
  28929. */
  28930. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28931. /**
  28932. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28933. * @param name defines the name of the mesh to create
  28934. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28935. * @param diameterTop set the top cap diameter (floats, default 1)
  28936. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28937. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28938. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28939. * @param scene defines the hosting scene
  28940. * @param updatable defines if the mesh must be flagged as updatable
  28941. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28942. * @returns a new Mesh
  28943. */
  28944. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28945. /**
  28946. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28947. * @param name defines the name of the mesh to create
  28948. * @param diameter sets the diameter size (float) of the torus (default 1)
  28949. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28950. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28951. * @param scene defines the hosting scene
  28952. * @param updatable defines if the mesh must be flagged as updatable
  28953. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28954. * @returns a new Mesh
  28955. */
  28956. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28957. /**
  28958. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28959. * @param name defines the name of the mesh to create
  28960. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28961. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28962. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28963. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28964. * @param p the number of windings on X axis (positive integers, default 2)
  28965. * @param q the number of windings on Y axis (positive integers, default 3)
  28966. * @param scene defines the hosting scene
  28967. * @param updatable defines if the mesh must be flagged as updatable
  28968. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28969. * @returns a new Mesh
  28970. */
  28971. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28972. /**
  28973. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28974. * @param name defines the name of the mesh to create
  28975. * @param points is an array successive Vector3
  28976. * @param scene defines the hosting scene
  28977. * @param updatable defines if the mesh must be flagged as updatable
  28978. * @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).
  28979. * @returns a new Mesh
  28980. */
  28981. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28982. /**
  28983. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28984. * @param name defines the name of the mesh to create
  28985. * @param points is an array successive Vector3
  28986. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28987. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28988. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28989. * @param scene defines the hosting scene
  28990. * @param updatable defines if the mesh must be flagged as updatable
  28991. * @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)
  28992. * @returns a new Mesh
  28993. */
  28994. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28995. /**
  28996. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28997. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28998. * 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.
  28999. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29000. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29001. * Remember you can only change the shape positions, not their number when updating a polygon.
  29002. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29003. * @param name defines the name of the mesh to create
  29004. * @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
  29005. * @param scene defines the hosting scene
  29006. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29007. * @param updatable defines if the mesh must be flagged as updatable
  29008. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29009. * @param earcutInjection can be used to inject your own earcut reference
  29010. * @returns a new Mesh
  29011. */
  29012. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29013. /**
  29014. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29015. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29016. * @param name defines the name of the mesh to create
  29017. * @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
  29018. * @param depth defines the height of extrusion
  29019. * @param scene defines the hosting scene
  29020. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29021. * @param updatable defines if the mesh must be flagged as updatable
  29022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29023. * @param earcutInjection can be used to inject your own earcut reference
  29024. * @returns a new Mesh
  29025. */
  29026. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29027. /**
  29028. * Creates an extruded shape mesh.
  29029. * 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
  29030. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29031. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29032. * @param name defines the name of the mesh to create
  29033. * @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
  29034. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29035. * @param scale is the value to scale the shape
  29036. * @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
  29037. * @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
  29038. * @param scene defines the hosting scene
  29039. * @param updatable defines if the mesh must be flagged as updatable
  29040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29041. * @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)
  29042. * @returns a new Mesh
  29043. */
  29044. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29045. /**
  29046. * Creates an custom extruded shape mesh.
  29047. * The custom extrusion is a parametric shape.
  29048. * It has no predefined shape. Its final shape will depend on the input parameters.
  29049. * Please consider using the same method from the MeshBuilder class instead
  29050. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29051. * @param name defines the name of the mesh to create
  29052. * @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
  29053. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29054. * @param scaleFunction is a custom Javascript function called on each path point
  29055. * @param rotationFunction is a custom Javascript function called on each path point
  29056. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29057. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29058. * @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
  29059. * @param scene defines the hosting scene
  29060. * @param updatable defines if the mesh must be flagged as updatable
  29061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29062. * @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)
  29063. * @returns a new Mesh
  29064. */
  29065. 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;
  29066. /**
  29067. * Creates lathe mesh.
  29068. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29069. * Please consider using the same method from the MeshBuilder class instead
  29070. * @param name defines the name of the mesh to create
  29071. * @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
  29072. * @param radius is the radius value of the lathe
  29073. * @param tessellation is the side number of the lathe.
  29074. * @param scene defines the hosting scene
  29075. * @param updatable defines if the mesh must be flagged as updatable
  29076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29077. * @returns a new Mesh
  29078. */
  29079. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29080. /**
  29081. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29082. * @param name defines the name of the mesh to create
  29083. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29084. * @param scene defines the hosting scene
  29085. * @param updatable defines if the mesh must be flagged as updatable
  29086. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29087. * @returns a new Mesh
  29088. */
  29089. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29090. /**
  29091. * Creates a ground mesh.
  29092. * Please consider using the same method from the MeshBuilder class instead
  29093. * @param name defines the name of the mesh to create
  29094. * @param width set the width of the ground
  29095. * @param height set the height of the ground
  29096. * @param subdivisions sets the number of subdivisions per side
  29097. * @param scene defines the hosting scene
  29098. * @param updatable defines if the mesh must be flagged as updatable
  29099. * @returns a new Mesh
  29100. */
  29101. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29102. /**
  29103. * Creates a tiled ground mesh.
  29104. * Please consider using the same method from the MeshBuilder class instead
  29105. * @param name defines the name of the mesh to create
  29106. * @param xmin set the ground minimum X coordinate
  29107. * @param zmin set the ground minimum Y coordinate
  29108. * @param xmax set the ground maximum X coordinate
  29109. * @param zmax set the ground maximum Z coordinate
  29110. * @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
  29111. * @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
  29112. * @param scene defines the hosting scene
  29113. * @param updatable defines if the mesh must be flagged as updatable
  29114. * @returns a new Mesh
  29115. */
  29116. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29117. w: number;
  29118. h: number;
  29119. }, precision: {
  29120. w: number;
  29121. h: number;
  29122. }, scene: Scene, updatable?: boolean): Mesh;
  29123. /**
  29124. * Creates a ground mesh from a height map.
  29125. * Please consider using the same method from the MeshBuilder class instead
  29126. * @see http://doc.babylonjs.com/babylon101/height_map
  29127. * @param name defines the name of the mesh to create
  29128. * @param url sets the URL of the height map image resource
  29129. * @param width set the ground width size
  29130. * @param height set the ground height size
  29131. * @param subdivisions sets the number of subdivision per side
  29132. * @param minHeight is the minimum altitude on the ground
  29133. * @param maxHeight is the maximum altitude on the ground
  29134. * @param scene defines the hosting scene
  29135. * @param updatable defines if the mesh must be flagged as updatable
  29136. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29137. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29138. * @returns a new Mesh
  29139. */
  29140. 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;
  29141. /**
  29142. * Creates a tube mesh.
  29143. * The tube is a parametric shape.
  29144. * It has no predefined shape. Its final shape will depend on the input parameters.
  29145. * Please consider using the same method from the MeshBuilder class instead
  29146. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  29147. * @param name defines the name of the mesh to create
  29148. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29149. * @param radius sets the tube radius size
  29150. * @param tessellation is the number of sides on the tubular surface
  29151. * @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
  29152. * @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
  29153. * @param scene defines the hosting scene
  29154. * @param updatable defines if the mesh must be flagged as updatable
  29155. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29156. * @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)
  29157. * @returns a new Mesh
  29158. */
  29159. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29160. (i: number, distance: number): number;
  29161. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29162. /**
  29163. * Creates a polyhedron mesh.
  29164. * Please consider using the same method from the MeshBuilder class instead.
  29165. * * 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
  29166. * * The parameter `size` (positive float, default 1) sets the polygon size
  29167. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29168. * * 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`
  29169. * * 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
  29170. * * 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)`)
  29171. * * 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
  29172. * * 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
  29173. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29174. * * If you create a double-sided mesh, you can choose what parts of 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
  29175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29176. * @param name defines the name of the mesh to create
  29177. * @param options defines the options used to create the mesh
  29178. * @param scene defines the hosting scene
  29179. * @returns a new Mesh
  29180. */
  29181. static CreatePolyhedron(name: string, options: {
  29182. type?: number;
  29183. size?: number;
  29184. sizeX?: number;
  29185. sizeY?: number;
  29186. sizeZ?: number;
  29187. custom?: any;
  29188. faceUV?: Vector4[];
  29189. faceColors?: Color4[];
  29190. updatable?: boolean;
  29191. sideOrientation?: number;
  29192. }, scene: Scene): Mesh;
  29193. /**
  29194. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29195. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29196. * * 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`)
  29197. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29198. * * 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
  29199. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29200. * * If you create a double-sided mesh, you can choose what parts of 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
  29201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29202. * @param name defines the name of the mesh
  29203. * @param options defines the options used to create the mesh
  29204. * @param scene defines the hosting scene
  29205. * @returns a new Mesh
  29206. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29207. */
  29208. static CreateIcoSphere(name: string, options: {
  29209. radius?: number;
  29210. flat?: boolean;
  29211. subdivisions?: number;
  29212. sideOrientation?: number;
  29213. updatable?: boolean;
  29214. }, scene: Scene): Mesh;
  29215. /**
  29216. * Creates a decal mesh.
  29217. * Please consider using the same method from the MeshBuilder class instead.
  29218. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29219. * @param name defines the name of the mesh
  29220. * @param sourceMesh defines the mesh receiving the decal
  29221. * @param position sets the position of the decal in world coordinates
  29222. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29223. * @param size sets the decal scaling
  29224. * @param angle sets the angle to rotate the decal
  29225. * @returns a new Mesh
  29226. */
  29227. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29228. /**
  29229. * Prepare internal position array for software CPU skinning
  29230. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29231. */
  29232. setPositionsForCPUSkinning(): Float32Array;
  29233. /**
  29234. * Prepare internal normal array for software CPU skinning
  29235. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29236. */
  29237. setNormalsForCPUSkinning(): Float32Array;
  29238. /**
  29239. * Updates the vertex buffer by applying transformation from the bones
  29240. * @param skeleton defines the skeleton to apply to current mesh
  29241. * @returns the current mesh
  29242. */
  29243. applySkeleton(skeleton: Skeleton): Mesh;
  29244. /**
  29245. * 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
  29246. * @param meshes defines the list of meshes to scan
  29247. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29248. */
  29249. static MinMax(meshes: AbstractMesh[]): {
  29250. min: Vector3;
  29251. max: Vector3;
  29252. };
  29253. /**
  29254. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29255. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29256. * @returns a vector3
  29257. */
  29258. static Center(meshesOrMinMaxVector: {
  29259. min: Vector3;
  29260. max: Vector3;
  29261. } | AbstractMesh[]): Vector3;
  29262. /**
  29263. * Merge the array of meshes into a single mesh for performance reasons.
  29264. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29265. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29266. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29267. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29268. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29269. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29270. * @returns a new mesh
  29271. */
  29272. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29273. /** @hidden */
  29274. addInstance(instance: InstancedMesh): void;
  29275. /** @hidden */
  29276. removeInstance(instance: InstancedMesh): void;
  29277. }
  29278. }
  29279. declare module "babylonjs/Cameras/camera" {
  29280. import { SmartArray } from "babylonjs/Misc/smartArray";
  29281. import { Observable } from "babylonjs/Misc/observable";
  29282. import { Nullable } from "babylonjs/types";
  29283. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29284. import { Scene } from "babylonjs/scene";
  29285. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29286. import { Node } from "babylonjs/node";
  29287. import { Mesh } from "babylonjs/Meshes/mesh";
  29288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29289. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29290. import { Viewport } from "babylonjs/Maths/math.viewport";
  29291. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29292. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29293. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29294. import { Ray } from "babylonjs/Culling/ray";
  29295. /**
  29296. * This is the base class of all the camera used in the application.
  29297. * @see http://doc.babylonjs.com/features/cameras
  29298. */
  29299. export class Camera extends Node {
  29300. /** @hidden */
  29301. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29302. /**
  29303. * This is the default projection mode used by the cameras.
  29304. * It helps recreating a feeling of perspective and better appreciate depth.
  29305. * This is the best way to simulate real life cameras.
  29306. */
  29307. static readonly PERSPECTIVE_CAMERA: number;
  29308. /**
  29309. * This helps creating camera with an orthographic mode.
  29310. * 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.
  29311. */
  29312. static readonly ORTHOGRAPHIC_CAMERA: number;
  29313. /**
  29314. * This is the default FOV mode for perspective cameras.
  29315. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29316. */
  29317. static readonly FOVMODE_VERTICAL_FIXED: number;
  29318. /**
  29319. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29320. */
  29321. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29322. /**
  29323. * This specifies ther is no need for a camera rig.
  29324. * Basically only one eye is rendered corresponding to the camera.
  29325. */
  29326. static readonly RIG_MODE_NONE: number;
  29327. /**
  29328. * Simulates a camera Rig with one blue eye and one red eye.
  29329. * This can be use with 3d blue and red glasses.
  29330. */
  29331. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29332. /**
  29333. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29334. */
  29335. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29336. /**
  29337. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29338. */
  29339. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29340. /**
  29341. * Defines that both eyes of the camera will be rendered over under each other.
  29342. */
  29343. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29344. /**
  29345. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29346. */
  29347. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29348. /**
  29349. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29350. */
  29351. static readonly RIG_MODE_VR: number;
  29352. /**
  29353. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29354. */
  29355. static readonly RIG_MODE_WEBVR: number;
  29356. /**
  29357. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29358. */
  29359. static readonly RIG_MODE_CUSTOM: number;
  29360. /**
  29361. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29362. */
  29363. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29364. /**
  29365. * Define the input manager associated with the camera.
  29366. */
  29367. inputs: CameraInputsManager<Camera>;
  29368. /** @hidden */
  29369. _position: Vector3;
  29370. /**
  29371. * Define the current local position of the camera in the scene
  29372. */
  29373. get position(): Vector3;
  29374. set position(newPosition: Vector3);
  29375. /**
  29376. * The vector the camera should consider as up.
  29377. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29378. */
  29379. upVector: Vector3;
  29380. /**
  29381. * Define the current limit on the left side for an orthographic camera
  29382. * In scene unit
  29383. */
  29384. orthoLeft: Nullable<number>;
  29385. /**
  29386. * Define the current limit on the right side for an orthographic camera
  29387. * In scene unit
  29388. */
  29389. orthoRight: Nullable<number>;
  29390. /**
  29391. * Define the current limit on the bottom side for an orthographic camera
  29392. * In scene unit
  29393. */
  29394. orthoBottom: Nullable<number>;
  29395. /**
  29396. * Define the current limit on the top side for an orthographic camera
  29397. * In scene unit
  29398. */
  29399. orthoTop: Nullable<number>;
  29400. /**
  29401. * Field Of View is set in Radians. (default is 0.8)
  29402. */
  29403. fov: number;
  29404. /**
  29405. * Define the minimum distance the camera can see from.
  29406. * This is important to note that the depth buffer are not infinite and the closer it starts
  29407. * the more your scene might encounter depth fighting issue.
  29408. */
  29409. minZ: number;
  29410. /**
  29411. * Define the maximum distance the camera can see to.
  29412. * This is important to note that the depth buffer are not infinite and the further it end
  29413. * the more your scene might encounter depth fighting issue.
  29414. */
  29415. maxZ: number;
  29416. /**
  29417. * Define the default inertia of the camera.
  29418. * This helps giving a smooth feeling to the camera movement.
  29419. */
  29420. inertia: number;
  29421. /**
  29422. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29423. */
  29424. mode: number;
  29425. /**
  29426. * Define whether the camera is intermediate.
  29427. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29428. */
  29429. isIntermediate: boolean;
  29430. /**
  29431. * Define the viewport of the camera.
  29432. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29433. */
  29434. viewport: Viewport;
  29435. /**
  29436. * Restricts the camera to viewing objects with the same layerMask.
  29437. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29438. */
  29439. layerMask: number;
  29440. /**
  29441. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29442. */
  29443. fovMode: number;
  29444. /**
  29445. * Rig mode of the camera.
  29446. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29447. * This is normally controlled byt the camera themselves as internal use.
  29448. */
  29449. cameraRigMode: number;
  29450. /**
  29451. * Defines the distance between both "eyes" in case of a RIG
  29452. */
  29453. interaxialDistance: number;
  29454. /**
  29455. * Defines if stereoscopic rendering is done side by side or over under.
  29456. */
  29457. isStereoscopicSideBySide: boolean;
  29458. /**
  29459. * 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
  29460. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29461. * else in the scene. (Eg. security camera)
  29462. *
  29463. * 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)
  29464. */
  29465. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29466. /**
  29467. * When set, the camera will render to this render target instead of the default canvas
  29468. *
  29469. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29470. */
  29471. outputRenderTarget: Nullable<RenderTargetTexture>;
  29472. /**
  29473. * Observable triggered when the camera view matrix has changed.
  29474. */
  29475. onViewMatrixChangedObservable: Observable<Camera>;
  29476. /**
  29477. * Observable triggered when the camera Projection matrix has changed.
  29478. */
  29479. onProjectionMatrixChangedObservable: Observable<Camera>;
  29480. /**
  29481. * Observable triggered when the inputs have been processed.
  29482. */
  29483. onAfterCheckInputsObservable: Observable<Camera>;
  29484. /**
  29485. * Observable triggered when reset has been called and applied to the camera.
  29486. */
  29487. onRestoreStateObservable: Observable<Camera>;
  29488. /**
  29489. * Is this camera a part of a rig system?
  29490. */
  29491. isRigCamera: boolean;
  29492. /**
  29493. * If isRigCamera set to true this will be set with the parent camera.
  29494. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29495. */
  29496. rigParent?: Camera;
  29497. /** @hidden */
  29498. _cameraRigParams: any;
  29499. /** @hidden */
  29500. _rigCameras: Camera[];
  29501. /** @hidden */
  29502. _rigPostProcess: Nullable<PostProcess>;
  29503. protected _webvrViewMatrix: Matrix;
  29504. /** @hidden */
  29505. _skipRendering: boolean;
  29506. /** @hidden */
  29507. _projectionMatrix: Matrix;
  29508. /** @hidden */
  29509. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29510. /** @hidden */
  29511. _activeMeshes: SmartArray<AbstractMesh>;
  29512. protected _globalPosition: Vector3;
  29513. /** @hidden */
  29514. _computedViewMatrix: Matrix;
  29515. private _doNotComputeProjectionMatrix;
  29516. private _transformMatrix;
  29517. private _frustumPlanes;
  29518. private _refreshFrustumPlanes;
  29519. private _storedFov;
  29520. private _stateStored;
  29521. /**
  29522. * Instantiates a new camera object.
  29523. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29524. * @see http://doc.babylonjs.com/features/cameras
  29525. * @param name Defines the name of the camera in the scene
  29526. * @param position Defines the position of the camera
  29527. * @param scene Defines the scene the camera belongs too
  29528. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29529. */
  29530. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29531. /**
  29532. * Store current camera state (fov, position, etc..)
  29533. * @returns the camera
  29534. */
  29535. storeState(): Camera;
  29536. /**
  29537. * Restores the camera state values if it has been stored. You must call storeState() first
  29538. */
  29539. protected _restoreStateValues(): boolean;
  29540. /**
  29541. * Restored camera state. You must call storeState() first.
  29542. * @returns true if restored and false otherwise
  29543. */
  29544. restoreState(): boolean;
  29545. /**
  29546. * Gets the class name of the camera.
  29547. * @returns the class name
  29548. */
  29549. getClassName(): string;
  29550. /** @hidden */
  29551. readonly _isCamera: boolean;
  29552. /**
  29553. * Gets a string representation of the camera useful for debug purpose.
  29554. * @param fullDetails Defines that a more verboe level of logging is required
  29555. * @returns the string representation
  29556. */
  29557. toString(fullDetails?: boolean): string;
  29558. /**
  29559. * Gets the current world space position of the camera.
  29560. */
  29561. get globalPosition(): Vector3;
  29562. /**
  29563. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29564. * @returns the active meshe list
  29565. */
  29566. getActiveMeshes(): SmartArray<AbstractMesh>;
  29567. /**
  29568. * Check whether a mesh is part of the current active mesh list of the camera
  29569. * @param mesh Defines the mesh to check
  29570. * @returns true if active, false otherwise
  29571. */
  29572. isActiveMesh(mesh: Mesh): boolean;
  29573. /**
  29574. * Is this camera ready to be used/rendered
  29575. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29576. * @return true if the camera is ready
  29577. */
  29578. isReady(completeCheck?: boolean): boolean;
  29579. /** @hidden */
  29580. _initCache(): void;
  29581. /** @hidden */
  29582. _updateCache(ignoreParentClass?: boolean): void;
  29583. /** @hidden */
  29584. _isSynchronized(): boolean;
  29585. /** @hidden */
  29586. _isSynchronizedViewMatrix(): boolean;
  29587. /** @hidden */
  29588. _isSynchronizedProjectionMatrix(): boolean;
  29589. /**
  29590. * Attach the input controls to a specific dom element to get the input from.
  29591. * @param element Defines the element the controls should be listened from
  29592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29593. */
  29594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29595. /**
  29596. * Detach the current controls from the specified dom element.
  29597. * @param element Defines the element to stop listening the inputs from
  29598. */
  29599. detachControl(element: HTMLElement): void;
  29600. /**
  29601. * Update the camera state according to the different inputs gathered during the frame.
  29602. */
  29603. update(): void;
  29604. /** @hidden */
  29605. _checkInputs(): void;
  29606. /** @hidden */
  29607. get rigCameras(): Camera[];
  29608. /**
  29609. * Gets the post process used by the rig cameras
  29610. */
  29611. get rigPostProcess(): Nullable<PostProcess>;
  29612. /**
  29613. * Internal, gets the first post proces.
  29614. * @returns the first post process to be run on this camera.
  29615. */
  29616. _getFirstPostProcess(): Nullable<PostProcess>;
  29617. private _cascadePostProcessesToRigCams;
  29618. /**
  29619. * Attach a post process to the camera.
  29620. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29621. * @param postProcess The post process to attach to the camera
  29622. * @param insertAt The position of the post process in case several of them are in use in the scene
  29623. * @returns the position the post process has been inserted at
  29624. */
  29625. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29626. /**
  29627. * Detach a post process to the camera.
  29628. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29629. * @param postProcess The post process to detach from the camera
  29630. */
  29631. detachPostProcess(postProcess: PostProcess): void;
  29632. /**
  29633. * Gets the current world matrix of the camera
  29634. */
  29635. getWorldMatrix(): Matrix;
  29636. /** @hidden */
  29637. _getViewMatrix(): Matrix;
  29638. /**
  29639. * Gets the current view matrix of the camera.
  29640. * @param force forces the camera to recompute the matrix without looking at the cached state
  29641. * @returns the view matrix
  29642. */
  29643. getViewMatrix(force?: boolean): Matrix;
  29644. /**
  29645. * Freeze the projection matrix.
  29646. * It will prevent the cache check of the camera projection compute and can speed up perf
  29647. * if no parameter of the camera are meant to change
  29648. * @param projection Defines manually a projection if necessary
  29649. */
  29650. freezeProjectionMatrix(projection?: Matrix): void;
  29651. /**
  29652. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29653. */
  29654. unfreezeProjectionMatrix(): void;
  29655. /**
  29656. * Gets the current projection matrix of the camera.
  29657. * @param force forces the camera to recompute the matrix without looking at the cached state
  29658. * @returns the projection matrix
  29659. */
  29660. getProjectionMatrix(force?: boolean): Matrix;
  29661. /**
  29662. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29663. * @returns a Matrix
  29664. */
  29665. getTransformationMatrix(): Matrix;
  29666. private _updateFrustumPlanes;
  29667. /**
  29668. * Checks if a cullable object (mesh...) is in the camera frustum
  29669. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29670. * @param target The object to check
  29671. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29672. * @returns true if the object is in frustum otherwise false
  29673. */
  29674. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29675. /**
  29676. * Checks if a cullable object (mesh...) is in the camera frustum
  29677. * Unlike isInFrustum this cheks the full bounding box
  29678. * @param target The object to check
  29679. * @returns true if the object is in frustum otherwise false
  29680. */
  29681. isCompletelyInFrustum(target: ICullable): boolean;
  29682. /**
  29683. * Gets a ray in the forward direction from the camera.
  29684. * @param length Defines the length of the ray to create
  29685. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29686. * @param origin Defines the start point of the ray which defaults to the camera position
  29687. * @returns the forward ray
  29688. */
  29689. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29690. /**
  29691. * Releases resources associated with this node.
  29692. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29693. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29694. */
  29695. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29696. /** @hidden */
  29697. _isLeftCamera: boolean;
  29698. /**
  29699. * Gets the left camera of a rig setup in case of Rigged Camera
  29700. */
  29701. get isLeftCamera(): boolean;
  29702. /** @hidden */
  29703. _isRightCamera: boolean;
  29704. /**
  29705. * Gets the right camera of a rig setup in case of Rigged Camera
  29706. */
  29707. get isRightCamera(): boolean;
  29708. /**
  29709. * Gets the left camera of a rig setup in case of Rigged Camera
  29710. */
  29711. get leftCamera(): Nullable<FreeCamera>;
  29712. /**
  29713. * Gets the right camera of a rig setup in case of Rigged Camera
  29714. */
  29715. get rightCamera(): Nullable<FreeCamera>;
  29716. /**
  29717. * Gets the left camera target of a rig setup in case of Rigged Camera
  29718. * @returns the target position
  29719. */
  29720. getLeftTarget(): Nullable<Vector3>;
  29721. /**
  29722. * Gets the right camera target of a rig setup in case of Rigged Camera
  29723. * @returns the target position
  29724. */
  29725. getRightTarget(): Nullable<Vector3>;
  29726. /**
  29727. * @hidden
  29728. */
  29729. setCameraRigMode(mode: number, rigParams: any): void;
  29730. /** @hidden */
  29731. static _setStereoscopicRigMode(camera: Camera): void;
  29732. /** @hidden */
  29733. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29734. /** @hidden */
  29735. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29736. /** @hidden */
  29737. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29738. /** @hidden */
  29739. _getVRProjectionMatrix(): Matrix;
  29740. protected _updateCameraRotationMatrix(): void;
  29741. protected _updateWebVRCameraRotationMatrix(): void;
  29742. /**
  29743. * This function MUST be overwritten by the different WebVR cameras available.
  29744. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29745. * @hidden
  29746. */
  29747. _getWebVRProjectionMatrix(): Matrix;
  29748. /**
  29749. * This function MUST be overwritten by the different WebVR cameras available.
  29750. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29751. * @hidden
  29752. */
  29753. _getWebVRViewMatrix(): Matrix;
  29754. /** @hidden */
  29755. setCameraRigParameter(name: string, value: any): void;
  29756. /**
  29757. * needs to be overridden by children so sub has required properties to be copied
  29758. * @hidden
  29759. */
  29760. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29761. /**
  29762. * May need to be overridden by children
  29763. * @hidden
  29764. */
  29765. _updateRigCameras(): void;
  29766. /** @hidden */
  29767. _setupInputs(): void;
  29768. /**
  29769. * Serialiaze the camera setup to a json represention
  29770. * @returns the JSON representation
  29771. */
  29772. serialize(): any;
  29773. /**
  29774. * Clones the current camera.
  29775. * @param name The cloned camera name
  29776. * @returns the cloned camera
  29777. */
  29778. clone(name: string): Camera;
  29779. /**
  29780. * Gets the direction of the camera relative to a given local axis.
  29781. * @param localAxis Defines the reference axis to provide a relative direction.
  29782. * @return the direction
  29783. */
  29784. getDirection(localAxis: Vector3): Vector3;
  29785. /**
  29786. * Returns the current camera absolute rotation
  29787. */
  29788. get absoluteRotation(): Quaternion;
  29789. /**
  29790. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29791. * @param localAxis Defines the reference axis to provide a relative direction.
  29792. * @param result Defines the vector to store the result in
  29793. */
  29794. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29795. /**
  29796. * Gets a camera constructor for a given camera type
  29797. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29798. * @param name The name of the camera the result will be able to instantiate
  29799. * @param scene The scene the result will construct the camera in
  29800. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29801. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29802. * @returns a factory method to construc the camera
  29803. */
  29804. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29805. /**
  29806. * Compute the world matrix of the camera.
  29807. * @returns the camera world matrix
  29808. */
  29809. computeWorldMatrix(): Matrix;
  29810. /**
  29811. * Parse a JSON and creates the camera from the parsed information
  29812. * @param parsedCamera The JSON to parse
  29813. * @param scene The scene to instantiate the camera in
  29814. * @returns the newly constructed camera
  29815. */
  29816. static Parse(parsedCamera: any, scene: Scene): Camera;
  29817. }
  29818. }
  29819. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29820. import { Nullable } from "babylonjs/types";
  29821. import { Scene } from "babylonjs/scene";
  29822. import { Vector4 } from "babylonjs/Maths/math.vector";
  29823. import { Mesh } from "babylonjs/Meshes/mesh";
  29824. /**
  29825. * Class containing static functions to help procedurally build meshes
  29826. */
  29827. export class DiscBuilder {
  29828. /**
  29829. * Creates a plane polygonal mesh. By default, this is a disc
  29830. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29831. * * 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
  29832. * * 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
  29833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29836. * @param name defines the name of the mesh
  29837. * @param options defines the options used to create the mesh
  29838. * @param scene defines the hosting scene
  29839. * @returns the plane polygonal mesh
  29840. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29841. */
  29842. static CreateDisc(name: string, options: {
  29843. radius?: number;
  29844. tessellation?: number;
  29845. arc?: number;
  29846. updatable?: boolean;
  29847. sideOrientation?: number;
  29848. frontUVs?: Vector4;
  29849. backUVs?: Vector4;
  29850. }, scene?: Nullable<Scene>): Mesh;
  29851. }
  29852. }
  29853. declare module "babylonjs/Materials/fresnelParameters" {
  29854. import { DeepImmutable } from "babylonjs/types";
  29855. import { Color3 } from "babylonjs/Maths/math.color";
  29856. /**
  29857. * Options to be used when creating a FresnelParameters.
  29858. */
  29859. export type IFresnelParametersCreationOptions = {
  29860. /**
  29861. * Define the color used on edges (grazing angle)
  29862. */
  29863. leftColor?: Color3;
  29864. /**
  29865. * Define the color used on center
  29866. */
  29867. rightColor?: Color3;
  29868. /**
  29869. * Define bias applied to computed fresnel term
  29870. */
  29871. bias?: number;
  29872. /**
  29873. * Defined the power exponent applied to fresnel term
  29874. */
  29875. power?: number;
  29876. /**
  29877. * Define if the fresnel effect is enable or not.
  29878. */
  29879. isEnabled?: boolean;
  29880. };
  29881. /**
  29882. * Serialized format for FresnelParameters.
  29883. */
  29884. export type IFresnelParametersSerialized = {
  29885. /**
  29886. * Define the color used on edges (grazing angle) [as an array]
  29887. */
  29888. leftColor: number[];
  29889. /**
  29890. * Define the color used on center [as an array]
  29891. */
  29892. rightColor: number[];
  29893. /**
  29894. * Define bias applied to computed fresnel term
  29895. */
  29896. bias: number;
  29897. /**
  29898. * Defined the power exponent applied to fresnel term
  29899. */
  29900. power?: number;
  29901. /**
  29902. * Define if the fresnel effect is enable or not.
  29903. */
  29904. isEnabled: boolean;
  29905. };
  29906. /**
  29907. * This represents all the required information to add a fresnel effect on a material:
  29908. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29909. */
  29910. export class FresnelParameters {
  29911. private _isEnabled;
  29912. /**
  29913. * Define if the fresnel effect is enable or not.
  29914. */
  29915. get isEnabled(): boolean;
  29916. set isEnabled(value: boolean);
  29917. /**
  29918. * Define the color used on edges (grazing angle)
  29919. */
  29920. leftColor: Color3;
  29921. /**
  29922. * Define the color used on center
  29923. */
  29924. rightColor: Color3;
  29925. /**
  29926. * Define bias applied to computed fresnel term
  29927. */
  29928. bias: number;
  29929. /**
  29930. * Defined the power exponent applied to fresnel term
  29931. */
  29932. power: number;
  29933. /**
  29934. * Creates a new FresnelParameters object.
  29935. *
  29936. * @param options provide your own settings to optionally to override defaults
  29937. */
  29938. constructor(options?: IFresnelParametersCreationOptions);
  29939. /**
  29940. * Clones the current fresnel and its valuues
  29941. * @returns a clone fresnel configuration
  29942. */
  29943. clone(): FresnelParameters;
  29944. /**
  29945. * Determines equality between FresnelParameters objects
  29946. * @param otherFresnelParameters defines the second operand
  29947. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29948. */
  29949. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29950. /**
  29951. * Serializes the current fresnel parameters to a JSON representation.
  29952. * @return the JSON serialization
  29953. */
  29954. serialize(): IFresnelParametersSerialized;
  29955. /**
  29956. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29957. * @param parsedFresnelParameters Define the JSON representation
  29958. * @returns the parsed parameters
  29959. */
  29960. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29961. }
  29962. }
  29963. declare module "babylonjs/Materials/materialFlags" {
  29964. /**
  29965. * This groups all the flags used to control the materials channel.
  29966. */
  29967. export class MaterialFlags {
  29968. private static _DiffuseTextureEnabled;
  29969. /**
  29970. * Are diffuse textures enabled in the application.
  29971. */
  29972. static get DiffuseTextureEnabled(): boolean;
  29973. static set DiffuseTextureEnabled(value: boolean);
  29974. private static _DetailTextureEnabled;
  29975. /**
  29976. * Are detail textures enabled in the application.
  29977. */
  29978. static get DetailTextureEnabled(): boolean;
  29979. static set DetailTextureEnabled(value: boolean);
  29980. private static _AmbientTextureEnabled;
  29981. /**
  29982. * Are ambient textures enabled in the application.
  29983. */
  29984. static get AmbientTextureEnabled(): boolean;
  29985. static set AmbientTextureEnabled(value: boolean);
  29986. private static _OpacityTextureEnabled;
  29987. /**
  29988. * Are opacity textures enabled in the application.
  29989. */
  29990. static get OpacityTextureEnabled(): boolean;
  29991. static set OpacityTextureEnabled(value: boolean);
  29992. private static _ReflectionTextureEnabled;
  29993. /**
  29994. * Are reflection textures enabled in the application.
  29995. */
  29996. static get ReflectionTextureEnabled(): boolean;
  29997. static set ReflectionTextureEnabled(value: boolean);
  29998. private static _EmissiveTextureEnabled;
  29999. /**
  30000. * Are emissive textures enabled in the application.
  30001. */
  30002. static get EmissiveTextureEnabled(): boolean;
  30003. static set EmissiveTextureEnabled(value: boolean);
  30004. private static _SpecularTextureEnabled;
  30005. /**
  30006. * Are specular textures enabled in the application.
  30007. */
  30008. static get SpecularTextureEnabled(): boolean;
  30009. static set SpecularTextureEnabled(value: boolean);
  30010. private static _BumpTextureEnabled;
  30011. /**
  30012. * Are bump textures enabled in the application.
  30013. */
  30014. static get BumpTextureEnabled(): boolean;
  30015. static set BumpTextureEnabled(value: boolean);
  30016. private static _LightmapTextureEnabled;
  30017. /**
  30018. * Are lightmap textures enabled in the application.
  30019. */
  30020. static get LightmapTextureEnabled(): boolean;
  30021. static set LightmapTextureEnabled(value: boolean);
  30022. private static _RefractionTextureEnabled;
  30023. /**
  30024. * Are refraction textures enabled in the application.
  30025. */
  30026. static get RefractionTextureEnabled(): boolean;
  30027. static set RefractionTextureEnabled(value: boolean);
  30028. private static _ColorGradingTextureEnabled;
  30029. /**
  30030. * Are color grading textures enabled in the application.
  30031. */
  30032. static get ColorGradingTextureEnabled(): boolean;
  30033. static set ColorGradingTextureEnabled(value: boolean);
  30034. private static _FresnelEnabled;
  30035. /**
  30036. * Are fresnels enabled in the application.
  30037. */
  30038. static get FresnelEnabled(): boolean;
  30039. static set FresnelEnabled(value: boolean);
  30040. private static _ClearCoatTextureEnabled;
  30041. /**
  30042. * Are clear coat textures enabled in the application.
  30043. */
  30044. static get ClearCoatTextureEnabled(): boolean;
  30045. static set ClearCoatTextureEnabled(value: boolean);
  30046. private static _ClearCoatBumpTextureEnabled;
  30047. /**
  30048. * Are clear coat bump textures enabled in the application.
  30049. */
  30050. static get ClearCoatBumpTextureEnabled(): boolean;
  30051. static set ClearCoatBumpTextureEnabled(value: boolean);
  30052. private static _ClearCoatTintTextureEnabled;
  30053. /**
  30054. * Are clear coat tint textures enabled in the application.
  30055. */
  30056. static get ClearCoatTintTextureEnabled(): boolean;
  30057. static set ClearCoatTintTextureEnabled(value: boolean);
  30058. private static _SheenTextureEnabled;
  30059. /**
  30060. * Are sheen textures enabled in the application.
  30061. */
  30062. static get SheenTextureEnabled(): boolean;
  30063. static set SheenTextureEnabled(value: boolean);
  30064. private static _AnisotropicTextureEnabled;
  30065. /**
  30066. * Are anisotropic textures enabled in the application.
  30067. */
  30068. static get AnisotropicTextureEnabled(): boolean;
  30069. static set AnisotropicTextureEnabled(value: boolean);
  30070. private static _ThicknessTextureEnabled;
  30071. /**
  30072. * Are thickness textures enabled in the application.
  30073. */
  30074. static get ThicknessTextureEnabled(): boolean;
  30075. static set ThicknessTextureEnabled(value: boolean);
  30076. }
  30077. }
  30078. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30079. /** @hidden */
  30080. export var defaultFragmentDeclaration: {
  30081. name: string;
  30082. shader: string;
  30083. };
  30084. }
  30085. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30086. /** @hidden */
  30087. export var defaultUboDeclaration: {
  30088. name: string;
  30089. shader: string;
  30090. };
  30091. }
  30092. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30093. /** @hidden */
  30094. export var lightFragmentDeclaration: {
  30095. name: string;
  30096. shader: string;
  30097. };
  30098. }
  30099. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30100. /** @hidden */
  30101. export var lightUboDeclaration: {
  30102. name: string;
  30103. shader: string;
  30104. };
  30105. }
  30106. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30107. /** @hidden */
  30108. export var lightsFragmentFunctions: {
  30109. name: string;
  30110. shader: string;
  30111. };
  30112. }
  30113. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30114. /** @hidden */
  30115. export var shadowsFragmentFunctions: {
  30116. name: string;
  30117. shader: string;
  30118. };
  30119. }
  30120. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30121. /** @hidden */
  30122. export var fresnelFunction: {
  30123. name: string;
  30124. shader: string;
  30125. };
  30126. }
  30127. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30128. /** @hidden */
  30129. export var bumpFragmentMainFunctions: {
  30130. name: string;
  30131. shader: string;
  30132. };
  30133. }
  30134. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30135. /** @hidden */
  30136. export var bumpFragmentFunctions: {
  30137. name: string;
  30138. shader: string;
  30139. };
  30140. }
  30141. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30142. /** @hidden */
  30143. export var logDepthDeclaration: {
  30144. name: string;
  30145. shader: string;
  30146. };
  30147. }
  30148. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30149. /** @hidden */
  30150. export var bumpFragment: {
  30151. name: string;
  30152. shader: string;
  30153. };
  30154. }
  30155. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30156. /** @hidden */
  30157. export var depthPrePass: {
  30158. name: string;
  30159. shader: string;
  30160. };
  30161. }
  30162. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30163. /** @hidden */
  30164. export var lightFragment: {
  30165. name: string;
  30166. shader: string;
  30167. };
  30168. }
  30169. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30170. /** @hidden */
  30171. export var logDepthFragment: {
  30172. name: string;
  30173. shader: string;
  30174. };
  30175. }
  30176. declare module "babylonjs/Shaders/default.fragment" {
  30177. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30178. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30179. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30180. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30181. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30182. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30183. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30184. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30185. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30186. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30187. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30188. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30189. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30190. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30191. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30192. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30193. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30194. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30195. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30196. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30197. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30198. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30199. /** @hidden */
  30200. export var defaultPixelShader: {
  30201. name: string;
  30202. shader: string;
  30203. };
  30204. }
  30205. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30206. /** @hidden */
  30207. export var defaultVertexDeclaration: {
  30208. name: string;
  30209. shader: string;
  30210. };
  30211. }
  30212. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30213. /** @hidden */
  30214. export var bumpVertexDeclaration: {
  30215. name: string;
  30216. shader: string;
  30217. };
  30218. }
  30219. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30220. /** @hidden */
  30221. export var bumpVertex: {
  30222. name: string;
  30223. shader: string;
  30224. };
  30225. }
  30226. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30227. /** @hidden */
  30228. export var fogVertex: {
  30229. name: string;
  30230. shader: string;
  30231. };
  30232. }
  30233. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30234. /** @hidden */
  30235. export var shadowsVertex: {
  30236. name: string;
  30237. shader: string;
  30238. };
  30239. }
  30240. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30241. /** @hidden */
  30242. export var pointCloudVertex: {
  30243. name: string;
  30244. shader: string;
  30245. };
  30246. }
  30247. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30248. /** @hidden */
  30249. export var logDepthVertex: {
  30250. name: string;
  30251. shader: string;
  30252. };
  30253. }
  30254. declare module "babylonjs/Shaders/default.vertex" {
  30255. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30256. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30257. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30258. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30259. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30260. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30261. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30262. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30263. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30264. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30265. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30266. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30267. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30268. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30269. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30270. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30271. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30272. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30273. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30274. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30275. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30276. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30277. /** @hidden */
  30278. export var defaultVertexShader: {
  30279. name: string;
  30280. shader: string;
  30281. };
  30282. }
  30283. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30284. import { Nullable } from "babylonjs/types";
  30285. import { Scene } from "babylonjs/scene";
  30286. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30287. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30288. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30289. /**
  30290. * @hidden
  30291. */
  30292. export interface IMaterialDetailMapDefines {
  30293. DETAIL: boolean;
  30294. DETAILDIRECTUV: number;
  30295. DETAIL_NORMALBLENDMETHOD: number;
  30296. /** @hidden */
  30297. _areTexturesDirty: boolean;
  30298. }
  30299. /**
  30300. * Define the code related to the detail map parameters of a material
  30301. *
  30302. * Inspired from:
  30303. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  30304. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30305. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30306. */
  30307. export class DetailMapConfiguration {
  30308. private _texture;
  30309. /**
  30310. * The detail texture of the material.
  30311. */
  30312. texture: Nullable<BaseTexture>;
  30313. /**
  30314. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30315. * Bigger values mean stronger blending
  30316. */
  30317. diffuseBlendLevel: number;
  30318. /**
  30319. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30320. * Bigger values mean stronger blending. Only used with PBR materials
  30321. */
  30322. roughnessBlendLevel: number;
  30323. /**
  30324. * Defines how strong the bump effect from the detail map is
  30325. * Bigger values mean stronger effect
  30326. */
  30327. bumpLevel: number;
  30328. private _normalBlendMethod;
  30329. /**
  30330. * The method used to blend the bump and detail normals together
  30331. */
  30332. normalBlendMethod: number;
  30333. private _isEnabled;
  30334. /**
  30335. * Enable or disable the detail map on this material
  30336. */
  30337. isEnabled: boolean;
  30338. /** @hidden */
  30339. private _internalMarkAllSubMeshesAsTexturesDirty;
  30340. /** @hidden */
  30341. _markAllSubMeshesAsTexturesDirty(): void;
  30342. /**
  30343. * Instantiate a new detail map
  30344. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30345. */
  30346. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30347. /**
  30348. * Gets whether the submesh is ready to be used or not.
  30349. * @param defines the list of "defines" to update.
  30350. * @param scene defines the scene the material belongs to.
  30351. * @returns - boolean indicating that the submesh is ready or not.
  30352. */
  30353. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30354. /**
  30355. * Update the defines for detail map usage
  30356. * @param defines the list of "defines" to update.
  30357. * @param scene defines the scene the material belongs to.
  30358. */
  30359. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30360. /**
  30361. * Binds the material data.
  30362. * @param uniformBuffer defines the Uniform buffer to fill in.
  30363. * @param scene defines the scene the material belongs to.
  30364. * @param isFrozen defines whether the material is frozen or not.
  30365. */
  30366. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30367. /**
  30368. * Checks to see if a texture is used in the material.
  30369. * @param texture - Base texture to use.
  30370. * @returns - Boolean specifying if a texture is used in the material.
  30371. */
  30372. hasTexture(texture: BaseTexture): boolean;
  30373. /**
  30374. * Returns an array of the actively used textures.
  30375. * @param activeTextures Array of BaseTextures
  30376. */
  30377. getActiveTextures(activeTextures: BaseTexture[]): void;
  30378. /**
  30379. * Returns the animatable textures.
  30380. * @param animatables Array of animatable textures.
  30381. */
  30382. getAnimatables(animatables: IAnimatable[]): void;
  30383. /**
  30384. * Disposes the resources of the material.
  30385. * @param forceDisposeTextures - Forces the disposal of all textures.
  30386. */
  30387. dispose(forceDisposeTextures?: boolean): void;
  30388. /**
  30389. * Get the current class name useful for serialization or dynamic coding.
  30390. * @returns "DetailMap"
  30391. */
  30392. getClassName(): string;
  30393. /**
  30394. * Add the required uniforms to the current list.
  30395. * @param uniforms defines the current uniform list.
  30396. */
  30397. static AddUniforms(uniforms: string[]): void;
  30398. /**
  30399. * Add the required samplers to the current list.
  30400. * @param samplers defines the current sampler list.
  30401. */
  30402. static AddSamplers(samplers: string[]): void;
  30403. /**
  30404. * Add the required uniforms to the current buffer.
  30405. * @param uniformBuffer defines the current uniform buffer.
  30406. */
  30407. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30408. /**
  30409. * Makes a duplicate of the current instance into another one.
  30410. * @param detailMap define the instance where to copy the info
  30411. */
  30412. copyTo(detailMap: DetailMapConfiguration): void;
  30413. /**
  30414. * Serializes this detail map instance
  30415. * @returns - An object with the serialized instance.
  30416. */
  30417. serialize(): any;
  30418. /**
  30419. * Parses a detail map setting from a serialized object.
  30420. * @param source - Serialized object.
  30421. * @param scene Defines the scene we are parsing for
  30422. * @param rootUrl Defines the rootUrl to load from
  30423. */
  30424. parse(source: any, scene: Scene, rootUrl: string): void;
  30425. }
  30426. }
  30427. declare module "babylonjs/Materials/standardMaterial" {
  30428. import { SmartArray } from "babylonjs/Misc/smartArray";
  30429. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30430. import { Nullable } from "babylonjs/types";
  30431. import { Scene } from "babylonjs/scene";
  30432. import { Matrix } from "babylonjs/Maths/math.vector";
  30433. import { Color3 } from "babylonjs/Maths/math.color";
  30434. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30436. import { Mesh } from "babylonjs/Meshes/mesh";
  30437. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30438. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30439. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30440. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30441. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30442. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30443. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30444. import "babylonjs/Shaders/default.fragment";
  30445. import "babylonjs/Shaders/default.vertex";
  30446. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30447. /** @hidden */
  30448. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30449. MAINUV1: boolean;
  30450. MAINUV2: boolean;
  30451. DIFFUSE: boolean;
  30452. DIFFUSEDIRECTUV: number;
  30453. DETAIL: boolean;
  30454. DETAILDIRECTUV: number;
  30455. DETAIL_NORMALBLENDMETHOD: number;
  30456. AMBIENT: boolean;
  30457. AMBIENTDIRECTUV: number;
  30458. OPACITY: boolean;
  30459. OPACITYDIRECTUV: number;
  30460. OPACITYRGB: boolean;
  30461. REFLECTION: boolean;
  30462. EMISSIVE: boolean;
  30463. EMISSIVEDIRECTUV: number;
  30464. SPECULAR: boolean;
  30465. SPECULARDIRECTUV: number;
  30466. BUMP: boolean;
  30467. BUMPDIRECTUV: number;
  30468. PARALLAX: boolean;
  30469. PARALLAXOCCLUSION: boolean;
  30470. SPECULAROVERALPHA: boolean;
  30471. CLIPPLANE: boolean;
  30472. CLIPPLANE2: boolean;
  30473. CLIPPLANE3: boolean;
  30474. CLIPPLANE4: boolean;
  30475. CLIPPLANE5: boolean;
  30476. CLIPPLANE6: boolean;
  30477. ALPHATEST: boolean;
  30478. DEPTHPREPASS: boolean;
  30479. ALPHAFROMDIFFUSE: boolean;
  30480. POINTSIZE: boolean;
  30481. FOG: boolean;
  30482. SPECULARTERM: boolean;
  30483. DIFFUSEFRESNEL: boolean;
  30484. OPACITYFRESNEL: boolean;
  30485. REFLECTIONFRESNEL: boolean;
  30486. REFRACTIONFRESNEL: boolean;
  30487. EMISSIVEFRESNEL: boolean;
  30488. FRESNEL: boolean;
  30489. NORMAL: boolean;
  30490. UV1: boolean;
  30491. UV2: boolean;
  30492. VERTEXCOLOR: boolean;
  30493. VERTEXALPHA: boolean;
  30494. NUM_BONE_INFLUENCERS: number;
  30495. BonesPerMesh: number;
  30496. BONETEXTURE: boolean;
  30497. INSTANCES: boolean;
  30498. THIN_INSTANCES: boolean;
  30499. GLOSSINESS: boolean;
  30500. ROUGHNESS: boolean;
  30501. EMISSIVEASILLUMINATION: boolean;
  30502. LINKEMISSIVEWITHDIFFUSE: boolean;
  30503. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30504. LIGHTMAP: boolean;
  30505. LIGHTMAPDIRECTUV: number;
  30506. OBJECTSPACE_NORMALMAP: boolean;
  30507. USELIGHTMAPASSHADOWMAP: boolean;
  30508. REFLECTIONMAP_3D: boolean;
  30509. REFLECTIONMAP_SPHERICAL: boolean;
  30510. REFLECTIONMAP_PLANAR: boolean;
  30511. REFLECTIONMAP_CUBIC: boolean;
  30512. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30513. REFLECTIONMAP_PROJECTION: boolean;
  30514. REFLECTIONMAP_SKYBOX: boolean;
  30515. REFLECTIONMAP_EXPLICIT: boolean;
  30516. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30517. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30518. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30519. INVERTCUBICMAP: boolean;
  30520. LOGARITHMICDEPTH: boolean;
  30521. REFRACTION: boolean;
  30522. REFRACTIONMAP_3D: boolean;
  30523. REFLECTIONOVERALPHA: boolean;
  30524. TWOSIDEDLIGHTING: boolean;
  30525. SHADOWFLOAT: boolean;
  30526. MORPHTARGETS: boolean;
  30527. MORPHTARGETS_NORMAL: boolean;
  30528. MORPHTARGETS_TANGENT: boolean;
  30529. MORPHTARGETS_UV: boolean;
  30530. NUM_MORPH_INFLUENCERS: number;
  30531. NONUNIFORMSCALING: boolean;
  30532. PREMULTIPLYALPHA: boolean;
  30533. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30534. ALPHABLEND: boolean;
  30535. RGBDLIGHTMAP: boolean;
  30536. RGBDREFLECTION: boolean;
  30537. RGBDREFRACTION: boolean;
  30538. IMAGEPROCESSING: boolean;
  30539. VIGNETTE: boolean;
  30540. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30541. VIGNETTEBLENDMODEOPAQUE: boolean;
  30542. TONEMAPPING: boolean;
  30543. TONEMAPPING_ACES: boolean;
  30544. CONTRAST: boolean;
  30545. COLORCURVES: boolean;
  30546. COLORGRADING: boolean;
  30547. COLORGRADING3D: boolean;
  30548. SAMPLER3DGREENDEPTH: boolean;
  30549. SAMPLER3DBGRMAP: boolean;
  30550. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30551. MULTIVIEW: boolean;
  30552. /**
  30553. * If the reflection texture on this material is in linear color space
  30554. * @hidden
  30555. */
  30556. IS_REFLECTION_LINEAR: boolean;
  30557. /**
  30558. * If the refraction texture on this material is in linear color space
  30559. * @hidden
  30560. */
  30561. IS_REFRACTION_LINEAR: boolean;
  30562. EXPOSURE: boolean;
  30563. constructor();
  30564. setReflectionMode(modeToEnable: string): void;
  30565. }
  30566. /**
  30567. * This is the default material used in Babylon. It is the best trade off between quality
  30568. * and performances.
  30569. * @see http://doc.babylonjs.com/babylon101/materials
  30570. */
  30571. export class StandardMaterial extends PushMaterial {
  30572. private _diffuseTexture;
  30573. /**
  30574. * The basic texture of the material as viewed under a light.
  30575. */
  30576. diffuseTexture: Nullable<BaseTexture>;
  30577. private _ambientTexture;
  30578. /**
  30579. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30580. */
  30581. ambientTexture: Nullable<BaseTexture>;
  30582. private _opacityTexture;
  30583. /**
  30584. * Define the transparency of the material from a texture.
  30585. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30586. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30587. */
  30588. opacityTexture: Nullable<BaseTexture>;
  30589. private _reflectionTexture;
  30590. /**
  30591. * Define the texture used to display the reflection.
  30592. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30593. */
  30594. reflectionTexture: Nullable<BaseTexture>;
  30595. private _emissiveTexture;
  30596. /**
  30597. * Define texture of the material as if self lit.
  30598. * This will be mixed in the final result even in the absence of light.
  30599. */
  30600. emissiveTexture: Nullable<BaseTexture>;
  30601. private _specularTexture;
  30602. /**
  30603. * Define how the color and intensity of the highlight given by the light in the material.
  30604. */
  30605. specularTexture: Nullable<BaseTexture>;
  30606. private _bumpTexture;
  30607. /**
  30608. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30609. * 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.
  30610. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  30611. */
  30612. bumpTexture: Nullable<BaseTexture>;
  30613. private _lightmapTexture;
  30614. /**
  30615. * Complex lighting can be computationally expensive to compute at runtime.
  30616. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30617. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  30618. */
  30619. lightmapTexture: Nullable<BaseTexture>;
  30620. private _refractionTexture;
  30621. /**
  30622. * Define the texture used to display the refraction.
  30623. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30624. */
  30625. refractionTexture: Nullable<BaseTexture>;
  30626. /**
  30627. * The color of the material lit by the environmental background lighting.
  30628. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30629. */
  30630. ambientColor: Color3;
  30631. /**
  30632. * The basic color of the material as viewed under a light.
  30633. */
  30634. diffuseColor: Color3;
  30635. /**
  30636. * Define how the color and intensity of the highlight given by the light in the material.
  30637. */
  30638. specularColor: Color3;
  30639. /**
  30640. * Define the color of the material as if self lit.
  30641. * This will be mixed in the final result even in the absence of light.
  30642. */
  30643. emissiveColor: Color3;
  30644. /**
  30645. * Defines how sharp are the highlights in the material.
  30646. * The bigger the value the sharper giving a more glossy feeling to the result.
  30647. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30648. */
  30649. specularPower: number;
  30650. private _useAlphaFromDiffuseTexture;
  30651. /**
  30652. * Does the transparency come from the diffuse texture alpha channel.
  30653. */
  30654. useAlphaFromDiffuseTexture: boolean;
  30655. private _useEmissiveAsIllumination;
  30656. /**
  30657. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30658. */
  30659. useEmissiveAsIllumination: boolean;
  30660. private _linkEmissiveWithDiffuse;
  30661. /**
  30662. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30663. * the emissive level when the final color is close to one.
  30664. */
  30665. linkEmissiveWithDiffuse: boolean;
  30666. private _useSpecularOverAlpha;
  30667. /**
  30668. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30669. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30670. */
  30671. useSpecularOverAlpha: boolean;
  30672. private _useReflectionOverAlpha;
  30673. /**
  30674. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30675. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30676. */
  30677. useReflectionOverAlpha: boolean;
  30678. private _disableLighting;
  30679. /**
  30680. * Does lights from the scene impacts this material.
  30681. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30682. */
  30683. disableLighting: boolean;
  30684. private _useObjectSpaceNormalMap;
  30685. /**
  30686. * Allows using an object space normal map (instead of tangent space).
  30687. */
  30688. useObjectSpaceNormalMap: boolean;
  30689. private _useParallax;
  30690. /**
  30691. * Is parallax enabled or not.
  30692. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30693. */
  30694. useParallax: boolean;
  30695. private _useParallaxOcclusion;
  30696. /**
  30697. * Is parallax occlusion enabled or not.
  30698. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30699. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  30700. */
  30701. useParallaxOcclusion: boolean;
  30702. /**
  30703. * 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.
  30704. */
  30705. parallaxScaleBias: number;
  30706. private _roughness;
  30707. /**
  30708. * Helps to define how blurry the reflections should appears in the material.
  30709. */
  30710. roughness: number;
  30711. /**
  30712. * In case of refraction, define the value of the index of refraction.
  30713. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30714. */
  30715. indexOfRefraction: number;
  30716. /**
  30717. * Invert the refraction texture alongside the y axis.
  30718. * It can be useful with procedural textures or probe for instance.
  30719. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30720. */
  30721. invertRefractionY: boolean;
  30722. /**
  30723. * Defines the alpha limits in alpha test mode.
  30724. */
  30725. alphaCutOff: number;
  30726. private _useLightmapAsShadowmap;
  30727. /**
  30728. * In case of light mapping, define whether the map contains light or shadow informations.
  30729. */
  30730. useLightmapAsShadowmap: boolean;
  30731. private _diffuseFresnelParameters;
  30732. /**
  30733. * Define the diffuse fresnel parameters of the material.
  30734. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30735. */
  30736. diffuseFresnelParameters: FresnelParameters;
  30737. private _opacityFresnelParameters;
  30738. /**
  30739. * Define the opacity fresnel parameters of the material.
  30740. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30741. */
  30742. opacityFresnelParameters: FresnelParameters;
  30743. private _reflectionFresnelParameters;
  30744. /**
  30745. * Define the reflection fresnel parameters of the material.
  30746. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30747. */
  30748. reflectionFresnelParameters: FresnelParameters;
  30749. private _refractionFresnelParameters;
  30750. /**
  30751. * Define the refraction fresnel parameters of the material.
  30752. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30753. */
  30754. refractionFresnelParameters: FresnelParameters;
  30755. private _emissiveFresnelParameters;
  30756. /**
  30757. * Define the emissive fresnel parameters of the material.
  30758. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30759. */
  30760. emissiveFresnelParameters: FresnelParameters;
  30761. private _useReflectionFresnelFromSpecular;
  30762. /**
  30763. * If true automatically deducts the fresnels values from the material specularity.
  30764. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30765. */
  30766. useReflectionFresnelFromSpecular: boolean;
  30767. private _useGlossinessFromSpecularMapAlpha;
  30768. /**
  30769. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30770. */
  30771. useGlossinessFromSpecularMapAlpha: boolean;
  30772. private _maxSimultaneousLights;
  30773. /**
  30774. * Defines the maximum number of lights that can be used in the material
  30775. */
  30776. maxSimultaneousLights: number;
  30777. private _invertNormalMapX;
  30778. /**
  30779. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30780. */
  30781. invertNormalMapX: boolean;
  30782. private _invertNormalMapY;
  30783. /**
  30784. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30785. */
  30786. invertNormalMapY: boolean;
  30787. private _twoSidedLighting;
  30788. /**
  30789. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30790. */
  30791. twoSidedLighting: boolean;
  30792. /**
  30793. * Default configuration related to image processing available in the standard Material.
  30794. */
  30795. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30796. /**
  30797. * Gets the image processing configuration used either in this material.
  30798. */
  30799. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30800. /**
  30801. * Sets the Default image processing configuration used either in the this material.
  30802. *
  30803. * If sets to null, the scene one is in use.
  30804. */
  30805. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30806. /**
  30807. * Keep track of the image processing observer to allow dispose and replace.
  30808. */
  30809. private _imageProcessingObserver;
  30810. /**
  30811. * Attaches a new image processing configuration to the Standard Material.
  30812. * @param configuration
  30813. */
  30814. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30815. /**
  30816. * Gets wether the color curves effect is enabled.
  30817. */
  30818. get cameraColorCurvesEnabled(): boolean;
  30819. /**
  30820. * Sets wether the color curves effect is enabled.
  30821. */
  30822. set cameraColorCurvesEnabled(value: boolean);
  30823. /**
  30824. * Gets wether the color grading effect is enabled.
  30825. */
  30826. get cameraColorGradingEnabled(): boolean;
  30827. /**
  30828. * Gets wether the color grading effect is enabled.
  30829. */
  30830. set cameraColorGradingEnabled(value: boolean);
  30831. /**
  30832. * Gets wether tonemapping is enabled or not.
  30833. */
  30834. get cameraToneMappingEnabled(): boolean;
  30835. /**
  30836. * Sets wether tonemapping is enabled or not
  30837. */
  30838. set cameraToneMappingEnabled(value: boolean);
  30839. /**
  30840. * The camera exposure used on this material.
  30841. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30842. * This corresponds to a photographic exposure.
  30843. */
  30844. get cameraExposure(): number;
  30845. /**
  30846. * The camera exposure used on this material.
  30847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30848. * This corresponds to a photographic exposure.
  30849. */
  30850. set cameraExposure(value: number);
  30851. /**
  30852. * Gets The camera contrast used on this material.
  30853. */
  30854. get cameraContrast(): number;
  30855. /**
  30856. * Sets The camera contrast used on this material.
  30857. */
  30858. set cameraContrast(value: number);
  30859. /**
  30860. * Gets the Color Grading 2D Lookup Texture.
  30861. */
  30862. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30863. /**
  30864. * Sets the Color Grading 2D Lookup Texture.
  30865. */
  30866. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30867. /**
  30868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30870. * 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;
  30871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30872. */
  30873. get cameraColorCurves(): Nullable<ColorCurves>;
  30874. /**
  30875. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30876. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30877. * 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;
  30878. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30879. */
  30880. set cameraColorCurves(value: Nullable<ColorCurves>);
  30881. /**
  30882. * Defines the detail map parameters for the material.
  30883. */
  30884. readonly detailMap: DetailMapConfiguration;
  30885. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30886. protected _worldViewProjectionMatrix: Matrix;
  30887. protected _globalAmbientColor: Color3;
  30888. protected _useLogarithmicDepth: boolean;
  30889. protected _rebuildInParallel: boolean;
  30890. /**
  30891. * Instantiates a new standard material.
  30892. * This is the default material used in Babylon. It is the best trade off between quality
  30893. * and performances.
  30894. * @see http://doc.babylonjs.com/babylon101/materials
  30895. * @param name Define the name of the material in the scene
  30896. * @param scene Define the scene the material belong to
  30897. */
  30898. constructor(name: string, scene: Scene);
  30899. /**
  30900. * Gets a boolean indicating that current material needs to register RTT
  30901. */
  30902. get hasRenderTargetTextures(): boolean;
  30903. /**
  30904. * Gets the current class name of the material e.g. "StandardMaterial"
  30905. * Mainly use in serialization.
  30906. * @returns the class name
  30907. */
  30908. getClassName(): string;
  30909. /**
  30910. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30911. * You can try switching to logarithmic depth.
  30912. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30913. */
  30914. get useLogarithmicDepth(): boolean;
  30915. set useLogarithmicDepth(value: boolean);
  30916. /**
  30917. * Specifies if the material will require alpha blending
  30918. * @returns a boolean specifying if alpha blending is needed
  30919. */
  30920. needAlphaBlending(): boolean;
  30921. /**
  30922. * Specifies if this material should be rendered in alpha test mode
  30923. * @returns a boolean specifying if an alpha test is needed.
  30924. */
  30925. needAlphaTesting(): boolean;
  30926. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30927. /**
  30928. * Get the texture used for alpha test purpose.
  30929. * @returns the diffuse texture in case of the standard material.
  30930. */
  30931. getAlphaTestTexture(): Nullable<BaseTexture>;
  30932. /**
  30933. * Get if the submesh is ready to be used and all its information available.
  30934. * Child classes can use it to update shaders
  30935. * @param mesh defines the mesh to check
  30936. * @param subMesh defines which submesh to check
  30937. * @param useInstances specifies that instances should be used
  30938. * @returns a boolean indicating that the submesh is ready or not
  30939. */
  30940. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30941. /**
  30942. * Builds the material UBO layouts.
  30943. * Used internally during the effect preparation.
  30944. */
  30945. buildUniformLayout(): void;
  30946. /**
  30947. * Unbinds the material from the mesh
  30948. */
  30949. unbind(): void;
  30950. /**
  30951. * Binds the submesh to this material by preparing the effect and shader to draw
  30952. * @param world defines the world transformation matrix
  30953. * @param mesh defines the mesh containing the submesh
  30954. * @param subMesh defines the submesh to bind the material to
  30955. */
  30956. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30957. /**
  30958. * Get the list of animatables in the material.
  30959. * @returns the list of animatables object used in the material
  30960. */
  30961. getAnimatables(): IAnimatable[];
  30962. /**
  30963. * Gets the active textures from the material
  30964. * @returns an array of textures
  30965. */
  30966. getActiveTextures(): BaseTexture[];
  30967. /**
  30968. * Specifies if the material uses a texture
  30969. * @param texture defines the texture to check against the material
  30970. * @returns a boolean specifying if the material uses the texture
  30971. */
  30972. hasTexture(texture: BaseTexture): boolean;
  30973. /**
  30974. * Disposes the material
  30975. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30976. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30977. */
  30978. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30979. /**
  30980. * Makes a duplicate of the material, and gives it a new name
  30981. * @param name defines the new name for the duplicated material
  30982. * @returns the cloned material
  30983. */
  30984. clone(name: string): StandardMaterial;
  30985. /**
  30986. * Serializes this material in a JSON representation
  30987. * @returns the serialized material object
  30988. */
  30989. serialize(): any;
  30990. /**
  30991. * Creates a standard material from parsed material data
  30992. * @param source defines the JSON representation of the material
  30993. * @param scene defines the hosting scene
  30994. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30995. * @returns a new standard material
  30996. */
  30997. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30998. /**
  30999. * Are diffuse textures enabled in the application.
  31000. */
  31001. static get DiffuseTextureEnabled(): boolean;
  31002. static set DiffuseTextureEnabled(value: boolean);
  31003. /**
  31004. * Are detail textures enabled in the application.
  31005. */
  31006. static get DetailTextureEnabled(): boolean;
  31007. static set DetailTextureEnabled(value: boolean);
  31008. /**
  31009. * Are ambient textures enabled in the application.
  31010. */
  31011. static get AmbientTextureEnabled(): boolean;
  31012. static set AmbientTextureEnabled(value: boolean);
  31013. /**
  31014. * Are opacity textures enabled in the application.
  31015. */
  31016. static get OpacityTextureEnabled(): boolean;
  31017. static set OpacityTextureEnabled(value: boolean);
  31018. /**
  31019. * Are reflection textures enabled in the application.
  31020. */
  31021. static get ReflectionTextureEnabled(): boolean;
  31022. static set ReflectionTextureEnabled(value: boolean);
  31023. /**
  31024. * Are emissive textures enabled in the application.
  31025. */
  31026. static get EmissiveTextureEnabled(): boolean;
  31027. static set EmissiveTextureEnabled(value: boolean);
  31028. /**
  31029. * Are specular textures enabled in the application.
  31030. */
  31031. static get SpecularTextureEnabled(): boolean;
  31032. static set SpecularTextureEnabled(value: boolean);
  31033. /**
  31034. * Are bump textures enabled in the application.
  31035. */
  31036. static get BumpTextureEnabled(): boolean;
  31037. static set BumpTextureEnabled(value: boolean);
  31038. /**
  31039. * Are lightmap textures enabled in the application.
  31040. */
  31041. static get LightmapTextureEnabled(): boolean;
  31042. static set LightmapTextureEnabled(value: boolean);
  31043. /**
  31044. * Are refraction textures enabled in the application.
  31045. */
  31046. static get RefractionTextureEnabled(): boolean;
  31047. static set RefractionTextureEnabled(value: boolean);
  31048. /**
  31049. * Are color grading textures enabled in the application.
  31050. */
  31051. static get ColorGradingTextureEnabled(): boolean;
  31052. static set ColorGradingTextureEnabled(value: boolean);
  31053. /**
  31054. * Are fresnels enabled in the application.
  31055. */
  31056. static get FresnelEnabled(): boolean;
  31057. static set FresnelEnabled(value: boolean);
  31058. }
  31059. }
  31060. declare module "babylonjs/Particles/solidParticleSystem" {
  31061. import { Nullable } from "babylonjs/types";
  31062. import { Mesh } from "babylonjs/Meshes/mesh";
  31063. import { Scene, IDisposable } from "babylonjs/scene";
  31064. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31065. import { Material } from "babylonjs/Materials/material";
  31066. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31067. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31068. /**
  31069. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31070. *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.
  31071. * The SPS is also a particle system. It provides some methods to manage the particles.
  31072. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31073. *
  31074. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  31075. */
  31076. export class SolidParticleSystem implements IDisposable {
  31077. /**
  31078. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31079. * Example : var p = SPS.particles[i];
  31080. */
  31081. particles: SolidParticle[];
  31082. /**
  31083. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31084. */
  31085. nbParticles: number;
  31086. /**
  31087. * If the particles must ever face the camera (default false). Useful for planar particles.
  31088. */
  31089. billboard: boolean;
  31090. /**
  31091. * Recompute normals when adding a shape
  31092. */
  31093. recomputeNormals: boolean;
  31094. /**
  31095. * This a counter ofr your own usage. It's not set by any SPS functions.
  31096. */
  31097. counter: number;
  31098. /**
  31099. * The SPS name. This name is also given to the underlying mesh.
  31100. */
  31101. name: string;
  31102. /**
  31103. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31104. */
  31105. mesh: Mesh;
  31106. /**
  31107. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31108. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31109. */
  31110. vars: any;
  31111. /**
  31112. * This array is populated when the SPS is set as 'pickable'.
  31113. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31114. * Each element of this array is an object `{idx: int, faceId: int}`.
  31115. * `idx` is the picked particle index in the `SPS.particles` array
  31116. * `faceId` is the picked face index counted within this particle.
  31117. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31118. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31119. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31120. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31121. */
  31122. pickedParticles: {
  31123. idx: number;
  31124. faceId: number;
  31125. }[];
  31126. /**
  31127. * This array is populated when the SPS is set as 'pickable'
  31128. * Each key of this array is a submesh index.
  31129. * Each element of this array is a second array defined like this :
  31130. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31131. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31132. * `idx` is the picked particle index in the `SPS.particles` array
  31133. * `faceId` is the picked face index counted within this particle.
  31134. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31135. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31136. */
  31137. pickedBySubMesh: {
  31138. idx: number;
  31139. faceId: number;
  31140. }[][];
  31141. /**
  31142. * This array is populated when `enableDepthSort` is set to true.
  31143. * Each element of this array is an instance of the class DepthSortedParticle.
  31144. */
  31145. depthSortedParticles: DepthSortedParticle[];
  31146. /**
  31147. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31148. * @hidden
  31149. */
  31150. _bSphereOnly: boolean;
  31151. /**
  31152. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31153. * @hidden
  31154. */
  31155. _bSphereRadiusFactor: number;
  31156. private _scene;
  31157. private _positions;
  31158. private _indices;
  31159. private _normals;
  31160. private _colors;
  31161. private _uvs;
  31162. private _indices32;
  31163. private _positions32;
  31164. private _normals32;
  31165. private _fixedNormal32;
  31166. private _colors32;
  31167. private _uvs32;
  31168. private _index;
  31169. private _updatable;
  31170. private _pickable;
  31171. private _isVisibilityBoxLocked;
  31172. private _alwaysVisible;
  31173. private _depthSort;
  31174. private _expandable;
  31175. private _shapeCounter;
  31176. private _copy;
  31177. private _color;
  31178. private _computeParticleColor;
  31179. private _computeParticleTexture;
  31180. private _computeParticleRotation;
  31181. private _computeParticleVertex;
  31182. private _computeBoundingBox;
  31183. private _depthSortParticles;
  31184. private _camera;
  31185. private _mustUnrotateFixedNormals;
  31186. private _particlesIntersect;
  31187. private _needs32Bits;
  31188. private _isNotBuilt;
  31189. private _lastParticleId;
  31190. private _idxOfId;
  31191. private _multimaterialEnabled;
  31192. private _useModelMaterial;
  31193. private _indicesByMaterial;
  31194. private _materialIndexes;
  31195. private _depthSortFunction;
  31196. private _materialSortFunction;
  31197. private _materials;
  31198. private _multimaterial;
  31199. private _materialIndexesById;
  31200. private _defaultMaterial;
  31201. private _autoUpdateSubMeshes;
  31202. private _tmpVertex;
  31203. /**
  31204. * Creates a SPS (Solid Particle System) object.
  31205. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31206. * @param scene (Scene) is the scene in which the SPS is added.
  31207. * @param options defines the options of the sps e.g.
  31208. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31209. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31210. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31211. * * 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.
  31212. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31213. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31214. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31215. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31216. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31217. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31218. */
  31219. constructor(name: string, scene: Scene, options?: {
  31220. updatable?: boolean;
  31221. isPickable?: boolean;
  31222. enableDepthSort?: boolean;
  31223. particleIntersection?: boolean;
  31224. boundingSphereOnly?: boolean;
  31225. bSphereRadiusFactor?: number;
  31226. expandable?: boolean;
  31227. useModelMaterial?: boolean;
  31228. enableMultiMaterial?: boolean;
  31229. });
  31230. /**
  31231. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31232. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31233. * @returns the created mesh
  31234. */
  31235. buildMesh(): Mesh;
  31236. /**
  31237. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31238. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31239. * Thus the particles generated from `digest()` have their property `position` set yet.
  31240. * @param mesh ( Mesh ) is the mesh to be digested
  31241. * @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
  31242. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31243. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31244. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31245. * @returns the current SPS
  31246. */
  31247. digest(mesh: Mesh, options?: {
  31248. facetNb?: number;
  31249. number?: number;
  31250. delta?: number;
  31251. storage?: [];
  31252. }): SolidParticleSystem;
  31253. /**
  31254. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31255. * @hidden
  31256. */
  31257. private _unrotateFixedNormals;
  31258. /**
  31259. * Resets the temporary working copy particle
  31260. * @hidden
  31261. */
  31262. private _resetCopy;
  31263. /**
  31264. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31265. * @param p the current index in the positions array to be updated
  31266. * @param ind the current index in the indices array
  31267. * @param shape a Vector3 array, the shape geometry
  31268. * @param positions the positions array to be updated
  31269. * @param meshInd the shape indices array
  31270. * @param indices the indices array to be updated
  31271. * @param meshUV the shape uv array
  31272. * @param uvs the uv array to be updated
  31273. * @param meshCol the shape color array
  31274. * @param colors the color array to be updated
  31275. * @param meshNor the shape normals array
  31276. * @param normals the normals array to be updated
  31277. * @param idx the particle index
  31278. * @param idxInShape the particle index in its shape
  31279. * @param options the addShape() method passed options
  31280. * @model the particle model
  31281. * @hidden
  31282. */
  31283. private _meshBuilder;
  31284. /**
  31285. * Returns a shape Vector3 array from positions float array
  31286. * @param positions float array
  31287. * @returns a vector3 array
  31288. * @hidden
  31289. */
  31290. private _posToShape;
  31291. /**
  31292. * Returns a shapeUV array from a float uvs (array deep copy)
  31293. * @param uvs as a float array
  31294. * @returns a shapeUV array
  31295. * @hidden
  31296. */
  31297. private _uvsToShapeUV;
  31298. /**
  31299. * Adds a new particle object in the particles array
  31300. * @param idx particle index in particles array
  31301. * @param id particle id
  31302. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31303. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31304. * @param model particle ModelShape object
  31305. * @param shapeId model shape identifier
  31306. * @param idxInShape index of the particle in the current model
  31307. * @param bInfo model bounding info object
  31308. * @param storage target storage array, if any
  31309. * @hidden
  31310. */
  31311. private _addParticle;
  31312. /**
  31313. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31314. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31315. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31316. * @param nb (positive integer) the number of particles to be created from this model
  31317. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31318. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31319. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31320. * @returns the number of shapes in the system
  31321. */
  31322. addShape(mesh: Mesh, nb: number, options?: {
  31323. positionFunction?: any;
  31324. vertexFunction?: any;
  31325. storage?: [];
  31326. }): number;
  31327. /**
  31328. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31329. * @hidden
  31330. */
  31331. private _rebuildParticle;
  31332. /**
  31333. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31334. * @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.
  31335. * @returns the SPS.
  31336. */
  31337. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31338. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31339. * Returns an array with the removed particles.
  31340. * 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.
  31341. * The SPS can't be empty so at least one particle needs to remain in place.
  31342. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31343. * @param start index of the first particle to remove
  31344. * @param end index of the last particle to remove (included)
  31345. * @returns an array populated with the removed particles
  31346. */
  31347. removeParticles(start: number, end: number): SolidParticle[];
  31348. /**
  31349. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31350. * @param solidParticleArray an array populated with Solid Particles objects
  31351. * @returns the SPS
  31352. */
  31353. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31354. /**
  31355. * Creates a new particle and modifies the SPS mesh geometry :
  31356. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31357. * - calls _addParticle() to populate the particle array
  31358. * factorized code from addShape() and insertParticlesFromArray()
  31359. * @param idx particle index in the particles array
  31360. * @param i particle index in its shape
  31361. * @param modelShape particle ModelShape object
  31362. * @param shape shape vertex array
  31363. * @param meshInd shape indices array
  31364. * @param meshUV shape uv array
  31365. * @param meshCol shape color array
  31366. * @param meshNor shape normals array
  31367. * @param bbInfo shape bounding info
  31368. * @param storage target particle storage
  31369. * @options addShape() passed options
  31370. * @hidden
  31371. */
  31372. private _insertNewParticle;
  31373. /**
  31374. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31375. * This method calls `updateParticle()` for each particle of the SPS.
  31376. * For an animated SPS, it is usually called within the render loop.
  31377. * 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.
  31378. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31379. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31380. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31381. * @returns the SPS.
  31382. */
  31383. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31384. /**
  31385. * Disposes the SPS.
  31386. */
  31387. dispose(): void;
  31388. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31389. * idx is the particle index in the SPS
  31390. * faceId is the picked face index counted within this particle.
  31391. * Returns null if the pickInfo can't identify a picked particle.
  31392. * @param pickingInfo (PickingInfo object)
  31393. * @returns {idx: number, faceId: number} or null
  31394. */
  31395. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31396. idx: number;
  31397. faceId: number;
  31398. }>;
  31399. /**
  31400. * Returns a SolidParticle object from its identifier : particle.id
  31401. * @param id (integer) the particle Id
  31402. * @returns the searched particle or null if not found in the SPS.
  31403. */
  31404. getParticleById(id: number): Nullable<SolidParticle>;
  31405. /**
  31406. * Returns a new array populated with the particles having the passed shapeId.
  31407. * @param shapeId (integer) the shape identifier
  31408. * @returns a new solid particle array
  31409. */
  31410. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31411. /**
  31412. * Populates the passed array "ref" with the particles having the passed shapeId.
  31413. * @param shapeId the shape identifier
  31414. * @returns the SPS
  31415. * @param ref
  31416. */
  31417. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31418. /**
  31419. * Computes the required SubMeshes according the materials assigned to the particles.
  31420. * @returns the solid particle system.
  31421. * Does nothing if called before the SPS mesh is built.
  31422. */
  31423. computeSubMeshes(): SolidParticleSystem;
  31424. /**
  31425. * Sorts the solid particles by material when MultiMaterial is enabled.
  31426. * Updates the indices32 array.
  31427. * Updates the indicesByMaterial array.
  31428. * Updates the mesh indices array.
  31429. * @returns the SPS
  31430. * @hidden
  31431. */
  31432. private _sortParticlesByMaterial;
  31433. /**
  31434. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31435. * @hidden
  31436. */
  31437. private _setMaterialIndexesById;
  31438. /**
  31439. * Returns an array with unique values of Materials from the passed array
  31440. * @param array the material array to be checked and filtered
  31441. * @hidden
  31442. */
  31443. private _filterUniqueMaterialId;
  31444. /**
  31445. * Sets a new Standard Material as _defaultMaterial if not already set.
  31446. * @hidden
  31447. */
  31448. private _setDefaultMaterial;
  31449. /**
  31450. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31451. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31452. * @returns the SPS.
  31453. */
  31454. refreshVisibleSize(): SolidParticleSystem;
  31455. /**
  31456. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31457. * @param size the size (float) of the visibility box
  31458. * note : this doesn't lock the SPS mesh bounding box.
  31459. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31460. */
  31461. setVisibilityBox(size: number): void;
  31462. /**
  31463. * Gets whether the SPS as always visible or not
  31464. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31465. */
  31466. get isAlwaysVisible(): boolean;
  31467. /**
  31468. * Sets the SPS as always visible or not
  31469. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31470. */
  31471. set isAlwaysVisible(val: boolean);
  31472. /**
  31473. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31474. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31475. */
  31476. set isVisibilityBoxLocked(val: boolean);
  31477. /**
  31478. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31479. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31480. */
  31481. get isVisibilityBoxLocked(): boolean;
  31482. /**
  31483. * Tells to `setParticles()` to compute the particle rotations or not.
  31484. * Default value : true. The SPS is faster when it's set to false.
  31485. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31486. */
  31487. set computeParticleRotation(val: boolean);
  31488. /**
  31489. * Tells to `setParticles()` to compute the particle colors or not.
  31490. * Default value : true. The SPS is faster when it's set to false.
  31491. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31492. */
  31493. set computeParticleColor(val: boolean);
  31494. set computeParticleTexture(val: boolean);
  31495. /**
  31496. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31497. * Default value : false. The SPS is faster when it's set to false.
  31498. * Note : the particle custom vertex positions aren't stored values.
  31499. */
  31500. set computeParticleVertex(val: boolean);
  31501. /**
  31502. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31503. */
  31504. set computeBoundingBox(val: boolean);
  31505. /**
  31506. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31507. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31508. * Default : `true`
  31509. */
  31510. set depthSortParticles(val: boolean);
  31511. /**
  31512. * Gets if `setParticles()` computes the particle rotations or not.
  31513. * Default value : true. The SPS is faster when it's set to false.
  31514. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31515. */
  31516. get computeParticleRotation(): boolean;
  31517. /**
  31518. * Gets if `setParticles()` computes the particle colors or not.
  31519. * Default value : true. The SPS is faster when it's set to false.
  31520. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31521. */
  31522. get computeParticleColor(): boolean;
  31523. /**
  31524. * Gets if `setParticles()` computes the particle textures or not.
  31525. * Default value : true. The SPS is faster when it's set to false.
  31526. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31527. */
  31528. get computeParticleTexture(): boolean;
  31529. /**
  31530. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31531. * Default value : false. The SPS is faster when it's set to false.
  31532. * Note : the particle custom vertex positions aren't stored values.
  31533. */
  31534. get computeParticleVertex(): boolean;
  31535. /**
  31536. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31537. */
  31538. get computeBoundingBox(): boolean;
  31539. /**
  31540. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31541. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31542. * Default : `true`
  31543. */
  31544. get depthSortParticles(): boolean;
  31545. /**
  31546. * Gets if the SPS is created as expandable at construction time.
  31547. * Default : `false`
  31548. */
  31549. get expandable(): boolean;
  31550. /**
  31551. * Gets if the SPS supports the Multi Materials
  31552. */
  31553. get multimaterialEnabled(): boolean;
  31554. /**
  31555. * Gets if the SPS uses the model materials for its own multimaterial.
  31556. */
  31557. get useModelMaterial(): boolean;
  31558. /**
  31559. * The SPS used material array.
  31560. */
  31561. get materials(): Material[];
  31562. /**
  31563. * Sets the SPS MultiMaterial from the passed materials.
  31564. * Note : the passed array is internally copied and not used then by reference.
  31565. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31566. */
  31567. setMultiMaterial(materials: Material[]): void;
  31568. /**
  31569. * The SPS computed multimaterial object
  31570. */
  31571. get multimaterial(): MultiMaterial;
  31572. set multimaterial(mm: MultiMaterial);
  31573. /**
  31574. * If the subMeshes must be updated on the next call to setParticles()
  31575. */
  31576. get autoUpdateSubMeshes(): boolean;
  31577. set autoUpdateSubMeshes(val: boolean);
  31578. /**
  31579. * This function does nothing. It may be overwritten to set all the particle first values.
  31580. * The SPS doesn't call this function, you may have to call it by your own.
  31581. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31582. */
  31583. initParticles(): void;
  31584. /**
  31585. * This function does nothing. It may be overwritten to recycle a particle.
  31586. * The SPS doesn't call this function, you may have to call it by your own.
  31587. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31588. * @param particle The particle to recycle
  31589. * @returns the recycled particle
  31590. */
  31591. recycleParticle(particle: SolidParticle): SolidParticle;
  31592. /**
  31593. * Updates a particle : this function should be overwritten by the user.
  31594. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31595. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31596. * @example : just set a particle position or velocity and recycle conditions
  31597. * @param particle The particle to update
  31598. * @returns the updated particle
  31599. */
  31600. updateParticle(particle: SolidParticle): SolidParticle;
  31601. /**
  31602. * Updates a vertex of a particle : it can be overwritten by the user.
  31603. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31604. * @param particle the current particle
  31605. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31606. * @param pt the index of the current vertex in the particle shape
  31607. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31608. * @example : just set a vertex particle position or color
  31609. * @returns the sps
  31610. */
  31611. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31612. /**
  31613. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31614. * This does nothing and may be overwritten by the user.
  31615. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31616. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31617. * @param update the boolean update value actually passed to setParticles()
  31618. */
  31619. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31620. /**
  31621. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31622. * This will be passed three parameters.
  31623. * This does nothing and may be overwritten by the user.
  31624. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31625. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31626. * @param update the boolean update value actually passed to setParticles()
  31627. */
  31628. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31629. }
  31630. }
  31631. declare module "babylonjs/Particles/solidParticle" {
  31632. import { Nullable } from "babylonjs/types";
  31633. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31634. import { Color4 } from "babylonjs/Maths/math.color";
  31635. import { Mesh } from "babylonjs/Meshes/mesh";
  31636. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31637. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31638. import { Plane } from "babylonjs/Maths/math.plane";
  31639. import { Material } from "babylonjs/Materials/material";
  31640. /**
  31641. * Represents one particle of a solid particle system.
  31642. */
  31643. export class SolidParticle {
  31644. /**
  31645. * particle global index
  31646. */
  31647. idx: number;
  31648. /**
  31649. * particle identifier
  31650. */
  31651. id: number;
  31652. /**
  31653. * The color of the particle
  31654. */
  31655. color: Nullable<Color4>;
  31656. /**
  31657. * The world space position of the particle.
  31658. */
  31659. position: Vector3;
  31660. /**
  31661. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31662. */
  31663. rotation: Vector3;
  31664. /**
  31665. * The world space rotation quaternion of the particle.
  31666. */
  31667. rotationQuaternion: Nullable<Quaternion>;
  31668. /**
  31669. * The scaling of the particle.
  31670. */
  31671. scaling: Vector3;
  31672. /**
  31673. * The uvs of the particle.
  31674. */
  31675. uvs: Vector4;
  31676. /**
  31677. * The current speed of the particle.
  31678. */
  31679. velocity: Vector3;
  31680. /**
  31681. * The pivot point in the particle local space.
  31682. */
  31683. pivot: Vector3;
  31684. /**
  31685. * Must the particle be translated from its pivot point in its local space ?
  31686. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31687. * Default : false
  31688. */
  31689. translateFromPivot: boolean;
  31690. /**
  31691. * Is the particle active or not ?
  31692. */
  31693. alive: boolean;
  31694. /**
  31695. * Is the particle visible or not ?
  31696. */
  31697. isVisible: boolean;
  31698. /**
  31699. * Index of this particle in the global "positions" array (Internal use)
  31700. * @hidden
  31701. */
  31702. _pos: number;
  31703. /**
  31704. * @hidden Index of this particle in the global "indices" array (Internal use)
  31705. */
  31706. _ind: number;
  31707. /**
  31708. * @hidden ModelShape of this particle (Internal use)
  31709. */
  31710. _model: ModelShape;
  31711. /**
  31712. * ModelShape id of this particle
  31713. */
  31714. shapeId: number;
  31715. /**
  31716. * Index of the particle in its shape id
  31717. */
  31718. idxInShape: number;
  31719. /**
  31720. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31721. */
  31722. _modelBoundingInfo: BoundingInfo;
  31723. /**
  31724. * @hidden Particle BoundingInfo object (Internal use)
  31725. */
  31726. _boundingInfo: BoundingInfo;
  31727. /**
  31728. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31729. */
  31730. _sps: SolidParticleSystem;
  31731. /**
  31732. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31733. */
  31734. _stillInvisible: boolean;
  31735. /**
  31736. * @hidden Last computed particle rotation matrix
  31737. */
  31738. _rotationMatrix: number[];
  31739. /**
  31740. * Parent particle Id, if any.
  31741. * Default null.
  31742. */
  31743. parentId: Nullable<number>;
  31744. /**
  31745. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31746. */
  31747. materialIndex: Nullable<number>;
  31748. /**
  31749. * Custom object or properties.
  31750. */
  31751. props: Nullable<any>;
  31752. /**
  31753. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31754. * The possible values are :
  31755. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31756. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31757. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31758. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31759. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31760. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31761. * */
  31762. cullingStrategy: number;
  31763. /**
  31764. * @hidden Internal global position in the SPS.
  31765. */
  31766. _globalPosition: Vector3;
  31767. /**
  31768. * Creates a Solid Particle object.
  31769. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31770. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31771. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31772. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31773. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31774. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31775. * @param shapeId (integer) is the model shape identifier in the SPS.
  31776. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31777. * @param sps defines the sps it is associated to
  31778. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31779. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31780. */
  31781. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31782. /**
  31783. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31784. * @param target the particle target
  31785. * @returns the current particle
  31786. */
  31787. copyToRef(target: SolidParticle): SolidParticle;
  31788. /**
  31789. * Legacy support, changed scale to scaling
  31790. */
  31791. get scale(): Vector3;
  31792. /**
  31793. * Legacy support, changed scale to scaling
  31794. */
  31795. set scale(scale: Vector3);
  31796. /**
  31797. * Legacy support, changed quaternion to rotationQuaternion
  31798. */
  31799. get quaternion(): Nullable<Quaternion>;
  31800. /**
  31801. * Legacy support, changed quaternion to rotationQuaternion
  31802. */
  31803. set quaternion(q: Nullable<Quaternion>);
  31804. /**
  31805. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31806. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31807. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31808. * @returns true if it intersects
  31809. */
  31810. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31811. /**
  31812. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31813. * A particle is in the frustum if its bounding box intersects the frustum
  31814. * @param frustumPlanes defines the frustum to test
  31815. * @returns true if the particle is in the frustum planes
  31816. */
  31817. isInFrustum(frustumPlanes: Plane[]): boolean;
  31818. /**
  31819. * get the rotation matrix of the particle
  31820. * @hidden
  31821. */
  31822. getRotationMatrix(m: Matrix): void;
  31823. }
  31824. /**
  31825. * Represents the shape of the model used by one particle of a solid particle system.
  31826. * SPS internal tool, don't use it manually.
  31827. */
  31828. export class ModelShape {
  31829. /**
  31830. * The shape id
  31831. * @hidden
  31832. */
  31833. shapeID: number;
  31834. /**
  31835. * flat array of model positions (internal use)
  31836. * @hidden
  31837. */
  31838. _shape: Vector3[];
  31839. /**
  31840. * flat array of model UVs (internal use)
  31841. * @hidden
  31842. */
  31843. _shapeUV: number[];
  31844. /**
  31845. * color array of the model
  31846. * @hidden
  31847. */
  31848. _shapeColors: number[];
  31849. /**
  31850. * indices array of the model
  31851. * @hidden
  31852. */
  31853. _indices: number[];
  31854. /**
  31855. * normals array of the model
  31856. * @hidden
  31857. */
  31858. _normals: number[];
  31859. /**
  31860. * length of the shape in the model indices array (internal use)
  31861. * @hidden
  31862. */
  31863. _indicesLength: number;
  31864. /**
  31865. * Custom position function (internal use)
  31866. * @hidden
  31867. */
  31868. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31869. /**
  31870. * Custom vertex function (internal use)
  31871. * @hidden
  31872. */
  31873. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31874. /**
  31875. * Model material (internal use)
  31876. * @hidden
  31877. */
  31878. _material: Nullable<Material>;
  31879. /**
  31880. * 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.
  31881. * SPS internal tool, don't use it manually.
  31882. * @hidden
  31883. */
  31884. 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>);
  31885. }
  31886. /**
  31887. * Represents a Depth Sorted Particle in the solid particle system.
  31888. * @hidden
  31889. */
  31890. export class DepthSortedParticle {
  31891. /**
  31892. * Particle index
  31893. */
  31894. idx: number;
  31895. /**
  31896. * Index of the particle in the "indices" array
  31897. */
  31898. ind: number;
  31899. /**
  31900. * Length of the particle shape in the "indices" array
  31901. */
  31902. indicesLength: number;
  31903. /**
  31904. * Squared distance from the particle to the camera
  31905. */
  31906. sqDistance: number;
  31907. /**
  31908. * Material index when used with MultiMaterials
  31909. */
  31910. materialIndex: number;
  31911. /**
  31912. * Creates a new sorted particle
  31913. * @param materialIndex
  31914. */
  31915. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31916. }
  31917. /**
  31918. * Represents a solid particle vertex
  31919. */
  31920. export class SolidParticleVertex {
  31921. /**
  31922. * Vertex position
  31923. */
  31924. position: Vector3;
  31925. /**
  31926. * Vertex color
  31927. */
  31928. color: Color4;
  31929. /**
  31930. * Vertex UV
  31931. */
  31932. uv: Vector2;
  31933. /**
  31934. * Creates a new solid particle vertex
  31935. */
  31936. constructor();
  31937. /** Vertex x coordinate */
  31938. get x(): number;
  31939. set x(val: number);
  31940. /** Vertex y coordinate */
  31941. get y(): number;
  31942. set y(val: number);
  31943. /** Vertex z coordinate */
  31944. get z(): number;
  31945. set z(val: number);
  31946. }
  31947. }
  31948. declare module "babylonjs/Collisions/meshCollisionData" {
  31949. import { Collider } from "babylonjs/Collisions/collider";
  31950. import { Vector3 } from "babylonjs/Maths/math.vector";
  31951. import { Nullable } from "babylonjs/types";
  31952. import { Observer } from "babylonjs/Misc/observable";
  31953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31954. /**
  31955. * @hidden
  31956. */
  31957. export class _MeshCollisionData {
  31958. _checkCollisions: boolean;
  31959. _collisionMask: number;
  31960. _collisionGroup: number;
  31961. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31962. _collider: Nullable<Collider>;
  31963. _oldPositionForCollisions: Vector3;
  31964. _diffPositionForCollisions: Vector3;
  31965. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31966. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31967. }
  31968. }
  31969. declare module "babylonjs/Meshes/abstractMesh" {
  31970. import { Observable } from "babylonjs/Misc/observable";
  31971. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  31972. import { Camera } from "babylonjs/Cameras/camera";
  31973. import { Scene, IDisposable } from "babylonjs/scene";
  31974. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31975. import { Node } from "babylonjs/node";
  31976. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  31977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31978. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31979. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31980. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31981. import { Material } from "babylonjs/Materials/material";
  31982. import { Light } from "babylonjs/Lights/light";
  31983. import { Skeleton } from "babylonjs/Bones/skeleton";
  31984. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  31985. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  31986. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31987. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  31988. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  31989. import { Plane } from "babylonjs/Maths/math.plane";
  31990. import { Ray } from "babylonjs/Culling/ray";
  31991. import { Collider } from "babylonjs/Collisions/collider";
  31992. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31993. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  31994. /** @hidden */
  31995. class _FacetDataStorage {
  31996. facetPositions: Vector3[];
  31997. facetNormals: Vector3[];
  31998. facetPartitioning: number[][];
  31999. facetNb: number;
  32000. partitioningSubdivisions: number;
  32001. partitioningBBoxRatio: number;
  32002. facetDataEnabled: boolean;
  32003. facetParameters: any;
  32004. bbSize: Vector3;
  32005. subDiv: {
  32006. max: number;
  32007. X: number;
  32008. Y: number;
  32009. Z: number;
  32010. };
  32011. facetDepthSort: boolean;
  32012. facetDepthSortEnabled: boolean;
  32013. depthSortedIndices: IndicesArray;
  32014. depthSortedFacets: {
  32015. ind: number;
  32016. sqDistance: number;
  32017. }[];
  32018. facetDepthSortFunction: (f1: {
  32019. ind: number;
  32020. sqDistance: number;
  32021. }, f2: {
  32022. ind: number;
  32023. sqDistance: number;
  32024. }) => number;
  32025. facetDepthSortFrom: Vector3;
  32026. facetDepthSortOrigin: Vector3;
  32027. invertedMatrix: Matrix;
  32028. }
  32029. /**
  32030. * @hidden
  32031. **/
  32032. class _InternalAbstractMeshDataInfo {
  32033. _hasVertexAlpha: boolean;
  32034. _useVertexColors: boolean;
  32035. _numBoneInfluencers: number;
  32036. _applyFog: boolean;
  32037. _receiveShadows: boolean;
  32038. _facetData: _FacetDataStorage;
  32039. _visibility: number;
  32040. _skeleton: Nullable<Skeleton>;
  32041. _layerMask: number;
  32042. _computeBonesUsingShaders: boolean;
  32043. _isActive: boolean;
  32044. _onlyForInstances: boolean;
  32045. _isActiveIntermediate: boolean;
  32046. _onlyForInstancesIntermediate: boolean;
  32047. _actAsRegularMesh: boolean;
  32048. }
  32049. /**
  32050. * Class used to store all common mesh properties
  32051. */
  32052. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32053. /** No occlusion */
  32054. static OCCLUSION_TYPE_NONE: number;
  32055. /** Occlusion set to optimisitic */
  32056. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32057. /** Occlusion set to strict */
  32058. static OCCLUSION_TYPE_STRICT: number;
  32059. /** Use an accurante occlusion algorithm */
  32060. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32061. /** Use a conservative occlusion algorithm */
  32062. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32063. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32064. * Test order :
  32065. * Is the bounding sphere outside the frustum ?
  32066. * If not, are the bounding box vertices outside the frustum ?
  32067. * It not, then the cullable object is in the frustum.
  32068. */
  32069. static readonly CULLINGSTRATEGY_STANDARD: number;
  32070. /** Culling strategy : Bounding Sphere Only.
  32071. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32072. * It's also less accurate than the standard because some not visible objects can still be selected.
  32073. * Test : is the bounding sphere outside the frustum ?
  32074. * If not, then the cullable object is in the frustum.
  32075. */
  32076. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32077. /** Culling strategy : Optimistic Inclusion.
  32078. * This in an inclusion test first, then the standard exclusion test.
  32079. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32080. * 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.
  32081. * Anyway, it's as accurate as the standard strategy.
  32082. * Test :
  32083. * Is the cullable object bounding sphere center in the frustum ?
  32084. * If not, apply the default culling strategy.
  32085. */
  32086. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32087. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32088. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32089. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32090. * 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.
  32091. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32092. * Test :
  32093. * Is the cullable object bounding sphere center in the frustum ?
  32094. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32095. */
  32096. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32097. /**
  32098. * No billboard
  32099. */
  32100. static get BILLBOARDMODE_NONE(): number;
  32101. /** Billboard on X axis */
  32102. static get BILLBOARDMODE_X(): number;
  32103. /** Billboard on Y axis */
  32104. static get BILLBOARDMODE_Y(): number;
  32105. /** Billboard on Z axis */
  32106. static get BILLBOARDMODE_Z(): number;
  32107. /** Billboard on all axes */
  32108. static get BILLBOARDMODE_ALL(): number;
  32109. /** Billboard on using position instead of orientation */
  32110. static get BILLBOARDMODE_USE_POSITION(): number;
  32111. /** @hidden */
  32112. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32113. /**
  32114. * The culling strategy to use to check whether the mesh must be rendered or not.
  32115. * This value can be changed at any time and will be used on the next render mesh selection.
  32116. * The possible values are :
  32117. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32118. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32119. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32120. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32121. * Please read each static variable documentation to get details about the culling process.
  32122. * */
  32123. cullingStrategy: number;
  32124. /**
  32125. * Gets the number of facets in the mesh
  32126. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32127. */
  32128. get facetNb(): number;
  32129. /**
  32130. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32132. */
  32133. get partitioningSubdivisions(): number;
  32134. set partitioningSubdivisions(nb: number);
  32135. /**
  32136. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32137. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32138. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32139. */
  32140. get partitioningBBoxRatio(): number;
  32141. set partitioningBBoxRatio(ratio: number);
  32142. /**
  32143. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32144. * Works only for updatable meshes.
  32145. * Doesn't work with multi-materials
  32146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32147. */
  32148. get mustDepthSortFacets(): boolean;
  32149. set mustDepthSortFacets(sort: boolean);
  32150. /**
  32151. * The location (Vector3) where the facet depth sort must be computed from.
  32152. * By default, the active camera position.
  32153. * Used only when facet depth sort is enabled
  32154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32155. */
  32156. get facetDepthSortFrom(): Vector3;
  32157. set facetDepthSortFrom(location: Vector3);
  32158. /**
  32159. * gets a boolean indicating if facetData is enabled
  32160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32161. */
  32162. get isFacetDataEnabled(): boolean;
  32163. /** @hidden */
  32164. _updateNonUniformScalingState(value: boolean): boolean;
  32165. /**
  32166. * An event triggered when this mesh collides with another one
  32167. */
  32168. onCollideObservable: Observable<AbstractMesh>;
  32169. /** Set a function to call when this mesh collides with another one */
  32170. set onCollide(callback: () => void);
  32171. /**
  32172. * An event triggered when the collision's position changes
  32173. */
  32174. onCollisionPositionChangeObservable: Observable<Vector3>;
  32175. /** Set a function to call when the collision's position changes */
  32176. set onCollisionPositionChange(callback: () => void);
  32177. /**
  32178. * An event triggered when material is changed
  32179. */
  32180. onMaterialChangedObservable: Observable<AbstractMesh>;
  32181. /**
  32182. * Gets or sets the orientation for POV movement & rotation
  32183. */
  32184. definedFacingForward: boolean;
  32185. /** @hidden */
  32186. _occlusionQuery: Nullable<WebGLQuery>;
  32187. /** @hidden */
  32188. _renderingGroup: Nullable<RenderingGroup>;
  32189. /**
  32190. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32191. */
  32192. get visibility(): number;
  32193. /**
  32194. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32195. */
  32196. set visibility(value: number);
  32197. /** Gets or sets the alpha index used to sort transparent meshes
  32198. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32199. */
  32200. alphaIndex: number;
  32201. /**
  32202. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32203. */
  32204. isVisible: boolean;
  32205. /**
  32206. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32207. */
  32208. isPickable: boolean;
  32209. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32210. showSubMeshesBoundingBox: boolean;
  32211. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32212. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32213. */
  32214. isBlocker: boolean;
  32215. /**
  32216. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32217. */
  32218. enablePointerMoveEvents: boolean;
  32219. /**
  32220. * Specifies the rendering group id for this mesh (0 by default)
  32221. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32222. */
  32223. renderingGroupId: number;
  32224. private _material;
  32225. /** Gets or sets current material */
  32226. get material(): Nullable<Material>;
  32227. set material(value: Nullable<Material>);
  32228. /**
  32229. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32230. * @see http://doc.babylonjs.com/babylon101/shadows
  32231. */
  32232. get receiveShadows(): boolean;
  32233. set receiveShadows(value: boolean);
  32234. /** Defines color to use when rendering outline */
  32235. outlineColor: Color3;
  32236. /** Define width to use when rendering outline */
  32237. outlineWidth: number;
  32238. /** Defines color to use when rendering overlay */
  32239. overlayColor: Color3;
  32240. /** Defines alpha to use when rendering overlay */
  32241. overlayAlpha: number;
  32242. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32243. get hasVertexAlpha(): boolean;
  32244. set hasVertexAlpha(value: boolean);
  32245. /** 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) */
  32246. get useVertexColors(): boolean;
  32247. set useVertexColors(value: boolean);
  32248. /**
  32249. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32250. */
  32251. get computeBonesUsingShaders(): boolean;
  32252. set computeBonesUsingShaders(value: boolean);
  32253. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32254. get numBoneInfluencers(): number;
  32255. set numBoneInfluencers(value: number);
  32256. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32257. get applyFog(): boolean;
  32258. set applyFog(value: boolean);
  32259. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32260. useOctreeForRenderingSelection: boolean;
  32261. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32262. useOctreeForPicking: boolean;
  32263. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32264. useOctreeForCollisions: boolean;
  32265. /**
  32266. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32267. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32268. */
  32269. get layerMask(): number;
  32270. set layerMask(value: number);
  32271. /**
  32272. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32273. */
  32274. alwaysSelectAsActiveMesh: boolean;
  32275. /**
  32276. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32277. */
  32278. doNotSyncBoundingInfo: boolean;
  32279. /**
  32280. * Gets or sets the current action manager
  32281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32282. */
  32283. actionManager: Nullable<AbstractActionManager>;
  32284. private _meshCollisionData;
  32285. /**
  32286. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32287. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32288. */
  32289. ellipsoid: Vector3;
  32290. /**
  32291. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32292. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32293. */
  32294. ellipsoidOffset: Vector3;
  32295. /**
  32296. * Gets or sets a collision mask used to mask collisions (default is -1).
  32297. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32298. */
  32299. get collisionMask(): number;
  32300. set collisionMask(mask: number);
  32301. /**
  32302. * Gets or sets the current collision group mask (-1 by default).
  32303. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32304. */
  32305. get collisionGroup(): number;
  32306. set collisionGroup(mask: number);
  32307. /**
  32308. * Gets or sets current surrounding meshes (null by default).
  32309. *
  32310. * By default collision detection is tested against every mesh in the scene.
  32311. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32312. * meshes will be tested for the collision.
  32313. *
  32314. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32315. */
  32316. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32317. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32318. /**
  32319. * Defines edge width used when edgesRenderer is enabled
  32320. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32321. */
  32322. edgesWidth: number;
  32323. /**
  32324. * Defines edge color used when edgesRenderer is enabled
  32325. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32326. */
  32327. edgesColor: Color4;
  32328. /** @hidden */
  32329. _edgesRenderer: Nullable<IEdgesRenderer>;
  32330. /** @hidden */
  32331. _masterMesh: Nullable<AbstractMesh>;
  32332. /** @hidden */
  32333. _boundingInfo: Nullable<BoundingInfo>;
  32334. /** @hidden */
  32335. _renderId: number;
  32336. /**
  32337. * Gets or sets the list of subMeshes
  32338. * @see http://doc.babylonjs.com/how_to/multi_materials
  32339. */
  32340. subMeshes: SubMesh[];
  32341. /** @hidden */
  32342. _intersectionsInProgress: AbstractMesh[];
  32343. /** @hidden */
  32344. _unIndexed: boolean;
  32345. /** @hidden */
  32346. _lightSources: Light[];
  32347. /** Gets the list of lights affecting that mesh */
  32348. get lightSources(): Light[];
  32349. /** @hidden */
  32350. get _positions(): Nullable<Vector3[]>;
  32351. /** @hidden */
  32352. _waitingData: {
  32353. lods: Nullable<any>;
  32354. actions: Nullable<any>;
  32355. freezeWorldMatrix: Nullable<boolean>;
  32356. };
  32357. /** @hidden */
  32358. _bonesTransformMatrices: Nullable<Float32Array>;
  32359. /** @hidden */
  32360. _transformMatrixTexture: Nullable<RawTexture>;
  32361. /**
  32362. * Gets or sets a skeleton to apply skining transformations
  32363. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32364. */
  32365. set skeleton(value: Nullable<Skeleton>);
  32366. get skeleton(): Nullable<Skeleton>;
  32367. /**
  32368. * An event triggered when the mesh is rebuilt.
  32369. */
  32370. onRebuildObservable: Observable<AbstractMesh>;
  32371. /**
  32372. * Creates a new AbstractMesh
  32373. * @param name defines the name of the mesh
  32374. * @param scene defines the hosting scene
  32375. */
  32376. constructor(name: string, scene?: Nullable<Scene>);
  32377. /**
  32378. * Returns the string "AbstractMesh"
  32379. * @returns "AbstractMesh"
  32380. */
  32381. getClassName(): string;
  32382. /**
  32383. * Gets a string representation of the current mesh
  32384. * @param fullDetails defines a boolean indicating if full details must be included
  32385. * @returns a string representation of the current mesh
  32386. */
  32387. toString(fullDetails?: boolean): string;
  32388. /**
  32389. * @hidden
  32390. */
  32391. protected _getEffectiveParent(): Nullable<Node>;
  32392. /** @hidden */
  32393. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32394. /** @hidden */
  32395. _rebuild(): void;
  32396. /** @hidden */
  32397. _resyncLightSources(): void;
  32398. /** @hidden */
  32399. _resyncLightSource(light: Light): void;
  32400. /** @hidden */
  32401. _unBindEffect(): void;
  32402. /** @hidden */
  32403. _removeLightSource(light: Light, dispose: boolean): void;
  32404. private _markSubMeshesAsDirty;
  32405. /** @hidden */
  32406. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32407. /** @hidden */
  32408. _markSubMeshesAsAttributesDirty(): void;
  32409. /** @hidden */
  32410. _markSubMeshesAsMiscDirty(): void;
  32411. /**
  32412. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32413. */
  32414. get scaling(): Vector3;
  32415. set scaling(newScaling: Vector3);
  32416. /**
  32417. * Returns true if the mesh is blocked. Implemented by child classes
  32418. */
  32419. get isBlocked(): boolean;
  32420. /**
  32421. * Returns the mesh itself by default. Implemented by child classes
  32422. * @param camera defines the camera to use to pick the right LOD level
  32423. * @returns the currentAbstractMesh
  32424. */
  32425. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32426. /**
  32427. * Returns 0 by default. Implemented by child classes
  32428. * @returns an integer
  32429. */
  32430. getTotalVertices(): number;
  32431. /**
  32432. * Returns a positive integer : the total number of indices in this mesh geometry.
  32433. * @returns the numner of indices or zero if the mesh has no geometry.
  32434. */
  32435. getTotalIndices(): number;
  32436. /**
  32437. * Returns null by default. Implemented by child classes
  32438. * @returns null
  32439. */
  32440. getIndices(): Nullable<IndicesArray>;
  32441. /**
  32442. * Returns the array of the requested vertex data kind. Implemented by child classes
  32443. * @param kind defines the vertex data kind to use
  32444. * @returns null
  32445. */
  32446. getVerticesData(kind: string): Nullable<FloatArray>;
  32447. /**
  32448. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32449. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32450. * Note that a new underlying VertexBuffer object is created each call.
  32451. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32452. * @param kind defines vertex data kind:
  32453. * * VertexBuffer.PositionKind
  32454. * * VertexBuffer.UVKind
  32455. * * VertexBuffer.UV2Kind
  32456. * * VertexBuffer.UV3Kind
  32457. * * VertexBuffer.UV4Kind
  32458. * * VertexBuffer.UV5Kind
  32459. * * VertexBuffer.UV6Kind
  32460. * * VertexBuffer.ColorKind
  32461. * * VertexBuffer.MatricesIndicesKind
  32462. * * VertexBuffer.MatricesIndicesExtraKind
  32463. * * VertexBuffer.MatricesWeightsKind
  32464. * * VertexBuffer.MatricesWeightsExtraKind
  32465. * @param data defines the data source
  32466. * @param updatable defines if the data must be flagged as updatable (or static)
  32467. * @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
  32468. * @returns the current mesh
  32469. */
  32470. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32471. /**
  32472. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32473. * If the mesh has no geometry, it is simply returned as it is.
  32474. * @param kind defines vertex data kind:
  32475. * * VertexBuffer.PositionKind
  32476. * * VertexBuffer.UVKind
  32477. * * VertexBuffer.UV2Kind
  32478. * * VertexBuffer.UV3Kind
  32479. * * VertexBuffer.UV4Kind
  32480. * * VertexBuffer.UV5Kind
  32481. * * VertexBuffer.UV6Kind
  32482. * * VertexBuffer.ColorKind
  32483. * * VertexBuffer.MatricesIndicesKind
  32484. * * VertexBuffer.MatricesIndicesExtraKind
  32485. * * VertexBuffer.MatricesWeightsKind
  32486. * * VertexBuffer.MatricesWeightsExtraKind
  32487. * @param data defines the data source
  32488. * @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
  32489. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32490. * @returns the current mesh
  32491. */
  32492. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32493. /**
  32494. * Sets the mesh indices,
  32495. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32496. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32497. * @param totalVertices Defines the total number of vertices
  32498. * @returns the current mesh
  32499. */
  32500. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32501. /**
  32502. * Gets a boolean indicating if specific vertex data is present
  32503. * @param kind defines the vertex data kind to use
  32504. * @returns true is data kind is present
  32505. */
  32506. isVerticesDataPresent(kind: string): boolean;
  32507. /**
  32508. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32509. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32510. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32511. * @returns a BoundingInfo
  32512. */
  32513. getBoundingInfo(): BoundingInfo;
  32514. /**
  32515. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32516. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32517. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32518. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32519. * @returns the current mesh
  32520. */
  32521. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32522. /**
  32523. * Overwrite the current bounding info
  32524. * @param boundingInfo defines the new bounding info
  32525. * @returns the current mesh
  32526. */
  32527. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32528. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32529. get useBones(): boolean;
  32530. /** @hidden */
  32531. _preActivate(): void;
  32532. /** @hidden */
  32533. _preActivateForIntermediateRendering(renderId: number): void;
  32534. /** @hidden */
  32535. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32536. /** @hidden */
  32537. _postActivate(): void;
  32538. /** @hidden */
  32539. _freeze(): void;
  32540. /** @hidden */
  32541. _unFreeze(): void;
  32542. /**
  32543. * Gets the current world matrix
  32544. * @returns a Matrix
  32545. */
  32546. getWorldMatrix(): Matrix;
  32547. /** @hidden */
  32548. _getWorldMatrixDeterminant(): number;
  32549. /**
  32550. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32551. */
  32552. get isAnInstance(): boolean;
  32553. /**
  32554. * Gets a boolean indicating if this mesh has instances
  32555. */
  32556. get hasInstances(): boolean;
  32557. /**
  32558. * Gets a boolean indicating if this mesh has thin instances
  32559. */
  32560. get hasThinInstances(): boolean;
  32561. /**
  32562. * Perform relative position change from the point of view of behind the front of the mesh.
  32563. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32564. * Supports definition of mesh facing forward or backward
  32565. * @param amountRight defines the distance on the right axis
  32566. * @param amountUp defines the distance on the up axis
  32567. * @param amountForward defines the distance on the forward axis
  32568. * @returns the current mesh
  32569. */
  32570. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32571. /**
  32572. * Calculate relative position change from the point of view of behind the front of the mesh.
  32573. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32574. * Supports definition of mesh facing forward or backward
  32575. * @param amountRight defines the distance on the right axis
  32576. * @param amountUp defines the distance on the up axis
  32577. * @param amountForward defines the distance on the forward axis
  32578. * @returns the new displacement vector
  32579. */
  32580. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32581. /**
  32582. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32583. * Supports definition of mesh facing forward or backward
  32584. * @param flipBack defines the flip
  32585. * @param twirlClockwise defines the twirl
  32586. * @param tiltRight defines the tilt
  32587. * @returns the current mesh
  32588. */
  32589. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32590. /**
  32591. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32592. * Supports definition of mesh facing forward or backward.
  32593. * @param flipBack defines the flip
  32594. * @param twirlClockwise defines the twirl
  32595. * @param tiltRight defines the tilt
  32596. * @returns the new rotation vector
  32597. */
  32598. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32599. /**
  32600. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32601. * This means the mesh underlying bounding box and sphere are recomputed.
  32602. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32603. * @returns the current mesh
  32604. */
  32605. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32606. /** @hidden */
  32607. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32608. /** @hidden */
  32609. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32610. /** @hidden */
  32611. _updateBoundingInfo(): AbstractMesh;
  32612. /** @hidden */
  32613. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32614. /** @hidden */
  32615. protected _afterComputeWorldMatrix(): void;
  32616. /** @hidden */
  32617. get _effectiveMesh(): AbstractMesh;
  32618. /**
  32619. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32620. * A mesh is in the frustum if its bounding box intersects the frustum
  32621. * @param frustumPlanes defines the frustum to test
  32622. * @returns true if the mesh is in the frustum planes
  32623. */
  32624. isInFrustum(frustumPlanes: Plane[]): boolean;
  32625. /**
  32626. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32627. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32628. * @param frustumPlanes defines the frustum to test
  32629. * @returns true if the mesh is completely in the frustum planes
  32630. */
  32631. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32632. /**
  32633. * True if the mesh intersects another mesh or a SolidParticle object
  32634. * @param mesh defines a target mesh or SolidParticle to test
  32635. * @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)
  32636. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32637. * @returns true if there is an intersection
  32638. */
  32639. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32640. /**
  32641. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32642. * @param point defines the point to test
  32643. * @returns true if there is an intersection
  32644. */
  32645. intersectsPoint(point: Vector3): boolean;
  32646. /**
  32647. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32648. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32649. */
  32650. get checkCollisions(): boolean;
  32651. set checkCollisions(collisionEnabled: boolean);
  32652. /**
  32653. * Gets Collider object used to compute collisions (not physics)
  32654. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32655. */
  32656. get collider(): Nullable<Collider>;
  32657. /**
  32658. * Move the mesh using collision engine
  32659. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32660. * @param displacement defines the requested displacement vector
  32661. * @returns the current mesh
  32662. */
  32663. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32664. private _onCollisionPositionChange;
  32665. /** @hidden */
  32666. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32667. /** @hidden */
  32668. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32669. /** @hidden */
  32670. _checkCollision(collider: Collider): AbstractMesh;
  32671. /** @hidden */
  32672. _generatePointsArray(): boolean;
  32673. /**
  32674. * Checks if the passed Ray intersects with the mesh
  32675. * @param ray defines the ray to use
  32676. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32677. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32678. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32679. * @returns the picking info
  32680. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32681. */
  32682. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32683. /**
  32684. * Clones the current mesh
  32685. * @param name defines the mesh name
  32686. * @param newParent defines the new mesh parent
  32687. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32688. * @returns the new mesh
  32689. */
  32690. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32691. /**
  32692. * Disposes all the submeshes of the current meshnp
  32693. * @returns the current mesh
  32694. */
  32695. releaseSubMeshes(): AbstractMesh;
  32696. /**
  32697. * Releases resources associated with this abstract mesh.
  32698. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32699. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32700. */
  32701. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32702. /**
  32703. * Adds the passed mesh as a child to the current mesh
  32704. * @param mesh defines the child mesh
  32705. * @returns the current mesh
  32706. */
  32707. addChild(mesh: AbstractMesh): AbstractMesh;
  32708. /**
  32709. * Removes the passed mesh from the current mesh children list
  32710. * @param mesh defines the child mesh
  32711. * @returns the current mesh
  32712. */
  32713. removeChild(mesh: AbstractMesh): AbstractMesh;
  32714. /** @hidden */
  32715. private _initFacetData;
  32716. /**
  32717. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32718. * This method can be called within the render loop.
  32719. * 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
  32720. * @returns the current mesh
  32721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32722. */
  32723. updateFacetData(): AbstractMesh;
  32724. /**
  32725. * Returns the facetLocalNormals array.
  32726. * The normals are expressed in the mesh local spac
  32727. * @returns an array of Vector3
  32728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32729. */
  32730. getFacetLocalNormals(): Vector3[];
  32731. /**
  32732. * Returns the facetLocalPositions array.
  32733. * The facet positions are expressed in the mesh local space
  32734. * @returns an array of Vector3
  32735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32736. */
  32737. getFacetLocalPositions(): Vector3[];
  32738. /**
  32739. * Returns the facetLocalPartioning array
  32740. * @returns an array of array of numbers
  32741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32742. */
  32743. getFacetLocalPartitioning(): number[][];
  32744. /**
  32745. * Returns the i-th facet position in the world system.
  32746. * This method allocates a new Vector3 per call
  32747. * @param i defines the facet index
  32748. * @returns a new Vector3
  32749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32750. */
  32751. getFacetPosition(i: number): Vector3;
  32752. /**
  32753. * Sets the reference Vector3 with the i-th facet position in the world system
  32754. * @param i defines the facet index
  32755. * @param ref defines the target vector
  32756. * @returns the current mesh
  32757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32758. */
  32759. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32760. /**
  32761. * Returns the i-th facet normal in the world system.
  32762. * This method allocates a new Vector3 per call
  32763. * @param i defines the facet index
  32764. * @returns a new Vector3
  32765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32766. */
  32767. getFacetNormal(i: number): Vector3;
  32768. /**
  32769. * Sets the reference Vector3 with the i-th facet normal in the world system
  32770. * @param i defines the facet index
  32771. * @param ref defines the target vector
  32772. * @returns the current mesh
  32773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32774. */
  32775. getFacetNormalToRef(i: number, ref: Vector3): this;
  32776. /**
  32777. * 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)
  32778. * @param x defines x coordinate
  32779. * @param y defines y coordinate
  32780. * @param z defines z coordinate
  32781. * @returns the array of facet indexes
  32782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32783. */
  32784. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32785. /**
  32786. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32787. * @param projected sets as the (x,y,z) world projection on the facet
  32788. * @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
  32789. * @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
  32790. * @param x defines x coordinate
  32791. * @param y defines y coordinate
  32792. * @param z defines z coordinate
  32793. * @returns the face index if found (or null instead)
  32794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32795. */
  32796. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32797. /**
  32798. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32799. * @param projected sets as the (x,y,z) local projection on the facet
  32800. * @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
  32801. * @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
  32802. * @param x defines x coordinate
  32803. * @param y defines y coordinate
  32804. * @param z defines z coordinate
  32805. * @returns the face index if found (or null instead)
  32806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32807. */
  32808. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32809. /**
  32810. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32811. * @returns the parameters
  32812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32813. */
  32814. getFacetDataParameters(): any;
  32815. /**
  32816. * Disables the feature FacetData and frees the related memory
  32817. * @returns the current mesh
  32818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  32819. */
  32820. disableFacetData(): AbstractMesh;
  32821. /**
  32822. * Updates the AbstractMesh indices array
  32823. * @param indices defines the data source
  32824. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32825. * @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)
  32826. * @returns the current mesh
  32827. */
  32828. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32829. /**
  32830. * Creates new normals data for the mesh
  32831. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32832. * @returns the current mesh
  32833. */
  32834. createNormals(updatable: boolean): AbstractMesh;
  32835. /**
  32836. * Align the mesh with a normal
  32837. * @param normal defines the normal to use
  32838. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32839. * @returns the current mesh
  32840. */
  32841. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32842. /** @hidden */
  32843. _checkOcclusionQuery(): boolean;
  32844. /**
  32845. * Disables the mesh edge rendering mode
  32846. * @returns the currentAbstractMesh
  32847. */
  32848. disableEdgesRendering(): AbstractMesh;
  32849. /**
  32850. * Enables the edge rendering mode on the mesh.
  32851. * This mode makes the mesh edges visible
  32852. * @param epsilon defines the maximal distance between two angles to detect a face
  32853. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32854. * @returns the currentAbstractMesh
  32855. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32856. */
  32857. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32858. }
  32859. }
  32860. declare module "babylonjs/Actions/actionEvent" {
  32861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32862. import { Nullable } from "babylonjs/types";
  32863. import { Sprite } from "babylonjs/Sprites/sprite";
  32864. import { Scene } from "babylonjs/scene";
  32865. import { Vector2 } from "babylonjs/Maths/math.vector";
  32866. /**
  32867. * Interface used to define ActionEvent
  32868. */
  32869. export interface IActionEvent {
  32870. /** The mesh or sprite that triggered the action */
  32871. source: any;
  32872. /** The X mouse cursor position at the time of the event */
  32873. pointerX: number;
  32874. /** The Y mouse cursor position at the time of the event */
  32875. pointerY: number;
  32876. /** The mesh that is currently pointed at (can be null) */
  32877. meshUnderPointer: Nullable<AbstractMesh>;
  32878. /** the original (browser) event that triggered the ActionEvent */
  32879. sourceEvent?: any;
  32880. /** additional data for the event */
  32881. additionalData?: any;
  32882. }
  32883. /**
  32884. * ActionEvent is the event being sent when an action is triggered.
  32885. */
  32886. export class ActionEvent implements IActionEvent {
  32887. /** The mesh or sprite that triggered the action */
  32888. source: any;
  32889. /** The X mouse cursor position at the time of the event */
  32890. pointerX: number;
  32891. /** The Y mouse cursor position at the time of the event */
  32892. pointerY: number;
  32893. /** The mesh that is currently pointed at (can be null) */
  32894. meshUnderPointer: Nullable<AbstractMesh>;
  32895. /** the original (browser) event that triggered the ActionEvent */
  32896. sourceEvent?: any;
  32897. /** additional data for the event */
  32898. additionalData?: any;
  32899. /**
  32900. * Creates a new ActionEvent
  32901. * @param source The mesh or sprite that triggered the action
  32902. * @param pointerX The X mouse cursor position at the time of the event
  32903. * @param pointerY The Y mouse cursor position at the time of the event
  32904. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32905. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32906. * @param additionalData additional data for the event
  32907. */
  32908. constructor(
  32909. /** The mesh or sprite that triggered the action */
  32910. source: any,
  32911. /** The X mouse cursor position at the time of the event */
  32912. pointerX: number,
  32913. /** The Y mouse cursor position at the time of the event */
  32914. pointerY: number,
  32915. /** The mesh that is currently pointed at (can be null) */
  32916. meshUnderPointer: Nullable<AbstractMesh>,
  32917. /** the original (browser) event that triggered the ActionEvent */
  32918. sourceEvent?: any,
  32919. /** additional data for the event */
  32920. additionalData?: any);
  32921. /**
  32922. * Helper function to auto-create an ActionEvent from a source mesh.
  32923. * @param source The source mesh that triggered the event
  32924. * @param evt The original (browser) event
  32925. * @param additionalData additional data for the event
  32926. * @returns the new ActionEvent
  32927. */
  32928. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32929. /**
  32930. * Helper function to auto-create an ActionEvent from a source sprite
  32931. * @param source The source sprite that triggered the event
  32932. * @param scene Scene associated with the sprite
  32933. * @param evt The original (browser) event
  32934. * @param additionalData additional data for the event
  32935. * @returns the new ActionEvent
  32936. */
  32937. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32938. /**
  32939. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32940. * @param scene the scene where the event occurred
  32941. * @param evt The original (browser) event
  32942. * @returns the new ActionEvent
  32943. */
  32944. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32945. /**
  32946. * Helper function to auto-create an ActionEvent from a primitive
  32947. * @param prim defines the target primitive
  32948. * @param pointerPos defines the pointer position
  32949. * @param evt The original (browser) event
  32950. * @param additionalData additional data for the event
  32951. * @returns the new ActionEvent
  32952. */
  32953. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32954. }
  32955. }
  32956. declare module "babylonjs/Actions/abstractActionManager" {
  32957. import { IDisposable } from "babylonjs/scene";
  32958. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  32959. import { IAction } from "babylonjs/Actions/action";
  32960. import { Nullable } from "babylonjs/types";
  32961. /**
  32962. * Abstract class used to decouple action Manager from scene and meshes.
  32963. * Do not instantiate.
  32964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32965. */
  32966. export abstract class AbstractActionManager implements IDisposable {
  32967. /** Gets the list of active triggers */
  32968. static Triggers: {
  32969. [key: string]: number;
  32970. };
  32971. /** Gets the cursor to use when hovering items */
  32972. hoverCursor: string;
  32973. /** Gets the list of actions */
  32974. actions: IAction[];
  32975. /**
  32976. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32977. */
  32978. isRecursive: boolean;
  32979. /**
  32980. * Releases all associated resources
  32981. */
  32982. abstract dispose(): void;
  32983. /**
  32984. * Does this action manager has pointer triggers
  32985. */
  32986. abstract get hasPointerTriggers(): boolean;
  32987. /**
  32988. * Does this action manager has pick triggers
  32989. */
  32990. abstract get hasPickTriggers(): boolean;
  32991. /**
  32992. * Process a specific trigger
  32993. * @param trigger defines the trigger to process
  32994. * @param evt defines the event details to be processed
  32995. */
  32996. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32997. /**
  32998. * Does this action manager handles actions of any of the given triggers
  32999. * @param triggers defines the triggers to be tested
  33000. * @return a boolean indicating whether one (or more) of the triggers is handled
  33001. */
  33002. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33003. /**
  33004. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33005. * speed.
  33006. * @param triggerA defines the trigger to be tested
  33007. * @param triggerB defines the trigger to be tested
  33008. * @return a boolean indicating whether one (or more) of the triggers is handled
  33009. */
  33010. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33011. /**
  33012. * Does this action manager handles actions of a given trigger
  33013. * @param trigger defines the trigger to be tested
  33014. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33015. * @return whether the trigger is handled
  33016. */
  33017. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33018. /**
  33019. * Serialize this manager to a JSON object
  33020. * @param name defines the property name to store this manager
  33021. * @returns a JSON representation of this manager
  33022. */
  33023. abstract serialize(name: string): any;
  33024. /**
  33025. * Registers an action to this action manager
  33026. * @param action defines the action to be registered
  33027. * @return the action amended (prepared) after registration
  33028. */
  33029. abstract registerAction(action: IAction): Nullable<IAction>;
  33030. /**
  33031. * Unregisters an action to this action manager
  33032. * @param action defines the action to be unregistered
  33033. * @return a boolean indicating whether the action has been unregistered
  33034. */
  33035. abstract unregisterAction(action: IAction): Boolean;
  33036. /**
  33037. * Does exist one action manager with at least one trigger
  33038. **/
  33039. static get HasTriggers(): boolean;
  33040. /**
  33041. * Does exist one action manager with at least one pick trigger
  33042. **/
  33043. static get HasPickTriggers(): boolean;
  33044. /**
  33045. * Does exist one action manager that handles actions of a given trigger
  33046. * @param trigger defines the trigger to be tested
  33047. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33048. **/
  33049. static HasSpecificTrigger(trigger: number): boolean;
  33050. }
  33051. }
  33052. declare module "babylonjs/node" {
  33053. import { Scene } from "babylonjs/scene";
  33054. import { Nullable } from "babylonjs/types";
  33055. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33056. import { Engine } from "babylonjs/Engines/engine";
  33057. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33058. import { Observable } from "babylonjs/Misc/observable";
  33059. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33060. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33061. import { Animatable } from "babylonjs/Animations/animatable";
  33062. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33063. import { Animation } from "babylonjs/Animations/animation";
  33064. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33066. /**
  33067. * Defines how a node can be built from a string name.
  33068. */
  33069. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33070. /**
  33071. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33072. */
  33073. export class Node implements IBehaviorAware<Node> {
  33074. /** @hidden */
  33075. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  33076. private static _NodeConstructors;
  33077. /**
  33078. * Add a new node constructor
  33079. * @param type defines the type name of the node to construct
  33080. * @param constructorFunc defines the constructor function
  33081. */
  33082. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33083. /**
  33084. * Returns a node constructor based on type name
  33085. * @param type defines the type name
  33086. * @param name defines the new node name
  33087. * @param scene defines the hosting scene
  33088. * @param options defines optional options to transmit to constructors
  33089. * @returns the new constructor or null
  33090. */
  33091. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33092. /**
  33093. * Gets or sets the name of the node
  33094. */
  33095. name: string;
  33096. /**
  33097. * Gets or sets the id of the node
  33098. */
  33099. id: string;
  33100. /**
  33101. * Gets or sets the unique id of the node
  33102. */
  33103. uniqueId: number;
  33104. /**
  33105. * Gets or sets a string used to store user defined state for the node
  33106. */
  33107. state: string;
  33108. /**
  33109. * Gets or sets an object used to store user defined information for the node
  33110. */
  33111. metadata: any;
  33112. /**
  33113. * For internal use only. Please do not use.
  33114. */
  33115. reservedDataStore: any;
  33116. /**
  33117. * List of inspectable custom properties (used by the Inspector)
  33118. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33119. */
  33120. inspectableCustomProperties: IInspectable[];
  33121. private _doNotSerialize;
  33122. /**
  33123. * Gets or sets a boolean used to define if the node must be serialized
  33124. */
  33125. get doNotSerialize(): boolean;
  33126. set doNotSerialize(value: boolean);
  33127. /** @hidden */
  33128. _isDisposed: boolean;
  33129. /**
  33130. * Gets a list of Animations associated with the node
  33131. */
  33132. animations: import("babylonjs/Animations/animation").Animation[];
  33133. protected _ranges: {
  33134. [name: string]: Nullable<AnimationRange>;
  33135. };
  33136. /**
  33137. * Callback raised when the node is ready to be used
  33138. */
  33139. onReady: Nullable<(node: Node) => void>;
  33140. private _isEnabled;
  33141. private _isParentEnabled;
  33142. private _isReady;
  33143. /** @hidden */
  33144. _currentRenderId: number;
  33145. private _parentUpdateId;
  33146. /** @hidden */
  33147. _childUpdateId: number;
  33148. /** @hidden */
  33149. _waitingParentId: Nullable<string>;
  33150. /** @hidden */
  33151. _scene: Scene;
  33152. /** @hidden */
  33153. _cache: any;
  33154. private _parentNode;
  33155. private _children;
  33156. /** @hidden */
  33157. _worldMatrix: Matrix;
  33158. /** @hidden */
  33159. _worldMatrixDeterminant: number;
  33160. /** @hidden */
  33161. _worldMatrixDeterminantIsDirty: boolean;
  33162. /** @hidden */
  33163. private _sceneRootNodesIndex;
  33164. /**
  33165. * Gets a boolean indicating if the node has been disposed
  33166. * @returns true if the node was disposed
  33167. */
  33168. isDisposed(): boolean;
  33169. /**
  33170. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33171. * @see https://doc.babylonjs.com/how_to/parenting
  33172. */
  33173. set parent(parent: Nullable<Node>);
  33174. get parent(): Nullable<Node>;
  33175. /** @hidden */
  33176. _addToSceneRootNodes(): void;
  33177. /** @hidden */
  33178. _removeFromSceneRootNodes(): void;
  33179. private _animationPropertiesOverride;
  33180. /**
  33181. * Gets or sets the animation properties override
  33182. */
  33183. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33184. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33185. /**
  33186. * Gets a string idenfifying the name of the class
  33187. * @returns "Node" string
  33188. */
  33189. getClassName(): string;
  33190. /** @hidden */
  33191. readonly _isNode: boolean;
  33192. /**
  33193. * An event triggered when the mesh is disposed
  33194. */
  33195. onDisposeObservable: Observable<Node>;
  33196. private _onDisposeObserver;
  33197. /**
  33198. * Sets a callback that will be raised when the node will be disposed
  33199. */
  33200. set onDispose(callback: () => void);
  33201. /**
  33202. * Creates a new Node
  33203. * @param name the name and id to be given to this node
  33204. * @param scene the scene this node will be added to
  33205. */
  33206. constructor(name: string, scene?: Nullable<Scene>);
  33207. /**
  33208. * Gets the scene of the node
  33209. * @returns a scene
  33210. */
  33211. getScene(): Scene;
  33212. /**
  33213. * Gets the engine of the node
  33214. * @returns a Engine
  33215. */
  33216. getEngine(): Engine;
  33217. private _behaviors;
  33218. /**
  33219. * Attach a behavior to the node
  33220. * @see http://doc.babylonjs.com/features/behaviour
  33221. * @param behavior defines the behavior to attach
  33222. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33223. * @returns the current Node
  33224. */
  33225. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33226. /**
  33227. * Remove an attached behavior
  33228. * @see http://doc.babylonjs.com/features/behaviour
  33229. * @param behavior defines the behavior to attach
  33230. * @returns the current Node
  33231. */
  33232. removeBehavior(behavior: Behavior<Node>): Node;
  33233. /**
  33234. * Gets the list of attached behaviors
  33235. * @see http://doc.babylonjs.com/features/behaviour
  33236. */
  33237. get behaviors(): Behavior<Node>[];
  33238. /**
  33239. * Gets an attached behavior by name
  33240. * @param name defines the name of the behavior to look for
  33241. * @see http://doc.babylonjs.com/features/behaviour
  33242. * @returns null if behavior was not found else the requested behavior
  33243. */
  33244. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33245. /**
  33246. * Returns the latest update of the World matrix
  33247. * @returns a Matrix
  33248. */
  33249. getWorldMatrix(): Matrix;
  33250. /** @hidden */
  33251. _getWorldMatrixDeterminant(): number;
  33252. /**
  33253. * Returns directly the latest state of the mesh World matrix.
  33254. * A Matrix is returned.
  33255. */
  33256. get worldMatrixFromCache(): Matrix;
  33257. /** @hidden */
  33258. _initCache(): void;
  33259. /** @hidden */
  33260. updateCache(force?: boolean): void;
  33261. /** @hidden */
  33262. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33263. /** @hidden */
  33264. _updateCache(ignoreParentClass?: boolean): void;
  33265. /** @hidden */
  33266. _isSynchronized(): boolean;
  33267. /** @hidden */
  33268. _markSyncedWithParent(): void;
  33269. /** @hidden */
  33270. isSynchronizedWithParent(): boolean;
  33271. /** @hidden */
  33272. isSynchronized(): boolean;
  33273. /**
  33274. * Is this node ready to be used/rendered
  33275. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33276. * @return true if the node is ready
  33277. */
  33278. isReady(completeCheck?: boolean): boolean;
  33279. /**
  33280. * Is this node enabled?
  33281. * 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
  33282. * @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
  33283. * @return whether this node (and its parent) is enabled
  33284. */
  33285. isEnabled(checkAncestors?: boolean): boolean;
  33286. /** @hidden */
  33287. protected _syncParentEnabledState(): void;
  33288. /**
  33289. * Set the enabled state of this node
  33290. * @param value defines the new enabled state
  33291. */
  33292. setEnabled(value: boolean): void;
  33293. /**
  33294. * Is this node a descendant of the given node?
  33295. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33296. * @param ancestor defines the parent node to inspect
  33297. * @returns a boolean indicating if this node is a descendant of the given node
  33298. */
  33299. isDescendantOf(ancestor: Node): boolean;
  33300. /** @hidden */
  33301. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33302. /**
  33303. * Will return all nodes that have this node as ascendant
  33304. * @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
  33305. * @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
  33306. * @return all children nodes of all types
  33307. */
  33308. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33309. /**
  33310. * Get all child-meshes of this node
  33311. * @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)
  33312. * @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
  33313. * @returns an array of AbstractMesh
  33314. */
  33315. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33316. /**
  33317. * Get all direct children of this node
  33318. * @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
  33319. * @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)
  33320. * @returns an array of Node
  33321. */
  33322. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33323. /** @hidden */
  33324. _setReady(state: boolean): void;
  33325. /**
  33326. * Get an animation by name
  33327. * @param name defines the name of the animation to look for
  33328. * @returns null if not found else the requested animation
  33329. */
  33330. getAnimationByName(name: string): Nullable<Animation>;
  33331. /**
  33332. * Creates an animation range for this node
  33333. * @param name defines the name of the range
  33334. * @param from defines the starting key
  33335. * @param to defines the end key
  33336. */
  33337. createAnimationRange(name: string, from: number, to: number): void;
  33338. /**
  33339. * Delete a specific animation range
  33340. * @param name defines the name of the range to delete
  33341. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33342. */
  33343. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33344. /**
  33345. * Get an animation range by name
  33346. * @param name defines the name of the animation range to look for
  33347. * @returns null if not found else the requested animation range
  33348. */
  33349. getAnimationRange(name: string): Nullable<AnimationRange>;
  33350. /**
  33351. * Gets the list of all animation ranges defined on this node
  33352. * @returns an array
  33353. */
  33354. getAnimationRanges(): Nullable<AnimationRange>[];
  33355. /**
  33356. * Will start the animation sequence
  33357. * @param name defines the range frames for animation sequence
  33358. * @param loop defines if the animation should loop (false by default)
  33359. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33360. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33361. * @returns the object created for this animation. If range does not exist, it will return null
  33362. */
  33363. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33364. /**
  33365. * Serialize animation ranges into a JSON compatible object
  33366. * @returns serialization object
  33367. */
  33368. serializeAnimationRanges(): any;
  33369. /**
  33370. * Computes the world matrix of the node
  33371. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33372. * @returns the world matrix
  33373. */
  33374. computeWorldMatrix(force?: boolean): Matrix;
  33375. /**
  33376. * Releases resources associated with this node.
  33377. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33378. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33379. */
  33380. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33381. /**
  33382. * Parse animation range data from a serialization object and store them into a given node
  33383. * @param node defines where to store the animation ranges
  33384. * @param parsedNode defines the serialization object to read data from
  33385. * @param scene defines the hosting scene
  33386. */
  33387. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33388. /**
  33389. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33390. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33391. * @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
  33392. * @returns the new bounding vectors
  33393. */
  33394. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33395. min: Vector3;
  33396. max: Vector3;
  33397. };
  33398. }
  33399. }
  33400. declare module "babylonjs/Animations/animation" {
  33401. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33402. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33403. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33404. import { Nullable } from "babylonjs/types";
  33405. import { Scene } from "babylonjs/scene";
  33406. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33407. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33408. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33409. import { Node } from "babylonjs/node";
  33410. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33411. import { Size } from "babylonjs/Maths/math.size";
  33412. import { Animatable } from "babylonjs/Animations/animatable";
  33413. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33414. /**
  33415. * @hidden
  33416. */
  33417. export class _IAnimationState {
  33418. key: number;
  33419. repeatCount: number;
  33420. workValue?: any;
  33421. loopMode?: number;
  33422. offsetValue?: any;
  33423. highLimitValue?: any;
  33424. }
  33425. /**
  33426. * Class used to store any kind of animation
  33427. */
  33428. export class Animation {
  33429. /**Name of the animation */
  33430. name: string;
  33431. /**Property to animate */
  33432. targetProperty: string;
  33433. /**The frames per second of the animation */
  33434. framePerSecond: number;
  33435. /**The data type of the animation */
  33436. dataType: number;
  33437. /**The loop mode of the animation */
  33438. loopMode?: number | undefined;
  33439. /**Specifies if blending should be enabled */
  33440. enableBlending?: boolean | undefined;
  33441. /**
  33442. * Use matrix interpolation instead of using direct key value when animating matrices
  33443. */
  33444. static AllowMatricesInterpolation: boolean;
  33445. /**
  33446. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33447. */
  33448. static AllowMatrixDecomposeForInterpolation: boolean;
  33449. /** Define the Url to load snippets */
  33450. static SnippetUrl: string;
  33451. /** Snippet ID if the animation was created from the snippet server */
  33452. snippetId: string;
  33453. /**
  33454. * Stores the key frames of the animation
  33455. */
  33456. private _keys;
  33457. /**
  33458. * Stores the easing function of the animation
  33459. */
  33460. private _easingFunction;
  33461. /**
  33462. * @hidden Internal use only
  33463. */
  33464. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33465. /**
  33466. * The set of event that will be linked to this animation
  33467. */
  33468. private _events;
  33469. /**
  33470. * Stores an array of target property paths
  33471. */
  33472. targetPropertyPath: string[];
  33473. /**
  33474. * Stores the blending speed of the animation
  33475. */
  33476. blendingSpeed: number;
  33477. /**
  33478. * Stores the animation ranges for the animation
  33479. */
  33480. private _ranges;
  33481. /**
  33482. * @hidden Internal use
  33483. */
  33484. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33485. /**
  33486. * Sets up an animation
  33487. * @param property The property to animate
  33488. * @param animationType The animation type to apply
  33489. * @param framePerSecond The frames per second of the animation
  33490. * @param easingFunction The easing function used in the animation
  33491. * @returns The created animation
  33492. */
  33493. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33494. /**
  33495. * Create and start an animation on a node
  33496. * @param name defines the name of the global animation that will be run on all nodes
  33497. * @param node defines the root node where the animation will take place
  33498. * @param targetProperty defines property to animate
  33499. * @param framePerSecond defines the number of frame per second yo use
  33500. * @param totalFrame defines the number of frames in total
  33501. * @param from defines the initial value
  33502. * @param to defines the final value
  33503. * @param loopMode defines which loop mode you want to use (off by default)
  33504. * @param easingFunction defines the easing function to use (linear by default)
  33505. * @param onAnimationEnd defines the callback to call when animation end
  33506. * @returns the animatable created for this animation
  33507. */
  33508. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33509. /**
  33510. * Create and start an animation on a node and its descendants
  33511. * @param name defines the name of the global animation that will be run on all nodes
  33512. * @param node defines the root node where the animation will take place
  33513. * @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
  33514. * @param targetProperty defines property to animate
  33515. * @param framePerSecond defines the number of frame per second to use
  33516. * @param totalFrame defines the number of frames in total
  33517. * @param from defines the initial value
  33518. * @param to defines the final value
  33519. * @param loopMode defines which loop mode you want to use (off by default)
  33520. * @param easingFunction defines the easing function to use (linear by default)
  33521. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33522. * @returns the list of animatables created for all nodes
  33523. * @example https://www.babylonjs-playground.com/#MH0VLI
  33524. */
  33525. 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[]>;
  33526. /**
  33527. * Creates a new animation, merges it with the existing animations and starts it
  33528. * @param name Name of the animation
  33529. * @param node Node which contains the scene that begins the animations
  33530. * @param targetProperty Specifies which property to animate
  33531. * @param framePerSecond The frames per second of the animation
  33532. * @param totalFrame The total number of frames
  33533. * @param from The frame at the beginning of the animation
  33534. * @param to The frame at the end of the animation
  33535. * @param loopMode Specifies the loop mode of the animation
  33536. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33537. * @param onAnimationEnd Callback to run once the animation is complete
  33538. * @returns Nullable animation
  33539. */
  33540. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33541. /**
  33542. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33543. * @param sourceAnimation defines the Animation containing keyframes to convert
  33544. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33545. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33546. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33547. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33548. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33549. */
  33550. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33551. /**
  33552. * Transition property of an host to the target Value
  33553. * @param property The property to transition
  33554. * @param targetValue The target Value of the property
  33555. * @param host The object where the property to animate belongs
  33556. * @param scene Scene used to run the animation
  33557. * @param frameRate Framerate (in frame/s) to use
  33558. * @param transition The transition type we want to use
  33559. * @param duration The duration of the animation, in milliseconds
  33560. * @param onAnimationEnd Callback trigger at the end of the animation
  33561. * @returns Nullable animation
  33562. */
  33563. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33564. /**
  33565. * Return the array of runtime animations currently using this animation
  33566. */
  33567. get runtimeAnimations(): RuntimeAnimation[];
  33568. /**
  33569. * Specifies if any of the runtime animations are currently running
  33570. */
  33571. get hasRunningRuntimeAnimations(): boolean;
  33572. /**
  33573. * Initializes the animation
  33574. * @param name Name of the animation
  33575. * @param targetProperty Property to animate
  33576. * @param framePerSecond The frames per second of the animation
  33577. * @param dataType The data type of the animation
  33578. * @param loopMode The loop mode of the animation
  33579. * @param enableBlending Specifies if blending should be enabled
  33580. */
  33581. constructor(
  33582. /**Name of the animation */
  33583. name: string,
  33584. /**Property to animate */
  33585. targetProperty: string,
  33586. /**The frames per second of the animation */
  33587. framePerSecond: number,
  33588. /**The data type of the animation */
  33589. dataType: number,
  33590. /**The loop mode of the animation */
  33591. loopMode?: number | undefined,
  33592. /**Specifies if blending should be enabled */
  33593. enableBlending?: boolean | undefined);
  33594. /**
  33595. * Converts the animation to a string
  33596. * @param fullDetails support for multiple levels of logging within scene loading
  33597. * @returns String form of the animation
  33598. */
  33599. toString(fullDetails?: boolean): string;
  33600. /**
  33601. * Add an event to this animation
  33602. * @param event Event to add
  33603. */
  33604. addEvent(event: AnimationEvent): void;
  33605. /**
  33606. * Remove all events found at the given frame
  33607. * @param frame The frame to remove events from
  33608. */
  33609. removeEvents(frame: number): void;
  33610. /**
  33611. * Retrieves all the events from the animation
  33612. * @returns Events from the animation
  33613. */
  33614. getEvents(): AnimationEvent[];
  33615. /**
  33616. * Creates an animation range
  33617. * @param name Name of the animation range
  33618. * @param from Starting frame of the animation range
  33619. * @param to Ending frame of the animation
  33620. */
  33621. createRange(name: string, from: number, to: number): void;
  33622. /**
  33623. * Deletes an animation range by name
  33624. * @param name Name of the animation range to delete
  33625. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33626. */
  33627. deleteRange(name: string, deleteFrames?: boolean): void;
  33628. /**
  33629. * Gets the animation range by name, or null if not defined
  33630. * @param name Name of the animation range
  33631. * @returns Nullable animation range
  33632. */
  33633. getRange(name: string): Nullable<AnimationRange>;
  33634. /**
  33635. * Gets the key frames from the animation
  33636. * @returns The key frames of the animation
  33637. */
  33638. getKeys(): Array<IAnimationKey>;
  33639. /**
  33640. * Gets the highest frame rate of the animation
  33641. * @returns Highest frame rate of the animation
  33642. */
  33643. getHighestFrame(): number;
  33644. /**
  33645. * Gets the easing function of the animation
  33646. * @returns Easing function of the animation
  33647. */
  33648. getEasingFunction(): IEasingFunction;
  33649. /**
  33650. * Sets the easing function of the animation
  33651. * @param easingFunction A custom mathematical formula for animation
  33652. */
  33653. setEasingFunction(easingFunction: EasingFunction): void;
  33654. /**
  33655. * Interpolates a scalar linearly
  33656. * @param startValue Start value of the animation curve
  33657. * @param endValue End value of the animation curve
  33658. * @param gradient Scalar amount to interpolate
  33659. * @returns Interpolated scalar value
  33660. */
  33661. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33662. /**
  33663. * Interpolates a scalar cubically
  33664. * @param startValue Start value of the animation curve
  33665. * @param outTangent End tangent of the animation
  33666. * @param endValue End value of the animation curve
  33667. * @param inTangent Start tangent of the animation curve
  33668. * @param gradient Scalar amount to interpolate
  33669. * @returns Interpolated scalar value
  33670. */
  33671. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33672. /**
  33673. * Interpolates a quaternion using a spherical linear interpolation
  33674. * @param startValue Start value of the animation curve
  33675. * @param endValue End value of the animation curve
  33676. * @param gradient Scalar amount to interpolate
  33677. * @returns Interpolated quaternion value
  33678. */
  33679. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33680. /**
  33681. * Interpolates a quaternion cubically
  33682. * @param startValue Start value of the animation curve
  33683. * @param outTangent End tangent of the animation curve
  33684. * @param endValue End value of the animation curve
  33685. * @param inTangent Start tangent of the animation curve
  33686. * @param gradient Scalar amount to interpolate
  33687. * @returns Interpolated quaternion value
  33688. */
  33689. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33690. /**
  33691. * Interpolates a Vector3 linearl
  33692. * @param startValue Start value of the animation curve
  33693. * @param endValue End value of the animation curve
  33694. * @param gradient Scalar amount to interpolate
  33695. * @returns Interpolated scalar value
  33696. */
  33697. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33698. /**
  33699. * Interpolates a Vector3 cubically
  33700. * @param startValue Start value of the animation curve
  33701. * @param outTangent End tangent of the animation
  33702. * @param endValue End value of the animation curve
  33703. * @param inTangent Start tangent of the animation curve
  33704. * @param gradient Scalar amount to interpolate
  33705. * @returns InterpolatedVector3 value
  33706. */
  33707. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33708. /**
  33709. * Interpolates a Vector2 linearly
  33710. * @param startValue Start value of the animation curve
  33711. * @param endValue End value of the animation curve
  33712. * @param gradient Scalar amount to interpolate
  33713. * @returns Interpolated Vector2 value
  33714. */
  33715. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33716. /**
  33717. * Interpolates a Vector2 cubically
  33718. * @param startValue Start value of the animation curve
  33719. * @param outTangent End tangent of the animation
  33720. * @param endValue End value of the animation curve
  33721. * @param inTangent Start tangent of the animation curve
  33722. * @param gradient Scalar amount to interpolate
  33723. * @returns Interpolated Vector2 value
  33724. */
  33725. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33726. /**
  33727. * Interpolates a size linearly
  33728. * @param startValue Start value of the animation curve
  33729. * @param endValue End value of the animation curve
  33730. * @param gradient Scalar amount to interpolate
  33731. * @returns Interpolated Size value
  33732. */
  33733. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33734. /**
  33735. * Interpolates a Color3 linearly
  33736. * @param startValue Start value of the animation curve
  33737. * @param endValue End value of the animation curve
  33738. * @param gradient Scalar amount to interpolate
  33739. * @returns Interpolated Color3 value
  33740. */
  33741. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33742. /**
  33743. * Interpolates a Color4 linearly
  33744. * @param startValue Start value of the animation curve
  33745. * @param endValue End value of the animation curve
  33746. * @param gradient Scalar amount to interpolate
  33747. * @returns Interpolated Color3 value
  33748. */
  33749. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33750. /**
  33751. * @hidden Internal use only
  33752. */
  33753. _getKeyValue(value: any): any;
  33754. /**
  33755. * @hidden Internal use only
  33756. */
  33757. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33758. /**
  33759. * Defines the function to use to interpolate matrices
  33760. * @param startValue defines the start matrix
  33761. * @param endValue defines the end matrix
  33762. * @param gradient defines the gradient between both matrices
  33763. * @param result defines an optional target matrix where to store the interpolation
  33764. * @returns the interpolated matrix
  33765. */
  33766. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33767. /**
  33768. * Makes a copy of the animation
  33769. * @returns Cloned animation
  33770. */
  33771. clone(): Animation;
  33772. /**
  33773. * Sets the key frames of the animation
  33774. * @param values The animation key frames to set
  33775. */
  33776. setKeys(values: Array<IAnimationKey>): void;
  33777. /**
  33778. * Serializes the animation to an object
  33779. * @returns Serialized object
  33780. */
  33781. serialize(): any;
  33782. /**
  33783. * Float animation type
  33784. */
  33785. static readonly ANIMATIONTYPE_FLOAT: number;
  33786. /**
  33787. * Vector3 animation type
  33788. */
  33789. static readonly ANIMATIONTYPE_VECTOR3: number;
  33790. /**
  33791. * Quaternion animation type
  33792. */
  33793. static readonly ANIMATIONTYPE_QUATERNION: number;
  33794. /**
  33795. * Matrix animation type
  33796. */
  33797. static readonly ANIMATIONTYPE_MATRIX: number;
  33798. /**
  33799. * Color3 animation type
  33800. */
  33801. static readonly ANIMATIONTYPE_COLOR3: number;
  33802. /**
  33803. * Color3 animation type
  33804. */
  33805. static readonly ANIMATIONTYPE_COLOR4: number;
  33806. /**
  33807. * Vector2 animation type
  33808. */
  33809. static readonly ANIMATIONTYPE_VECTOR2: number;
  33810. /**
  33811. * Size animation type
  33812. */
  33813. static readonly ANIMATIONTYPE_SIZE: number;
  33814. /**
  33815. * Relative Loop Mode
  33816. */
  33817. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33818. /**
  33819. * Cycle Loop Mode
  33820. */
  33821. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33822. /**
  33823. * Constant Loop Mode
  33824. */
  33825. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33826. /** @hidden */
  33827. static _UniversalLerp(left: any, right: any, amount: number): any;
  33828. /**
  33829. * Parses an animation object and creates an animation
  33830. * @param parsedAnimation Parsed animation object
  33831. * @returns Animation object
  33832. */
  33833. static Parse(parsedAnimation: any): Animation;
  33834. /**
  33835. * Appends the serialized animations from the source animations
  33836. * @param source Source containing the animations
  33837. * @param destination Target to store the animations
  33838. */
  33839. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33840. /**
  33841. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33842. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33843. * @param url defines the url to load from
  33844. * @returns a promise that will resolve to the new animation or an array of animations
  33845. */
  33846. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33847. /**
  33848. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33849. * @param snippetId defines the snippet to load
  33850. * @returns a promise that will resolve to the new animation or a new array of animations
  33851. */
  33852. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33853. }
  33854. }
  33855. declare module "babylonjs/Animations/animatable.interface" {
  33856. import { Nullable } from "babylonjs/types";
  33857. import { Animation } from "babylonjs/Animations/animation";
  33858. /**
  33859. * Interface containing an array of animations
  33860. */
  33861. export interface IAnimatable {
  33862. /**
  33863. * Array of animations
  33864. */
  33865. animations: Nullable<Array<Animation>>;
  33866. }
  33867. }
  33868. declare module "babylonjs/Misc/decorators" {
  33869. import { Nullable } from "babylonjs/types";
  33870. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33871. import { Scene } from "babylonjs/scene";
  33872. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33873. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33874. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33875. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33876. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33877. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33878. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33879. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33880. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33881. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33882. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33883. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33884. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33885. /**
  33886. * Decorator used to define property that can be serialized as reference to a camera
  33887. * @param sourceName defines the name of the property to decorate
  33888. */
  33889. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33890. /**
  33891. * Class used to help serialization objects
  33892. */
  33893. export class SerializationHelper {
  33894. /** @hidden */
  33895. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  33896. /** @hidden */
  33897. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  33898. /** @hidden */
  33899. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  33900. /** @hidden */
  33901. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  33902. /**
  33903. * Appends the serialized animations from the source animations
  33904. * @param source Source containing the animations
  33905. * @param destination Target to store the animations
  33906. */
  33907. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33908. /**
  33909. * Static function used to serialized a specific entity
  33910. * @param entity defines the entity to serialize
  33911. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33912. * @returns a JSON compatible object representing the serialization of the entity
  33913. */
  33914. static Serialize<T>(entity: T, serializationObject?: any): any;
  33915. /**
  33916. * Creates a new entity from a serialization data object
  33917. * @param creationFunction defines a function used to instanciated the new entity
  33918. * @param source defines the source serialization data
  33919. * @param scene defines the hosting scene
  33920. * @param rootUrl defines the root url for resources
  33921. * @returns a new entity
  33922. */
  33923. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33924. /**
  33925. * Clones an object
  33926. * @param creationFunction defines the function used to instanciate the new object
  33927. * @param source defines the source object
  33928. * @returns the cloned object
  33929. */
  33930. static Clone<T>(creationFunction: () => T, source: T): T;
  33931. /**
  33932. * Instanciates a new object based on a source one (some data will be shared between both object)
  33933. * @param creationFunction defines the function used to instanciate the new object
  33934. * @param source defines the source object
  33935. * @returns the new object
  33936. */
  33937. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33938. }
  33939. }
  33940. declare module "babylonjs/Materials/Textures/baseTexture" {
  33941. import { Observable } from "babylonjs/Misc/observable";
  33942. import { Nullable } from "babylonjs/types";
  33943. import { Scene } from "babylonjs/scene";
  33944. import { Matrix } from "babylonjs/Maths/math.vector";
  33945. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33946. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33947. import { ISize } from "babylonjs/Maths/math.size";
  33948. import "babylonjs/Misc/fileTools";
  33949. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33950. /**
  33951. * Base class of all the textures in babylon.
  33952. * It groups all the common properties the materials, post process, lights... might need
  33953. * in order to make a correct use of the texture.
  33954. */
  33955. export class BaseTexture implements IAnimatable {
  33956. /**
  33957. * Default anisotropic filtering level for the application.
  33958. * It is set to 4 as a good tradeoff between perf and quality.
  33959. */
  33960. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33961. /**
  33962. * Gets or sets the unique id of the texture
  33963. */
  33964. uniqueId: number;
  33965. /**
  33966. * Define the name of the texture.
  33967. */
  33968. name: string;
  33969. /**
  33970. * Gets or sets an object used to store user defined information.
  33971. */
  33972. metadata: any;
  33973. /**
  33974. * For internal use only. Please do not use.
  33975. */
  33976. reservedDataStore: any;
  33977. private _hasAlpha;
  33978. /**
  33979. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33980. */
  33981. set hasAlpha(value: boolean);
  33982. get hasAlpha(): boolean;
  33983. /**
  33984. * Defines if the alpha value should be determined via the rgb values.
  33985. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33986. */
  33987. getAlphaFromRGB: boolean;
  33988. /**
  33989. * Intensity or strength of the texture.
  33990. * It is commonly used by materials to fine tune the intensity of the texture
  33991. */
  33992. level: number;
  33993. /**
  33994. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33995. * This is part of the texture as textures usually maps to one uv set.
  33996. */
  33997. coordinatesIndex: number;
  33998. private _coordinatesMode;
  33999. /**
  34000. * How a texture is mapped.
  34001. *
  34002. * | Value | Type | Description |
  34003. * | ----- | ----------------------------------- | ----------- |
  34004. * | 0 | EXPLICIT_MODE | |
  34005. * | 1 | SPHERICAL_MODE | |
  34006. * | 2 | PLANAR_MODE | |
  34007. * | 3 | CUBIC_MODE | |
  34008. * | 4 | PROJECTION_MODE | |
  34009. * | 5 | SKYBOX_MODE | |
  34010. * | 6 | INVCUBIC_MODE | |
  34011. * | 7 | EQUIRECTANGULAR_MODE | |
  34012. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34013. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34014. */
  34015. set coordinatesMode(value: number);
  34016. get coordinatesMode(): number;
  34017. /**
  34018. * | Value | Type | Description |
  34019. * | ----- | ------------------ | ----------- |
  34020. * | 0 | CLAMP_ADDRESSMODE | |
  34021. * | 1 | WRAP_ADDRESSMODE | |
  34022. * | 2 | MIRROR_ADDRESSMODE | |
  34023. */
  34024. wrapU: number;
  34025. /**
  34026. * | Value | Type | Description |
  34027. * | ----- | ------------------ | ----------- |
  34028. * | 0 | CLAMP_ADDRESSMODE | |
  34029. * | 1 | WRAP_ADDRESSMODE | |
  34030. * | 2 | MIRROR_ADDRESSMODE | |
  34031. */
  34032. wrapV: number;
  34033. /**
  34034. * | Value | Type | Description |
  34035. * | ----- | ------------------ | ----------- |
  34036. * | 0 | CLAMP_ADDRESSMODE | |
  34037. * | 1 | WRAP_ADDRESSMODE | |
  34038. * | 2 | MIRROR_ADDRESSMODE | |
  34039. */
  34040. wrapR: number;
  34041. /**
  34042. * With compliant hardware and browser (supporting anisotropic filtering)
  34043. * this defines the level of anisotropic filtering in the texture.
  34044. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34045. */
  34046. anisotropicFilteringLevel: number;
  34047. /**
  34048. * Define if the texture is a cube texture or if false a 2d texture.
  34049. */
  34050. get isCube(): boolean;
  34051. set isCube(value: boolean);
  34052. /**
  34053. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34054. */
  34055. get is3D(): boolean;
  34056. set is3D(value: boolean);
  34057. /**
  34058. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34059. */
  34060. get is2DArray(): boolean;
  34061. set is2DArray(value: boolean);
  34062. /**
  34063. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34064. * HDR texture are usually stored in linear space.
  34065. * This only impacts the PBR and Background materials
  34066. */
  34067. gammaSpace: boolean;
  34068. /**
  34069. * Gets or sets whether or not the texture contains RGBD data.
  34070. */
  34071. get isRGBD(): boolean;
  34072. set isRGBD(value: boolean);
  34073. /**
  34074. * Is Z inverted in the texture (useful in a cube texture).
  34075. */
  34076. invertZ: boolean;
  34077. /**
  34078. * Are mip maps generated for this texture or not.
  34079. */
  34080. get noMipmap(): boolean;
  34081. /**
  34082. * @hidden
  34083. */
  34084. lodLevelInAlpha: boolean;
  34085. /**
  34086. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34087. */
  34088. get lodGenerationOffset(): number;
  34089. set lodGenerationOffset(value: number);
  34090. /**
  34091. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34092. */
  34093. get lodGenerationScale(): number;
  34094. set lodGenerationScale(value: number);
  34095. /**
  34096. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34097. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34098. * average roughness values.
  34099. */
  34100. get linearSpecularLOD(): boolean;
  34101. set linearSpecularLOD(value: boolean);
  34102. /**
  34103. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34104. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34105. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34106. */
  34107. get irradianceTexture(): Nullable<BaseTexture>;
  34108. set irradianceTexture(value: Nullable<BaseTexture>);
  34109. /**
  34110. * Define if the texture is a render target.
  34111. */
  34112. isRenderTarget: boolean;
  34113. /**
  34114. * Define the unique id of the texture in the scene.
  34115. */
  34116. get uid(): string;
  34117. /** @hidden */
  34118. _prefiltered: boolean;
  34119. /**
  34120. * Return a string representation of the texture.
  34121. * @returns the texture as a string
  34122. */
  34123. toString(): string;
  34124. /**
  34125. * Get the class name of the texture.
  34126. * @returns "BaseTexture"
  34127. */
  34128. getClassName(): string;
  34129. /**
  34130. * Define the list of animation attached to the texture.
  34131. */
  34132. animations: import("babylonjs/Animations/animation").Animation[];
  34133. /**
  34134. * An event triggered when the texture is disposed.
  34135. */
  34136. onDisposeObservable: Observable<BaseTexture>;
  34137. private _onDisposeObserver;
  34138. /**
  34139. * Callback triggered when the texture has been disposed.
  34140. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34141. */
  34142. set onDispose(callback: () => void);
  34143. /**
  34144. * Define the current state of the loading sequence when in delayed load mode.
  34145. */
  34146. delayLoadState: number;
  34147. private _scene;
  34148. private _engine;
  34149. /** @hidden */
  34150. _texture: Nullable<InternalTexture>;
  34151. private _uid;
  34152. /**
  34153. * Define if the texture is preventinga material to render or not.
  34154. * If not and the texture is not ready, the engine will use a default black texture instead.
  34155. */
  34156. get isBlocking(): boolean;
  34157. /**
  34158. * Instantiates a new BaseTexture.
  34159. * Base class of all the textures in babylon.
  34160. * It groups all the common properties the materials, post process, lights... might need
  34161. * in order to make a correct use of the texture.
  34162. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34163. */
  34164. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34165. /**
  34166. * Get the scene the texture belongs to.
  34167. * @returns the scene or null if undefined
  34168. */
  34169. getScene(): Nullable<Scene>;
  34170. /** @hidden */
  34171. protected _getEngine(): Nullable<ThinEngine>;
  34172. /**
  34173. * Get the texture transform matrix used to offset tile the texture for istance.
  34174. * @returns the transformation matrix
  34175. */
  34176. getTextureMatrix(): Matrix;
  34177. /**
  34178. * Get the texture reflection matrix used to rotate/transform the reflection.
  34179. * @returns the reflection matrix
  34180. */
  34181. getReflectionTextureMatrix(): Matrix;
  34182. /**
  34183. * Get the underlying lower level texture from Babylon.
  34184. * @returns the insternal texture
  34185. */
  34186. getInternalTexture(): Nullable<InternalTexture>;
  34187. /**
  34188. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34189. * @returns true if ready or not blocking
  34190. */
  34191. isReadyOrNotBlocking(): boolean;
  34192. /**
  34193. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34194. * @returns true if fully ready
  34195. */
  34196. isReady(): boolean;
  34197. private _cachedSize;
  34198. /**
  34199. * Get the size of the texture.
  34200. * @returns the texture size.
  34201. */
  34202. getSize(): ISize;
  34203. /**
  34204. * Get the base size of the texture.
  34205. * It can be different from the size if the texture has been resized for POT for instance
  34206. * @returns the base size
  34207. */
  34208. getBaseSize(): ISize;
  34209. /**
  34210. * Update the sampling mode of the texture.
  34211. * Default is Trilinear mode.
  34212. *
  34213. * | Value | Type | Description |
  34214. * | ----- | ------------------ | ----------- |
  34215. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34216. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34217. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34218. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34219. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34220. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34221. * | 7 | NEAREST_LINEAR | |
  34222. * | 8 | NEAREST_NEAREST | |
  34223. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34224. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34225. * | 11 | LINEAR_LINEAR | |
  34226. * | 12 | LINEAR_NEAREST | |
  34227. *
  34228. * > _mag_: magnification filter (close to the viewer)
  34229. * > _min_: minification filter (far from the viewer)
  34230. * > _mip_: filter used between mip map levels
  34231. *@param samplingMode Define the new sampling mode of the texture
  34232. */
  34233. updateSamplingMode(samplingMode: number): void;
  34234. /**
  34235. * Scales the texture if is `canRescale()`
  34236. * @param ratio the resize factor we want to use to rescale
  34237. */
  34238. scale(ratio: number): void;
  34239. /**
  34240. * Get if the texture can rescale.
  34241. */
  34242. get canRescale(): boolean;
  34243. /** @hidden */
  34244. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34245. /** @hidden */
  34246. _rebuild(): void;
  34247. /**
  34248. * Triggers the load sequence in delayed load mode.
  34249. */
  34250. delayLoad(): void;
  34251. /**
  34252. * Clones the texture.
  34253. * @returns the cloned texture
  34254. */
  34255. clone(): Nullable<BaseTexture>;
  34256. /**
  34257. * Get the texture underlying type (INT, FLOAT...)
  34258. */
  34259. get textureType(): number;
  34260. /**
  34261. * Get the texture underlying format (RGB, RGBA...)
  34262. */
  34263. get textureFormat(): number;
  34264. /**
  34265. * Indicates that textures need to be re-calculated for all materials
  34266. */
  34267. protected _markAllSubMeshesAsTexturesDirty(): void;
  34268. /**
  34269. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34270. * This will returns an RGBA array buffer containing either in values (0-255) or
  34271. * float values (0-1) depending of the underlying buffer type.
  34272. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34273. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34274. * @param buffer defines a user defined buffer to fill with data (can be null)
  34275. * @returns The Array buffer containing the pixels data.
  34276. */
  34277. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34278. /**
  34279. * Release and destroy the underlying lower level texture aka internalTexture.
  34280. */
  34281. releaseInternalTexture(): void;
  34282. /** @hidden */
  34283. get _lodTextureHigh(): Nullable<BaseTexture>;
  34284. /** @hidden */
  34285. get _lodTextureMid(): Nullable<BaseTexture>;
  34286. /** @hidden */
  34287. get _lodTextureLow(): Nullable<BaseTexture>;
  34288. /**
  34289. * Dispose the texture and release its associated resources.
  34290. */
  34291. dispose(): void;
  34292. /**
  34293. * Serialize the texture into a JSON representation that can be parsed later on.
  34294. * @returns the JSON representation of the texture
  34295. */
  34296. serialize(): any;
  34297. /**
  34298. * Helper function to be called back once a list of texture contains only ready textures.
  34299. * @param textures Define the list of textures to wait for
  34300. * @param callback Define the callback triggered once the entire list will be ready
  34301. */
  34302. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34303. private static _isScene;
  34304. }
  34305. }
  34306. declare module "babylonjs/Materials/effect" {
  34307. import { Observable } from "babylonjs/Misc/observable";
  34308. import { Nullable } from "babylonjs/types";
  34309. import { IDisposable } from "babylonjs/scene";
  34310. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34311. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34312. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34313. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34314. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34315. import { Engine } from "babylonjs/Engines/engine";
  34316. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34317. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34318. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34319. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34320. /**
  34321. * Options to be used when creating an effect.
  34322. */
  34323. export interface IEffectCreationOptions {
  34324. /**
  34325. * Atrributes that will be used in the shader.
  34326. */
  34327. attributes: string[];
  34328. /**
  34329. * Uniform varible names that will be set in the shader.
  34330. */
  34331. uniformsNames: string[];
  34332. /**
  34333. * Uniform buffer variable names that will be set in the shader.
  34334. */
  34335. uniformBuffersNames: string[];
  34336. /**
  34337. * Sampler texture variable names that will be set in the shader.
  34338. */
  34339. samplers: string[];
  34340. /**
  34341. * Define statements that will be set in the shader.
  34342. */
  34343. defines: any;
  34344. /**
  34345. * Possible fallbacks for this effect to improve performance when needed.
  34346. */
  34347. fallbacks: Nullable<IEffectFallbacks>;
  34348. /**
  34349. * Callback that will be called when the shader is compiled.
  34350. */
  34351. onCompiled: Nullable<(effect: Effect) => void>;
  34352. /**
  34353. * Callback that will be called if an error occurs during shader compilation.
  34354. */
  34355. onError: Nullable<(effect: Effect, errors: string) => void>;
  34356. /**
  34357. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34358. */
  34359. indexParameters?: any;
  34360. /**
  34361. * Max number of lights that can be used in the shader.
  34362. */
  34363. maxSimultaneousLights?: number;
  34364. /**
  34365. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34366. */
  34367. transformFeedbackVaryings?: Nullable<string[]>;
  34368. /**
  34369. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  34370. */
  34371. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34372. }
  34373. /**
  34374. * Effect containing vertex and fragment shader that can be executed on an object.
  34375. */
  34376. export class Effect implements IDisposable {
  34377. /**
  34378. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34379. */
  34380. static ShadersRepository: string;
  34381. /**
  34382. * Enable logging of the shader code when a compilation error occurs
  34383. */
  34384. static LogShaderCodeOnCompilationError: boolean;
  34385. /**
  34386. * Name of the effect.
  34387. */
  34388. name: any;
  34389. /**
  34390. * String container all the define statements that should be set on the shader.
  34391. */
  34392. defines: string;
  34393. /**
  34394. * Callback that will be called when the shader is compiled.
  34395. */
  34396. onCompiled: Nullable<(effect: Effect) => void>;
  34397. /**
  34398. * Callback that will be called if an error occurs during shader compilation.
  34399. */
  34400. onError: Nullable<(effect: Effect, errors: string) => void>;
  34401. /**
  34402. * Callback that will be called when effect is bound.
  34403. */
  34404. onBind: Nullable<(effect: Effect) => void>;
  34405. /**
  34406. * Unique ID of the effect.
  34407. */
  34408. uniqueId: number;
  34409. /**
  34410. * Observable that will be called when the shader is compiled.
  34411. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34412. */
  34413. onCompileObservable: Observable<Effect>;
  34414. /**
  34415. * Observable that will be called if an error occurs during shader compilation.
  34416. */
  34417. onErrorObservable: Observable<Effect>;
  34418. /** @hidden */
  34419. _onBindObservable: Nullable<Observable<Effect>>;
  34420. /**
  34421. * @hidden
  34422. * Specifies if the effect was previously ready
  34423. */
  34424. _wasPreviouslyReady: boolean;
  34425. /**
  34426. * Observable that will be called when effect is bound.
  34427. */
  34428. get onBindObservable(): Observable<Effect>;
  34429. /** @hidden */
  34430. _bonesComputationForcedToCPU: boolean;
  34431. private static _uniqueIdSeed;
  34432. private _engine;
  34433. private _uniformBuffersNames;
  34434. private _uniformBuffersNamesList;
  34435. private _uniformsNames;
  34436. private _samplerList;
  34437. private _samplers;
  34438. private _isReady;
  34439. private _compilationError;
  34440. private _allFallbacksProcessed;
  34441. private _attributesNames;
  34442. private _attributes;
  34443. private _attributeLocationByName;
  34444. private _uniforms;
  34445. /**
  34446. * Key for the effect.
  34447. * @hidden
  34448. */
  34449. _key: string;
  34450. private _indexParameters;
  34451. private _fallbacks;
  34452. private _vertexSourceCode;
  34453. private _fragmentSourceCode;
  34454. private _vertexSourceCodeOverride;
  34455. private _fragmentSourceCodeOverride;
  34456. private _transformFeedbackVaryings;
  34457. /**
  34458. * Compiled shader to webGL program.
  34459. * @hidden
  34460. */
  34461. _pipelineContext: Nullable<IPipelineContext>;
  34462. private _valueCache;
  34463. private static _baseCache;
  34464. /**
  34465. * Instantiates an effect.
  34466. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34467. * @param baseName Name of the effect.
  34468. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34469. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34470. * @param samplers List of sampler variables that will be passed to the shader.
  34471. * @param engine Engine to be used to render the effect
  34472. * @param defines Define statements to be added to the shader.
  34473. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34474. * @param onCompiled Callback that will be called when the shader is compiled.
  34475. * @param onError Callback that will be called if an error occurs during shader compilation.
  34476. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34477. */
  34478. 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);
  34479. private _useFinalCode;
  34480. /**
  34481. * Unique key for this effect
  34482. */
  34483. get key(): string;
  34484. /**
  34485. * If the effect has been compiled and prepared.
  34486. * @returns if the effect is compiled and prepared.
  34487. */
  34488. isReady(): boolean;
  34489. private _isReadyInternal;
  34490. /**
  34491. * The engine the effect was initialized with.
  34492. * @returns the engine.
  34493. */
  34494. getEngine(): Engine;
  34495. /**
  34496. * The pipeline context for this effect
  34497. * @returns the associated pipeline context
  34498. */
  34499. getPipelineContext(): Nullable<IPipelineContext>;
  34500. /**
  34501. * The set of names of attribute variables for the shader.
  34502. * @returns An array of attribute names.
  34503. */
  34504. getAttributesNames(): string[];
  34505. /**
  34506. * Returns the attribute at the given index.
  34507. * @param index The index of the attribute.
  34508. * @returns The location of the attribute.
  34509. */
  34510. getAttributeLocation(index: number): number;
  34511. /**
  34512. * Returns the attribute based on the name of the variable.
  34513. * @param name of the attribute to look up.
  34514. * @returns the attribute location.
  34515. */
  34516. getAttributeLocationByName(name: string): number;
  34517. /**
  34518. * The number of attributes.
  34519. * @returns the numnber of attributes.
  34520. */
  34521. getAttributesCount(): number;
  34522. /**
  34523. * Gets the index of a uniform variable.
  34524. * @param uniformName of the uniform to look up.
  34525. * @returns the index.
  34526. */
  34527. getUniformIndex(uniformName: string): number;
  34528. /**
  34529. * Returns the attribute based on the name of the variable.
  34530. * @param uniformName of the uniform to look up.
  34531. * @returns the location of the uniform.
  34532. */
  34533. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34534. /**
  34535. * Returns an array of sampler variable names
  34536. * @returns The array of sampler variable names.
  34537. */
  34538. getSamplers(): string[];
  34539. /**
  34540. * Returns an array of uniform variable names
  34541. * @returns The array of uniform variable names.
  34542. */
  34543. getUniformNames(): string[];
  34544. /**
  34545. * Returns an array of uniform buffer variable names
  34546. * @returns The array of uniform buffer variable names.
  34547. */
  34548. getUniformBuffersNames(): string[];
  34549. /**
  34550. * Returns the index parameters used to create the effect
  34551. * @returns The index parameters object
  34552. */
  34553. getIndexParameters(): any;
  34554. /**
  34555. * The error from the last compilation.
  34556. * @returns the error string.
  34557. */
  34558. getCompilationError(): string;
  34559. /**
  34560. * Gets a boolean indicating that all fallbacks were used during compilation
  34561. * @returns true if all fallbacks were used
  34562. */
  34563. allFallbacksProcessed(): boolean;
  34564. /**
  34565. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34566. * @param func The callback to be used.
  34567. */
  34568. executeWhenCompiled(func: (effect: Effect) => void): void;
  34569. private _checkIsReady;
  34570. private _loadShader;
  34571. /**
  34572. * Gets the vertex shader source code of this effect
  34573. */
  34574. get vertexSourceCode(): string;
  34575. /**
  34576. * Gets the fragment shader source code of this effect
  34577. */
  34578. get fragmentSourceCode(): string;
  34579. /**
  34580. * Recompiles the webGL program
  34581. * @param vertexSourceCode The source code for the vertex shader.
  34582. * @param fragmentSourceCode The source code for the fragment shader.
  34583. * @param onCompiled Callback called when completed.
  34584. * @param onError Callback called on error.
  34585. * @hidden
  34586. */
  34587. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34588. /**
  34589. * Prepares the effect
  34590. * @hidden
  34591. */
  34592. _prepareEffect(): void;
  34593. private _getShaderCodeAndErrorLine;
  34594. private _processCompilationErrors;
  34595. /**
  34596. * Checks if the effect is supported. (Must be called after compilation)
  34597. */
  34598. get isSupported(): boolean;
  34599. /**
  34600. * Binds a texture to the engine to be used as output of the shader.
  34601. * @param channel Name of the output variable.
  34602. * @param texture Texture to bind.
  34603. * @hidden
  34604. */
  34605. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34606. /**
  34607. * Sets a texture on the engine to be used in the shader.
  34608. * @param channel Name of the sampler variable.
  34609. * @param texture Texture to set.
  34610. */
  34611. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34612. /**
  34613. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34614. * @param channel Name of the sampler variable.
  34615. * @param texture Texture to set.
  34616. */
  34617. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34618. /**
  34619. * Sets an array of textures on the engine to be used in the shader.
  34620. * @param channel Name of the variable.
  34621. * @param textures Textures to set.
  34622. */
  34623. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34624. /**
  34625. * 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)
  34626. * @param channel Name of the sampler variable.
  34627. * @param postProcess Post process to get the input texture from.
  34628. */
  34629. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34630. /**
  34631. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34632. * 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)
  34633. * @param channel Name of the sampler variable.
  34634. * @param postProcess Post process to get the output texture from.
  34635. */
  34636. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34637. /** @hidden */
  34638. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34639. /** @hidden */
  34640. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34641. /** @hidden */
  34642. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34643. /** @hidden */
  34644. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34645. /**
  34646. * Binds a buffer to a uniform.
  34647. * @param buffer Buffer to bind.
  34648. * @param name Name of the uniform variable to bind to.
  34649. */
  34650. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34651. /**
  34652. * Binds block to a uniform.
  34653. * @param blockName Name of the block to bind.
  34654. * @param index Index to bind.
  34655. */
  34656. bindUniformBlock(blockName: string, index: number): void;
  34657. /**
  34658. * Sets an interger value on a uniform variable.
  34659. * @param uniformName Name of the variable.
  34660. * @param value Value to be set.
  34661. * @returns this effect.
  34662. */
  34663. setInt(uniformName: string, value: number): Effect;
  34664. /**
  34665. * Sets an int array on a uniform variable.
  34666. * @param uniformName Name of the variable.
  34667. * @param array array to be set.
  34668. * @returns this effect.
  34669. */
  34670. setIntArray(uniformName: string, array: Int32Array): Effect;
  34671. /**
  34672. * 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)
  34673. * @param uniformName Name of the variable.
  34674. * @param array array to be set.
  34675. * @returns this effect.
  34676. */
  34677. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34678. /**
  34679. * 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)
  34680. * @param uniformName Name of the variable.
  34681. * @param array array to be set.
  34682. * @returns this effect.
  34683. */
  34684. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34685. /**
  34686. * 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)
  34687. * @param uniformName Name of the variable.
  34688. * @param array array to be set.
  34689. * @returns this effect.
  34690. */
  34691. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34692. /**
  34693. * Sets an float array on a uniform variable.
  34694. * @param uniformName Name of the variable.
  34695. * @param array array to be set.
  34696. * @returns this effect.
  34697. */
  34698. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34699. /**
  34700. * 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)
  34701. * @param uniformName Name of the variable.
  34702. * @param array array to be set.
  34703. * @returns this effect.
  34704. */
  34705. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34706. /**
  34707. * 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)
  34708. * @param uniformName Name of the variable.
  34709. * @param array array to be set.
  34710. * @returns this effect.
  34711. */
  34712. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34713. /**
  34714. * 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)
  34715. * @param uniformName Name of the variable.
  34716. * @param array array to be set.
  34717. * @returns this effect.
  34718. */
  34719. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34720. /**
  34721. * Sets an array on a uniform variable.
  34722. * @param uniformName Name of the variable.
  34723. * @param array array to be set.
  34724. * @returns this effect.
  34725. */
  34726. setArray(uniformName: string, array: number[]): Effect;
  34727. /**
  34728. * 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)
  34729. * @param uniformName Name of the variable.
  34730. * @param array array to be set.
  34731. * @returns this effect.
  34732. */
  34733. setArray2(uniformName: string, array: number[]): Effect;
  34734. /**
  34735. * 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)
  34736. * @param uniformName Name of the variable.
  34737. * @param array array to be set.
  34738. * @returns this effect.
  34739. */
  34740. setArray3(uniformName: string, array: number[]): Effect;
  34741. /**
  34742. * 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)
  34743. * @param uniformName Name of the variable.
  34744. * @param array array to be set.
  34745. * @returns this effect.
  34746. */
  34747. setArray4(uniformName: string, array: number[]): Effect;
  34748. /**
  34749. * Sets matrices on a uniform variable.
  34750. * @param uniformName Name of the variable.
  34751. * @param matrices matrices to be set.
  34752. * @returns this effect.
  34753. */
  34754. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34755. /**
  34756. * Sets matrix on a uniform variable.
  34757. * @param uniformName Name of the variable.
  34758. * @param matrix matrix to be set.
  34759. * @returns this effect.
  34760. */
  34761. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34762. /**
  34763. * 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)
  34764. * @param uniformName Name of the variable.
  34765. * @param matrix matrix to be set.
  34766. * @returns this effect.
  34767. */
  34768. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34769. /**
  34770. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34771. * @param uniformName Name of the variable.
  34772. * @param matrix matrix to be set.
  34773. * @returns this effect.
  34774. */
  34775. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34776. /**
  34777. * Sets a float on a uniform variable.
  34778. * @param uniformName Name of the variable.
  34779. * @param value value to be set.
  34780. * @returns this effect.
  34781. */
  34782. setFloat(uniformName: string, value: number): Effect;
  34783. /**
  34784. * Sets a boolean on a uniform variable.
  34785. * @param uniformName Name of the variable.
  34786. * @param bool value to be set.
  34787. * @returns this effect.
  34788. */
  34789. setBool(uniformName: string, bool: boolean): Effect;
  34790. /**
  34791. * Sets a Vector2 on a uniform variable.
  34792. * @param uniformName Name of the variable.
  34793. * @param vector2 vector2 to be set.
  34794. * @returns this effect.
  34795. */
  34796. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34797. /**
  34798. * Sets a float2 on a uniform variable.
  34799. * @param uniformName Name of the variable.
  34800. * @param x First float in float2.
  34801. * @param y Second float in float2.
  34802. * @returns this effect.
  34803. */
  34804. setFloat2(uniformName: string, x: number, y: number): Effect;
  34805. /**
  34806. * Sets a Vector3 on a uniform variable.
  34807. * @param uniformName Name of the variable.
  34808. * @param vector3 Value to be set.
  34809. * @returns this effect.
  34810. */
  34811. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34812. /**
  34813. * Sets a float3 on a uniform variable.
  34814. * @param uniformName Name of the variable.
  34815. * @param x First float in float3.
  34816. * @param y Second float in float3.
  34817. * @param z Third float in float3.
  34818. * @returns this effect.
  34819. */
  34820. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34821. /**
  34822. * Sets a Vector4 on a uniform variable.
  34823. * @param uniformName Name of the variable.
  34824. * @param vector4 Value to be set.
  34825. * @returns this effect.
  34826. */
  34827. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34828. /**
  34829. * Sets a float4 on a uniform variable.
  34830. * @param uniformName Name of the variable.
  34831. * @param x First float in float4.
  34832. * @param y Second float in float4.
  34833. * @param z Third float in float4.
  34834. * @param w Fourth float in float4.
  34835. * @returns this effect.
  34836. */
  34837. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34838. /**
  34839. * Sets a Color3 on a uniform variable.
  34840. * @param uniformName Name of the variable.
  34841. * @param color3 Value to be set.
  34842. * @returns this effect.
  34843. */
  34844. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34845. /**
  34846. * Sets a Color4 on a uniform variable.
  34847. * @param uniformName Name of the variable.
  34848. * @param color3 Value to be set.
  34849. * @param alpha Alpha value to be set.
  34850. * @returns this effect.
  34851. */
  34852. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34853. /**
  34854. * Sets a Color4 on a uniform variable
  34855. * @param uniformName defines the name of the variable
  34856. * @param color4 defines the value to be set
  34857. * @returns this effect.
  34858. */
  34859. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34860. /** Release all associated resources */
  34861. dispose(): void;
  34862. /**
  34863. * This function will add a new shader to the shader store
  34864. * @param name the name of the shader
  34865. * @param pixelShader optional pixel shader content
  34866. * @param vertexShader optional vertex shader content
  34867. */
  34868. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34869. /**
  34870. * Store of each shader (The can be looked up using effect.key)
  34871. */
  34872. static ShadersStore: {
  34873. [key: string]: string;
  34874. };
  34875. /**
  34876. * Store of each included file for a shader (The can be looked up using effect.key)
  34877. */
  34878. static IncludesShadersStore: {
  34879. [key: string]: string;
  34880. };
  34881. /**
  34882. * Resets the cache of effects.
  34883. */
  34884. static ResetCache(): void;
  34885. }
  34886. }
  34887. declare module "babylonjs/Engines/engineCapabilities" {
  34888. /**
  34889. * Interface used to describe the capabilities of the engine relatively to the current browser
  34890. */
  34891. export interface EngineCapabilities {
  34892. /** Maximum textures units per fragment shader */
  34893. maxTexturesImageUnits: number;
  34894. /** Maximum texture units per vertex shader */
  34895. maxVertexTextureImageUnits: number;
  34896. /** Maximum textures units in the entire pipeline */
  34897. maxCombinedTexturesImageUnits: number;
  34898. /** Maximum texture size */
  34899. maxTextureSize: number;
  34900. /** Maximum texture samples */
  34901. maxSamples?: number;
  34902. /** Maximum cube texture size */
  34903. maxCubemapTextureSize: number;
  34904. /** Maximum render texture size */
  34905. maxRenderTextureSize: number;
  34906. /** Maximum number of vertex attributes */
  34907. maxVertexAttribs: number;
  34908. /** Maximum number of varyings */
  34909. maxVaryingVectors: number;
  34910. /** Maximum number of uniforms per vertex shader */
  34911. maxVertexUniformVectors: number;
  34912. /** Maximum number of uniforms per fragment shader */
  34913. maxFragmentUniformVectors: number;
  34914. /** Defines if standard derivates (dx/dy) are supported */
  34915. standardDerivatives: boolean;
  34916. /** Defines if s3tc texture compression is supported */
  34917. s3tc?: WEBGL_compressed_texture_s3tc;
  34918. /** Defines if pvrtc texture compression is supported */
  34919. pvrtc: any;
  34920. /** Defines if etc1 texture compression is supported */
  34921. etc1: any;
  34922. /** Defines if etc2 texture compression is supported */
  34923. etc2: any;
  34924. /** Defines if astc texture compression is supported */
  34925. astc: any;
  34926. /** Defines if float textures are supported */
  34927. textureFloat: boolean;
  34928. /** Defines if vertex array objects are supported */
  34929. vertexArrayObject: boolean;
  34930. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34931. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34932. /** Gets the maximum level of anisotropy supported */
  34933. maxAnisotropy: number;
  34934. /** Defines if instancing is supported */
  34935. instancedArrays: boolean;
  34936. /** Defines if 32 bits indices are supported */
  34937. uintIndices: boolean;
  34938. /** Defines if high precision shaders are supported */
  34939. highPrecisionShaderSupported: boolean;
  34940. /** Defines if depth reading in the fragment shader is supported */
  34941. fragmentDepthSupported: boolean;
  34942. /** Defines if float texture linear filtering is supported*/
  34943. textureFloatLinearFiltering: boolean;
  34944. /** Defines if rendering to float textures is supported */
  34945. textureFloatRender: boolean;
  34946. /** Defines if half float textures are supported*/
  34947. textureHalfFloat: boolean;
  34948. /** Defines if half float texture linear filtering is supported*/
  34949. textureHalfFloatLinearFiltering: boolean;
  34950. /** Defines if rendering to half float textures is supported */
  34951. textureHalfFloatRender: boolean;
  34952. /** Defines if textureLOD shader command is supported */
  34953. textureLOD: boolean;
  34954. /** Defines if draw buffers extension is supported */
  34955. drawBuffersExtension: boolean;
  34956. /** Defines if depth textures are supported */
  34957. depthTextureExtension: boolean;
  34958. /** Defines if float color buffer are supported */
  34959. colorBufferFloat: boolean;
  34960. /** Gets disjoint timer query extension (null if not supported) */
  34961. timerQuery?: EXT_disjoint_timer_query;
  34962. /** Defines if timestamp can be used with timer query */
  34963. canUseTimestampForTimerQuery: boolean;
  34964. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34965. multiview?: any;
  34966. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34967. oculusMultiview?: any;
  34968. /** Function used to let the system compiles shaders in background */
  34969. parallelShaderCompile?: {
  34970. COMPLETION_STATUS_KHR: number;
  34971. };
  34972. /** Max number of texture samples for MSAA */
  34973. maxMSAASamples: number;
  34974. /** Defines if the blend min max extension is supported */
  34975. blendMinMax: boolean;
  34976. }
  34977. }
  34978. declare module "babylonjs/States/depthCullingState" {
  34979. import { Nullable } from "babylonjs/types";
  34980. /**
  34981. * @hidden
  34982. **/
  34983. export class DepthCullingState {
  34984. private _isDepthTestDirty;
  34985. private _isDepthMaskDirty;
  34986. private _isDepthFuncDirty;
  34987. private _isCullFaceDirty;
  34988. private _isCullDirty;
  34989. private _isZOffsetDirty;
  34990. private _isFrontFaceDirty;
  34991. private _depthTest;
  34992. private _depthMask;
  34993. private _depthFunc;
  34994. private _cull;
  34995. private _cullFace;
  34996. private _zOffset;
  34997. private _frontFace;
  34998. /**
  34999. * Initializes the state.
  35000. */
  35001. constructor();
  35002. get isDirty(): boolean;
  35003. get zOffset(): number;
  35004. set zOffset(value: number);
  35005. get cullFace(): Nullable<number>;
  35006. set cullFace(value: Nullable<number>);
  35007. get cull(): Nullable<boolean>;
  35008. set cull(value: Nullable<boolean>);
  35009. get depthFunc(): Nullable<number>;
  35010. set depthFunc(value: Nullable<number>);
  35011. get depthMask(): boolean;
  35012. set depthMask(value: boolean);
  35013. get depthTest(): boolean;
  35014. set depthTest(value: boolean);
  35015. get frontFace(): Nullable<number>;
  35016. set frontFace(value: Nullable<number>);
  35017. reset(): void;
  35018. apply(gl: WebGLRenderingContext): void;
  35019. }
  35020. }
  35021. declare module "babylonjs/States/stencilState" {
  35022. /**
  35023. * @hidden
  35024. **/
  35025. export class StencilState {
  35026. /** 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 */
  35027. static readonly ALWAYS: number;
  35028. /** Passed to stencilOperation to specify that stencil value must be kept */
  35029. static readonly KEEP: number;
  35030. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35031. static readonly REPLACE: number;
  35032. private _isStencilTestDirty;
  35033. private _isStencilMaskDirty;
  35034. private _isStencilFuncDirty;
  35035. private _isStencilOpDirty;
  35036. private _stencilTest;
  35037. private _stencilMask;
  35038. private _stencilFunc;
  35039. private _stencilFuncRef;
  35040. private _stencilFuncMask;
  35041. private _stencilOpStencilFail;
  35042. private _stencilOpDepthFail;
  35043. private _stencilOpStencilDepthPass;
  35044. get isDirty(): boolean;
  35045. get stencilFunc(): number;
  35046. set stencilFunc(value: number);
  35047. get stencilFuncRef(): number;
  35048. set stencilFuncRef(value: number);
  35049. get stencilFuncMask(): number;
  35050. set stencilFuncMask(value: number);
  35051. get stencilOpStencilFail(): number;
  35052. set stencilOpStencilFail(value: number);
  35053. get stencilOpDepthFail(): number;
  35054. set stencilOpDepthFail(value: number);
  35055. get stencilOpStencilDepthPass(): number;
  35056. set stencilOpStencilDepthPass(value: number);
  35057. get stencilMask(): number;
  35058. set stencilMask(value: number);
  35059. get stencilTest(): boolean;
  35060. set stencilTest(value: boolean);
  35061. constructor();
  35062. reset(): void;
  35063. apply(gl: WebGLRenderingContext): void;
  35064. }
  35065. }
  35066. declare module "babylonjs/States/alphaCullingState" {
  35067. /**
  35068. * @hidden
  35069. **/
  35070. export class AlphaState {
  35071. private _isAlphaBlendDirty;
  35072. private _isBlendFunctionParametersDirty;
  35073. private _isBlendEquationParametersDirty;
  35074. private _isBlendConstantsDirty;
  35075. private _alphaBlend;
  35076. private _blendFunctionParameters;
  35077. private _blendEquationParameters;
  35078. private _blendConstants;
  35079. /**
  35080. * Initializes the state.
  35081. */
  35082. constructor();
  35083. get isDirty(): boolean;
  35084. get alphaBlend(): boolean;
  35085. set alphaBlend(value: boolean);
  35086. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35087. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35088. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35089. reset(): void;
  35090. apply(gl: WebGLRenderingContext): void;
  35091. }
  35092. }
  35093. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35094. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35095. /** @hidden */
  35096. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35097. attributeProcessor(attribute: string): string;
  35098. varyingProcessor(varying: string, isFragment: boolean): string;
  35099. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35100. }
  35101. }
  35102. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35103. /**
  35104. * Interface for attribute information associated with buffer instanciation
  35105. */
  35106. export interface InstancingAttributeInfo {
  35107. /**
  35108. * Name of the GLSL attribute
  35109. * if attribute index is not specified, this is used to retrieve the index from the effect
  35110. */
  35111. attributeName: string;
  35112. /**
  35113. * Index/offset of the attribute in the vertex shader
  35114. * if not specified, this will be computes from the name.
  35115. */
  35116. index?: number;
  35117. /**
  35118. * size of the attribute, 1, 2, 3 or 4
  35119. */
  35120. attributeSize: number;
  35121. /**
  35122. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35123. */
  35124. offset: number;
  35125. /**
  35126. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35127. * default to 1
  35128. */
  35129. divisor?: number;
  35130. /**
  35131. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35132. * default is FLOAT
  35133. */
  35134. attributeType?: number;
  35135. /**
  35136. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35137. */
  35138. normalized?: boolean;
  35139. }
  35140. }
  35141. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35142. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35143. import { Nullable } from "babylonjs/types";
  35144. module "babylonjs/Engines/thinEngine" {
  35145. interface ThinEngine {
  35146. /**
  35147. * Update a video texture
  35148. * @param texture defines the texture to update
  35149. * @param video defines the video element to use
  35150. * @param invertY defines if data must be stored with Y axis inverted
  35151. */
  35152. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35153. }
  35154. }
  35155. }
  35156. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  35157. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35158. import { Nullable } from "babylonjs/types";
  35159. module "babylonjs/Engines/thinEngine" {
  35160. interface ThinEngine {
  35161. /**
  35162. * Creates a dynamic texture
  35163. * @param width defines the width of the texture
  35164. * @param height defines the height of the texture
  35165. * @param generateMipMaps defines if the engine should generate the mip levels
  35166. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35167. * @returns the dynamic texture inside an InternalTexture
  35168. */
  35169. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35170. /**
  35171. * Update the content of a dynamic texture
  35172. * @param texture defines the texture to update
  35173. * @param canvas defines the canvas containing the source
  35174. * @param invertY defines if data must be stored with Y axis inverted
  35175. * @param premulAlpha defines if alpha is stored as premultiplied
  35176. * @param format defines the format of the data
  35177. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35178. */
  35179. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35180. }
  35181. }
  35182. }
  35183. declare module "babylonjs/Materials/Textures/videoTexture" {
  35184. import { Observable } from "babylonjs/Misc/observable";
  35185. import { Nullable } from "babylonjs/types";
  35186. import { Scene } from "babylonjs/scene";
  35187. import { Texture } from "babylonjs/Materials/Textures/texture";
  35188. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35189. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35190. /**
  35191. * Settings for finer control over video usage
  35192. */
  35193. export interface VideoTextureSettings {
  35194. /**
  35195. * Applies `autoplay` to video, if specified
  35196. */
  35197. autoPlay?: boolean;
  35198. /**
  35199. * Applies `loop` to video, if specified
  35200. */
  35201. loop?: boolean;
  35202. /**
  35203. * Automatically updates internal texture from video at every frame in the render loop
  35204. */
  35205. autoUpdateTexture: boolean;
  35206. /**
  35207. * Image src displayed during the video loading or until the user interacts with the video.
  35208. */
  35209. poster?: string;
  35210. }
  35211. /**
  35212. * If you want to display a video in your scene, this is the special texture for that.
  35213. * This special texture works similar to other textures, with the exception of a few parameters.
  35214. * @see https://doc.babylonjs.com/how_to/video_texture
  35215. */
  35216. export class VideoTexture extends Texture {
  35217. /**
  35218. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35219. */
  35220. readonly autoUpdateTexture: boolean;
  35221. /**
  35222. * The video instance used by the texture internally
  35223. */
  35224. readonly video: HTMLVideoElement;
  35225. private _onUserActionRequestedObservable;
  35226. /**
  35227. * Event triggerd when a dom action is required by the user to play the video.
  35228. * This happens due to recent changes in browser policies preventing video to auto start.
  35229. */
  35230. get onUserActionRequestedObservable(): Observable<Texture>;
  35231. private _generateMipMaps;
  35232. private _stillImageCaptured;
  35233. private _displayingPosterTexture;
  35234. private _settings;
  35235. private _createInternalTextureOnEvent;
  35236. private _frameId;
  35237. private _currentSrc;
  35238. /**
  35239. * Creates a video texture.
  35240. * If you want to display a video in your scene, this is the special texture for that.
  35241. * This special texture works similar to other textures, with the exception of a few parameters.
  35242. * @see https://doc.babylonjs.com/how_to/video_texture
  35243. * @param name optional name, will detect from video source, if not defined
  35244. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35245. * @param scene is obviously the current scene.
  35246. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35247. * @param invertY is false by default but can be used to invert video on Y axis
  35248. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35249. * @param settings allows finer control over video usage
  35250. */
  35251. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35252. private _getName;
  35253. private _getVideo;
  35254. private _createInternalTexture;
  35255. private reset;
  35256. /**
  35257. * @hidden Internal method to initiate `update`.
  35258. */
  35259. _rebuild(): void;
  35260. /**
  35261. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35262. */
  35263. update(): void;
  35264. /**
  35265. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35266. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35267. */
  35268. updateTexture(isVisible: boolean): void;
  35269. protected _updateInternalTexture: () => void;
  35270. /**
  35271. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35272. * @param url New url.
  35273. */
  35274. updateURL(url: string): void;
  35275. /**
  35276. * Clones the texture.
  35277. * @returns the cloned texture
  35278. */
  35279. clone(): VideoTexture;
  35280. /**
  35281. * Dispose the texture and release its associated resources.
  35282. */
  35283. dispose(): void;
  35284. /**
  35285. * Creates a video texture straight from a stream.
  35286. * @param scene Define the scene the texture should be created in
  35287. * @param stream Define the stream the texture should be created from
  35288. * @returns The created video texture as a promise
  35289. */
  35290. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35291. /**
  35292. * Creates a video texture straight from your WebCam video feed.
  35293. * @param scene Define the scene the texture should be created in
  35294. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35295. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35296. * @returns The created video texture as a promise
  35297. */
  35298. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35299. minWidth: number;
  35300. maxWidth: number;
  35301. minHeight: number;
  35302. maxHeight: number;
  35303. deviceId: string;
  35304. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35305. /**
  35306. * Creates a video texture straight from your WebCam video feed.
  35307. * @param scene Define the scene the texture should be created in
  35308. * @param onReady Define a callback to triggered once the texture will be ready
  35309. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35310. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35311. */
  35312. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35313. minWidth: number;
  35314. maxWidth: number;
  35315. minHeight: number;
  35316. maxHeight: number;
  35317. deviceId: string;
  35318. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35319. }
  35320. }
  35321. declare module "babylonjs/Engines/thinEngine" {
  35322. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35323. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35324. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35325. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35326. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35327. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35328. import { Observable } from "babylonjs/Misc/observable";
  35329. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35330. import { StencilState } from "babylonjs/States/stencilState";
  35331. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35332. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35333. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35334. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35335. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35336. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35337. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35338. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35339. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35340. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35341. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35342. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35343. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35344. import { WebRequest } from "babylonjs/Misc/webRequest";
  35345. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35346. /**
  35347. * Defines the interface used by objects working like Scene
  35348. * @hidden
  35349. */
  35350. export interface ISceneLike {
  35351. _addPendingData(data: any): void;
  35352. _removePendingData(data: any): void;
  35353. offlineProvider: IOfflineProvider;
  35354. }
  35355. /** Interface defining initialization parameters for Engine class */
  35356. export interface EngineOptions extends WebGLContextAttributes {
  35357. /**
  35358. * Defines if the engine should no exceed a specified device ratio
  35359. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35360. */
  35361. limitDeviceRatio?: number;
  35362. /**
  35363. * Defines if webvr should be enabled automatically
  35364. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35365. */
  35366. autoEnableWebVR?: boolean;
  35367. /**
  35368. * Defines if webgl2 should be turned off even if supported
  35369. * @see http://doc.babylonjs.com/features/webgl2
  35370. */
  35371. disableWebGL2Support?: boolean;
  35372. /**
  35373. * Defines if webaudio should be initialized as well
  35374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35375. */
  35376. audioEngine?: boolean;
  35377. /**
  35378. * Defines if animations should run using a deterministic lock step
  35379. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35380. */
  35381. deterministicLockstep?: boolean;
  35382. /** Defines the maximum steps to use with deterministic lock step mode */
  35383. lockstepMaxSteps?: number;
  35384. /** Defines the seconds between each deterministic lock step */
  35385. timeStep?: number;
  35386. /**
  35387. * Defines that engine should ignore context lost events
  35388. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35389. */
  35390. doNotHandleContextLost?: boolean;
  35391. /**
  35392. * Defines that engine should ignore modifying touch action attribute and style
  35393. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35394. */
  35395. doNotHandleTouchAction?: boolean;
  35396. /**
  35397. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35398. */
  35399. useHighPrecisionFloats?: boolean;
  35400. /**
  35401. * Make the canvas XR Compatible for XR sessions
  35402. */
  35403. xrCompatible?: boolean;
  35404. }
  35405. /**
  35406. * The base engine class (root of all engines)
  35407. */
  35408. export class ThinEngine {
  35409. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35410. static ExceptionList: ({
  35411. key: string;
  35412. capture: string;
  35413. captureConstraint: number;
  35414. targets: string[];
  35415. } | {
  35416. key: string;
  35417. capture: null;
  35418. captureConstraint: null;
  35419. targets: string[];
  35420. })[];
  35421. /** @hidden */
  35422. static _TextureLoaders: IInternalTextureLoader[];
  35423. /**
  35424. * Returns the current npm package of the sdk
  35425. */
  35426. static get NpmPackage(): string;
  35427. /**
  35428. * Returns the current version of the framework
  35429. */
  35430. static get Version(): string;
  35431. /**
  35432. * Returns a string describing the current engine
  35433. */
  35434. get description(): string;
  35435. /**
  35436. * Gets or sets the epsilon value used by collision engine
  35437. */
  35438. static CollisionsEpsilon: number;
  35439. /**
  35440. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35441. */
  35442. static get ShadersRepository(): string;
  35443. static set ShadersRepository(value: string);
  35444. /** @hidden */
  35445. _shaderProcessor: IShaderProcessor;
  35446. /**
  35447. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35448. */
  35449. forcePOTTextures: boolean;
  35450. /**
  35451. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35452. */
  35453. isFullscreen: boolean;
  35454. /**
  35455. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35456. */
  35457. cullBackFaces: boolean;
  35458. /**
  35459. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35460. */
  35461. renderEvenInBackground: boolean;
  35462. /**
  35463. * Gets or sets a boolean indicating that cache can be kept between frames
  35464. */
  35465. preventCacheWipeBetweenFrames: boolean;
  35466. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35467. validateShaderPrograms: boolean;
  35468. /**
  35469. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35470. * This can provide greater z depth for distant objects.
  35471. */
  35472. useReverseDepthBuffer: boolean;
  35473. /**
  35474. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35475. */
  35476. disableUniformBuffers: boolean;
  35477. /** @hidden */
  35478. _uniformBuffers: UniformBuffer[];
  35479. /**
  35480. * Gets a boolean indicating that the engine supports uniform buffers
  35481. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35482. */
  35483. get supportsUniformBuffers(): boolean;
  35484. /** @hidden */
  35485. _gl: WebGLRenderingContext;
  35486. /** @hidden */
  35487. _webGLVersion: number;
  35488. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35489. protected _windowIsBackground: boolean;
  35490. protected _creationOptions: EngineOptions;
  35491. protected _highPrecisionShadersAllowed: boolean;
  35492. /** @hidden */
  35493. get _shouldUseHighPrecisionShader(): boolean;
  35494. /**
  35495. * Gets a boolean indicating that only power of 2 textures are supported
  35496. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35497. */
  35498. get needPOTTextures(): boolean;
  35499. /** @hidden */
  35500. _badOS: boolean;
  35501. /** @hidden */
  35502. _badDesktopOS: boolean;
  35503. private _hardwareScalingLevel;
  35504. /** @hidden */
  35505. _caps: EngineCapabilities;
  35506. private _isStencilEnable;
  35507. private _glVersion;
  35508. private _glRenderer;
  35509. private _glVendor;
  35510. /** @hidden */
  35511. _videoTextureSupported: boolean;
  35512. protected _renderingQueueLaunched: boolean;
  35513. protected _activeRenderLoops: (() => void)[];
  35514. /**
  35515. * Observable signaled when a context lost event is raised
  35516. */
  35517. onContextLostObservable: Observable<ThinEngine>;
  35518. /**
  35519. * Observable signaled when a context restored event is raised
  35520. */
  35521. onContextRestoredObservable: Observable<ThinEngine>;
  35522. private _onContextLost;
  35523. private _onContextRestored;
  35524. protected _contextWasLost: boolean;
  35525. /** @hidden */
  35526. _doNotHandleContextLost: boolean;
  35527. /**
  35528. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35529. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35530. */
  35531. get doNotHandleContextLost(): boolean;
  35532. set doNotHandleContextLost(value: boolean);
  35533. /**
  35534. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35535. */
  35536. disableVertexArrayObjects: boolean;
  35537. /** @hidden */
  35538. protected _colorWrite: boolean;
  35539. /** @hidden */
  35540. protected _colorWriteChanged: boolean;
  35541. /** @hidden */
  35542. protected _depthCullingState: DepthCullingState;
  35543. /** @hidden */
  35544. protected _stencilState: StencilState;
  35545. /** @hidden */
  35546. _alphaState: AlphaState;
  35547. /** @hidden */
  35548. _alphaMode: number;
  35549. /** @hidden */
  35550. _alphaEquation: number;
  35551. /** @hidden */
  35552. _internalTexturesCache: InternalTexture[];
  35553. /** @hidden */
  35554. protected _activeChannel: number;
  35555. private _currentTextureChannel;
  35556. /** @hidden */
  35557. protected _boundTexturesCache: {
  35558. [key: string]: Nullable<InternalTexture>;
  35559. };
  35560. /** @hidden */
  35561. protected _currentEffect: Nullable<Effect>;
  35562. /** @hidden */
  35563. protected _currentProgram: Nullable<WebGLProgram>;
  35564. private _compiledEffects;
  35565. private _vertexAttribArraysEnabled;
  35566. /** @hidden */
  35567. protected _cachedViewport: Nullable<IViewportLike>;
  35568. private _cachedVertexArrayObject;
  35569. /** @hidden */
  35570. protected _cachedVertexBuffers: any;
  35571. /** @hidden */
  35572. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35573. /** @hidden */
  35574. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35575. /** @hidden */
  35576. _currentRenderTarget: Nullable<InternalTexture>;
  35577. private _uintIndicesCurrentlySet;
  35578. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35579. /** @hidden */
  35580. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35581. /** @hidden */
  35582. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35583. private _currentBufferPointers;
  35584. private _currentInstanceLocations;
  35585. private _currentInstanceBuffers;
  35586. private _textureUnits;
  35587. /** @hidden */
  35588. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35589. /** @hidden */
  35590. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35591. /** @hidden */
  35592. _boundRenderFunction: any;
  35593. private _vaoRecordInProgress;
  35594. private _mustWipeVertexAttributes;
  35595. private _emptyTexture;
  35596. private _emptyCubeTexture;
  35597. private _emptyTexture3D;
  35598. private _emptyTexture2DArray;
  35599. /** @hidden */
  35600. _frameHandler: number;
  35601. private _nextFreeTextureSlots;
  35602. private _maxSimultaneousTextures;
  35603. private _activeRequests;
  35604. /** @hidden */
  35605. _transformTextureUrl: Nullable<(url: string) => string>;
  35606. protected get _supportsHardwareTextureRescaling(): boolean;
  35607. private _framebufferDimensionsObject;
  35608. /**
  35609. * sets the object from which width and height will be taken from when getting render width and height
  35610. * Will fallback to the gl object
  35611. * @param dimensions the framebuffer width and height that will be used.
  35612. */
  35613. set framebufferDimensionsObject(dimensions: Nullable<{
  35614. framebufferWidth: number;
  35615. framebufferHeight: number;
  35616. }>);
  35617. /**
  35618. * Gets the current viewport
  35619. */
  35620. get currentViewport(): Nullable<IViewportLike>;
  35621. /**
  35622. * Gets the default empty texture
  35623. */
  35624. get emptyTexture(): InternalTexture;
  35625. /**
  35626. * Gets the default empty 3D texture
  35627. */
  35628. get emptyTexture3D(): InternalTexture;
  35629. /**
  35630. * Gets the default empty 2D array texture
  35631. */
  35632. get emptyTexture2DArray(): InternalTexture;
  35633. /**
  35634. * Gets the default empty cube texture
  35635. */
  35636. get emptyCubeTexture(): InternalTexture;
  35637. /**
  35638. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35639. */
  35640. readonly premultipliedAlpha: boolean;
  35641. /**
  35642. * Observable event triggered before each texture is initialized
  35643. */
  35644. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35645. /**
  35646. * Creates a new engine
  35647. * @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
  35648. * @param antialias defines enable antialiasing (default: false)
  35649. * @param options defines further options to be sent to the getContext() function
  35650. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35651. */
  35652. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35653. private _rebuildInternalTextures;
  35654. private _rebuildEffects;
  35655. /**
  35656. * Gets a boolean indicating if all created effects are ready
  35657. * @returns true if all effects are ready
  35658. */
  35659. areAllEffectsReady(): boolean;
  35660. protected _rebuildBuffers(): void;
  35661. protected _initGLContext(): void;
  35662. /**
  35663. * Gets version of the current webGL context
  35664. */
  35665. get webGLVersion(): number;
  35666. /**
  35667. * Gets a string idenfifying the name of the class
  35668. * @returns "Engine" string
  35669. */
  35670. getClassName(): string;
  35671. /**
  35672. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35673. */
  35674. get isStencilEnable(): boolean;
  35675. /** @hidden */
  35676. _prepareWorkingCanvas(): void;
  35677. /**
  35678. * Reset the texture cache to empty state
  35679. */
  35680. resetTextureCache(): void;
  35681. /**
  35682. * Gets an object containing information about the current webGL context
  35683. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35684. */
  35685. getGlInfo(): {
  35686. vendor: string;
  35687. renderer: string;
  35688. version: string;
  35689. };
  35690. /**
  35691. * Defines the hardware scaling level.
  35692. * By default the hardware scaling level is computed from the window device ratio.
  35693. * 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.
  35694. * @param level defines the level to use
  35695. */
  35696. setHardwareScalingLevel(level: number): void;
  35697. /**
  35698. * Gets the current hardware scaling level.
  35699. * By default the hardware scaling level is computed from the window device ratio.
  35700. * 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.
  35701. * @returns a number indicating the current hardware scaling level
  35702. */
  35703. getHardwareScalingLevel(): number;
  35704. /**
  35705. * Gets the list of loaded textures
  35706. * @returns an array containing all loaded textures
  35707. */
  35708. getLoadedTexturesCache(): InternalTexture[];
  35709. /**
  35710. * Gets the object containing all engine capabilities
  35711. * @returns the EngineCapabilities object
  35712. */
  35713. getCaps(): EngineCapabilities;
  35714. /**
  35715. * stop executing a render loop function and remove it from the execution array
  35716. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35717. */
  35718. stopRenderLoop(renderFunction?: () => void): void;
  35719. /** @hidden */
  35720. _renderLoop(): void;
  35721. /**
  35722. * Gets the HTML canvas attached with the current webGL context
  35723. * @returns a HTML canvas
  35724. */
  35725. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35726. /**
  35727. * Gets host window
  35728. * @returns the host window object
  35729. */
  35730. getHostWindow(): Nullable<Window>;
  35731. /**
  35732. * Gets the current render width
  35733. * @param useScreen defines if screen size must be used (or the current render target if any)
  35734. * @returns a number defining the current render width
  35735. */
  35736. getRenderWidth(useScreen?: boolean): number;
  35737. /**
  35738. * Gets the current render height
  35739. * @param useScreen defines if screen size must be used (or the current render target if any)
  35740. * @returns a number defining the current render height
  35741. */
  35742. getRenderHeight(useScreen?: boolean): number;
  35743. /**
  35744. * Can be used to override the current requestAnimationFrame requester.
  35745. * @hidden
  35746. */
  35747. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35748. /**
  35749. * Register and execute a render loop. The engine can have more than one render function
  35750. * @param renderFunction defines the function to continuously execute
  35751. */
  35752. runRenderLoop(renderFunction: () => void): void;
  35753. /**
  35754. * Clear the current render buffer or the current render target (if any is set up)
  35755. * @param color defines the color to use
  35756. * @param backBuffer defines if the back buffer must be cleared
  35757. * @param depth defines if the depth buffer must be cleared
  35758. * @param stencil defines if the stencil buffer must be cleared
  35759. */
  35760. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35761. private _viewportCached;
  35762. /** @hidden */
  35763. _viewport(x: number, y: number, width: number, height: number): void;
  35764. /**
  35765. * Set the WebGL's viewport
  35766. * @param viewport defines the viewport element to be used
  35767. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35768. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35769. */
  35770. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35771. /**
  35772. * Begin a new frame
  35773. */
  35774. beginFrame(): void;
  35775. /**
  35776. * Enf the current frame
  35777. */
  35778. endFrame(): void;
  35779. /**
  35780. * Resize the view according to the canvas' size
  35781. */
  35782. resize(): void;
  35783. /**
  35784. * Force a specific size of the canvas
  35785. * @param width defines the new canvas' width
  35786. * @param height defines the new canvas' height
  35787. */
  35788. setSize(width: number, height: number): void;
  35789. /**
  35790. * Binds the frame buffer to the specified texture.
  35791. * @param texture The texture to render to or null for the default canvas
  35792. * @param faceIndex The face of the texture to render to in case of cube texture
  35793. * @param requiredWidth The width of the target to render to
  35794. * @param requiredHeight The height of the target to render to
  35795. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35796. * @param lodLevel defines the lod level to bind to the frame buffer
  35797. * @param layer defines the 2d array index to bind to frame buffer to
  35798. */
  35799. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35800. /** @hidden */
  35801. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35802. /**
  35803. * Unbind the current render target texture from the webGL context
  35804. * @param texture defines the render target texture to unbind
  35805. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35806. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35807. */
  35808. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35809. /**
  35810. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35811. */
  35812. flushFramebuffer(): void;
  35813. /**
  35814. * Unbind the current render target and bind the default framebuffer
  35815. */
  35816. restoreDefaultFramebuffer(): void;
  35817. /** @hidden */
  35818. protected _resetVertexBufferBinding(): void;
  35819. /**
  35820. * Creates a vertex buffer
  35821. * @param data the data for the vertex buffer
  35822. * @returns the new WebGL static buffer
  35823. */
  35824. createVertexBuffer(data: DataArray): DataBuffer;
  35825. private _createVertexBuffer;
  35826. /**
  35827. * Creates a dynamic vertex buffer
  35828. * @param data the data for the dynamic vertex buffer
  35829. * @returns the new WebGL dynamic buffer
  35830. */
  35831. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35832. protected _resetIndexBufferBinding(): void;
  35833. /**
  35834. * Creates a new index buffer
  35835. * @param indices defines the content of the index buffer
  35836. * @param updatable defines if the index buffer must be updatable
  35837. * @returns a new webGL buffer
  35838. */
  35839. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35840. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35841. /**
  35842. * Bind a webGL buffer to the webGL context
  35843. * @param buffer defines the buffer to bind
  35844. */
  35845. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35846. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35847. private bindBuffer;
  35848. /**
  35849. * update the bound buffer with the given data
  35850. * @param data defines the data to update
  35851. */
  35852. updateArrayBuffer(data: Float32Array): void;
  35853. private _vertexAttribPointer;
  35854. /** @hidden */
  35855. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35856. private _bindVertexBuffersAttributes;
  35857. /**
  35858. * Records a vertex array object
  35859. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35860. * @param vertexBuffers defines the list of vertex buffers to store
  35861. * @param indexBuffer defines the index buffer to store
  35862. * @param effect defines the effect to store
  35863. * @returns the new vertex array object
  35864. */
  35865. recordVertexArrayObject(vertexBuffers: {
  35866. [key: string]: VertexBuffer;
  35867. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35868. /**
  35869. * Bind a specific vertex array object
  35870. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35871. * @param vertexArrayObject defines the vertex array object to bind
  35872. * @param indexBuffer defines the index buffer to bind
  35873. */
  35874. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35875. /**
  35876. * Bind webGl buffers directly to the webGL context
  35877. * @param vertexBuffer defines the vertex buffer to bind
  35878. * @param indexBuffer defines the index buffer to bind
  35879. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35880. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35881. * @param effect defines the effect associated with the vertex buffer
  35882. */
  35883. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35884. private _unbindVertexArrayObject;
  35885. /**
  35886. * Bind a list of vertex buffers to the webGL context
  35887. * @param vertexBuffers defines the list of vertex buffers to bind
  35888. * @param indexBuffer defines the index buffer to bind
  35889. * @param effect defines the effect associated with the vertex buffers
  35890. */
  35891. bindBuffers(vertexBuffers: {
  35892. [key: string]: Nullable<VertexBuffer>;
  35893. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35894. /**
  35895. * Unbind all instance attributes
  35896. */
  35897. unbindInstanceAttributes(): void;
  35898. /**
  35899. * Release and free the memory of a vertex array object
  35900. * @param vao defines the vertex array object to delete
  35901. */
  35902. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35903. /** @hidden */
  35904. _releaseBuffer(buffer: DataBuffer): boolean;
  35905. protected _deleteBuffer(buffer: DataBuffer): void;
  35906. /**
  35907. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35908. * @param instancesBuffer defines the webGL buffer to update and bind
  35909. * @param data defines the data to store in the buffer
  35910. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35911. */
  35912. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35913. /**
  35914. * Bind the content of a webGL buffer used with instantiation
  35915. * @param instancesBuffer defines the webGL buffer to bind
  35916. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35917. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35918. */
  35919. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35920. /**
  35921. * Disable the instance attribute corresponding to the name in parameter
  35922. * @param name defines the name of the attribute to disable
  35923. */
  35924. disableInstanceAttributeByName(name: string): void;
  35925. /**
  35926. * Disable the instance attribute corresponding to the location in parameter
  35927. * @param attributeLocation defines the attribute location of the attribute to disable
  35928. */
  35929. disableInstanceAttribute(attributeLocation: number): void;
  35930. /**
  35931. * Disable the attribute corresponding to the location in parameter
  35932. * @param attributeLocation defines the attribute location of the attribute to disable
  35933. */
  35934. disableAttributeByIndex(attributeLocation: number): void;
  35935. /**
  35936. * Send a draw order
  35937. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35938. * @param indexStart defines the starting index
  35939. * @param indexCount defines the number of index to draw
  35940. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35941. */
  35942. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35943. /**
  35944. * Draw a list of points
  35945. * @param verticesStart defines the index of first vertex to draw
  35946. * @param verticesCount defines the count of vertices to draw
  35947. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35948. */
  35949. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35950. /**
  35951. * Draw a list of unindexed primitives
  35952. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35953. * @param verticesStart defines the index of first vertex to draw
  35954. * @param verticesCount defines the count of vertices to draw
  35955. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35956. */
  35957. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35958. /**
  35959. * Draw a list of indexed primitives
  35960. * @param fillMode defines the primitive to use
  35961. * @param indexStart defines the starting index
  35962. * @param indexCount defines the number of index to draw
  35963. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35964. */
  35965. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35966. /**
  35967. * Draw a list of unindexed primitives
  35968. * @param fillMode defines the primitive to use
  35969. * @param verticesStart defines the index of first vertex to draw
  35970. * @param verticesCount defines the count of vertices to draw
  35971. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35972. */
  35973. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35974. private _drawMode;
  35975. /** @hidden */
  35976. protected _reportDrawCall(): void;
  35977. /** @hidden */
  35978. _releaseEffect(effect: Effect): void;
  35979. /** @hidden */
  35980. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35981. /**
  35982. * Create a new effect (used to store vertex/fragment shaders)
  35983. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35984. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35985. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35986. * @param samplers defines an array of string used to represent textures
  35987. * @param defines defines the string containing the defines to use to compile the shaders
  35988. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35989. * @param onCompiled defines a function to call when the effect creation is successful
  35990. * @param onError defines a function to call when the effect creation has failed
  35991. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35992. * @returns the new Effect
  35993. */
  35994. 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;
  35995. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35996. private _compileShader;
  35997. private _compileRawShader;
  35998. /** @hidden */
  35999. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36000. /**
  36001. * Directly creates a webGL program
  36002. * @param pipelineContext defines the pipeline context to attach to
  36003. * @param vertexCode defines the vertex shader code to use
  36004. * @param fragmentCode defines the fragment shader code to use
  36005. * @param context defines the webGL context to use (if not set, the current one will be used)
  36006. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36007. * @returns the new webGL program
  36008. */
  36009. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36010. /**
  36011. * Creates a webGL program
  36012. * @param pipelineContext defines the pipeline context to attach to
  36013. * @param vertexCode defines the vertex shader code to use
  36014. * @param fragmentCode defines the fragment shader code to use
  36015. * @param defines defines the string containing the defines to use to compile the shaders
  36016. * @param context defines the webGL context to use (if not set, the current one will be used)
  36017. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36018. * @returns the new webGL program
  36019. */
  36020. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36021. /**
  36022. * Creates a new pipeline context
  36023. * @returns the new pipeline
  36024. */
  36025. createPipelineContext(): IPipelineContext;
  36026. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36027. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36028. /** @hidden */
  36029. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36030. /** @hidden */
  36031. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36032. /** @hidden */
  36033. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36034. /**
  36035. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36036. * @param pipelineContext defines the pipeline context to use
  36037. * @param uniformsNames defines the list of uniform names
  36038. * @returns an array of webGL uniform locations
  36039. */
  36040. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36041. /**
  36042. * Gets the lsit of active attributes for a given webGL program
  36043. * @param pipelineContext defines the pipeline context to use
  36044. * @param attributesNames defines the list of attribute names to get
  36045. * @returns an array of indices indicating the offset of each attribute
  36046. */
  36047. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36048. /**
  36049. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36050. * @param effect defines the effect to activate
  36051. */
  36052. enableEffect(effect: Nullable<Effect>): void;
  36053. /**
  36054. * Set the value of an uniform to a number (int)
  36055. * @param uniform defines the webGL uniform location where to store the value
  36056. * @param value defines the int number to store
  36057. */
  36058. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36059. /**
  36060. * Set the value of an uniform to an array of int32
  36061. * @param uniform defines the webGL uniform location where to store the value
  36062. * @param array defines the array of int32 to store
  36063. */
  36064. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36065. /**
  36066. * Set the value of an uniform to an array of int32 (stored as vec2)
  36067. * @param uniform defines the webGL uniform location where to store the value
  36068. * @param array defines the array of int32 to store
  36069. */
  36070. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36071. /**
  36072. * Set the value of an uniform to an array of int32 (stored as vec3)
  36073. * @param uniform defines the webGL uniform location where to store the value
  36074. * @param array defines the array of int32 to store
  36075. */
  36076. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36077. /**
  36078. * Set the value of an uniform to an array of int32 (stored as vec4)
  36079. * @param uniform defines the webGL uniform location where to store the value
  36080. * @param array defines the array of int32 to store
  36081. */
  36082. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36083. /**
  36084. * Set the value of an uniform to an array of number
  36085. * @param uniform defines the webGL uniform location where to store the value
  36086. * @param array defines the array of number to store
  36087. */
  36088. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36089. /**
  36090. * Set the value of an uniform to an array of number (stored as vec2)
  36091. * @param uniform defines the webGL uniform location where to store the value
  36092. * @param array defines the array of number to store
  36093. */
  36094. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36095. /**
  36096. * Set the value of an uniform to an array of number (stored as vec3)
  36097. * @param uniform defines the webGL uniform location where to store the value
  36098. * @param array defines the array of number to store
  36099. */
  36100. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36101. /**
  36102. * Set the value of an uniform to an array of number (stored as vec4)
  36103. * @param uniform defines the webGL uniform location where to store the value
  36104. * @param array defines the array of number to store
  36105. */
  36106. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36107. /**
  36108. * Set the value of an uniform to an array of float32 (stored as matrices)
  36109. * @param uniform defines the webGL uniform location where to store the value
  36110. * @param matrices defines the array of float32 to store
  36111. */
  36112. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36113. /**
  36114. * Set the value of an uniform to a matrix (3x3)
  36115. * @param uniform defines the webGL uniform location where to store the value
  36116. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36117. */
  36118. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36119. /**
  36120. * Set the value of an uniform to a matrix (2x2)
  36121. * @param uniform defines the webGL uniform location where to store the value
  36122. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36123. */
  36124. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36125. /**
  36126. * Set the value of an uniform to a number (float)
  36127. * @param uniform defines the webGL uniform location where to store the value
  36128. * @param value defines the float number to store
  36129. */
  36130. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36131. /**
  36132. * Set the value of an uniform to a vec2
  36133. * @param uniform defines the webGL uniform location where to store the value
  36134. * @param x defines the 1st component of the value
  36135. * @param y defines the 2nd component of the value
  36136. */
  36137. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36138. /**
  36139. * Set the value of an uniform to a vec3
  36140. * @param uniform defines the webGL uniform location where to store the value
  36141. * @param x defines the 1st component of the value
  36142. * @param y defines the 2nd component of the value
  36143. * @param z defines the 3rd component of the value
  36144. */
  36145. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36146. /**
  36147. * Set the value of an uniform to a vec4
  36148. * @param uniform defines the webGL uniform location where to store the value
  36149. * @param x defines the 1st component of the value
  36150. * @param y defines the 2nd component of the value
  36151. * @param z defines the 3rd component of the value
  36152. * @param w defines the 4th component of the value
  36153. */
  36154. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36155. /**
  36156. * Apply all cached states (depth, culling, stencil and alpha)
  36157. */
  36158. applyStates(): void;
  36159. /**
  36160. * Enable or disable color writing
  36161. * @param enable defines the state to set
  36162. */
  36163. setColorWrite(enable: boolean): void;
  36164. /**
  36165. * Gets a boolean indicating if color writing is enabled
  36166. * @returns the current color writing state
  36167. */
  36168. getColorWrite(): boolean;
  36169. /**
  36170. * Gets the depth culling state manager
  36171. */
  36172. get depthCullingState(): DepthCullingState;
  36173. /**
  36174. * Gets the alpha state manager
  36175. */
  36176. get alphaState(): AlphaState;
  36177. /**
  36178. * Gets the stencil state manager
  36179. */
  36180. get stencilState(): StencilState;
  36181. /**
  36182. * Clears the list of texture accessible through engine.
  36183. * This can help preventing texture load conflict due to name collision.
  36184. */
  36185. clearInternalTexturesCache(): void;
  36186. /**
  36187. * Force the entire cache to be cleared
  36188. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36189. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36190. */
  36191. wipeCaches(bruteForce?: boolean): void;
  36192. /** @hidden */
  36193. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36194. min: number;
  36195. mag: number;
  36196. };
  36197. /** @hidden */
  36198. _createTexture(): WebGLTexture;
  36199. /**
  36200. * Usually called from Texture.ts.
  36201. * Passed information to create a WebGLTexture
  36202. * @param url defines a value which contains one of the following:
  36203. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36204. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36205. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36206. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36207. * @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)
  36208. * @param scene needed for loading to the correct scene
  36209. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36210. * @param onLoad optional callback to be called upon successful completion
  36211. * @param onError optional callback to be called upon failure
  36212. * @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
  36213. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36214. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36215. * @param forcedExtension defines the extension to use to pick the right loader
  36216. * @param mimeType defines an optional mime type
  36217. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36218. */
  36219. 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;
  36220. /**
  36221. * Loads an image as an HTMLImageElement.
  36222. * @param input url string, ArrayBuffer, or Blob to load
  36223. * @param onLoad callback called when the image successfully loads
  36224. * @param onError callback called when the image fails to load
  36225. * @param offlineProvider offline provider for caching
  36226. * @param mimeType optional mime type
  36227. * @returns the HTMLImageElement of the loaded image
  36228. * @hidden
  36229. */
  36230. 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>;
  36231. /**
  36232. * @hidden
  36233. */
  36234. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36235. private _unpackFlipYCached;
  36236. /**
  36237. * In case you are sharing the context with other applications, it might
  36238. * be interested to not cache the unpack flip y state to ensure a consistent
  36239. * value would be set.
  36240. */
  36241. enableUnpackFlipYCached: boolean;
  36242. /** @hidden */
  36243. _unpackFlipY(value: boolean): void;
  36244. /** @hidden */
  36245. _getUnpackAlignement(): number;
  36246. private _getTextureTarget;
  36247. /**
  36248. * Update the sampling mode of a given texture
  36249. * @param samplingMode defines the required sampling mode
  36250. * @param texture defines the texture to update
  36251. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36252. */
  36253. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36254. /**
  36255. * Update the sampling mode of a given texture
  36256. * @param texture defines the texture to update
  36257. * @param wrapU defines the texture wrap mode of the u coordinates
  36258. * @param wrapV defines the texture wrap mode of the v coordinates
  36259. * @param wrapR defines the texture wrap mode of the r coordinates
  36260. */
  36261. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36262. /** @hidden */
  36263. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36264. width: number;
  36265. height: number;
  36266. layers?: number;
  36267. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36268. /** @hidden */
  36269. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36270. /** @hidden */
  36271. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36272. /**
  36273. * Update a portion of an internal texture
  36274. * @param texture defines the texture to update
  36275. * @param imageData defines the data to store into the texture
  36276. * @param xOffset defines the x coordinates of the update rectangle
  36277. * @param yOffset defines the y coordinates of the update rectangle
  36278. * @param width defines the width of the update rectangle
  36279. * @param height defines the height of the update rectangle
  36280. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36281. * @param lod defines the lod level to update (0 by default)
  36282. */
  36283. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36284. /** @hidden */
  36285. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36286. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36287. private _prepareWebGLTexture;
  36288. /** @hidden */
  36289. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36290. private _getDepthStencilBuffer;
  36291. /** @hidden */
  36292. _releaseFramebufferObjects(texture: InternalTexture): void;
  36293. /** @hidden */
  36294. _releaseTexture(texture: InternalTexture): void;
  36295. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36296. protected _setProgram(program: WebGLProgram): void;
  36297. protected _boundUniforms: {
  36298. [key: number]: WebGLUniformLocation;
  36299. };
  36300. /**
  36301. * Binds an effect to the webGL context
  36302. * @param effect defines the effect to bind
  36303. */
  36304. bindSamplers(effect: Effect): void;
  36305. private _activateCurrentTexture;
  36306. /** @hidden */
  36307. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36308. /** @hidden */
  36309. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36310. /**
  36311. * Unbind all textures from the webGL context
  36312. */
  36313. unbindAllTextures(): void;
  36314. /**
  36315. * Sets a texture to the according uniform.
  36316. * @param channel The texture channel
  36317. * @param uniform The uniform to set
  36318. * @param texture The texture to apply
  36319. */
  36320. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36321. private _bindSamplerUniformToChannel;
  36322. private _getTextureWrapMode;
  36323. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36324. /**
  36325. * Sets an array of texture to the webGL context
  36326. * @param channel defines the channel where the texture array must be set
  36327. * @param uniform defines the associated uniform location
  36328. * @param textures defines the array of textures to bind
  36329. */
  36330. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36331. /** @hidden */
  36332. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36333. private _setTextureParameterFloat;
  36334. private _setTextureParameterInteger;
  36335. /**
  36336. * Unbind all vertex attributes from the webGL context
  36337. */
  36338. unbindAllAttributes(): void;
  36339. /**
  36340. * 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
  36341. */
  36342. releaseEffects(): void;
  36343. /**
  36344. * Dispose and release all associated resources
  36345. */
  36346. dispose(): void;
  36347. /**
  36348. * Attach a new callback raised when context lost event is fired
  36349. * @param callback defines the callback to call
  36350. */
  36351. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36352. /**
  36353. * Attach a new callback raised when context restored event is fired
  36354. * @param callback defines the callback to call
  36355. */
  36356. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36357. /**
  36358. * Get the current error code of the webGL context
  36359. * @returns the error code
  36360. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36361. */
  36362. getError(): number;
  36363. private _canRenderToFloatFramebuffer;
  36364. private _canRenderToHalfFloatFramebuffer;
  36365. private _canRenderToFramebuffer;
  36366. /** @hidden */
  36367. _getWebGLTextureType(type: number): number;
  36368. /** @hidden */
  36369. _getInternalFormat(format: number): number;
  36370. /** @hidden */
  36371. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36372. /** @hidden */
  36373. _getRGBAMultiSampleBufferFormat(type: number): number;
  36374. /** @hidden */
  36375. _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;
  36376. /**
  36377. * Loads a file from a url
  36378. * @param url url to load
  36379. * @param onSuccess callback called when the file successfully loads
  36380. * @param onProgress callback called while file is loading (if the server supports this mode)
  36381. * @param offlineProvider defines the offline provider for caching
  36382. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36383. * @param onError callback called when the file fails to load
  36384. * @returns a file request object
  36385. * @hidden
  36386. */
  36387. 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;
  36388. /**
  36389. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36390. * @param x defines the x coordinate of the rectangle where pixels must be read
  36391. * @param y defines the y coordinate of the rectangle where pixels must be read
  36392. * @param width defines the width of the rectangle where pixels must be read
  36393. * @param height defines the height of the rectangle where pixels must be read
  36394. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36395. * @returns a Uint8Array containing RGBA colors
  36396. */
  36397. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36398. private static _isSupported;
  36399. /**
  36400. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36401. * @returns true if the engine can be created
  36402. * @ignorenaming
  36403. */
  36404. static isSupported(): boolean;
  36405. /**
  36406. * Find the next highest power of two.
  36407. * @param x Number to start search from.
  36408. * @return Next highest power of two.
  36409. */
  36410. static CeilingPOT(x: number): number;
  36411. /**
  36412. * Find the next lowest power of two.
  36413. * @param x Number to start search from.
  36414. * @return Next lowest power of two.
  36415. */
  36416. static FloorPOT(x: number): number;
  36417. /**
  36418. * Find the nearest power of two.
  36419. * @param x Number to start search from.
  36420. * @return Next nearest power of two.
  36421. */
  36422. static NearestPOT(x: number): number;
  36423. /**
  36424. * Get the closest exponent of two
  36425. * @param value defines the value to approximate
  36426. * @param max defines the maximum value to return
  36427. * @param mode defines how to define the closest value
  36428. * @returns closest exponent of two of the given value
  36429. */
  36430. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36431. /**
  36432. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36433. * @param func - the function to be called
  36434. * @param requester - the object that will request the next frame. Falls back to window.
  36435. * @returns frame number
  36436. */
  36437. static QueueNewFrame(func: () => void, requester?: any): number;
  36438. /**
  36439. * Gets host document
  36440. * @returns the host document object
  36441. */
  36442. getHostDocument(): Nullable<Document>;
  36443. }
  36444. }
  36445. declare module "babylonjs/Maths/sphericalPolynomial" {
  36446. import { Vector3 } from "babylonjs/Maths/math.vector";
  36447. import { Color3 } from "babylonjs/Maths/math.color";
  36448. /**
  36449. * Class representing spherical harmonics coefficients to the 3rd degree
  36450. */
  36451. export class SphericalHarmonics {
  36452. /**
  36453. * Defines whether or not the harmonics have been prescaled for rendering.
  36454. */
  36455. preScaled: boolean;
  36456. /**
  36457. * The l0,0 coefficients of the spherical harmonics
  36458. */
  36459. l00: Vector3;
  36460. /**
  36461. * The l1,-1 coefficients of the spherical harmonics
  36462. */
  36463. l1_1: Vector3;
  36464. /**
  36465. * The l1,0 coefficients of the spherical harmonics
  36466. */
  36467. l10: Vector3;
  36468. /**
  36469. * The l1,1 coefficients of the spherical harmonics
  36470. */
  36471. l11: Vector3;
  36472. /**
  36473. * The l2,-2 coefficients of the spherical harmonics
  36474. */
  36475. l2_2: Vector3;
  36476. /**
  36477. * The l2,-1 coefficients of the spherical harmonics
  36478. */
  36479. l2_1: Vector3;
  36480. /**
  36481. * The l2,0 coefficients of the spherical harmonics
  36482. */
  36483. l20: Vector3;
  36484. /**
  36485. * The l2,1 coefficients of the spherical harmonics
  36486. */
  36487. l21: Vector3;
  36488. /**
  36489. * The l2,2 coefficients of the spherical harmonics
  36490. */
  36491. l22: Vector3;
  36492. /**
  36493. * Adds a light to the spherical harmonics
  36494. * @param direction the direction of the light
  36495. * @param color the color of the light
  36496. * @param deltaSolidAngle the delta solid angle of the light
  36497. */
  36498. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36499. /**
  36500. * Scales the spherical harmonics by the given amount
  36501. * @param scale the amount to scale
  36502. */
  36503. scaleInPlace(scale: number): void;
  36504. /**
  36505. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36506. *
  36507. * ```
  36508. * E_lm = A_l * L_lm
  36509. * ```
  36510. *
  36511. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36512. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36513. * the scaling factors are given in equation 9.
  36514. */
  36515. convertIncidentRadianceToIrradiance(): void;
  36516. /**
  36517. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36518. *
  36519. * ```
  36520. * L = (1/pi) * E * rho
  36521. * ```
  36522. *
  36523. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36524. */
  36525. convertIrradianceToLambertianRadiance(): void;
  36526. /**
  36527. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36528. * required operations at run time.
  36529. *
  36530. * This is simply done by scaling back the SH with Ylm constants parameter.
  36531. * The trigonometric part being applied by the shader at run time.
  36532. */
  36533. preScaleForRendering(): void;
  36534. /**
  36535. * Constructs a spherical harmonics from an array.
  36536. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36537. * @returns the spherical harmonics
  36538. */
  36539. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36540. /**
  36541. * Gets the spherical harmonics from polynomial
  36542. * @param polynomial the spherical polynomial
  36543. * @returns the spherical harmonics
  36544. */
  36545. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36546. }
  36547. /**
  36548. * Class representing spherical polynomial coefficients to the 3rd degree
  36549. */
  36550. export class SphericalPolynomial {
  36551. private _harmonics;
  36552. /**
  36553. * The spherical harmonics used to create the polynomials.
  36554. */
  36555. get preScaledHarmonics(): SphericalHarmonics;
  36556. /**
  36557. * The x coefficients of the spherical polynomial
  36558. */
  36559. x: Vector3;
  36560. /**
  36561. * The y coefficients of the spherical polynomial
  36562. */
  36563. y: Vector3;
  36564. /**
  36565. * The z coefficients of the spherical polynomial
  36566. */
  36567. z: Vector3;
  36568. /**
  36569. * The xx coefficients of the spherical polynomial
  36570. */
  36571. xx: Vector3;
  36572. /**
  36573. * The yy coefficients of the spherical polynomial
  36574. */
  36575. yy: Vector3;
  36576. /**
  36577. * The zz coefficients of the spherical polynomial
  36578. */
  36579. zz: Vector3;
  36580. /**
  36581. * The xy coefficients of the spherical polynomial
  36582. */
  36583. xy: Vector3;
  36584. /**
  36585. * The yz coefficients of the spherical polynomial
  36586. */
  36587. yz: Vector3;
  36588. /**
  36589. * The zx coefficients of the spherical polynomial
  36590. */
  36591. zx: Vector3;
  36592. /**
  36593. * Adds an ambient color to the spherical polynomial
  36594. * @param color the color to add
  36595. */
  36596. addAmbient(color: Color3): void;
  36597. /**
  36598. * Scales the spherical polynomial by the given amount
  36599. * @param scale the amount to scale
  36600. */
  36601. scaleInPlace(scale: number): void;
  36602. /**
  36603. * Gets the spherical polynomial from harmonics
  36604. * @param harmonics the spherical harmonics
  36605. * @returns the spherical polynomial
  36606. */
  36607. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36608. /**
  36609. * Constructs a spherical polynomial from an array.
  36610. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36611. * @returns the spherical polynomial
  36612. */
  36613. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36614. }
  36615. }
  36616. declare module "babylonjs/Materials/Textures/internalTexture" {
  36617. import { Observable } from "babylonjs/Misc/observable";
  36618. import { Nullable, int } from "babylonjs/types";
  36619. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36621. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36622. /**
  36623. * Defines the source of the internal texture
  36624. */
  36625. export enum InternalTextureSource {
  36626. /**
  36627. * The source of the texture data is unknown
  36628. */
  36629. Unknown = 0,
  36630. /**
  36631. * Texture data comes from an URL
  36632. */
  36633. Url = 1,
  36634. /**
  36635. * Texture data is only used for temporary storage
  36636. */
  36637. Temp = 2,
  36638. /**
  36639. * Texture data comes from raw data (ArrayBuffer)
  36640. */
  36641. Raw = 3,
  36642. /**
  36643. * Texture content is dynamic (video or dynamic texture)
  36644. */
  36645. Dynamic = 4,
  36646. /**
  36647. * Texture content is generated by rendering to it
  36648. */
  36649. RenderTarget = 5,
  36650. /**
  36651. * Texture content is part of a multi render target process
  36652. */
  36653. MultiRenderTarget = 6,
  36654. /**
  36655. * Texture data comes from a cube data file
  36656. */
  36657. Cube = 7,
  36658. /**
  36659. * Texture data comes from a raw cube data
  36660. */
  36661. CubeRaw = 8,
  36662. /**
  36663. * Texture data come from a prefiltered cube data file
  36664. */
  36665. CubePrefiltered = 9,
  36666. /**
  36667. * Texture content is raw 3D data
  36668. */
  36669. Raw3D = 10,
  36670. /**
  36671. * Texture content is raw 2D array data
  36672. */
  36673. Raw2DArray = 11,
  36674. /**
  36675. * Texture content is a depth texture
  36676. */
  36677. Depth = 12,
  36678. /**
  36679. * Texture data comes from a raw cube data encoded with RGBD
  36680. */
  36681. CubeRawRGBD = 13
  36682. }
  36683. /**
  36684. * Class used to store data associated with WebGL texture data for the engine
  36685. * This class should not be used directly
  36686. */
  36687. export class InternalTexture {
  36688. /** @hidden */
  36689. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36690. /**
  36691. * Defines if the texture is ready
  36692. */
  36693. isReady: boolean;
  36694. /**
  36695. * Defines if the texture is a cube texture
  36696. */
  36697. isCube: boolean;
  36698. /**
  36699. * Defines if the texture contains 3D data
  36700. */
  36701. is3D: boolean;
  36702. /**
  36703. * Defines if the texture contains 2D array data
  36704. */
  36705. is2DArray: boolean;
  36706. /**
  36707. * Defines if the texture contains multiview data
  36708. */
  36709. isMultiview: boolean;
  36710. /**
  36711. * Gets the URL used to load this texture
  36712. */
  36713. url: string;
  36714. /**
  36715. * Gets the sampling mode of the texture
  36716. */
  36717. samplingMode: number;
  36718. /**
  36719. * Gets a boolean indicating if the texture needs mipmaps generation
  36720. */
  36721. generateMipMaps: boolean;
  36722. /**
  36723. * Gets the number of samples used by the texture (WebGL2+ only)
  36724. */
  36725. samples: number;
  36726. /**
  36727. * Gets the type of the texture (int, float...)
  36728. */
  36729. type: number;
  36730. /**
  36731. * Gets the format of the texture (RGB, RGBA...)
  36732. */
  36733. format: number;
  36734. /**
  36735. * Observable called when the texture is loaded
  36736. */
  36737. onLoadedObservable: Observable<InternalTexture>;
  36738. /**
  36739. * Gets the width of the texture
  36740. */
  36741. width: number;
  36742. /**
  36743. * Gets the height of the texture
  36744. */
  36745. height: number;
  36746. /**
  36747. * Gets the depth of the texture
  36748. */
  36749. depth: number;
  36750. /**
  36751. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36752. */
  36753. baseWidth: number;
  36754. /**
  36755. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36756. */
  36757. baseHeight: number;
  36758. /**
  36759. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36760. */
  36761. baseDepth: number;
  36762. /**
  36763. * Gets a boolean indicating if the texture is inverted on Y axis
  36764. */
  36765. invertY: boolean;
  36766. /** @hidden */
  36767. _invertVScale: boolean;
  36768. /** @hidden */
  36769. _associatedChannel: number;
  36770. /** @hidden */
  36771. _source: InternalTextureSource;
  36772. /** @hidden */
  36773. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36774. /** @hidden */
  36775. _bufferView: Nullable<ArrayBufferView>;
  36776. /** @hidden */
  36777. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36778. /** @hidden */
  36779. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36780. /** @hidden */
  36781. _size: number;
  36782. /** @hidden */
  36783. _extension: string;
  36784. /** @hidden */
  36785. _files: Nullable<string[]>;
  36786. /** @hidden */
  36787. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36788. /** @hidden */
  36789. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36790. /** @hidden */
  36791. _framebuffer: Nullable<WebGLFramebuffer>;
  36792. /** @hidden */
  36793. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36794. /** @hidden */
  36795. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36796. /** @hidden */
  36797. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36798. /** @hidden */
  36799. _attachments: Nullable<number[]>;
  36800. /** @hidden */
  36801. _cachedCoordinatesMode: Nullable<number>;
  36802. /** @hidden */
  36803. _cachedWrapU: Nullable<number>;
  36804. /** @hidden */
  36805. _cachedWrapV: Nullable<number>;
  36806. /** @hidden */
  36807. _cachedWrapR: Nullable<number>;
  36808. /** @hidden */
  36809. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36810. /** @hidden */
  36811. _isDisabled: boolean;
  36812. /** @hidden */
  36813. _compression: Nullable<string>;
  36814. /** @hidden */
  36815. _generateStencilBuffer: boolean;
  36816. /** @hidden */
  36817. _generateDepthBuffer: boolean;
  36818. /** @hidden */
  36819. _comparisonFunction: number;
  36820. /** @hidden */
  36821. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36822. /** @hidden */
  36823. _lodGenerationScale: number;
  36824. /** @hidden */
  36825. _lodGenerationOffset: number;
  36826. /** @hidden */
  36827. _depthStencilTexture: Nullable<InternalTexture>;
  36828. /** @hidden */
  36829. _colorTextureArray: Nullable<WebGLTexture>;
  36830. /** @hidden */
  36831. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36832. /** @hidden */
  36833. _lodTextureHigh: Nullable<BaseTexture>;
  36834. /** @hidden */
  36835. _lodTextureMid: Nullable<BaseTexture>;
  36836. /** @hidden */
  36837. _lodTextureLow: Nullable<BaseTexture>;
  36838. /** @hidden */
  36839. _isRGBD: boolean;
  36840. /** @hidden */
  36841. _linearSpecularLOD: boolean;
  36842. /** @hidden */
  36843. _irradianceTexture: Nullable<BaseTexture>;
  36844. /** @hidden */
  36845. _webGLTexture: Nullable<WebGLTexture>;
  36846. /** @hidden */
  36847. _references: number;
  36848. private _engine;
  36849. /**
  36850. * Gets the Engine the texture belongs to.
  36851. * @returns The babylon engine
  36852. */
  36853. getEngine(): ThinEngine;
  36854. /**
  36855. * Gets the data source type of the texture
  36856. */
  36857. get source(): InternalTextureSource;
  36858. /**
  36859. * Creates a new InternalTexture
  36860. * @param engine defines the engine to use
  36861. * @param source defines the type of data that will be used
  36862. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36863. */
  36864. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36865. /**
  36866. * Increments the number of references (ie. the number of Texture that point to it)
  36867. */
  36868. incrementReferences(): void;
  36869. /**
  36870. * Change the size of the texture (not the size of the content)
  36871. * @param width defines the new width
  36872. * @param height defines the new height
  36873. * @param depth defines the new depth (1 by default)
  36874. */
  36875. updateSize(width: int, height: int, depth?: int): void;
  36876. /** @hidden */
  36877. _rebuild(): void;
  36878. /** @hidden */
  36879. _swapAndDie(target: InternalTexture): void;
  36880. /**
  36881. * Dispose the current allocated resources
  36882. */
  36883. dispose(): void;
  36884. }
  36885. }
  36886. declare module "babylonjs/Audio/analyser" {
  36887. import { Scene } from "babylonjs/scene";
  36888. /**
  36889. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36891. */
  36892. export class Analyser {
  36893. /**
  36894. * Gets or sets the smoothing
  36895. * @ignorenaming
  36896. */
  36897. SMOOTHING: number;
  36898. /**
  36899. * Gets or sets the FFT table size
  36900. * @ignorenaming
  36901. */
  36902. FFT_SIZE: number;
  36903. /**
  36904. * Gets or sets the bar graph amplitude
  36905. * @ignorenaming
  36906. */
  36907. BARGRAPHAMPLITUDE: number;
  36908. /**
  36909. * Gets or sets the position of the debug canvas
  36910. * @ignorenaming
  36911. */
  36912. DEBUGCANVASPOS: {
  36913. x: number;
  36914. y: number;
  36915. };
  36916. /**
  36917. * Gets or sets the debug canvas size
  36918. * @ignorenaming
  36919. */
  36920. DEBUGCANVASSIZE: {
  36921. width: number;
  36922. height: number;
  36923. };
  36924. private _byteFreqs;
  36925. private _byteTime;
  36926. private _floatFreqs;
  36927. private _webAudioAnalyser;
  36928. private _debugCanvas;
  36929. private _debugCanvasContext;
  36930. private _scene;
  36931. private _registerFunc;
  36932. private _audioEngine;
  36933. /**
  36934. * Creates a new analyser
  36935. * @param scene defines hosting scene
  36936. */
  36937. constructor(scene: Scene);
  36938. /**
  36939. * Get the number of data values you will have to play with for the visualization
  36940. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36941. * @returns a number
  36942. */
  36943. getFrequencyBinCount(): number;
  36944. /**
  36945. * Gets the current frequency data as a byte array
  36946. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36947. * @returns a Uint8Array
  36948. */
  36949. getByteFrequencyData(): Uint8Array;
  36950. /**
  36951. * Gets the current waveform as a byte array
  36952. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36953. * @returns a Uint8Array
  36954. */
  36955. getByteTimeDomainData(): Uint8Array;
  36956. /**
  36957. * Gets the current frequency data as a float array
  36958. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36959. * @returns a Float32Array
  36960. */
  36961. getFloatFrequencyData(): Float32Array;
  36962. /**
  36963. * Renders the debug canvas
  36964. */
  36965. drawDebugCanvas(): void;
  36966. /**
  36967. * Stops rendering the debug canvas and removes it
  36968. */
  36969. stopDebugCanvas(): void;
  36970. /**
  36971. * Connects two audio nodes
  36972. * @param inputAudioNode defines first node to connect
  36973. * @param outputAudioNode defines second node to connect
  36974. */
  36975. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36976. /**
  36977. * Releases all associated resources
  36978. */
  36979. dispose(): void;
  36980. }
  36981. }
  36982. declare module "babylonjs/Audio/audioEngine" {
  36983. import { IDisposable } from "babylonjs/scene";
  36984. import { Analyser } from "babylonjs/Audio/analyser";
  36985. import { Nullable } from "babylonjs/types";
  36986. import { Observable } from "babylonjs/Misc/observable";
  36987. /**
  36988. * This represents an audio engine and it is responsible
  36989. * to play, synchronize and analyse sounds throughout the application.
  36990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36991. */
  36992. export interface IAudioEngine extends IDisposable {
  36993. /**
  36994. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36995. */
  36996. readonly canUseWebAudio: boolean;
  36997. /**
  36998. * Gets the current AudioContext if available.
  36999. */
  37000. readonly audioContext: Nullable<AudioContext>;
  37001. /**
  37002. * The master gain node defines the global audio volume of your audio engine.
  37003. */
  37004. readonly masterGain: GainNode;
  37005. /**
  37006. * Gets whether or not mp3 are supported by your browser.
  37007. */
  37008. readonly isMP3supported: boolean;
  37009. /**
  37010. * Gets whether or not ogg are supported by your browser.
  37011. */
  37012. readonly isOGGsupported: boolean;
  37013. /**
  37014. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37015. * @ignoreNaming
  37016. */
  37017. WarnedWebAudioUnsupported: boolean;
  37018. /**
  37019. * Defines if the audio engine relies on a custom unlocked button.
  37020. * In this case, the embedded button will not be displayed.
  37021. */
  37022. useCustomUnlockedButton: boolean;
  37023. /**
  37024. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37025. */
  37026. readonly unlocked: boolean;
  37027. /**
  37028. * Event raised when audio has been unlocked on the browser.
  37029. */
  37030. onAudioUnlockedObservable: Observable<AudioEngine>;
  37031. /**
  37032. * Event raised when audio has been locked on the browser.
  37033. */
  37034. onAudioLockedObservable: Observable<AudioEngine>;
  37035. /**
  37036. * Flags the audio engine in Locked state.
  37037. * This happens due to new browser policies preventing audio to autoplay.
  37038. */
  37039. lock(): void;
  37040. /**
  37041. * Unlocks the audio engine once a user action has been done on the dom.
  37042. * This is helpful to resume play once browser policies have been satisfied.
  37043. */
  37044. unlock(): void;
  37045. /**
  37046. * Gets the global volume sets on the master gain.
  37047. * @returns the global volume if set or -1 otherwise
  37048. */
  37049. getGlobalVolume(): number;
  37050. /**
  37051. * Sets the global volume of your experience (sets on the master gain).
  37052. * @param newVolume Defines the new global volume of the application
  37053. */
  37054. setGlobalVolume(newVolume: number): void;
  37055. /**
  37056. * Connect the audio engine to an audio analyser allowing some amazing
  37057. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37059. * @param analyser The analyser to connect to the engine
  37060. */
  37061. connectToAnalyser(analyser: Analyser): void;
  37062. }
  37063. /**
  37064. * This represents the default audio engine used in babylon.
  37065. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37067. */
  37068. export class AudioEngine implements IAudioEngine {
  37069. private _audioContext;
  37070. private _audioContextInitialized;
  37071. private _muteButton;
  37072. private _hostElement;
  37073. /**
  37074. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37075. */
  37076. canUseWebAudio: boolean;
  37077. /**
  37078. * The master gain node defines the global audio volume of your audio engine.
  37079. */
  37080. masterGain: GainNode;
  37081. /**
  37082. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37083. * @ignoreNaming
  37084. */
  37085. WarnedWebAudioUnsupported: boolean;
  37086. /**
  37087. * Gets whether or not mp3 are supported by your browser.
  37088. */
  37089. isMP3supported: boolean;
  37090. /**
  37091. * Gets whether or not ogg are supported by your browser.
  37092. */
  37093. isOGGsupported: boolean;
  37094. /**
  37095. * Gets whether audio has been unlocked on the device.
  37096. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37097. * a user interaction has happened.
  37098. */
  37099. unlocked: boolean;
  37100. /**
  37101. * Defines if the audio engine relies on a custom unlocked button.
  37102. * In this case, the embedded button will not be displayed.
  37103. */
  37104. useCustomUnlockedButton: boolean;
  37105. /**
  37106. * Event raised when audio has been unlocked on the browser.
  37107. */
  37108. onAudioUnlockedObservable: Observable<AudioEngine>;
  37109. /**
  37110. * Event raised when audio has been locked on the browser.
  37111. */
  37112. onAudioLockedObservable: Observable<AudioEngine>;
  37113. /**
  37114. * Gets the current AudioContext if available.
  37115. */
  37116. get audioContext(): Nullable<AudioContext>;
  37117. private _connectedAnalyser;
  37118. /**
  37119. * Instantiates a new audio engine.
  37120. *
  37121. * There should be only one per page as some browsers restrict the number
  37122. * of audio contexts you can create.
  37123. * @param hostElement defines the host element where to display the mute icon if necessary
  37124. */
  37125. constructor(hostElement?: Nullable<HTMLElement>);
  37126. /**
  37127. * Flags the audio engine in Locked state.
  37128. * This happens due to new browser policies preventing audio to autoplay.
  37129. */
  37130. lock(): void;
  37131. /**
  37132. * Unlocks the audio engine once a user action has been done on the dom.
  37133. * This is helpful to resume play once browser policies have been satisfied.
  37134. */
  37135. unlock(): void;
  37136. private _resumeAudioContext;
  37137. private _initializeAudioContext;
  37138. private _tryToRun;
  37139. private _triggerRunningState;
  37140. private _triggerSuspendedState;
  37141. private _displayMuteButton;
  37142. private _moveButtonToTopLeft;
  37143. private _onResize;
  37144. private _hideMuteButton;
  37145. /**
  37146. * Destroy and release the resources associated with the audio ccontext.
  37147. */
  37148. dispose(): void;
  37149. /**
  37150. * Gets the global volume sets on the master gain.
  37151. * @returns the global volume if set or -1 otherwise
  37152. */
  37153. getGlobalVolume(): number;
  37154. /**
  37155. * Sets the global volume of your experience (sets on the master gain).
  37156. * @param newVolume Defines the new global volume of the application
  37157. */
  37158. setGlobalVolume(newVolume: number): void;
  37159. /**
  37160. * Connect the audio engine to an audio analyser allowing some amazing
  37161. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37163. * @param analyser The analyser to connect to the engine
  37164. */
  37165. connectToAnalyser(analyser: Analyser): void;
  37166. }
  37167. }
  37168. declare module "babylonjs/Loading/loadingScreen" {
  37169. /**
  37170. * Interface used to present a loading screen while loading a scene
  37171. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37172. */
  37173. export interface ILoadingScreen {
  37174. /**
  37175. * Function called to display the loading screen
  37176. */
  37177. displayLoadingUI: () => void;
  37178. /**
  37179. * Function called to hide the loading screen
  37180. */
  37181. hideLoadingUI: () => void;
  37182. /**
  37183. * Gets or sets the color to use for the background
  37184. */
  37185. loadingUIBackgroundColor: string;
  37186. /**
  37187. * Gets or sets the text to display while loading
  37188. */
  37189. loadingUIText: string;
  37190. }
  37191. /**
  37192. * Class used for the default loading screen
  37193. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37194. */
  37195. export class DefaultLoadingScreen implements ILoadingScreen {
  37196. private _renderingCanvas;
  37197. private _loadingText;
  37198. private _loadingDivBackgroundColor;
  37199. private _loadingDiv;
  37200. private _loadingTextDiv;
  37201. /** Gets or sets the logo url to use for the default loading screen */
  37202. static DefaultLogoUrl: string;
  37203. /** Gets or sets the spinner url to use for the default loading screen */
  37204. static DefaultSpinnerUrl: string;
  37205. /**
  37206. * Creates a new default loading screen
  37207. * @param _renderingCanvas defines the canvas used to render the scene
  37208. * @param _loadingText defines the default text to display
  37209. * @param _loadingDivBackgroundColor defines the default background color
  37210. */
  37211. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37212. /**
  37213. * Function called to display the loading screen
  37214. */
  37215. displayLoadingUI(): void;
  37216. /**
  37217. * Function called to hide the loading screen
  37218. */
  37219. hideLoadingUI(): void;
  37220. /**
  37221. * Gets or sets the text to display while loading
  37222. */
  37223. set loadingUIText(text: string);
  37224. get loadingUIText(): string;
  37225. /**
  37226. * Gets or sets the color to use for the background
  37227. */
  37228. get loadingUIBackgroundColor(): string;
  37229. set loadingUIBackgroundColor(color: string);
  37230. private _resizeLoadingUI;
  37231. }
  37232. }
  37233. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37234. /**
  37235. * Interface for any object that can request an animation frame
  37236. */
  37237. export interface ICustomAnimationFrameRequester {
  37238. /**
  37239. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37240. */
  37241. renderFunction?: Function;
  37242. /**
  37243. * Called to request the next frame to render to
  37244. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37245. */
  37246. requestAnimationFrame: Function;
  37247. /**
  37248. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37249. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37250. */
  37251. requestID?: number;
  37252. }
  37253. }
  37254. declare module "babylonjs/Misc/performanceMonitor" {
  37255. /**
  37256. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37257. */
  37258. export class PerformanceMonitor {
  37259. private _enabled;
  37260. private _rollingFrameTime;
  37261. private _lastFrameTimeMs;
  37262. /**
  37263. * constructor
  37264. * @param frameSampleSize The number of samples required to saturate the sliding window
  37265. */
  37266. constructor(frameSampleSize?: number);
  37267. /**
  37268. * Samples current frame
  37269. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37270. */
  37271. sampleFrame(timeMs?: number): void;
  37272. /**
  37273. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37274. */
  37275. get averageFrameTime(): number;
  37276. /**
  37277. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37278. */
  37279. get averageFrameTimeVariance(): number;
  37280. /**
  37281. * Returns the frame time of the most recent frame
  37282. */
  37283. get instantaneousFrameTime(): number;
  37284. /**
  37285. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37286. */
  37287. get averageFPS(): number;
  37288. /**
  37289. * Returns the average framerate in frames per second using the most recent frame time
  37290. */
  37291. get instantaneousFPS(): number;
  37292. /**
  37293. * Returns true if enough samples have been taken to completely fill the sliding window
  37294. */
  37295. get isSaturated(): boolean;
  37296. /**
  37297. * Enables contributions to the sliding window sample set
  37298. */
  37299. enable(): void;
  37300. /**
  37301. * Disables contributions to the sliding window sample set
  37302. * Samples will not be interpolated over the disabled period
  37303. */
  37304. disable(): void;
  37305. /**
  37306. * Returns true if sampling is enabled
  37307. */
  37308. get isEnabled(): boolean;
  37309. /**
  37310. * Resets performance monitor
  37311. */
  37312. reset(): void;
  37313. }
  37314. /**
  37315. * RollingAverage
  37316. *
  37317. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37318. */
  37319. export class RollingAverage {
  37320. /**
  37321. * Current average
  37322. */
  37323. average: number;
  37324. /**
  37325. * Current variance
  37326. */
  37327. variance: number;
  37328. protected _samples: Array<number>;
  37329. protected _sampleCount: number;
  37330. protected _pos: number;
  37331. protected _m2: number;
  37332. /**
  37333. * constructor
  37334. * @param length The number of samples required to saturate the sliding window
  37335. */
  37336. constructor(length: number);
  37337. /**
  37338. * Adds a sample to the sample set
  37339. * @param v The sample value
  37340. */
  37341. add(v: number): void;
  37342. /**
  37343. * Returns previously added values or null if outside of history or outside the sliding window domain
  37344. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37345. * @return Value previously recorded with add() or null if outside of range
  37346. */
  37347. history(i: number): number;
  37348. /**
  37349. * Returns true if enough samples have been taken to completely fill the sliding window
  37350. * @return true if sample-set saturated
  37351. */
  37352. isSaturated(): boolean;
  37353. /**
  37354. * Resets the rolling average (equivalent to 0 samples taken so far)
  37355. */
  37356. reset(): void;
  37357. /**
  37358. * Wraps a value around the sample range boundaries
  37359. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37360. * @return Wrapped position in sample range
  37361. */
  37362. protected _wrapPosition(i: number): number;
  37363. }
  37364. }
  37365. declare module "babylonjs/Misc/perfCounter" {
  37366. /**
  37367. * This class is used to track a performance counter which is number based.
  37368. * The user has access to many properties which give statistics of different nature.
  37369. *
  37370. * The implementer can track two kinds of Performance Counter: time and count.
  37371. * 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.
  37372. * 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.
  37373. */
  37374. export class PerfCounter {
  37375. /**
  37376. * Gets or sets a global boolean to turn on and off all the counters
  37377. */
  37378. static Enabled: boolean;
  37379. /**
  37380. * Returns the smallest value ever
  37381. */
  37382. get min(): number;
  37383. /**
  37384. * Returns the biggest value ever
  37385. */
  37386. get max(): number;
  37387. /**
  37388. * Returns the average value since the performance counter is running
  37389. */
  37390. get average(): number;
  37391. /**
  37392. * Returns the average value of the last second the counter was monitored
  37393. */
  37394. get lastSecAverage(): number;
  37395. /**
  37396. * Returns the current value
  37397. */
  37398. get current(): number;
  37399. /**
  37400. * Gets the accumulated total
  37401. */
  37402. get total(): number;
  37403. /**
  37404. * Gets the total value count
  37405. */
  37406. get count(): number;
  37407. /**
  37408. * Creates a new counter
  37409. */
  37410. constructor();
  37411. /**
  37412. * Call this method to start monitoring a new frame.
  37413. * 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.
  37414. */
  37415. fetchNewFrame(): void;
  37416. /**
  37417. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37418. * @param newCount the count value to add to the monitored count
  37419. * @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.
  37420. */
  37421. addCount(newCount: number, fetchResult: boolean): void;
  37422. /**
  37423. * Start monitoring this performance counter
  37424. */
  37425. beginMonitoring(): void;
  37426. /**
  37427. * Compute the time lapsed since the previous beginMonitoring() call.
  37428. * @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
  37429. */
  37430. endMonitoring(newFrame?: boolean): void;
  37431. private _fetchResult;
  37432. private _startMonitoringTime;
  37433. private _min;
  37434. private _max;
  37435. private _average;
  37436. private _current;
  37437. private _totalValueCount;
  37438. private _totalAccumulated;
  37439. private _lastSecAverage;
  37440. private _lastSecAccumulated;
  37441. private _lastSecTime;
  37442. private _lastSecValueCount;
  37443. }
  37444. }
  37445. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37446. module "babylonjs/Engines/thinEngine" {
  37447. interface ThinEngine {
  37448. /**
  37449. * Sets alpha constants used by some alpha blending modes
  37450. * @param r defines the red component
  37451. * @param g defines the green component
  37452. * @param b defines the blue component
  37453. * @param a defines the alpha component
  37454. */
  37455. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37456. /**
  37457. * Sets the current alpha mode
  37458. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37459. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37460. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37461. */
  37462. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37463. /**
  37464. * Gets the current alpha mode
  37465. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37466. * @returns the current alpha mode
  37467. */
  37468. getAlphaMode(): number;
  37469. /**
  37470. * Sets the current alpha equation
  37471. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37472. */
  37473. setAlphaEquation(equation: number): void;
  37474. /**
  37475. * Gets the current alpha equation.
  37476. * @returns the current alpha equation
  37477. */
  37478. getAlphaEquation(): number;
  37479. }
  37480. }
  37481. }
  37482. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37483. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37484. import { Nullable } from "babylonjs/types";
  37485. module "babylonjs/Engines/thinEngine" {
  37486. interface ThinEngine {
  37487. /** @hidden */
  37488. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37489. }
  37490. }
  37491. }
  37492. declare module "babylonjs/Engines/engine" {
  37493. import { Observable } from "babylonjs/Misc/observable";
  37494. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37495. import { Scene } from "babylonjs/scene";
  37496. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37497. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37498. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37499. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37500. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37501. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37502. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37503. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37504. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37506. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37507. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37508. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37509. import "babylonjs/Engines/Extensions/engine.alpha";
  37510. import "babylonjs/Engines/Extensions/engine.readTexture";
  37511. import { Material } from "babylonjs/Materials/material";
  37512. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37513. /**
  37514. * Defines the interface used by display changed events
  37515. */
  37516. export interface IDisplayChangedEventArgs {
  37517. /** Gets the vrDisplay object (if any) */
  37518. vrDisplay: Nullable<any>;
  37519. /** Gets a boolean indicating if webVR is supported */
  37520. vrSupported: boolean;
  37521. }
  37522. /**
  37523. * Defines the interface used by objects containing a viewport (like a camera)
  37524. */
  37525. interface IViewportOwnerLike {
  37526. /**
  37527. * Gets or sets the viewport
  37528. */
  37529. viewport: IViewportLike;
  37530. }
  37531. /**
  37532. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37533. */
  37534. export class Engine extends ThinEngine {
  37535. /** Defines that alpha blending is disabled */
  37536. static readonly ALPHA_DISABLE: number;
  37537. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37538. static readonly ALPHA_ADD: number;
  37539. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37540. static readonly ALPHA_COMBINE: number;
  37541. /** Defines that alpha blending to DEST - SRC * DEST */
  37542. static readonly ALPHA_SUBTRACT: number;
  37543. /** Defines that alpha blending to SRC * DEST */
  37544. static readonly ALPHA_MULTIPLY: number;
  37545. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37546. static readonly ALPHA_MAXIMIZED: number;
  37547. /** Defines that alpha blending to SRC + DEST */
  37548. static readonly ALPHA_ONEONE: number;
  37549. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37550. static readonly ALPHA_PREMULTIPLIED: number;
  37551. /**
  37552. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37553. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37554. */
  37555. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37556. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37557. static readonly ALPHA_INTERPOLATE: number;
  37558. /**
  37559. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37560. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37561. */
  37562. static readonly ALPHA_SCREENMODE: number;
  37563. /** Defines that the ressource is not delayed*/
  37564. static readonly DELAYLOADSTATE_NONE: number;
  37565. /** Defines that the ressource was successfully delay loaded */
  37566. static readonly DELAYLOADSTATE_LOADED: number;
  37567. /** Defines that the ressource is currently delay loading */
  37568. static readonly DELAYLOADSTATE_LOADING: number;
  37569. /** Defines that the ressource is delayed and has not started loading */
  37570. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37571. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37572. static readonly NEVER: number;
  37573. /** 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 */
  37574. static readonly ALWAYS: number;
  37575. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37576. static readonly LESS: number;
  37577. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37578. static readonly EQUAL: number;
  37579. /** 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 */
  37580. static readonly LEQUAL: number;
  37581. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37582. static readonly GREATER: number;
  37583. /** 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 */
  37584. static readonly GEQUAL: number;
  37585. /** 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 */
  37586. static readonly NOTEQUAL: number;
  37587. /** Passed to stencilOperation to specify that stencil value must be kept */
  37588. static readonly KEEP: number;
  37589. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37590. static readonly REPLACE: number;
  37591. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37592. static readonly INCR: number;
  37593. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37594. static readonly DECR: number;
  37595. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37596. static readonly INVERT: number;
  37597. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37598. static readonly INCR_WRAP: number;
  37599. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37600. static readonly DECR_WRAP: number;
  37601. /** Texture is not repeating outside of 0..1 UVs */
  37602. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37603. /** Texture is repeating outside of 0..1 UVs */
  37604. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37605. /** Texture is repeating and mirrored */
  37606. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37607. /** ALPHA */
  37608. static readonly TEXTUREFORMAT_ALPHA: number;
  37609. /** LUMINANCE */
  37610. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37611. /** LUMINANCE_ALPHA */
  37612. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37613. /** RGB */
  37614. static readonly TEXTUREFORMAT_RGB: number;
  37615. /** RGBA */
  37616. static readonly TEXTUREFORMAT_RGBA: number;
  37617. /** RED */
  37618. static readonly TEXTUREFORMAT_RED: number;
  37619. /** RED (2nd reference) */
  37620. static readonly TEXTUREFORMAT_R: number;
  37621. /** RG */
  37622. static readonly TEXTUREFORMAT_RG: number;
  37623. /** RED_INTEGER */
  37624. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37625. /** RED_INTEGER (2nd reference) */
  37626. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37627. /** RG_INTEGER */
  37628. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37629. /** RGB_INTEGER */
  37630. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37631. /** RGBA_INTEGER */
  37632. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37633. /** UNSIGNED_BYTE */
  37634. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37635. /** UNSIGNED_BYTE (2nd reference) */
  37636. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37637. /** FLOAT */
  37638. static readonly TEXTURETYPE_FLOAT: number;
  37639. /** HALF_FLOAT */
  37640. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37641. /** BYTE */
  37642. static readonly TEXTURETYPE_BYTE: number;
  37643. /** SHORT */
  37644. static readonly TEXTURETYPE_SHORT: number;
  37645. /** UNSIGNED_SHORT */
  37646. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37647. /** INT */
  37648. static readonly TEXTURETYPE_INT: number;
  37649. /** UNSIGNED_INT */
  37650. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37651. /** UNSIGNED_SHORT_4_4_4_4 */
  37652. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37653. /** UNSIGNED_SHORT_5_5_5_1 */
  37654. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37655. /** UNSIGNED_SHORT_5_6_5 */
  37656. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37657. /** UNSIGNED_INT_2_10_10_10_REV */
  37658. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37659. /** UNSIGNED_INT_24_8 */
  37660. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37661. /** UNSIGNED_INT_10F_11F_11F_REV */
  37662. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37663. /** UNSIGNED_INT_5_9_9_9_REV */
  37664. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37665. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37666. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37667. /** nearest is mag = nearest and min = nearest and mip = linear */
  37668. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37669. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37670. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37671. /** Trilinear is mag = linear and min = linear and mip = linear */
  37672. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37673. /** nearest is mag = nearest and min = nearest and mip = linear */
  37674. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37675. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37676. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37677. /** Trilinear is mag = linear and min = linear and mip = linear */
  37678. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37679. /** mag = nearest and min = nearest and mip = nearest */
  37680. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37681. /** mag = nearest and min = linear and mip = nearest */
  37682. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37683. /** mag = nearest and min = linear and mip = linear */
  37684. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37685. /** mag = nearest and min = linear and mip = none */
  37686. static readonly TEXTURE_NEAREST_LINEAR: number;
  37687. /** mag = nearest and min = nearest and mip = none */
  37688. static readonly TEXTURE_NEAREST_NEAREST: number;
  37689. /** mag = linear and min = nearest and mip = nearest */
  37690. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37691. /** mag = linear and min = nearest and mip = linear */
  37692. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37693. /** mag = linear and min = linear and mip = none */
  37694. static readonly TEXTURE_LINEAR_LINEAR: number;
  37695. /** mag = linear and min = nearest and mip = none */
  37696. static readonly TEXTURE_LINEAR_NEAREST: number;
  37697. /** Explicit coordinates mode */
  37698. static readonly TEXTURE_EXPLICIT_MODE: number;
  37699. /** Spherical coordinates mode */
  37700. static readonly TEXTURE_SPHERICAL_MODE: number;
  37701. /** Planar coordinates mode */
  37702. static readonly TEXTURE_PLANAR_MODE: number;
  37703. /** Cubic coordinates mode */
  37704. static readonly TEXTURE_CUBIC_MODE: number;
  37705. /** Projection coordinates mode */
  37706. static readonly TEXTURE_PROJECTION_MODE: number;
  37707. /** Skybox coordinates mode */
  37708. static readonly TEXTURE_SKYBOX_MODE: number;
  37709. /** Inverse Cubic coordinates mode */
  37710. static readonly TEXTURE_INVCUBIC_MODE: number;
  37711. /** Equirectangular coordinates mode */
  37712. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37713. /** Equirectangular Fixed coordinates mode */
  37714. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37715. /** Equirectangular Fixed Mirrored coordinates mode */
  37716. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37717. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37718. static readonly SCALEMODE_FLOOR: number;
  37719. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37720. static readonly SCALEMODE_NEAREST: number;
  37721. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37722. static readonly SCALEMODE_CEILING: number;
  37723. /**
  37724. * Returns the current npm package of the sdk
  37725. */
  37726. static get NpmPackage(): string;
  37727. /**
  37728. * Returns the current version of the framework
  37729. */
  37730. static get Version(): string;
  37731. /** Gets the list of created engines */
  37732. static get Instances(): Engine[];
  37733. /**
  37734. * Gets the latest created engine
  37735. */
  37736. static get LastCreatedEngine(): Nullable<Engine>;
  37737. /**
  37738. * Gets the latest created scene
  37739. */
  37740. static get LastCreatedScene(): Nullable<Scene>;
  37741. /**
  37742. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37743. * @param flag defines which part of the materials must be marked as dirty
  37744. * @param predicate defines a predicate used to filter which materials should be affected
  37745. */
  37746. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37747. /**
  37748. * Method called to create the default loading screen.
  37749. * This can be overriden in your own app.
  37750. * @param canvas The rendering canvas element
  37751. * @returns The loading screen
  37752. */
  37753. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37754. /**
  37755. * Method called to create the default rescale post process on each engine.
  37756. */
  37757. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37758. /**
  37759. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37760. **/
  37761. enableOfflineSupport: boolean;
  37762. /**
  37763. * 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)
  37764. **/
  37765. disableManifestCheck: boolean;
  37766. /**
  37767. * Gets the list of created scenes
  37768. */
  37769. scenes: Scene[];
  37770. /**
  37771. * Event raised when a new scene is created
  37772. */
  37773. onNewSceneAddedObservable: Observable<Scene>;
  37774. /**
  37775. * Gets the list of created postprocesses
  37776. */
  37777. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37778. /**
  37779. * Gets a boolean indicating if the pointer is currently locked
  37780. */
  37781. isPointerLock: boolean;
  37782. /**
  37783. * Observable event triggered each time the rendering canvas is resized
  37784. */
  37785. onResizeObservable: Observable<Engine>;
  37786. /**
  37787. * Observable event triggered each time the canvas loses focus
  37788. */
  37789. onCanvasBlurObservable: Observable<Engine>;
  37790. /**
  37791. * Observable event triggered each time the canvas gains focus
  37792. */
  37793. onCanvasFocusObservable: Observable<Engine>;
  37794. /**
  37795. * Observable event triggered each time the canvas receives pointerout event
  37796. */
  37797. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37798. /**
  37799. * Observable raised when the engine begins a new frame
  37800. */
  37801. onBeginFrameObservable: Observable<Engine>;
  37802. /**
  37803. * If set, will be used to request the next animation frame for the render loop
  37804. */
  37805. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37806. /**
  37807. * Observable raised when the engine ends the current frame
  37808. */
  37809. onEndFrameObservable: Observable<Engine>;
  37810. /**
  37811. * Observable raised when the engine is about to compile a shader
  37812. */
  37813. onBeforeShaderCompilationObservable: Observable<Engine>;
  37814. /**
  37815. * Observable raised when the engine has jsut compiled a shader
  37816. */
  37817. onAfterShaderCompilationObservable: Observable<Engine>;
  37818. /**
  37819. * Gets the audio engine
  37820. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37821. * @ignorenaming
  37822. */
  37823. static audioEngine: IAudioEngine;
  37824. /**
  37825. * Default AudioEngine factory responsible of creating the Audio Engine.
  37826. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37827. */
  37828. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37829. /**
  37830. * Default offline support factory responsible of creating a tool used to store data locally.
  37831. * By default, this will create a Database object if the workload has been embedded.
  37832. */
  37833. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37834. private _loadingScreen;
  37835. private _pointerLockRequested;
  37836. private _rescalePostProcess;
  37837. private _deterministicLockstep;
  37838. private _lockstepMaxSteps;
  37839. private _timeStep;
  37840. protected get _supportsHardwareTextureRescaling(): boolean;
  37841. private _fps;
  37842. private _deltaTime;
  37843. /** @hidden */
  37844. _drawCalls: PerfCounter;
  37845. /** 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 */
  37846. canvasTabIndex: number;
  37847. /**
  37848. * Turn this value on if you want to pause FPS computation when in background
  37849. */
  37850. disablePerformanceMonitorInBackground: boolean;
  37851. private _performanceMonitor;
  37852. /**
  37853. * Gets the performance monitor attached to this engine
  37854. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37855. */
  37856. get performanceMonitor(): PerformanceMonitor;
  37857. private _onFocus;
  37858. private _onBlur;
  37859. private _onCanvasPointerOut;
  37860. private _onCanvasBlur;
  37861. private _onCanvasFocus;
  37862. private _onFullscreenChange;
  37863. private _onPointerLockChange;
  37864. /**
  37865. * Gets the HTML element used to attach event listeners
  37866. * @returns a HTML element
  37867. */
  37868. getInputElement(): Nullable<HTMLElement>;
  37869. /**
  37870. * Creates a new engine
  37871. * @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
  37872. * @param antialias defines enable antialiasing (default: false)
  37873. * @param options defines further options to be sent to the getContext() function
  37874. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37875. */
  37876. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37877. /**
  37878. * Gets current aspect ratio
  37879. * @param viewportOwner defines the camera to use to get the aspect ratio
  37880. * @param useScreen defines if screen size must be used (or the current render target if any)
  37881. * @returns a number defining the aspect ratio
  37882. */
  37883. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37884. /**
  37885. * Gets current screen aspect ratio
  37886. * @returns a number defining the aspect ratio
  37887. */
  37888. getScreenAspectRatio(): number;
  37889. /**
  37890. * Gets the client rect of the HTML canvas attached with the current webGL context
  37891. * @returns a client rectanglee
  37892. */
  37893. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37894. /**
  37895. * Gets the client rect of the HTML element used for events
  37896. * @returns a client rectanglee
  37897. */
  37898. getInputElementClientRect(): Nullable<ClientRect>;
  37899. /**
  37900. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37901. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37902. * @returns true if engine is in deterministic lock step mode
  37903. */
  37904. isDeterministicLockStep(): boolean;
  37905. /**
  37906. * Gets the max steps when engine is running in deterministic lock step
  37907. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37908. * @returns the max steps
  37909. */
  37910. getLockstepMaxSteps(): number;
  37911. /**
  37912. * Returns the time in ms between steps when using deterministic lock step.
  37913. * @returns time step in (ms)
  37914. */
  37915. getTimeStep(): number;
  37916. /**
  37917. * Force the mipmap generation for the given render target texture
  37918. * @param texture defines the render target texture to use
  37919. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37920. */
  37921. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37922. /** States */
  37923. /**
  37924. * Set various states to the webGL context
  37925. * @param culling defines backface culling state
  37926. * @param zOffset defines the value to apply to zOffset (0 by default)
  37927. * @param force defines if states must be applied even if cache is up to date
  37928. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37929. */
  37930. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37931. /**
  37932. * Set the z offset to apply to current rendering
  37933. * @param value defines the offset to apply
  37934. */
  37935. setZOffset(value: number): void;
  37936. /**
  37937. * Gets the current value of the zOffset
  37938. * @returns the current zOffset state
  37939. */
  37940. getZOffset(): number;
  37941. /**
  37942. * Enable or disable depth buffering
  37943. * @param enable defines the state to set
  37944. */
  37945. setDepthBuffer(enable: boolean): void;
  37946. /**
  37947. * Gets a boolean indicating if depth writing is enabled
  37948. * @returns the current depth writing state
  37949. */
  37950. getDepthWrite(): boolean;
  37951. /**
  37952. * Enable or disable depth writing
  37953. * @param enable defines the state to set
  37954. */
  37955. setDepthWrite(enable: boolean): void;
  37956. /**
  37957. * Gets a boolean indicating if stencil buffer is enabled
  37958. * @returns the current stencil buffer state
  37959. */
  37960. getStencilBuffer(): boolean;
  37961. /**
  37962. * Enable or disable the stencil buffer
  37963. * @param enable defines if the stencil buffer must be enabled or disabled
  37964. */
  37965. setStencilBuffer(enable: boolean): void;
  37966. /**
  37967. * Gets the current stencil mask
  37968. * @returns a number defining the new stencil mask to use
  37969. */
  37970. getStencilMask(): number;
  37971. /**
  37972. * Sets the current stencil mask
  37973. * @param mask defines the new stencil mask to use
  37974. */
  37975. setStencilMask(mask: number): void;
  37976. /**
  37977. * Gets the current stencil function
  37978. * @returns a number defining the stencil function to use
  37979. */
  37980. getStencilFunction(): number;
  37981. /**
  37982. * Gets the current stencil reference value
  37983. * @returns a number defining the stencil reference value to use
  37984. */
  37985. getStencilFunctionReference(): number;
  37986. /**
  37987. * Gets the current stencil mask
  37988. * @returns a number defining the stencil mask to use
  37989. */
  37990. getStencilFunctionMask(): number;
  37991. /**
  37992. * Sets the current stencil function
  37993. * @param stencilFunc defines the new stencil function to use
  37994. */
  37995. setStencilFunction(stencilFunc: number): void;
  37996. /**
  37997. * Sets the current stencil reference
  37998. * @param reference defines the new stencil reference to use
  37999. */
  38000. setStencilFunctionReference(reference: number): void;
  38001. /**
  38002. * Sets the current stencil mask
  38003. * @param mask defines the new stencil mask to use
  38004. */
  38005. setStencilFunctionMask(mask: number): void;
  38006. /**
  38007. * Gets the current stencil operation when stencil fails
  38008. * @returns a number defining stencil operation to use when stencil fails
  38009. */
  38010. getStencilOperationFail(): number;
  38011. /**
  38012. * Gets the current stencil operation when depth fails
  38013. * @returns a number defining stencil operation to use when depth fails
  38014. */
  38015. getStencilOperationDepthFail(): number;
  38016. /**
  38017. * Gets the current stencil operation when stencil passes
  38018. * @returns a number defining stencil operation to use when stencil passes
  38019. */
  38020. getStencilOperationPass(): number;
  38021. /**
  38022. * Sets the stencil operation to use when stencil fails
  38023. * @param operation defines the stencil operation to use when stencil fails
  38024. */
  38025. setStencilOperationFail(operation: number): void;
  38026. /**
  38027. * Sets the stencil operation to use when depth fails
  38028. * @param operation defines the stencil operation to use when depth fails
  38029. */
  38030. setStencilOperationDepthFail(operation: number): void;
  38031. /**
  38032. * Sets the stencil operation to use when stencil passes
  38033. * @param operation defines the stencil operation to use when stencil passes
  38034. */
  38035. setStencilOperationPass(operation: number): void;
  38036. /**
  38037. * Sets a boolean indicating if the dithering state is enabled or disabled
  38038. * @param value defines the dithering state
  38039. */
  38040. setDitheringState(value: boolean): void;
  38041. /**
  38042. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38043. * @param value defines the rasterizer state
  38044. */
  38045. setRasterizerState(value: boolean): void;
  38046. /**
  38047. * Gets the current depth function
  38048. * @returns a number defining the depth function
  38049. */
  38050. getDepthFunction(): Nullable<number>;
  38051. /**
  38052. * Sets the current depth function
  38053. * @param depthFunc defines the function to use
  38054. */
  38055. setDepthFunction(depthFunc: number): void;
  38056. /**
  38057. * Sets the current depth function to GREATER
  38058. */
  38059. setDepthFunctionToGreater(): void;
  38060. /**
  38061. * Sets the current depth function to GEQUAL
  38062. */
  38063. setDepthFunctionToGreaterOrEqual(): void;
  38064. /**
  38065. * Sets the current depth function to LESS
  38066. */
  38067. setDepthFunctionToLess(): void;
  38068. /**
  38069. * Sets the current depth function to LEQUAL
  38070. */
  38071. setDepthFunctionToLessOrEqual(): void;
  38072. private _cachedStencilBuffer;
  38073. private _cachedStencilFunction;
  38074. private _cachedStencilMask;
  38075. private _cachedStencilOperationPass;
  38076. private _cachedStencilOperationFail;
  38077. private _cachedStencilOperationDepthFail;
  38078. private _cachedStencilReference;
  38079. /**
  38080. * Caches the the state of the stencil buffer
  38081. */
  38082. cacheStencilState(): void;
  38083. /**
  38084. * Restores the state of the stencil buffer
  38085. */
  38086. restoreStencilState(): void;
  38087. /**
  38088. * Directly set the WebGL Viewport
  38089. * @param x defines the x coordinate of the viewport (in screen space)
  38090. * @param y defines the y coordinate of the viewport (in screen space)
  38091. * @param width defines the width of the viewport (in screen space)
  38092. * @param height defines the height of the viewport (in screen space)
  38093. * @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
  38094. */
  38095. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38096. /**
  38097. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38098. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38099. * @param y defines the y-coordinate of the corner of the clear rectangle
  38100. * @param width defines the width of the clear rectangle
  38101. * @param height defines the height of the clear rectangle
  38102. * @param clearColor defines the clear color
  38103. */
  38104. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38105. /**
  38106. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38107. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38108. * @param y defines the y-coordinate of the corner of the clear rectangle
  38109. * @param width defines the width of the clear rectangle
  38110. * @param height defines the height of the clear rectangle
  38111. */
  38112. enableScissor(x: number, y: number, width: number, height: number): void;
  38113. /**
  38114. * Disable previously set scissor test rectangle
  38115. */
  38116. disableScissor(): void;
  38117. protected _reportDrawCall(): void;
  38118. /**
  38119. * Initializes a webVR display and starts listening to display change events
  38120. * The onVRDisplayChangedObservable will be notified upon these changes
  38121. * @returns The onVRDisplayChangedObservable
  38122. */
  38123. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38124. /** @hidden */
  38125. _prepareVRComponent(): void;
  38126. /** @hidden */
  38127. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38128. /** @hidden */
  38129. _submitVRFrame(): void;
  38130. /**
  38131. * Call this function to leave webVR mode
  38132. * Will do nothing if webVR is not supported or if there is no webVR device
  38133. * @see http://doc.babylonjs.com/how_to/webvr_camera
  38134. */
  38135. disableVR(): void;
  38136. /**
  38137. * Gets a boolean indicating that the system is in VR mode and is presenting
  38138. * @returns true if VR mode is engaged
  38139. */
  38140. isVRPresenting(): boolean;
  38141. /** @hidden */
  38142. _requestVRFrame(): void;
  38143. /** @hidden */
  38144. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38145. /**
  38146. * Gets the source code of the vertex shader associated with a specific webGL program
  38147. * @param program defines the program to use
  38148. * @returns a string containing the source code of the vertex shader associated with the program
  38149. */
  38150. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38151. /**
  38152. * Gets the source code of the fragment shader associated with a specific webGL program
  38153. * @param program defines the program to use
  38154. * @returns a string containing the source code of the fragment shader associated with the program
  38155. */
  38156. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38157. /**
  38158. * Sets a depth stencil texture from a render target to the according uniform.
  38159. * @param channel The texture channel
  38160. * @param uniform The uniform to set
  38161. * @param texture The render target texture containing the depth stencil texture to apply
  38162. */
  38163. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38164. /**
  38165. * Sets a texture to the webGL context from a postprocess
  38166. * @param channel defines the channel to use
  38167. * @param postProcess defines the source postprocess
  38168. */
  38169. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38170. /**
  38171. * Binds the output of the passed in post process to the texture channel specified
  38172. * @param channel The channel the texture should be bound to
  38173. * @param postProcess The post process which's output should be bound
  38174. */
  38175. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38176. protected _rebuildBuffers(): void;
  38177. /** @hidden */
  38178. _renderFrame(): void;
  38179. _renderLoop(): void;
  38180. /** @hidden */
  38181. _renderViews(): boolean;
  38182. /**
  38183. * Toggle full screen mode
  38184. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38185. */
  38186. switchFullscreen(requestPointerLock: boolean): void;
  38187. /**
  38188. * Enters full screen mode
  38189. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38190. */
  38191. enterFullscreen(requestPointerLock: boolean): void;
  38192. /**
  38193. * Exits full screen mode
  38194. */
  38195. exitFullscreen(): void;
  38196. /**
  38197. * Enters Pointerlock mode
  38198. */
  38199. enterPointerlock(): void;
  38200. /**
  38201. * Exits Pointerlock mode
  38202. */
  38203. exitPointerlock(): void;
  38204. /**
  38205. * Begin a new frame
  38206. */
  38207. beginFrame(): void;
  38208. /**
  38209. * Enf the current frame
  38210. */
  38211. endFrame(): void;
  38212. resize(): void;
  38213. /**
  38214. * Force a specific size of the canvas
  38215. * @param width defines the new canvas' width
  38216. * @param height defines the new canvas' height
  38217. */
  38218. setSize(width: number, height: number): void;
  38219. /**
  38220. * Updates a dynamic vertex buffer.
  38221. * @param vertexBuffer the vertex buffer to update
  38222. * @param data the data used to update the vertex buffer
  38223. * @param byteOffset the byte offset of the data
  38224. * @param byteLength the byte length of the data
  38225. */
  38226. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38227. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38228. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38229. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38230. _releaseTexture(texture: InternalTexture): void;
  38231. /**
  38232. * @hidden
  38233. * Rescales a texture
  38234. * @param source input texutre
  38235. * @param destination destination texture
  38236. * @param scene scene to use to render the resize
  38237. * @param internalFormat format to use when resizing
  38238. * @param onComplete callback to be called when resize has completed
  38239. */
  38240. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38241. /**
  38242. * Gets the current framerate
  38243. * @returns a number representing the framerate
  38244. */
  38245. getFps(): number;
  38246. /**
  38247. * Gets the time spent between current and previous frame
  38248. * @returns a number representing the delta time in ms
  38249. */
  38250. getDeltaTime(): number;
  38251. private _measureFps;
  38252. /** @hidden */
  38253. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38254. /**
  38255. * Update a dynamic index buffer
  38256. * @param indexBuffer defines the target index buffer
  38257. * @param indices defines the data to update
  38258. * @param offset defines the offset in the target index buffer where update should start
  38259. */
  38260. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38261. /**
  38262. * Updates the sample count of a render target texture
  38263. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38264. * @param texture defines the texture to update
  38265. * @param samples defines the sample count to set
  38266. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38267. */
  38268. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38269. /**
  38270. * Updates a depth texture Comparison Mode and Function.
  38271. * If the comparison Function is equal to 0, the mode will be set to none.
  38272. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38273. * @param texture The texture to set the comparison function for
  38274. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38275. */
  38276. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38277. /**
  38278. * Creates a webGL buffer to use with instanciation
  38279. * @param capacity defines the size of the buffer
  38280. * @returns the webGL buffer
  38281. */
  38282. createInstancesBuffer(capacity: number): DataBuffer;
  38283. /**
  38284. * Delete a webGL buffer used with instanciation
  38285. * @param buffer defines the webGL buffer to delete
  38286. */
  38287. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38288. private _clientWaitAsync;
  38289. /** @hidden */
  38290. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38291. dispose(): void;
  38292. private _disableTouchAction;
  38293. /**
  38294. * Display the loading screen
  38295. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38296. */
  38297. displayLoadingUI(): void;
  38298. /**
  38299. * Hide the loading screen
  38300. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38301. */
  38302. hideLoadingUI(): void;
  38303. /**
  38304. * Gets the current loading screen object
  38305. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38306. */
  38307. get loadingScreen(): ILoadingScreen;
  38308. /**
  38309. * Sets the current loading screen object
  38310. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38311. */
  38312. set loadingScreen(loadingScreen: ILoadingScreen);
  38313. /**
  38314. * Sets the current loading screen text
  38315. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38316. */
  38317. set loadingUIText(text: string);
  38318. /**
  38319. * Sets the current loading screen background color
  38320. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38321. */
  38322. set loadingUIBackgroundColor(color: string);
  38323. /** Pointerlock and fullscreen */
  38324. /**
  38325. * Ask the browser to promote the current element to pointerlock mode
  38326. * @param element defines the DOM element to promote
  38327. */
  38328. static _RequestPointerlock(element: HTMLElement): void;
  38329. /**
  38330. * Asks the browser to exit pointerlock mode
  38331. */
  38332. static _ExitPointerlock(): void;
  38333. /**
  38334. * Ask the browser to promote the current element to fullscreen rendering mode
  38335. * @param element defines the DOM element to promote
  38336. */
  38337. static _RequestFullscreen(element: HTMLElement): void;
  38338. /**
  38339. * Asks the browser to exit fullscreen mode
  38340. */
  38341. static _ExitFullscreen(): void;
  38342. }
  38343. }
  38344. declare module "babylonjs/Engines/engineStore" {
  38345. import { Nullable } from "babylonjs/types";
  38346. import { Engine } from "babylonjs/Engines/engine";
  38347. import { Scene } from "babylonjs/scene";
  38348. /**
  38349. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38350. * during the life time of the application.
  38351. */
  38352. export class EngineStore {
  38353. /** Gets the list of created engines */
  38354. static Instances: import("babylonjs/Engines/engine").Engine[];
  38355. /** @hidden */
  38356. static _LastCreatedScene: Nullable<Scene>;
  38357. /**
  38358. * Gets the latest created engine
  38359. */
  38360. static get LastCreatedEngine(): Nullable<Engine>;
  38361. /**
  38362. * Gets the latest created scene
  38363. */
  38364. static get LastCreatedScene(): Nullable<Scene>;
  38365. /**
  38366. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38367. * @ignorenaming
  38368. */
  38369. static UseFallbackTexture: boolean;
  38370. /**
  38371. * Texture content used if a texture cannot loaded
  38372. * @ignorenaming
  38373. */
  38374. static FallbackTexture: string;
  38375. }
  38376. }
  38377. declare module "babylonjs/Misc/promise" {
  38378. /**
  38379. * Helper class that provides a small promise polyfill
  38380. */
  38381. export class PromisePolyfill {
  38382. /**
  38383. * Static function used to check if the polyfill is required
  38384. * If this is the case then the function will inject the polyfill to window.Promise
  38385. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38386. */
  38387. static Apply(force?: boolean): void;
  38388. }
  38389. }
  38390. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38391. /**
  38392. * Interface for screenshot methods with describe argument called `size` as object with options
  38393. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38394. */
  38395. export interface IScreenshotSize {
  38396. /**
  38397. * number in pixels for canvas height
  38398. */
  38399. height?: number;
  38400. /**
  38401. * multiplier allowing render at a higher or lower resolution
  38402. * If value is defined then height and width will be ignored and taken from camera
  38403. */
  38404. precision?: number;
  38405. /**
  38406. * number in pixels for canvas width
  38407. */
  38408. width?: number;
  38409. }
  38410. }
  38411. declare module "babylonjs/Misc/tools" {
  38412. import { Nullable, float } from "babylonjs/types";
  38413. import { DomManagement } from "babylonjs/Misc/domManagement";
  38414. import { WebRequest } from "babylonjs/Misc/webRequest";
  38415. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38416. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38417. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38418. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38419. import { Camera } from "babylonjs/Cameras/camera";
  38420. import { Engine } from "babylonjs/Engines/engine";
  38421. interface IColor4Like {
  38422. r: float;
  38423. g: float;
  38424. b: float;
  38425. a: float;
  38426. }
  38427. /**
  38428. * Class containing a set of static utilities functions
  38429. */
  38430. export class Tools {
  38431. /**
  38432. * Gets or sets the base URL to use to load assets
  38433. */
  38434. static get BaseUrl(): string;
  38435. static set BaseUrl(value: string);
  38436. /**
  38437. * Enable/Disable Custom HTTP Request Headers globally.
  38438. * default = false
  38439. * @see CustomRequestHeaders
  38440. */
  38441. static UseCustomRequestHeaders: boolean;
  38442. /**
  38443. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38444. * i.e. when loading files, where the server/service expects an Authorization header
  38445. */
  38446. static CustomRequestHeaders: {
  38447. [key: string]: string;
  38448. };
  38449. /**
  38450. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38451. */
  38452. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38453. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38454. /**
  38455. * Default behaviour for cors in the application.
  38456. * It can be a string if the expected behavior is identical in the entire app.
  38457. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38458. */
  38459. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38460. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38461. /**
  38462. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38463. * @ignorenaming
  38464. */
  38465. static get UseFallbackTexture(): boolean;
  38466. static set UseFallbackTexture(value: boolean);
  38467. /**
  38468. * Use this object to register external classes like custom textures or material
  38469. * to allow the laoders to instantiate them
  38470. */
  38471. static get RegisteredExternalClasses(): {
  38472. [key: string]: Object;
  38473. };
  38474. static set RegisteredExternalClasses(classes: {
  38475. [key: string]: Object;
  38476. });
  38477. /**
  38478. * Texture content used if a texture cannot loaded
  38479. * @ignorenaming
  38480. */
  38481. static get fallbackTexture(): string;
  38482. static set fallbackTexture(value: string);
  38483. /**
  38484. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38485. * @param u defines the coordinate on X axis
  38486. * @param v defines the coordinate on Y axis
  38487. * @param width defines the width of the source data
  38488. * @param height defines the height of the source data
  38489. * @param pixels defines the source byte array
  38490. * @param color defines the output color
  38491. */
  38492. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38493. /**
  38494. * Interpolates between a and b via alpha
  38495. * @param a The lower value (returned when alpha = 0)
  38496. * @param b The upper value (returned when alpha = 1)
  38497. * @param alpha The interpolation-factor
  38498. * @return The mixed value
  38499. */
  38500. static Mix(a: number, b: number, alpha: number): number;
  38501. /**
  38502. * Tries to instantiate a new object from a given class name
  38503. * @param className defines the class name to instantiate
  38504. * @returns the new object or null if the system was not able to do the instantiation
  38505. */
  38506. static Instantiate(className: string): any;
  38507. /**
  38508. * Provides a slice function that will work even on IE
  38509. * @param data defines the array to slice
  38510. * @param start defines the start of the data (optional)
  38511. * @param end defines the end of the data (optional)
  38512. * @returns the new sliced array
  38513. */
  38514. static Slice<T>(data: T, start?: number, end?: number): T;
  38515. /**
  38516. * Polyfill for setImmediate
  38517. * @param action defines the action to execute after the current execution block
  38518. */
  38519. static SetImmediate(action: () => void): void;
  38520. /**
  38521. * Function indicating if a number is an exponent of 2
  38522. * @param value defines the value to test
  38523. * @returns true if the value is an exponent of 2
  38524. */
  38525. static IsExponentOfTwo(value: number): boolean;
  38526. private static _tmpFloatArray;
  38527. /**
  38528. * Returns the nearest 32-bit single precision float representation of a Number
  38529. * @param value A Number. If the parameter is of a different type, it will get converted
  38530. * to a number or to NaN if it cannot be converted
  38531. * @returns number
  38532. */
  38533. static FloatRound(value: number): number;
  38534. /**
  38535. * Extracts the filename from a path
  38536. * @param path defines the path to use
  38537. * @returns the filename
  38538. */
  38539. static GetFilename(path: string): string;
  38540. /**
  38541. * Extracts the "folder" part of a path (everything before the filename).
  38542. * @param uri The URI to extract the info from
  38543. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38544. * @returns The "folder" part of the path
  38545. */
  38546. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38547. /**
  38548. * Extracts text content from a DOM element hierarchy
  38549. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38550. */
  38551. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38552. /**
  38553. * Convert an angle in radians to degrees
  38554. * @param angle defines the angle to convert
  38555. * @returns the angle in degrees
  38556. */
  38557. static ToDegrees(angle: number): number;
  38558. /**
  38559. * Convert an angle in degrees to radians
  38560. * @param angle defines the angle to convert
  38561. * @returns the angle in radians
  38562. */
  38563. static ToRadians(angle: number): number;
  38564. /**
  38565. * Returns an array if obj is not an array
  38566. * @param obj defines the object to evaluate as an array
  38567. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38568. * @returns either obj directly if obj is an array or a new array containing obj
  38569. */
  38570. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38571. /**
  38572. * Gets the pointer prefix to use
  38573. * @param engine defines the engine we are finding the prefix for
  38574. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38575. */
  38576. static GetPointerPrefix(engine: Engine): string;
  38577. /**
  38578. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38579. * @param url define the url we are trying
  38580. * @param element define the dom element where to configure the cors policy
  38581. */
  38582. static SetCorsBehavior(url: string | string[], element: {
  38583. crossOrigin: string | null;
  38584. }): void;
  38585. /**
  38586. * Removes unwanted characters from an url
  38587. * @param url defines the url to clean
  38588. * @returns the cleaned url
  38589. */
  38590. static CleanUrl(url: string): string;
  38591. /**
  38592. * Gets or sets a function used to pre-process url before using them to load assets
  38593. */
  38594. static get PreprocessUrl(): (url: string) => string;
  38595. static set PreprocessUrl(processor: (url: string) => string);
  38596. /**
  38597. * Loads an image as an HTMLImageElement.
  38598. * @param input url string, ArrayBuffer, or Blob to load
  38599. * @param onLoad callback called when the image successfully loads
  38600. * @param onError callback called when the image fails to load
  38601. * @param offlineProvider offline provider for caching
  38602. * @param mimeType optional mime type
  38603. * @returns the HTMLImageElement of the loaded image
  38604. */
  38605. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38606. /**
  38607. * Loads a file from a url
  38608. * @param url url string, ArrayBuffer, or Blob to load
  38609. * @param onSuccess callback called when the file successfully loads
  38610. * @param onProgress callback called while file is loading (if the server supports this mode)
  38611. * @param offlineProvider defines the offline provider for caching
  38612. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38613. * @param onError callback called when the file fails to load
  38614. * @returns a file request object
  38615. */
  38616. 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;
  38617. /**
  38618. * Loads a file from a url
  38619. * @param url the file url to load
  38620. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38621. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38622. */
  38623. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38624. /**
  38625. * Load a script (identified by an url). When the url returns, the
  38626. * content of this file is added into a new script element, attached to the DOM (body element)
  38627. * @param scriptUrl defines the url of the script to laod
  38628. * @param onSuccess defines the callback called when the script is loaded
  38629. * @param onError defines the callback to call if an error occurs
  38630. * @param scriptId defines the id of the script element
  38631. */
  38632. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38633. /**
  38634. * Load an asynchronous script (identified by an url). When the url returns, the
  38635. * content of this file is added into a new script element, attached to the DOM (body element)
  38636. * @param scriptUrl defines the url of the script to laod
  38637. * @param scriptId defines the id of the script element
  38638. * @returns a promise request object
  38639. */
  38640. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38641. /**
  38642. * Loads a file from a blob
  38643. * @param fileToLoad defines the blob to use
  38644. * @param callback defines the callback to call when data is loaded
  38645. * @param progressCallback defines the callback to call during loading process
  38646. * @returns a file request object
  38647. */
  38648. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38649. /**
  38650. * Reads a file from a File object
  38651. * @param file defines the file to load
  38652. * @param onSuccess defines the callback to call when data is loaded
  38653. * @param onProgress defines the callback to call during loading process
  38654. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38655. * @param onError defines the callback to call when an error occurs
  38656. * @returns a file request object
  38657. */
  38658. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38659. /**
  38660. * Creates a data url from a given string content
  38661. * @param content defines the content to convert
  38662. * @returns the new data url link
  38663. */
  38664. static FileAsURL(content: string): string;
  38665. /**
  38666. * Format the given number to a specific decimal format
  38667. * @param value defines the number to format
  38668. * @param decimals defines the number of decimals to use
  38669. * @returns the formatted string
  38670. */
  38671. static Format(value: number, decimals?: number): string;
  38672. /**
  38673. * Tries to copy an object by duplicating every property
  38674. * @param source defines the source object
  38675. * @param destination defines the target object
  38676. * @param doNotCopyList defines a list of properties to avoid
  38677. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38678. */
  38679. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38680. /**
  38681. * Gets a boolean indicating if the given object has no own property
  38682. * @param obj defines the object to test
  38683. * @returns true if object has no own property
  38684. */
  38685. static IsEmpty(obj: any): boolean;
  38686. /**
  38687. * Function used to register events at window level
  38688. * @param windowElement defines the Window object to use
  38689. * @param events defines the events to register
  38690. */
  38691. static RegisterTopRootEvents(windowElement: Window, events: {
  38692. name: string;
  38693. handler: Nullable<(e: FocusEvent) => any>;
  38694. }[]): void;
  38695. /**
  38696. * Function used to unregister events from window level
  38697. * @param windowElement defines the Window object to use
  38698. * @param events defines the events to unregister
  38699. */
  38700. static UnregisterTopRootEvents(windowElement: Window, events: {
  38701. name: string;
  38702. handler: Nullable<(e: FocusEvent) => any>;
  38703. }[]): void;
  38704. /**
  38705. * @ignore
  38706. */
  38707. static _ScreenshotCanvas: HTMLCanvasElement;
  38708. /**
  38709. * Dumps the current bound framebuffer
  38710. * @param width defines the rendering width
  38711. * @param height defines the rendering height
  38712. * @param engine defines the hosting engine
  38713. * @param successCallback defines the callback triggered once the data are available
  38714. * @param mimeType defines the mime type of the result
  38715. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38716. */
  38717. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38718. /**
  38719. * Converts the canvas data to blob.
  38720. * This acts as a polyfill for browsers not supporting the to blob function.
  38721. * @param canvas Defines the canvas to extract the data from
  38722. * @param successCallback Defines the callback triggered once the data are available
  38723. * @param mimeType Defines the mime type of the result
  38724. */
  38725. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38726. /**
  38727. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38728. * @param successCallback defines the callback triggered once the data are available
  38729. * @param mimeType defines the mime type of the result
  38730. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38731. */
  38732. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38733. /**
  38734. * Downloads a blob in the browser
  38735. * @param blob defines the blob to download
  38736. * @param fileName defines the name of the downloaded file
  38737. */
  38738. static Download(blob: Blob, fileName: string): void;
  38739. /**
  38740. * Captures a screenshot of the current rendering
  38741. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38742. * @param engine defines the rendering engine
  38743. * @param camera defines the source camera
  38744. * @param size This parameter can be set to a single number or to an object with the
  38745. * following (optional) properties: precision, width, height. If a single number is passed,
  38746. * it will be used for both width and height. If an object is passed, the screenshot size
  38747. * will be derived from the parameters. The precision property is a multiplier allowing
  38748. * rendering at a higher or lower resolution
  38749. * @param successCallback defines the callback receives a single parameter which contains the
  38750. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38751. * src parameter of an <img> to display it
  38752. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38753. * Check your browser for supported MIME types
  38754. */
  38755. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38756. /**
  38757. * Captures a screenshot of the current rendering
  38758. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38759. * @param engine defines the rendering engine
  38760. * @param camera defines the source camera
  38761. * @param size This parameter can be set to a single number or to an object with the
  38762. * following (optional) properties: precision, width, height. If a single number is passed,
  38763. * it will be used for both width and height. If an object is passed, the screenshot size
  38764. * will be derived from the parameters. The precision property is a multiplier allowing
  38765. * rendering at a higher or lower resolution
  38766. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38767. * Check your browser for supported MIME types
  38768. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38769. * to the src parameter of an <img> to display it
  38770. */
  38771. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38772. /**
  38773. * Generates an image screenshot from the specified camera.
  38774. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38775. * @param engine The engine to use for rendering
  38776. * @param camera The camera to use for rendering
  38777. * @param size This parameter can be set to a single number or to an object with the
  38778. * following (optional) properties: precision, width, height. If a single number is passed,
  38779. * it will be used for both width and height. If an object is passed, the screenshot size
  38780. * will be derived from the parameters. The precision property is a multiplier allowing
  38781. * rendering at a higher or lower resolution
  38782. * @param successCallback The callback receives a single parameter which contains the
  38783. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38784. * src parameter of an <img> to display it
  38785. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38786. * Check your browser for supported MIME types
  38787. * @param samples Texture samples (default: 1)
  38788. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38789. * @param fileName A name for for the downloaded file.
  38790. */
  38791. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38792. /**
  38793. * Generates an image screenshot from the specified camera.
  38794. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  38795. * @param engine The engine to use for rendering
  38796. * @param camera The camera to use for rendering
  38797. * @param size This parameter can be set to a single number or to an object with the
  38798. * following (optional) properties: precision, width, height. If a single number is passed,
  38799. * it will be used for both width and height. If an object is passed, the screenshot size
  38800. * will be derived from the parameters. The precision property is a multiplier allowing
  38801. * rendering at a higher or lower resolution
  38802. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38803. * Check your browser for supported MIME types
  38804. * @param samples Texture samples (default: 1)
  38805. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38806. * @param fileName A name for for the downloaded file.
  38807. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38808. * to the src parameter of an <img> to display it
  38809. */
  38810. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38811. /**
  38812. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38813. * Be aware Math.random() could cause collisions, but:
  38814. * "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"
  38815. * @returns a pseudo random id
  38816. */
  38817. static RandomId(): string;
  38818. /**
  38819. * Test if the given uri is a base64 string
  38820. * @param uri The uri to test
  38821. * @return True if the uri is a base64 string or false otherwise
  38822. */
  38823. static IsBase64(uri: string): boolean;
  38824. /**
  38825. * Decode the given base64 uri.
  38826. * @param uri The uri to decode
  38827. * @return The decoded base64 data.
  38828. */
  38829. static DecodeBase64(uri: string): ArrayBuffer;
  38830. /**
  38831. * Gets the absolute url.
  38832. * @param url the input url
  38833. * @return the absolute url
  38834. */
  38835. static GetAbsoluteUrl(url: string): string;
  38836. /**
  38837. * No log
  38838. */
  38839. static readonly NoneLogLevel: number;
  38840. /**
  38841. * Only message logs
  38842. */
  38843. static readonly MessageLogLevel: number;
  38844. /**
  38845. * Only warning logs
  38846. */
  38847. static readonly WarningLogLevel: number;
  38848. /**
  38849. * Only error logs
  38850. */
  38851. static readonly ErrorLogLevel: number;
  38852. /**
  38853. * All logs
  38854. */
  38855. static readonly AllLogLevel: number;
  38856. /**
  38857. * Gets a value indicating the number of loading errors
  38858. * @ignorenaming
  38859. */
  38860. static get errorsCount(): number;
  38861. /**
  38862. * Callback called when a new log is added
  38863. */
  38864. static OnNewCacheEntry: (entry: string) => void;
  38865. /**
  38866. * Log a message to the console
  38867. * @param message defines the message to log
  38868. */
  38869. static Log(message: string): void;
  38870. /**
  38871. * Write a warning message to the console
  38872. * @param message defines the message to log
  38873. */
  38874. static Warn(message: string): void;
  38875. /**
  38876. * Write an error message to the console
  38877. * @param message defines the message to log
  38878. */
  38879. static Error(message: string): void;
  38880. /**
  38881. * Gets current log cache (list of logs)
  38882. */
  38883. static get LogCache(): string;
  38884. /**
  38885. * Clears the log cache
  38886. */
  38887. static ClearLogCache(): void;
  38888. /**
  38889. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38890. */
  38891. static set LogLevels(level: number);
  38892. /**
  38893. * Checks if the window object exists
  38894. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38895. */
  38896. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38897. /**
  38898. * No performance log
  38899. */
  38900. static readonly PerformanceNoneLogLevel: number;
  38901. /**
  38902. * Use user marks to log performance
  38903. */
  38904. static readonly PerformanceUserMarkLogLevel: number;
  38905. /**
  38906. * Log performance to the console
  38907. */
  38908. static readonly PerformanceConsoleLogLevel: number;
  38909. private static _performance;
  38910. /**
  38911. * Sets the current performance log level
  38912. */
  38913. static set PerformanceLogLevel(level: number);
  38914. private static _StartPerformanceCounterDisabled;
  38915. private static _EndPerformanceCounterDisabled;
  38916. private static _StartUserMark;
  38917. private static _EndUserMark;
  38918. private static _StartPerformanceConsole;
  38919. private static _EndPerformanceConsole;
  38920. /**
  38921. * Starts a performance counter
  38922. */
  38923. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38924. /**
  38925. * Ends a specific performance coutner
  38926. */
  38927. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38928. /**
  38929. * Gets either window.performance.now() if supported or Date.now() else
  38930. */
  38931. static get Now(): number;
  38932. /**
  38933. * This method will return the name of the class used to create the instance of the given object.
  38934. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38935. * @param object the object to get the class name from
  38936. * @param isType defines if the object is actually a type
  38937. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38938. */
  38939. static GetClassName(object: any, isType?: boolean): string;
  38940. /**
  38941. * Gets the first element of an array satisfying a given predicate
  38942. * @param array defines the array to browse
  38943. * @param predicate defines the predicate to use
  38944. * @returns null if not found or the element
  38945. */
  38946. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38947. /**
  38948. * This method will return the name of the full name of the class, including its owning module (if any).
  38949. * 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).
  38950. * @param object the object to get the class name from
  38951. * @param isType defines if the object is actually a type
  38952. * @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.
  38953. * @ignorenaming
  38954. */
  38955. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38956. /**
  38957. * Returns a promise that resolves after the given amount of time.
  38958. * @param delay Number of milliseconds to delay
  38959. * @returns Promise that resolves after the given amount of time
  38960. */
  38961. static DelayAsync(delay: number): Promise<void>;
  38962. /**
  38963. * Utility function to detect if the current user agent is Safari
  38964. * @returns whether or not the current user agent is safari
  38965. */
  38966. static IsSafari(): boolean;
  38967. }
  38968. /**
  38969. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38970. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38971. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38972. * @param name The name of the class, case should be preserved
  38973. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38974. */
  38975. export function className(name: string, module?: string): (target: Object) => void;
  38976. /**
  38977. * An implementation of a loop for asynchronous functions.
  38978. */
  38979. export class AsyncLoop {
  38980. /**
  38981. * Defines the number of iterations for the loop
  38982. */
  38983. iterations: number;
  38984. /**
  38985. * Defines the current index of the loop.
  38986. */
  38987. index: number;
  38988. private _done;
  38989. private _fn;
  38990. private _successCallback;
  38991. /**
  38992. * Constructor.
  38993. * @param iterations the number of iterations.
  38994. * @param func the function to run each iteration
  38995. * @param successCallback the callback that will be called upon succesful execution
  38996. * @param offset starting offset.
  38997. */
  38998. constructor(
  38999. /**
  39000. * Defines the number of iterations for the loop
  39001. */
  39002. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39003. /**
  39004. * Execute the next iteration. Must be called after the last iteration was finished.
  39005. */
  39006. executeNext(): void;
  39007. /**
  39008. * Break the loop and run the success callback.
  39009. */
  39010. breakLoop(): void;
  39011. /**
  39012. * Create and run an async loop.
  39013. * @param iterations the number of iterations.
  39014. * @param fn the function to run each iteration
  39015. * @param successCallback the callback that will be called upon succesful execution
  39016. * @param offset starting offset.
  39017. * @returns the created async loop object
  39018. */
  39019. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39020. /**
  39021. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39022. * @param iterations total number of iterations
  39023. * @param syncedIterations number of synchronous iterations in each async iteration.
  39024. * @param fn the function to call each iteration.
  39025. * @param callback a success call back that will be called when iterating stops.
  39026. * @param breakFunction a break condition (optional)
  39027. * @param timeout timeout settings for the setTimeout function. default - 0.
  39028. * @returns the created async loop object
  39029. */
  39030. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39031. }
  39032. }
  39033. declare module "babylonjs/Misc/stringDictionary" {
  39034. import { Nullable } from "babylonjs/types";
  39035. /**
  39036. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39037. * The underlying implementation relies on an associative array to ensure the best performances.
  39038. * The value can be anything including 'null' but except 'undefined'
  39039. */
  39040. export class StringDictionary<T> {
  39041. /**
  39042. * This will clear this dictionary and copy the content from the 'source' one.
  39043. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39044. * @param source the dictionary to take the content from and copy to this dictionary
  39045. */
  39046. copyFrom(source: StringDictionary<T>): void;
  39047. /**
  39048. * Get a value based from its key
  39049. * @param key the given key to get the matching value from
  39050. * @return the value if found, otherwise undefined is returned
  39051. */
  39052. get(key: string): T | undefined;
  39053. /**
  39054. * Get a value from its key or add it if it doesn't exist.
  39055. * This method will ensure you that a given key/data will be present in the dictionary.
  39056. * @param key the given key to get the matching value from
  39057. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39058. * The factory will only be invoked if there's no data for the given key.
  39059. * @return the value corresponding to the key.
  39060. */
  39061. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39062. /**
  39063. * Get a value from its key if present in the dictionary otherwise add it
  39064. * @param key the key to get the value from
  39065. * @param val if there's no such key/value pair in the dictionary add it with this value
  39066. * @return the value corresponding to the key
  39067. */
  39068. getOrAdd(key: string, val: T): T;
  39069. /**
  39070. * Check if there's a given key in the dictionary
  39071. * @param key the key to check for
  39072. * @return true if the key is present, false otherwise
  39073. */
  39074. contains(key: string): boolean;
  39075. /**
  39076. * Add a new key and its corresponding value
  39077. * @param key the key to add
  39078. * @param value the value corresponding to the key
  39079. * @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
  39080. */
  39081. add(key: string, value: T): boolean;
  39082. /**
  39083. * Update a specific value associated to a key
  39084. * @param key defines the key to use
  39085. * @param value defines the value to store
  39086. * @returns true if the value was updated (or false if the key was not found)
  39087. */
  39088. set(key: string, value: T): boolean;
  39089. /**
  39090. * Get the element of the given key and remove it from the dictionary
  39091. * @param key defines the key to search
  39092. * @returns the value associated with the key or null if not found
  39093. */
  39094. getAndRemove(key: string): Nullable<T>;
  39095. /**
  39096. * Remove a key/value from the dictionary.
  39097. * @param key the key to remove
  39098. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39099. */
  39100. remove(key: string): boolean;
  39101. /**
  39102. * Clear the whole content of the dictionary
  39103. */
  39104. clear(): void;
  39105. /**
  39106. * Gets the current count
  39107. */
  39108. get count(): number;
  39109. /**
  39110. * Execute a callback on each key/val of the dictionary.
  39111. * Note that you can remove any element in this dictionary in the callback implementation
  39112. * @param callback the callback to execute on a given key/value pair
  39113. */
  39114. forEach(callback: (key: string, val: T) => void): void;
  39115. /**
  39116. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39117. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39118. * Note that you can remove any element in this dictionary in the callback implementation
  39119. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39120. * @returns the first item
  39121. */
  39122. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39123. private _count;
  39124. private _data;
  39125. }
  39126. }
  39127. declare module "babylonjs/Collisions/collisionCoordinator" {
  39128. import { Nullable } from "babylonjs/types";
  39129. import { Scene } from "babylonjs/scene";
  39130. import { Vector3 } from "babylonjs/Maths/math.vector";
  39131. import { Collider } from "babylonjs/Collisions/collider";
  39132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39133. /** @hidden */
  39134. export interface ICollisionCoordinator {
  39135. createCollider(): Collider;
  39136. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39137. init(scene: Scene): void;
  39138. }
  39139. /** @hidden */
  39140. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39141. private _scene;
  39142. private _scaledPosition;
  39143. private _scaledVelocity;
  39144. private _finalPosition;
  39145. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39146. createCollider(): Collider;
  39147. init(scene: Scene): void;
  39148. private _collideWithWorld;
  39149. }
  39150. }
  39151. declare module "babylonjs/Inputs/scene.inputManager" {
  39152. import { Nullable } from "babylonjs/types";
  39153. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39154. import { Vector2 } from "babylonjs/Maths/math.vector";
  39155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39156. import { Scene } from "babylonjs/scene";
  39157. /**
  39158. * Class used to manage all inputs for the scene.
  39159. */
  39160. export class InputManager {
  39161. /** The distance in pixel that you have to move to prevent some events */
  39162. static DragMovementThreshold: number;
  39163. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39164. static LongPressDelay: number;
  39165. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39166. static DoubleClickDelay: number;
  39167. /** If you need to check double click without raising a single click at first click, enable this flag */
  39168. static ExclusiveDoubleClickMode: boolean;
  39169. private _wheelEventName;
  39170. private _onPointerMove;
  39171. private _onPointerDown;
  39172. private _onPointerUp;
  39173. private _initClickEvent;
  39174. private _initActionManager;
  39175. private _delayedSimpleClick;
  39176. private _delayedSimpleClickTimeout;
  39177. private _previousDelayedSimpleClickTimeout;
  39178. private _meshPickProceed;
  39179. private _previousButtonPressed;
  39180. private _currentPickResult;
  39181. private _previousPickResult;
  39182. private _totalPointersPressed;
  39183. private _doubleClickOccured;
  39184. private _pointerOverMesh;
  39185. private _pickedDownMesh;
  39186. private _pickedUpMesh;
  39187. private _pointerX;
  39188. private _pointerY;
  39189. private _unTranslatedPointerX;
  39190. private _unTranslatedPointerY;
  39191. private _startingPointerPosition;
  39192. private _previousStartingPointerPosition;
  39193. private _startingPointerTime;
  39194. private _previousStartingPointerTime;
  39195. private _pointerCaptures;
  39196. private _onKeyDown;
  39197. private _onKeyUp;
  39198. private _onCanvasFocusObserver;
  39199. private _onCanvasBlurObserver;
  39200. private _scene;
  39201. /**
  39202. * Creates a new InputManager
  39203. * @param scene defines the hosting scene
  39204. */
  39205. constructor(scene: Scene);
  39206. /**
  39207. * Gets the mesh that is currently under the pointer
  39208. */
  39209. get meshUnderPointer(): Nullable<AbstractMesh>;
  39210. /**
  39211. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39212. */
  39213. get unTranslatedPointer(): Vector2;
  39214. /**
  39215. * Gets or sets the current on-screen X position of the pointer
  39216. */
  39217. get pointerX(): number;
  39218. set pointerX(value: number);
  39219. /**
  39220. * Gets or sets the current on-screen Y position of the pointer
  39221. */
  39222. get pointerY(): number;
  39223. set pointerY(value: number);
  39224. private _updatePointerPosition;
  39225. private _processPointerMove;
  39226. private _setRayOnPointerInfo;
  39227. private _checkPrePointerObservable;
  39228. /**
  39229. * Use this method to simulate a pointer move on a mesh
  39230. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39231. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39232. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39233. */
  39234. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39235. /**
  39236. * Use this method to simulate a pointer down on a mesh
  39237. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39238. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39239. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39240. */
  39241. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39242. private _processPointerDown;
  39243. /** @hidden */
  39244. _isPointerSwiping(): boolean;
  39245. /**
  39246. * Use this method to simulate a pointer up on a mesh
  39247. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39248. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39249. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39250. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39251. */
  39252. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39253. private _processPointerUp;
  39254. /**
  39255. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39256. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39257. * @returns true if the pointer was captured
  39258. */
  39259. isPointerCaptured(pointerId?: number): boolean;
  39260. /**
  39261. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39262. * @param attachUp defines if you want to attach events to pointerup
  39263. * @param attachDown defines if you want to attach events to pointerdown
  39264. * @param attachMove defines if you want to attach events to pointermove
  39265. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39266. */
  39267. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39268. /**
  39269. * Detaches all event handlers
  39270. */
  39271. detachControl(): void;
  39272. /**
  39273. * Force the value of meshUnderPointer
  39274. * @param mesh defines the mesh to use
  39275. */
  39276. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39277. /**
  39278. * Gets the mesh under the pointer
  39279. * @returns a Mesh or null if no mesh is under the pointer
  39280. */
  39281. getPointerOverMesh(): Nullable<AbstractMesh>;
  39282. }
  39283. }
  39284. declare module "babylonjs/Animations/animationGroup" {
  39285. import { Animatable } from "babylonjs/Animations/animatable";
  39286. import { Animation } from "babylonjs/Animations/animation";
  39287. import { Scene, IDisposable } from "babylonjs/scene";
  39288. import { Observable } from "babylonjs/Misc/observable";
  39289. import { Nullable } from "babylonjs/types";
  39290. import "babylonjs/Animations/animatable";
  39291. /**
  39292. * This class defines the direct association between an animation and a target
  39293. */
  39294. export class TargetedAnimation {
  39295. /**
  39296. * Animation to perform
  39297. */
  39298. animation: Animation;
  39299. /**
  39300. * Target to animate
  39301. */
  39302. target: any;
  39303. /**
  39304. * Returns the string "TargetedAnimation"
  39305. * @returns "TargetedAnimation"
  39306. */
  39307. getClassName(): string;
  39308. /**
  39309. * Serialize the object
  39310. * @returns the JSON object representing the current entity
  39311. */
  39312. serialize(): any;
  39313. }
  39314. /**
  39315. * Use this class to create coordinated animations on multiple targets
  39316. */
  39317. export class AnimationGroup implements IDisposable {
  39318. /** The name of the animation group */
  39319. name: string;
  39320. private _scene;
  39321. private _targetedAnimations;
  39322. private _animatables;
  39323. private _from;
  39324. private _to;
  39325. private _isStarted;
  39326. private _isPaused;
  39327. private _speedRatio;
  39328. private _loopAnimation;
  39329. private _isAdditive;
  39330. /**
  39331. * Gets or sets the unique id of the node
  39332. */
  39333. uniqueId: number;
  39334. /**
  39335. * This observable will notify when one animation have ended
  39336. */
  39337. onAnimationEndObservable: Observable<TargetedAnimation>;
  39338. /**
  39339. * Observer raised when one animation loops
  39340. */
  39341. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39342. /**
  39343. * Observer raised when all animations have looped
  39344. */
  39345. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39346. /**
  39347. * This observable will notify when all animations have ended.
  39348. */
  39349. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39350. /**
  39351. * This observable will notify when all animations have paused.
  39352. */
  39353. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39354. /**
  39355. * This observable will notify when all animations are playing.
  39356. */
  39357. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39358. /**
  39359. * Gets the first frame
  39360. */
  39361. get from(): number;
  39362. /**
  39363. * Gets the last frame
  39364. */
  39365. get to(): number;
  39366. /**
  39367. * Define if the animations are started
  39368. */
  39369. get isStarted(): boolean;
  39370. /**
  39371. * Gets a value indicating that the current group is playing
  39372. */
  39373. get isPlaying(): boolean;
  39374. /**
  39375. * Gets or sets the speed ratio to use for all animations
  39376. */
  39377. get speedRatio(): number;
  39378. /**
  39379. * Gets or sets the speed ratio to use for all animations
  39380. */
  39381. set speedRatio(value: number);
  39382. /**
  39383. * Gets or sets if all animations should loop or not
  39384. */
  39385. get loopAnimation(): boolean;
  39386. set loopAnimation(value: boolean);
  39387. /**
  39388. * Gets or sets if all animations should be evaluated additively
  39389. */
  39390. get isAdditive(): boolean;
  39391. set isAdditive(value: boolean);
  39392. /**
  39393. * Gets the targeted animations for this animation group
  39394. */
  39395. get targetedAnimations(): Array<TargetedAnimation>;
  39396. /**
  39397. * returning the list of animatables controlled by this animation group.
  39398. */
  39399. get animatables(): Array<Animatable>;
  39400. /**
  39401. * Gets the list of target animations
  39402. */
  39403. get children(): TargetedAnimation[];
  39404. /**
  39405. * Instantiates a new Animation Group.
  39406. * This helps managing several animations at once.
  39407. * @see http://doc.babylonjs.com/how_to/group
  39408. * @param name Defines the name of the group
  39409. * @param scene Defines the scene the group belongs to
  39410. */
  39411. constructor(
  39412. /** The name of the animation group */
  39413. name: string, scene?: Nullable<Scene>);
  39414. /**
  39415. * Add an animation (with its target) in the group
  39416. * @param animation defines the animation we want to add
  39417. * @param target defines the target of the animation
  39418. * @returns the TargetedAnimation object
  39419. */
  39420. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39421. /**
  39422. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39423. * It can add constant keys at begin or end
  39424. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39425. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39426. * @returns the animation group
  39427. */
  39428. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39429. private _animationLoopCount;
  39430. private _animationLoopFlags;
  39431. private _processLoop;
  39432. /**
  39433. * Start all animations on given targets
  39434. * @param loop defines if animations must loop
  39435. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39436. * @param from defines the from key (optional)
  39437. * @param to defines the to key (optional)
  39438. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39439. * @returns the current animation group
  39440. */
  39441. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39442. /**
  39443. * Pause all animations
  39444. * @returns the animation group
  39445. */
  39446. pause(): AnimationGroup;
  39447. /**
  39448. * Play all animations to initial state
  39449. * This function will start() the animations if they were not started or will restart() them if they were paused
  39450. * @param loop defines if animations must loop
  39451. * @returns the animation group
  39452. */
  39453. play(loop?: boolean): AnimationGroup;
  39454. /**
  39455. * Reset all animations to initial state
  39456. * @returns the animation group
  39457. */
  39458. reset(): AnimationGroup;
  39459. /**
  39460. * Restart animations from key 0
  39461. * @returns the animation group
  39462. */
  39463. restart(): AnimationGroup;
  39464. /**
  39465. * Stop all animations
  39466. * @returns the animation group
  39467. */
  39468. stop(): AnimationGroup;
  39469. /**
  39470. * Set animation weight for all animatables
  39471. * @param weight defines the weight to use
  39472. * @return the animationGroup
  39473. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39474. */
  39475. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39476. /**
  39477. * Synchronize and normalize all animatables with a source animatable
  39478. * @param root defines the root animatable to synchronize with
  39479. * @return the animationGroup
  39480. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  39481. */
  39482. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39483. /**
  39484. * Goes to a specific frame in this animation group
  39485. * @param frame the frame number to go to
  39486. * @return the animationGroup
  39487. */
  39488. goToFrame(frame: number): AnimationGroup;
  39489. /**
  39490. * Dispose all associated resources
  39491. */
  39492. dispose(): void;
  39493. private _checkAnimationGroupEnded;
  39494. /**
  39495. * Clone the current animation group and returns a copy
  39496. * @param newName defines the name of the new group
  39497. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39498. * @returns the new aniamtion group
  39499. */
  39500. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39501. /**
  39502. * Serializes the animationGroup to an object
  39503. * @returns Serialized object
  39504. */
  39505. serialize(): any;
  39506. /**
  39507. * Returns a new AnimationGroup object parsed from the source provided.
  39508. * @param parsedAnimationGroup defines the source
  39509. * @param scene defines the scene that will receive the animationGroup
  39510. * @returns a new AnimationGroup
  39511. */
  39512. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39513. /**
  39514. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39515. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39516. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39517. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39518. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39519. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39520. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39521. */
  39522. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39523. /**
  39524. * Returns the string "AnimationGroup"
  39525. * @returns "AnimationGroup"
  39526. */
  39527. getClassName(): string;
  39528. /**
  39529. * Creates a detailled string about the object
  39530. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39531. * @returns a string representing the object
  39532. */
  39533. toString(fullDetails?: boolean): string;
  39534. }
  39535. }
  39536. declare module "babylonjs/scene" {
  39537. import { Nullable } from "babylonjs/types";
  39538. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39539. import { Observable } from "babylonjs/Misc/observable";
  39540. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39541. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39542. import { Geometry } from "babylonjs/Meshes/geometry";
  39543. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39544. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39546. import { Mesh } from "babylonjs/Meshes/mesh";
  39547. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39548. import { Bone } from "babylonjs/Bones/bone";
  39549. import { Skeleton } from "babylonjs/Bones/skeleton";
  39550. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39551. import { Camera } from "babylonjs/Cameras/camera";
  39552. import { AbstractScene } from "babylonjs/abstractScene";
  39553. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39554. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39555. import { Material } from "babylonjs/Materials/material";
  39556. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39557. import { Effect } from "babylonjs/Materials/effect";
  39558. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39559. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39560. import { Light } from "babylonjs/Lights/light";
  39561. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39562. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39563. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39564. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39565. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39566. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39567. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39568. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39569. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39570. import { Engine } from "babylonjs/Engines/engine";
  39571. import { Node } from "babylonjs/node";
  39572. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39573. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39574. import { WebRequest } from "babylonjs/Misc/webRequest";
  39575. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39576. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39577. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39578. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39579. import { Plane } from "babylonjs/Maths/math.plane";
  39580. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39581. import { Ray } from "babylonjs/Culling/ray";
  39582. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39583. import { Animation } from "babylonjs/Animations/animation";
  39584. import { Animatable } from "babylonjs/Animations/animatable";
  39585. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39586. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39587. import { Collider } from "babylonjs/Collisions/collider";
  39588. /**
  39589. * Define an interface for all classes that will hold resources
  39590. */
  39591. export interface IDisposable {
  39592. /**
  39593. * Releases all held resources
  39594. */
  39595. dispose(): void;
  39596. }
  39597. /** Interface defining initialization parameters for Scene class */
  39598. export interface SceneOptions {
  39599. /**
  39600. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39601. * It will improve performance when the number of geometries becomes important.
  39602. */
  39603. useGeometryUniqueIdsMap?: boolean;
  39604. /**
  39605. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39606. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39607. */
  39608. useMaterialMeshMap?: boolean;
  39609. /**
  39610. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39611. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39612. */
  39613. useClonedMeshMap?: boolean;
  39614. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39615. virtual?: boolean;
  39616. }
  39617. /**
  39618. * Represents a scene to be rendered by the engine.
  39619. * @see http://doc.babylonjs.com/features/scene
  39620. */
  39621. export class Scene extends AbstractScene implements IAnimatable {
  39622. /** The fog is deactivated */
  39623. static readonly FOGMODE_NONE: number;
  39624. /** The fog density is following an exponential function */
  39625. static readonly FOGMODE_EXP: number;
  39626. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39627. static readonly FOGMODE_EXP2: number;
  39628. /** The fog density is following a linear function. */
  39629. static readonly FOGMODE_LINEAR: number;
  39630. /**
  39631. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39632. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39633. */
  39634. static MinDeltaTime: number;
  39635. /**
  39636. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39637. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39638. */
  39639. static MaxDeltaTime: number;
  39640. /**
  39641. * Factory used to create the default material.
  39642. * @param name The name of the material to create
  39643. * @param scene The scene to create the material for
  39644. * @returns The default material
  39645. */
  39646. static DefaultMaterialFactory(scene: Scene): Material;
  39647. /**
  39648. * Factory used to create the a collision coordinator.
  39649. * @returns The collision coordinator
  39650. */
  39651. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39652. /** @hidden */
  39653. _inputManager: InputManager;
  39654. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39655. cameraToUseForPointers: Nullable<Camera>;
  39656. /** @hidden */
  39657. readonly _isScene: boolean;
  39658. /** @hidden */
  39659. _blockEntityCollection: boolean;
  39660. /**
  39661. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39662. */
  39663. autoClear: boolean;
  39664. /**
  39665. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39666. */
  39667. autoClearDepthAndStencil: boolean;
  39668. /**
  39669. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39670. */
  39671. clearColor: Color4;
  39672. /**
  39673. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39674. */
  39675. ambientColor: Color3;
  39676. /**
  39677. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39678. * It should only be one of the following (if not the default embedded one):
  39679. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39680. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39681. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39682. * The material properties need to be setup according to the type of texture in use.
  39683. */
  39684. environmentBRDFTexture: BaseTexture;
  39685. /** @hidden */
  39686. protected _environmentTexture: Nullable<BaseTexture>;
  39687. /**
  39688. * Texture used in all pbr material as the reflection texture.
  39689. * As in the majority of the scene they are the same (exception for multi room and so on),
  39690. * this is easier to reference from here than from all the materials.
  39691. */
  39692. get environmentTexture(): Nullable<BaseTexture>;
  39693. /**
  39694. * Texture used in all pbr material as the reflection texture.
  39695. * As in the majority of the scene they are the same (exception for multi room and so on),
  39696. * this is easier to set here than in all the materials.
  39697. */
  39698. set environmentTexture(value: Nullable<BaseTexture>);
  39699. /** @hidden */
  39700. protected _environmentIntensity: number;
  39701. /**
  39702. * Intensity of the environment in all pbr material.
  39703. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39704. * As in the majority of the scene they are the same (exception for multi room and so on),
  39705. * this is easier to reference from here than from all the materials.
  39706. */
  39707. get environmentIntensity(): number;
  39708. /**
  39709. * Intensity of the environment in all pbr material.
  39710. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39711. * As in the majority of the scene they are the same (exception for multi room and so on),
  39712. * this is easier to set here than in all the materials.
  39713. */
  39714. set environmentIntensity(value: number);
  39715. /** @hidden */
  39716. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39717. /**
  39718. * Default image processing configuration used either in the rendering
  39719. * Forward main pass or through the imageProcessingPostProcess if present.
  39720. * As in the majority of the scene they are the same (exception for multi camera),
  39721. * this is easier to reference from here than from all the materials and post process.
  39722. *
  39723. * No setter as we it is a shared configuration, you can set the values instead.
  39724. */
  39725. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39726. private _forceWireframe;
  39727. /**
  39728. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39729. */
  39730. set forceWireframe(value: boolean);
  39731. get forceWireframe(): boolean;
  39732. private _skipFrustumClipping;
  39733. /**
  39734. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39735. */
  39736. set skipFrustumClipping(value: boolean);
  39737. get skipFrustumClipping(): boolean;
  39738. private _forcePointsCloud;
  39739. /**
  39740. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39741. */
  39742. set forcePointsCloud(value: boolean);
  39743. get forcePointsCloud(): boolean;
  39744. /**
  39745. * Gets or sets the active clipplane 1
  39746. */
  39747. clipPlane: Nullable<Plane>;
  39748. /**
  39749. * Gets or sets the active clipplane 2
  39750. */
  39751. clipPlane2: Nullable<Plane>;
  39752. /**
  39753. * Gets or sets the active clipplane 3
  39754. */
  39755. clipPlane3: Nullable<Plane>;
  39756. /**
  39757. * Gets or sets the active clipplane 4
  39758. */
  39759. clipPlane4: Nullable<Plane>;
  39760. /**
  39761. * Gets or sets the active clipplane 5
  39762. */
  39763. clipPlane5: Nullable<Plane>;
  39764. /**
  39765. * Gets or sets the active clipplane 6
  39766. */
  39767. clipPlane6: Nullable<Plane>;
  39768. /**
  39769. * Gets or sets a boolean indicating if animations are enabled
  39770. */
  39771. animationsEnabled: boolean;
  39772. private _animationPropertiesOverride;
  39773. /**
  39774. * Gets or sets the animation properties override
  39775. */
  39776. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39777. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39778. /**
  39779. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39780. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39781. */
  39782. useConstantAnimationDeltaTime: boolean;
  39783. /**
  39784. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39785. * Please note that it requires to run a ray cast through the scene on every frame
  39786. */
  39787. constantlyUpdateMeshUnderPointer: boolean;
  39788. /**
  39789. * Defines the HTML cursor to use when hovering over interactive elements
  39790. */
  39791. hoverCursor: string;
  39792. /**
  39793. * Defines the HTML default cursor to use (empty by default)
  39794. */
  39795. defaultCursor: string;
  39796. /**
  39797. * Defines whether cursors are handled by the scene.
  39798. */
  39799. doNotHandleCursors: boolean;
  39800. /**
  39801. * This is used to call preventDefault() on pointer down
  39802. * in order to block unwanted artifacts like system double clicks
  39803. */
  39804. preventDefaultOnPointerDown: boolean;
  39805. /**
  39806. * This is used to call preventDefault() on pointer up
  39807. * in order to block unwanted artifacts like system double clicks
  39808. */
  39809. preventDefaultOnPointerUp: boolean;
  39810. /**
  39811. * Gets or sets user defined metadata
  39812. */
  39813. metadata: any;
  39814. /**
  39815. * For internal use only. Please do not use.
  39816. */
  39817. reservedDataStore: any;
  39818. /**
  39819. * Gets the name of the plugin used to load this scene (null by default)
  39820. */
  39821. loadingPluginName: string;
  39822. /**
  39823. * Use this array to add regular expressions used to disable offline support for specific urls
  39824. */
  39825. disableOfflineSupportExceptionRules: RegExp[];
  39826. /**
  39827. * An event triggered when the scene is disposed.
  39828. */
  39829. onDisposeObservable: Observable<Scene>;
  39830. private _onDisposeObserver;
  39831. /** Sets a function to be executed when this scene is disposed. */
  39832. set onDispose(callback: () => void);
  39833. /**
  39834. * An event triggered before rendering the scene (right after animations and physics)
  39835. */
  39836. onBeforeRenderObservable: Observable<Scene>;
  39837. private _onBeforeRenderObserver;
  39838. /** Sets a function to be executed before rendering this scene */
  39839. set beforeRender(callback: Nullable<() => void>);
  39840. /**
  39841. * An event triggered after rendering the scene
  39842. */
  39843. onAfterRenderObservable: Observable<Scene>;
  39844. /**
  39845. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39846. */
  39847. onAfterRenderCameraObservable: Observable<Camera>;
  39848. private _onAfterRenderObserver;
  39849. /** Sets a function to be executed after rendering this scene */
  39850. set afterRender(callback: Nullable<() => void>);
  39851. /**
  39852. * An event triggered before animating the scene
  39853. */
  39854. onBeforeAnimationsObservable: Observable<Scene>;
  39855. /**
  39856. * An event triggered after animations processing
  39857. */
  39858. onAfterAnimationsObservable: Observable<Scene>;
  39859. /**
  39860. * An event triggered before draw calls are ready to be sent
  39861. */
  39862. onBeforeDrawPhaseObservable: Observable<Scene>;
  39863. /**
  39864. * An event triggered after draw calls have been sent
  39865. */
  39866. onAfterDrawPhaseObservable: Observable<Scene>;
  39867. /**
  39868. * An event triggered when the scene is ready
  39869. */
  39870. onReadyObservable: Observable<Scene>;
  39871. /**
  39872. * An event triggered before rendering a camera
  39873. */
  39874. onBeforeCameraRenderObservable: Observable<Camera>;
  39875. private _onBeforeCameraRenderObserver;
  39876. /** Sets a function to be executed before rendering a camera*/
  39877. set beforeCameraRender(callback: () => void);
  39878. /**
  39879. * An event triggered after rendering a camera
  39880. */
  39881. onAfterCameraRenderObservable: Observable<Camera>;
  39882. private _onAfterCameraRenderObserver;
  39883. /** Sets a function to be executed after rendering a camera*/
  39884. set afterCameraRender(callback: () => void);
  39885. /**
  39886. * An event triggered when active meshes evaluation is about to start
  39887. */
  39888. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39889. /**
  39890. * An event triggered when active meshes evaluation is done
  39891. */
  39892. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39893. /**
  39894. * An event triggered when particles rendering is about to start
  39895. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39896. */
  39897. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39898. /**
  39899. * An event triggered when particles rendering is done
  39900. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39901. */
  39902. onAfterParticlesRenderingObservable: Observable<Scene>;
  39903. /**
  39904. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39905. */
  39906. onDataLoadedObservable: Observable<Scene>;
  39907. /**
  39908. * An event triggered when a camera is created
  39909. */
  39910. onNewCameraAddedObservable: Observable<Camera>;
  39911. /**
  39912. * An event triggered when a camera is removed
  39913. */
  39914. onCameraRemovedObservable: Observable<Camera>;
  39915. /**
  39916. * An event triggered when a light is created
  39917. */
  39918. onNewLightAddedObservable: Observable<Light>;
  39919. /**
  39920. * An event triggered when a light is removed
  39921. */
  39922. onLightRemovedObservable: Observable<Light>;
  39923. /**
  39924. * An event triggered when a geometry is created
  39925. */
  39926. onNewGeometryAddedObservable: Observable<Geometry>;
  39927. /**
  39928. * An event triggered when a geometry is removed
  39929. */
  39930. onGeometryRemovedObservable: Observable<Geometry>;
  39931. /**
  39932. * An event triggered when a transform node is created
  39933. */
  39934. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39935. /**
  39936. * An event triggered when a transform node is removed
  39937. */
  39938. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39939. /**
  39940. * An event triggered when a mesh is created
  39941. */
  39942. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39943. /**
  39944. * An event triggered when a mesh is removed
  39945. */
  39946. onMeshRemovedObservable: Observable<AbstractMesh>;
  39947. /**
  39948. * An event triggered when a skeleton is created
  39949. */
  39950. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39951. /**
  39952. * An event triggered when a skeleton is removed
  39953. */
  39954. onSkeletonRemovedObservable: Observable<Skeleton>;
  39955. /**
  39956. * An event triggered when a material is created
  39957. */
  39958. onNewMaterialAddedObservable: Observable<Material>;
  39959. /**
  39960. * An event triggered when a material is removed
  39961. */
  39962. onMaterialRemovedObservable: Observable<Material>;
  39963. /**
  39964. * An event triggered when a texture is created
  39965. */
  39966. onNewTextureAddedObservable: Observable<BaseTexture>;
  39967. /**
  39968. * An event triggered when a texture is removed
  39969. */
  39970. onTextureRemovedObservable: Observable<BaseTexture>;
  39971. /**
  39972. * An event triggered when render targets are about to be rendered
  39973. * Can happen multiple times per frame.
  39974. */
  39975. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39976. /**
  39977. * An event triggered when render targets were rendered.
  39978. * Can happen multiple times per frame.
  39979. */
  39980. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39981. /**
  39982. * An event triggered before calculating deterministic simulation step
  39983. */
  39984. onBeforeStepObservable: Observable<Scene>;
  39985. /**
  39986. * An event triggered after calculating deterministic simulation step
  39987. */
  39988. onAfterStepObservable: Observable<Scene>;
  39989. /**
  39990. * An event triggered when the activeCamera property is updated
  39991. */
  39992. onActiveCameraChanged: Observable<Scene>;
  39993. /**
  39994. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39995. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39996. * 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)
  39997. */
  39998. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39999. /**
  40000. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40001. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40002. * 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)
  40003. */
  40004. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40005. /**
  40006. * This Observable will when a mesh has been imported into the scene.
  40007. */
  40008. onMeshImportedObservable: Observable<AbstractMesh>;
  40009. /**
  40010. * This Observable will when an animation file has been imported into the scene.
  40011. */
  40012. onAnimationFileImportedObservable: Observable<Scene>;
  40013. /**
  40014. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40015. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40016. */
  40017. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40018. /** @hidden */
  40019. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40020. /**
  40021. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40022. */
  40023. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40024. /**
  40025. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40026. */
  40027. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40028. /**
  40029. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40030. */
  40031. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40032. /** Callback called when a pointer move is detected */
  40033. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40034. /** Callback called when a pointer down is detected */
  40035. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40036. /** Callback called when a pointer up is detected */
  40037. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40038. /** Callback called when a pointer pick is detected */
  40039. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40040. /**
  40041. * 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).
  40042. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40043. */
  40044. onPrePointerObservable: Observable<PointerInfoPre>;
  40045. /**
  40046. * Observable event triggered each time an input event is received from the rendering canvas
  40047. */
  40048. onPointerObservable: Observable<PointerInfo>;
  40049. /**
  40050. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40051. */
  40052. get unTranslatedPointer(): Vector2;
  40053. /**
  40054. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40055. */
  40056. static get DragMovementThreshold(): number;
  40057. static set DragMovementThreshold(value: number);
  40058. /**
  40059. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40060. */
  40061. static get LongPressDelay(): number;
  40062. static set LongPressDelay(value: number);
  40063. /**
  40064. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40065. */
  40066. static get DoubleClickDelay(): number;
  40067. static set DoubleClickDelay(value: number);
  40068. /** If you need to check double click without raising a single click at first click, enable this flag */
  40069. static get ExclusiveDoubleClickMode(): boolean;
  40070. static set ExclusiveDoubleClickMode(value: boolean);
  40071. /** @hidden */
  40072. _mirroredCameraPosition: Nullable<Vector3>;
  40073. /**
  40074. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40075. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40076. */
  40077. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40078. /**
  40079. * Observable event triggered each time an keyboard event is received from the hosting window
  40080. */
  40081. onKeyboardObservable: Observable<KeyboardInfo>;
  40082. private _useRightHandedSystem;
  40083. /**
  40084. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40085. */
  40086. set useRightHandedSystem(value: boolean);
  40087. get useRightHandedSystem(): boolean;
  40088. private _timeAccumulator;
  40089. private _currentStepId;
  40090. private _currentInternalStep;
  40091. /**
  40092. * Sets the step Id used by deterministic lock step
  40093. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40094. * @param newStepId defines the step Id
  40095. */
  40096. setStepId(newStepId: number): void;
  40097. /**
  40098. * Gets the step Id used by deterministic lock step
  40099. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40100. * @returns the step Id
  40101. */
  40102. getStepId(): number;
  40103. /**
  40104. * Gets the internal step used by deterministic lock step
  40105. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40106. * @returns the internal step
  40107. */
  40108. getInternalStep(): number;
  40109. private _fogEnabled;
  40110. /**
  40111. * Gets or sets a boolean indicating if fog is enabled on this scene
  40112. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40113. * (Default is true)
  40114. */
  40115. set fogEnabled(value: boolean);
  40116. get fogEnabled(): boolean;
  40117. private _fogMode;
  40118. /**
  40119. * Gets or sets the fog mode to use
  40120. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40121. * | mode | value |
  40122. * | --- | --- |
  40123. * | FOGMODE_NONE | 0 |
  40124. * | FOGMODE_EXP | 1 |
  40125. * | FOGMODE_EXP2 | 2 |
  40126. * | FOGMODE_LINEAR | 3 |
  40127. */
  40128. set fogMode(value: number);
  40129. get fogMode(): number;
  40130. /**
  40131. * Gets or sets the fog color to use
  40132. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40133. * (Default is Color3(0.2, 0.2, 0.3))
  40134. */
  40135. fogColor: Color3;
  40136. /**
  40137. * Gets or sets the fog density to use
  40138. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40139. * (Default is 0.1)
  40140. */
  40141. fogDensity: number;
  40142. /**
  40143. * Gets or sets the fog start distance to use
  40144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40145. * (Default is 0)
  40146. */
  40147. fogStart: number;
  40148. /**
  40149. * Gets or sets the fog end distance to use
  40150. * @see http://doc.babylonjs.com/babylon101/environment#fog
  40151. * (Default is 1000)
  40152. */
  40153. fogEnd: number;
  40154. private _shadowsEnabled;
  40155. /**
  40156. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40157. */
  40158. set shadowsEnabled(value: boolean);
  40159. get shadowsEnabled(): boolean;
  40160. private _lightsEnabled;
  40161. /**
  40162. * Gets or sets a boolean indicating if lights are enabled on this scene
  40163. */
  40164. set lightsEnabled(value: boolean);
  40165. get lightsEnabled(): boolean;
  40166. /** All of the active cameras added to this scene. */
  40167. activeCameras: Camera[];
  40168. /** @hidden */
  40169. _activeCamera: Nullable<Camera>;
  40170. /** Gets or sets the current active camera */
  40171. get activeCamera(): Nullable<Camera>;
  40172. set activeCamera(value: Nullable<Camera>);
  40173. private _defaultMaterial;
  40174. /** The default material used on meshes when no material is affected */
  40175. get defaultMaterial(): Material;
  40176. /** The default material used on meshes when no material is affected */
  40177. set defaultMaterial(value: Material);
  40178. private _texturesEnabled;
  40179. /**
  40180. * Gets or sets a boolean indicating if textures are enabled on this scene
  40181. */
  40182. set texturesEnabled(value: boolean);
  40183. get texturesEnabled(): boolean;
  40184. /**
  40185. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40186. */
  40187. physicsEnabled: boolean;
  40188. /**
  40189. * Gets or sets a boolean indicating if particles are enabled on this scene
  40190. */
  40191. particlesEnabled: boolean;
  40192. /**
  40193. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40194. */
  40195. spritesEnabled: boolean;
  40196. private _skeletonsEnabled;
  40197. /**
  40198. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40199. */
  40200. set skeletonsEnabled(value: boolean);
  40201. get skeletonsEnabled(): boolean;
  40202. /**
  40203. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40204. */
  40205. lensFlaresEnabled: boolean;
  40206. /**
  40207. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40209. */
  40210. collisionsEnabled: boolean;
  40211. private _collisionCoordinator;
  40212. /** @hidden */
  40213. get collisionCoordinator(): ICollisionCoordinator;
  40214. /**
  40215. * Defines the gravity applied to this scene (used only for collisions)
  40216. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40217. */
  40218. gravity: Vector3;
  40219. /**
  40220. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40221. */
  40222. postProcessesEnabled: boolean;
  40223. /**
  40224. * The list of postprocesses added to the scene
  40225. */
  40226. postProcesses: PostProcess[];
  40227. /**
  40228. * Gets the current postprocess manager
  40229. */
  40230. postProcessManager: PostProcessManager;
  40231. /**
  40232. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40233. */
  40234. renderTargetsEnabled: boolean;
  40235. /**
  40236. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40237. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40238. */
  40239. dumpNextRenderTargets: boolean;
  40240. /**
  40241. * The list of user defined render targets added to the scene
  40242. */
  40243. customRenderTargets: RenderTargetTexture[];
  40244. /**
  40245. * Defines if texture loading must be delayed
  40246. * If true, textures will only be loaded when they need to be rendered
  40247. */
  40248. useDelayedTextureLoading: boolean;
  40249. /**
  40250. * Gets the list of meshes imported to the scene through SceneLoader
  40251. */
  40252. importedMeshesFiles: String[];
  40253. /**
  40254. * Gets or sets a boolean indicating if probes are enabled on this scene
  40255. */
  40256. probesEnabled: boolean;
  40257. /**
  40258. * Gets or sets the current offline provider to use to store scene data
  40259. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40260. */
  40261. offlineProvider: IOfflineProvider;
  40262. /**
  40263. * Gets or sets the action manager associated with the scene
  40264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40265. */
  40266. actionManager: AbstractActionManager;
  40267. private _meshesForIntersections;
  40268. /**
  40269. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40270. */
  40271. proceduralTexturesEnabled: boolean;
  40272. private _engine;
  40273. private _totalVertices;
  40274. /** @hidden */
  40275. _activeIndices: PerfCounter;
  40276. /** @hidden */
  40277. _activeParticles: PerfCounter;
  40278. /** @hidden */
  40279. _activeBones: PerfCounter;
  40280. private _animationRatio;
  40281. /** @hidden */
  40282. _animationTimeLast: number;
  40283. /** @hidden */
  40284. _animationTime: number;
  40285. /**
  40286. * Gets or sets a general scale for animation speed
  40287. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40288. */
  40289. animationTimeScale: number;
  40290. /** @hidden */
  40291. _cachedMaterial: Nullable<Material>;
  40292. /** @hidden */
  40293. _cachedEffect: Nullable<Effect>;
  40294. /** @hidden */
  40295. _cachedVisibility: Nullable<number>;
  40296. private _renderId;
  40297. private _frameId;
  40298. private _executeWhenReadyTimeoutId;
  40299. private _intermediateRendering;
  40300. private _viewUpdateFlag;
  40301. private _projectionUpdateFlag;
  40302. /** @hidden */
  40303. _toBeDisposed: Nullable<IDisposable>[];
  40304. private _activeRequests;
  40305. /** @hidden */
  40306. _pendingData: any[];
  40307. private _isDisposed;
  40308. /**
  40309. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40310. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40311. */
  40312. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40313. private _activeMeshes;
  40314. private _processedMaterials;
  40315. private _renderTargets;
  40316. /** @hidden */
  40317. _activeParticleSystems: SmartArray<IParticleSystem>;
  40318. private _activeSkeletons;
  40319. private _softwareSkinnedMeshes;
  40320. private _renderingManager;
  40321. /** @hidden */
  40322. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40323. private _transformMatrix;
  40324. private _sceneUbo;
  40325. /** @hidden */
  40326. _viewMatrix: Matrix;
  40327. private _projectionMatrix;
  40328. /** @hidden */
  40329. _forcedViewPosition: Nullable<Vector3>;
  40330. /** @hidden */
  40331. _frustumPlanes: Plane[];
  40332. /**
  40333. * Gets the list of frustum planes (built from the active camera)
  40334. */
  40335. get frustumPlanes(): Plane[];
  40336. /**
  40337. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40338. * This is useful if there are more lights that the maximum simulteanous authorized
  40339. */
  40340. requireLightSorting: boolean;
  40341. /** @hidden */
  40342. readonly useMaterialMeshMap: boolean;
  40343. /** @hidden */
  40344. readonly useClonedMeshMap: boolean;
  40345. private _externalData;
  40346. private _uid;
  40347. /**
  40348. * @hidden
  40349. * Backing store of defined scene components.
  40350. */
  40351. _components: ISceneComponent[];
  40352. /**
  40353. * @hidden
  40354. * Backing store of defined scene components.
  40355. */
  40356. _serializableComponents: ISceneSerializableComponent[];
  40357. /**
  40358. * List of components to register on the next registration step.
  40359. */
  40360. private _transientComponents;
  40361. /**
  40362. * Registers the transient components if needed.
  40363. */
  40364. private _registerTransientComponents;
  40365. /**
  40366. * @hidden
  40367. * Add a component to the scene.
  40368. * Note that the ccomponent could be registered on th next frame if this is called after
  40369. * the register component stage.
  40370. * @param component Defines the component to add to the scene
  40371. */
  40372. _addComponent(component: ISceneComponent): void;
  40373. /**
  40374. * @hidden
  40375. * Gets a component from the scene.
  40376. * @param name defines the name of the component to retrieve
  40377. * @returns the component or null if not present
  40378. */
  40379. _getComponent(name: string): Nullable<ISceneComponent>;
  40380. /**
  40381. * @hidden
  40382. * Defines the actions happening before camera updates.
  40383. */
  40384. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40385. /**
  40386. * @hidden
  40387. * Defines the actions happening before clear the canvas.
  40388. */
  40389. _beforeClearStage: Stage<SimpleStageAction>;
  40390. /**
  40391. * @hidden
  40392. * Defines the actions when collecting render targets for the frame.
  40393. */
  40394. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40395. /**
  40396. * @hidden
  40397. * Defines the actions happening for one camera in the frame.
  40398. */
  40399. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40400. /**
  40401. * @hidden
  40402. * Defines the actions happening during the per mesh ready checks.
  40403. */
  40404. _isReadyForMeshStage: Stage<MeshStageAction>;
  40405. /**
  40406. * @hidden
  40407. * Defines the actions happening before evaluate active mesh checks.
  40408. */
  40409. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40410. /**
  40411. * @hidden
  40412. * Defines the actions happening during the evaluate sub mesh checks.
  40413. */
  40414. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40415. /**
  40416. * @hidden
  40417. * Defines the actions happening during the active mesh stage.
  40418. */
  40419. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40420. /**
  40421. * @hidden
  40422. * Defines the actions happening during the per camera render target step.
  40423. */
  40424. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40425. /**
  40426. * @hidden
  40427. * Defines the actions happening just before the active camera is drawing.
  40428. */
  40429. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40430. /**
  40431. * @hidden
  40432. * Defines the actions happening just before a render target is drawing.
  40433. */
  40434. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40435. /**
  40436. * @hidden
  40437. * Defines the actions happening just before a rendering group is drawing.
  40438. */
  40439. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40440. /**
  40441. * @hidden
  40442. * Defines the actions happening just before a mesh is drawing.
  40443. */
  40444. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40445. /**
  40446. * @hidden
  40447. * Defines the actions happening just after a mesh has been drawn.
  40448. */
  40449. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40450. /**
  40451. * @hidden
  40452. * Defines the actions happening just after a rendering group has been drawn.
  40453. */
  40454. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40455. /**
  40456. * @hidden
  40457. * Defines the actions happening just after the active camera has been drawn.
  40458. */
  40459. _afterCameraDrawStage: Stage<CameraStageAction>;
  40460. /**
  40461. * @hidden
  40462. * Defines the actions happening just after a render target has been drawn.
  40463. */
  40464. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40465. /**
  40466. * @hidden
  40467. * Defines the actions happening just after rendering all cameras and computing intersections.
  40468. */
  40469. _afterRenderStage: Stage<SimpleStageAction>;
  40470. /**
  40471. * @hidden
  40472. * Defines the actions happening when a pointer move event happens.
  40473. */
  40474. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40475. /**
  40476. * @hidden
  40477. * Defines the actions happening when a pointer down event happens.
  40478. */
  40479. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40480. /**
  40481. * @hidden
  40482. * Defines the actions happening when a pointer up event happens.
  40483. */
  40484. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40485. /**
  40486. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40487. */
  40488. private geometriesByUniqueId;
  40489. /**
  40490. * Creates a new Scene
  40491. * @param engine defines the engine to use to render this scene
  40492. * @param options defines the scene options
  40493. */
  40494. constructor(engine: Engine, options?: SceneOptions);
  40495. /**
  40496. * Gets a string idenfifying the name of the class
  40497. * @returns "Scene" string
  40498. */
  40499. getClassName(): string;
  40500. private _defaultMeshCandidates;
  40501. /**
  40502. * @hidden
  40503. */
  40504. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40505. private _defaultSubMeshCandidates;
  40506. /**
  40507. * @hidden
  40508. */
  40509. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40510. /**
  40511. * Sets the default candidate providers for the scene.
  40512. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40513. * and getCollidingSubMeshCandidates to their default function
  40514. */
  40515. setDefaultCandidateProviders(): void;
  40516. /**
  40517. * Gets the mesh that is currently under the pointer
  40518. */
  40519. get meshUnderPointer(): Nullable<AbstractMesh>;
  40520. /**
  40521. * Gets or sets the current on-screen X position of the pointer
  40522. */
  40523. get pointerX(): number;
  40524. set pointerX(value: number);
  40525. /**
  40526. * Gets or sets the current on-screen Y position of the pointer
  40527. */
  40528. get pointerY(): number;
  40529. set pointerY(value: number);
  40530. /**
  40531. * Gets the cached material (ie. the latest rendered one)
  40532. * @returns the cached material
  40533. */
  40534. getCachedMaterial(): Nullable<Material>;
  40535. /**
  40536. * Gets the cached effect (ie. the latest rendered one)
  40537. * @returns the cached effect
  40538. */
  40539. getCachedEffect(): Nullable<Effect>;
  40540. /**
  40541. * Gets the cached visibility state (ie. the latest rendered one)
  40542. * @returns the cached visibility state
  40543. */
  40544. getCachedVisibility(): Nullable<number>;
  40545. /**
  40546. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40547. * @param material defines the current material
  40548. * @param effect defines the current effect
  40549. * @param visibility defines the current visibility state
  40550. * @returns true if one parameter is not cached
  40551. */
  40552. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40553. /**
  40554. * Gets the engine associated with the scene
  40555. * @returns an Engine
  40556. */
  40557. getEngine(): Engine;
  40558. /**
  40559. * Gets the total number of vertices rendered per frame
  40560. * @returns the total number of vertices rendered per frame
  40561. */
  40562. getTotalVertices(): number;
  40563. /**
  40564. * Gets the performance counter for total vertices
  40565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40566. */
  40567. get totalVerticesPerfCounter(): PerfCounter;
  40568. /**
  40569. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40570. * @returns the total number of active indices rendered per frame
  40571. */
  40572. getActiveIndices(): number;
  40573. /**
  40574. * Gets the performance counter for active indices
  40575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40576. */
  40577. get totalActiveIndicesPerfCounter(): PerfCounter;
  40578. /**
  40579. * Gets the total number of active particles rendered per frame
  40580. * @returns the total number of active particles rendered per frame
  40581. */
  40582. getActiveParticles(): number;
  40583. /**
  40584. * Gets the performance counter for active particles
  40585. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40586. */
  40587. get activeParticlesPerfCounter(): PerfCounter;
  40588. /**
  40589. * Gets the total number of active bones rendered per frame
  40590. * @returns the total number of active bones rendered per frame
  40591. */
  40592. getActiveBones(): number;
  40593. /**
  40594. * Gets the performance counter for active bones
  40595. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40596. */
  40597. get activeBonesPerfCounter(): PerfCounter;
  40598. /**
  40599. * Gets the array of active meshes
  40600. * @returns an array of AbstractMesh
  40601. */
  40602. getActiveMeshes(): SmartArray<AbstractMesh>;
  40603. /**
  40604. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40605. * @returns a number
  40606. */
  40607. getAnimationRatio(): number;
  40608. /**
  40609. * Gets an unique Id for the current render phase
  40610. * @returns a number
  40611. */
  40612. getRenderId(): number;
  40613. /**
  40614. * Gets an unique Id for the current frame
  40615. * @returns a number
  40616. */
  40617. getFrameId(): number;
  40618. /** Call this function if you want to manually increment the render Id*/
  40619. incrementRenderId(): void;
  40620. private _createUbo;
  40621. /**
  40622. * Use this method to simulate a pointer move on a mesh
  40623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40626. * @returns the current scene
  40627. */
  40628. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40629. /**
  40630. * Use this method to simulate a pointer down on a mesh
  40631. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40632. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40633. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40634. * @returns the current scene
  40635. */
  40636. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40637. /**
  40638. * Use this method to simulate a pointer up on a mesh
  40639. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40640. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40641. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40642. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40643. * @returns the current scene
  40644. */
  40645. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40646. /**
  40647. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40648. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40649. * @returns true if the pointer was captured
  40650. */
  40651. isPointerCaptured(pointerId?: number): boolean;
  40652. /**
  40653. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40654. * @param attachUp defines if you want to attach events to pointerup
  40655. * @param attachDown defines if you want to attach events to pointerdown
  40656. * @param attachMove defines if you want to attach events to pointermove
  40657. */
  40658. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40659. /** Detaches all event handlers*/
  40660. detachControl(): void;
  40661. /**
  40662. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40663. * Delay loaded resources are not taking in account
  40664. * @return true if all required resources are ready
  40665. */
  40666. isReady(): boolean;
  40667. /** Resets all cached information relative to material (including effect and visibility) */
  40668. resetCachedMaterial(): void;
  40669. /**
  40670. * Registers a function to be called before every frame render
  40671. * @param func defines the function to register
  40672. */
  40673. registerBeforeRender(func: () => void): void;
  40674. /**
  40675. * Unregisters a function called before every frame render
  40676. * @param func defines the function to unregister
  40677. */
  40678. unregisterBeforeRender(func: () => void): void;
  40679. /**
  40680. * Registers a function to be called after every frame render
  40681. * @param func defines the function to register
  40682. */
  40683. registerAfterRender(func: () => void): void;
  40684. /**
  40685. * Unregisters a function called after every frame render
  40686. * @param func defines the function to unregister
  40687. */
  40688. unregisterAfterRender(func: () => void): void;
  40689. private _executeOnceBeforeRender;
  40690. /**
  40691. * The provided function will run before render once and will be disposed afterwards.
  40692. * A timeout delay can be provided so that the function will be executed in N ms.
  40693. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40694. * @param func The function to be executed.
  40695. * @param timeout optional delay in ms
  40696. */
  40697. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40698. /** @hidden */
  40699. _addPendingData(data: any): void;
  40700. /** @hidden */
  40701. _removePendingData(data: any): void;
  40702. /**
  40703. * Returns the number of items waiting to be loaded
  40704. * @returns the number of items waiting to be loaded
  40705. */
  40706. getWaitingItemsCount(): number;
  40707. /**
  40708. * Returns a boolean indicating if the scene is still loading data
  40709. */
  40710. get isLoading(): boolean;
  40711. /**
  40712. * Registers a function to be executed when the scene is ready
  40713. * @param {Function} func - the function to be executed
  40714. */
  40715. executeWhenReady(func: () => void): void;
  40716. /**
  40717. * Returns a promise that resolves when the scene is ready
  40718. * @returns A promise that resolves when the scene is ready
  40719. */
  40720. whenReadyAsync(): Promise<void>;
  40721. /** @hidden */
  40722. _checkIsReady(): void;
  40723. /**
  40724. * Gets all animatable attached to the scene
  40725. */
  40726. get animatables(): Animatable[];
  40727. /**
  40728. * Resets the last animation time frame.
  40729. * Useful to override when animations start running when loading a scene for the first time.
  40730. */
  40731. resetLastAnimationTimeFrame(): void;
  40732. /**
  40733. * Gets the current view matrix
  40734. * @returns a Matrix
  40735. */
  40736. getViewMatrix(): Matrix;
  40737. /**
  40738. * Gets the current projection matrix
  40739. * @returns a Matrix
  40740. */
  40741. getProjectionMatrix(): Matrix;
  40742. /**
  40743. * Gets the current transform matrix
  40744. * @returns a Matrix made of View * Projection
  40745. */
  40746. getTransformMatrix(): Matrix;
  40747. /**
  40748. * Sets the current transform matrix
  40749. * @param viewL defines the View matrix to use
  40750. * @param projectionL defines the Projection matrix to use
  40751. * @param viewR defines the right View matrix to use (if provided)
  40752. * @param projectionR defines the right Projection matrix to use (if provided)
  40753. */
  40754. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40755. /**
  40756. * Gets the uniform buffer used to store scene data
  40757. * @returns a UniformBuffer
  40758. */
  40759. getSceneUniformBuffer(): UniformBuffer;
  40760. /**
  40761. * Gets an unique (relatively to the current scene) Id
  40762. * @returns an unique number for the scene
  40763. */
  40764. getUniqueId(): number;
  40765. /**
  40766. * Add a mesh to the list of scene's meshes
  40767. * @param newMesh defines the mesh to add
  40768. * @param recursive if all child meshes should also be added to the scene
  40769. */
  40770. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40771. /**
  40772. * Remove a mesh for the list of scene's meshes
  40773. * @param toRemove defines the mesh to remove
  40774. * @param recursive if all child meshes should also be removed from the scene
  40775. * @returns the index where the mesh was in the mesh list
  40776. */
  40777. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40778. /**
  40779. * Add a transform node to the list of scene's transform nodes
  40780. * @param newTransformNode defines the transform node to add
  40781. */
  40782. addTransformNode(newTransformNode: TransformNode): void;
  40783. /**
  40784. * Remove a transform node for the list of scene's transform nodes
  40785. * @param toRemove defines the transform node to remove
  40786. * @returns the index where the transform node was in the transform node list
  40787. */
  40788. removeTransformNode(toRemove: TransformNode): number;
  40789. /**
  40790. * Remove a skeleton for the list of scene's skeletons
  40791. * @param toRemove defines the skeleton to remove
  40792. * @returns the index where the skeleton was in the skeleton list
  40793. */
  40794. removeSkeleton(toRemove: Skeleton): number;
  40795. /**
  40796. * Remove a morph target for the list of scene's morph targets
  40797. * @param toRemove defines the morph target to remove
  40798. * @returns the index where the morph target was in the morph target list
  40799. */
  40800. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40801. /**
  40802. * Remove a light for the list of scene's lights
  40803. * @param toRemove defines the light to remove
  40804. * @returns the index where the light was in the light list
  40805. */
  40806. removeLight(toRemove: Light): number;
  40807. /**
  40808. * Remove a camera for the list of scene's cameras
  40809. * @param toRemove defines the camera to remove
  40810. * @returns the index where the camera was in the camera list
  40811. */
  40812. removeCamera(toRemove: Camera): number;
  40813. /**
  40814. * Remove a particle system for the list of scene's particle systems
  40815. * @param toRemove defines the particle system to remove
  40816. * @returns the index where the particle system was in the particle system list
  40817. */
  40818. removeParticleSystem(toRemove: IParticleSystem): number;
  40819. /**
  40820. * Remove a animation for the list of scene's animations
  40821. * @param toRemove defines the animation to remove
  40822. * @returns the index where the animation was in the animation list
  40823. */
  40824. removeAnimation(toRemove: Animation): number;
  40825. /**
  40826. * Will stop the animation of the given target
  40827. * @param target - the target
  40828. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40829. * @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)
  40830. */
  40831. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40832. /**
  40833. * Removes the given animation group from this scene.
  40834. * @param toRemove The animation group to remove
  40835. * @returns The index of the removed animation group
  40836. */
  40837. removeAnimationGroup(toRemove: AnimationGroup): number;
  40838. /**
  40839. * Removes the given multi-material from this scene.
  40840. * @param toRemove The multi-material to remove
  40841. * @returns The index of the removed multi-material
  40842. */
  40843. removeMultiMaterial(toRemove: MultiMaterial): number;
  40844. /**
  40845. * Removes the given material from this scene.
  40846. * @param toRemove The material to remove
  40847. * @returns The index of the removed material
  40848. */
  40849. removeMaterial(toRemove: Material): number;
  40850. /**
  40851. * Removes the given action manager from this scene.
  40852. * @param toRemove The action manager to remove
  40853. * @returns The index of the removed action manager
  40854. */
  40855. removeActionManager(toRemove: AbstractActionManager): number;
  40856. /**
  40857. * Removes the given texture from this scene.
  40858. * @param toRemove The texture to remove
  40859. * @returns The index of the removed texture
  40860. */
  40861. removeTexture(toRemove: BaseTexture): number;
  40862. /**
  40863. * Adds the given light to this scene
  40864. * @param newLight The light to add
  40865. */
  40866. addLight(newLight: Light): void;
  40867. /**
  40868. * Sorts the list list based on light priorities
  40869. */
  40870. sortLightsByPriority(): void;
  40871. /**
  40872. * Adds the given camera to this scene
  40873. * @param newCamera The camera to add
  40874. */
  40875. addCamera(newCamera: Camera): void;
  40876. /**
  40877. * Adds the given skeleton to this scene
  40878. * @param newSkeleton The skeleton to add
  40879. */
  40880. addSkeleton(newSkeleton: Skeleton): void;
  40881. /**
  40882. * Adds the given particle system to this scene
  40883. * @param newParticleSystem The particle system to add
  40884. */
  40885. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40886. /**
  40887. * Adds the given animation to this scene
  40888. * @param newAnimation The animation to add
  40889. */
  40890. addAnimation(newAnimation: Animation): void;
  40891. /**
  40892. * Adds the given animation group to this scene.
  40893. * @param newAnimationGroup The animation group to add
  40894. */
  40895. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40896. /**
  40897. * Adds the given multi-material to this scene
  40898. * @param newMultiMaterial The multi-material to add
  40899. */
  40900. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40901. /**
  40902. * Adds the given material to this scene
  40903. * @param newMaterial The material to add
  40904. */
  40905. addMaterial(newMaterial: Material): void;
  40906. /**
  40907. * Adds the given morph target to this scene
  40908. * @param newMorphTargetManager The morph target to add
  40909. */
  40910. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40911. /**
  40912. * Adds the given geometry to this scene
  40913. * @param newGeometry The geometry to add
  40914. */
  40915. addGeometry(newGeometry: Geometry): void;
  40916. /**
  40917. * Adds the given action manager to this scene
  40918. * @param newActionManager The action manager to add
  40919. */
  40920. addActionManager(newActionManager: AbstractActionManager): void;
  40921. /**
  40922. * Adds the given texture to this scene.
  40923. * @param newTexture The texture to add
  40924. */
  40925. addTexture(newTexture: BaseTexture): void;
  40926. /**
  40927. * Switch active camera
  40928. * @param newCamera defines the new active camera
  40929. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40930. */
  40931. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40932. /**
  40933. * sets the active camera of the scene using its ID
  40934. * @param id defines the camera's ID
  40935. * @return the new active camera or null if none found.
  40936. */
  40937. setActiveCameraByID(id: string): Nullable<Camera>;
  40938. /**
  40939. * sets the active camera of the scene using its name
  40940. * @param name defines the camera's name
  40941. * @returns the new active camera or null if none found.
  40942. */
  40943. setActiveCameraByName(name: string): Nullable<Camera>;
  40944. /**
  40945. * get an animation group using its name
  40946. * @param name defines the material's name
  40947. * @return the animation group or null if none found.
  40948. */
  40949. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40950. /**
  40951. * Get a material using its unique id
  40952. * @param uniqueId defines the material's unique id
  40953. * @return the material or null if none found.
  40954. */
  40955. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40956. /**
  40957. * get a material using its id
  40958. * @param id defines the material's ID
  40959. * @return the material or null if none found.
  40960. */
  40961. getMaterialByID(id: string): Nullable<Material>;
  40962. /**
  40963. * Gets a the last added material using a given id
  40964. * @param id defines the material's ID
  40965. * @return the last material with the given id or null if none found.
  40966. */
  40967. getLastMaterialByID(id: string): Nullable<Material>;
  40968. /**
  40969. * Gets a material using its name
  40970. * @param name defines the material's name
  40971. * @return the material or null if none found.
  40972. */
  40973. getMaterialByName(name: string): Nullable<Material>;
  40974. /**
  40975. * Get a texture using its unique id
  40976. * @param uniqueId defines the texture's unique id
  40977. * @return the texture or null if none found.
  40978. */
  40979. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40980. /**
  40981. * Gets a camera using its id
  40982. * @param id defines the id to look for
  40983. * @returns the camera or null if not found
  40984. */
  40985. getCameraByID(id: string): Nullable<Camera>;
  40986. /**
  40987. * Gets a camera using its unique id
  40988. * @param uniqueId defines the unique id to look for
  40989. * @returns the camera or null if not found
  40990. */
  40991. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40992. /**
  40993. * Gets a camera using its name
  40994. * @param name defines the camera's name
  40995. * @return the camera or null if none found.
  40996. */
  40997. getCameraByName(name: string): Nullable<Camera>;
  40998. /**
  40999. * Gets a bone using its id
  41000. * @param id defines the bone's id
  41001. * @return the bone or null if not found
  41002. */
  41003. getBoneByID(id: string): Nullable<Bone>;
  41004. /**
  41005. * Gets a bone using its id
  41006. * @param name defines the bone's name
  41007. * @return the bone or null if not found
  41008. */
  41009. getBoneByName(name: string): Nullable<Bone>;
  41010. /**
  41011. * Gets a light node using its name
  41012. * @param name defines the the light's name
  41013. * @return the light or null if none found.
  41014. */
  41015. getLightByName(name: string): Nullable<Light>;
  41016. /**
  41017. * Gets a light node using its id
  41018. * @param id defines the light's id
  41019. * @return the light or null if none found.
  41020. */
  41021. getLightByID(id: string): Nullable<Light>;
  41022. /**
  41023. * Gets a light node using its scene-generated unique ID
  41024. * @param uniqueId defines the light's unique id
  41025. * @return the light or null if none found.
  41026. */
  41027. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41028. /**
  41029. * Gets a particle system by id
  41030. * @param id defines the particle system id
  41031. * @return the corresponding system or null if none found
  41032. */
  41033. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41034. /**
  41035. * Gets a geometry using its ID
  41036. * @param id defines the geometry's id
  41037. * @return the geometry or null if none found.
  41038. */
  41039. getGeometryByID(id: string): Nullable<Geometry>;
  41040. private _getGeometryByUniqueID;
  41041. /**
  41042. * Add a new geometry to this scene
  41043. * @param geometry defines the geometry to be added to the scene.
  41044. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41045. * @return a boolean defining if the geometry was added or not
  41046. */
  41047. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41048. /**
  41049. * Removes an existing geometry
  41050. * @param geometry defines the geometry to be removed from the scene
  41051. * @return a boolean defining if the geometry was removed or not
  41052. */
  41053. removeGeometry(geometry: Geometry): boolean;
  41054. /**
  41055. * Gets the list of geometries attached to the scene
  41056. * @returns an array of Geometry
  41057. */
  41058. getGeometries(): Geometry[];
  41059. /**
  41060. * Gets the first added mesh found of a given ID
  41061. * @param id defines the id to search for
  41062. * @return the mesh found or null if not found at all
  41063. */
  41064. getMeshByID(id: string): Nullable<AbstractMesh>;
  41065. /**
  41066. * Gets a list of meshes using their id
  41067. * @param id defines the id to search for
  41068. * @returns a list of meshes
  41069. */
  41070. getMeshesByID(id: string): Array<AbstractMesh>;
  41071. /**
  41072. * Gets the first added transform node found of a given ID
  41073. * @param id defines the id to search for
  41074. * @return the found transform node or null if not found at all.
  41075. */
  41076. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41077. /**
  41078. * Gets a transform node with its auto-generated unique id
  41079. * @param uniqueId efines the unique id to search for
  41080. * @return the found transform node or null if not found at all.
  41081. */
  41082. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41083. /**
  41084. * Gets a list of transform nodes using their id
  41085. * @param id defines the id to search for
  41086. * @returns a list of transform nodes
  41087. */
  41088. getTransformNodesByID(id: string): Array<TransformNode>;
  41089. /**
  41090. * Gets a mesh with its auto-generated unique id
  41091. * @param uniqueId defines the unique id to search for
  41092. * @return the found mesh or null if not found at all.
  41093. */
  41094. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41095. /**
  41096. * Gets a the last added mesh using a given id
  41097. * @param id defines the id to search for
  41098. * @return the found mesh or null if not found at all.
  41099. */
  41100. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41101. /**
  41102. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41103. * @param id defines the id to search for
  41104. * @return the found node or null if not found at all
  41105. */
  41106. getLastEntryByID(id: string): Nullable<Node>;
  41107. /**
  41108. * Gets a node (Mesh, Camera, Light) using a given id
  41109. * @param id defines the id to search for
  41110. * @return the found node or null if not found at all
  41111. */
  41112. getNodeByID(id: string): Nullable<Node>;
  41113. /**
  41114. * Gets a node (Mesh, Camera, Light) using a given name
  41115. * @param name defines the name to search for
  41116. * @return the found node or null if not found at all.
  41117. */
  41118. getNodeByName(name: string): Nullable<Node>;
  41119. /**
  41120. * Gets a mesh using a given name
  41121. * @param name defines the name to search for
  41122. * @return the found mesh or null if not found at all.
  41123. */
  41124. getMeshByName(name: string): Nullable<AbstractMesh>;
  41125. /**
  41126. * Gets a transform node using a given name
  41127. * @param name defines the name to search for
  41128. * @return the found transform node or null if not found at all.
  41129. */
  41130. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41131. /**
  41132. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41133. * @param id defines the id to search for
  41134. * @return the found skeleton or null if not found at all.
  41135. */
  41136. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41137. /**
  41138. * Gets a skeleton using a given auto generated unique id
  41139. * @param uniqueId defines the unique id to search for
  41140. * @return the found skeleton or null if not found at all.
  41141. */
  41142. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41143. /**
  41144. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41145. * @param id defines the id to search for
  41146. * @return the found skeleton or null if not found at all.
  41147. */
  41148. getSkeletonById(id: string): Nullable<Skeleton>;
  41149. /**
  41150. * Gets a skeleton using a given name
  41151. * @param name defines the name to search for
  41152. * @return the found skeleton or null if not found at all.
  41153. */
  41154. getSkeletonByName(name: string): Nullable<Skeleton>;
  41155. /**
  41156. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41157. * @param id defines the id to search for
  41158. * @return the found morph target manager or null if not found at all.
  41159. */
  41160. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41161. /**
  41162. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41163. * @param id defines the id to search for
  41164. * @return the found morph target or null if not found at all.
  41165. */
  41166. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41167. /**
  41168. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41169. * @param name defines the name to search for
  41170. * @return the found morph target or null if not found at all.
  41171. */
  41172. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41173. /**
  41174. * Gets a boolean indicating if the given mesh is active
  41175. * @param mesh defines the mesh to look for
  41176. * @returns true if the mesh is in the active list
  41177. */
  41178. isActiveMesh(mesh: AbstractMesh): boolean;
  41179. /**
  41180. * Return a unique id as a string which can serve as an identifier for the scene
  41181. */
  41182. get uid(): string;
  41183. /**
  41184. * Add an externaly attached data from its key.
  41185. * This method call will fail and return false, if such key already exists.
  41186. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41187. * @param key the unique key that identifies the data
  41188. * @param data the data object to associate to the key for this Engine instance
  41189. * @return true if no such key were already present and the data was added successfully, false otherwise
  41190. */
  41191. addExternalData<T>(key: string, data: T): boolean;
  41192. /**
  41193. * Get an externaly attached data from its key
  41194. * @param key the unique key that identifies the data
  41195. * @return the associated data, if present (can be null), or undefined if not present
  41196. */
  41197. getExternalData<T>(key: string): Nullable<T>;
  41198. /**
  41199. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41200. * @param key the unique key that identifies the data
  41201. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41202. * @return the associated data, can be null if the factory returned null.
  41203. */
  41204. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41205. /**
  41206. * Remove an externaly attached data from the Engine instance
  41207. * @param key the unique key that identifies the data
  41208. * @return true if the data was successfully removed, false if it doesn't exist
  41209. */
  41210. removeExternalData(key: string): boolean;
  41211. private _evaluateSubMesh;
  41212. /**
  41213. * Clear the processed materials smart array preventing retention point in material dispose.
  41214. */
  41215. freeProcessedMaterials(): void;
  41216. private _preventFreeActiveMeshesAndRenderingGroups;
  41217. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41218. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41219. * when disposing several meshes in a row or a hierarchy of meshes.
  41220. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41221. */
  41222. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41223. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41224. /**
  41225. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41226. */
  41227. freeActiveMeshes(): void;
  41228. /**
  41229. * Clear the info related to rendering groups preventing retention points during dispose.
  41230. */
  41231. freeRenderingGroups(): void;
  41232. /** @hidden */
  41233. _isInIntermediateRendering(): boolean;
  41234. /**
  41235. * Lambda returning the list of potentially active meshes.
  41236. */
  41237. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41238. /**
  41239. * Lambda returning the list of potentially active sub meshes.
  41240. */
  41241. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41242. /**
  41243. * Lambda returning the list of potentially intersecting sub meshes.
  41244. */
  41245. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41246. /**
  41247. * Lambda returning the list of potentially colliding sub meshes.
  41248. */
  41249. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41250. private _activeMeshesFrozen;
  41251. private _skipEvaluateActiveMeshesCompletely;
  41252. /**
  41253. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41254. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41255. * @returns the current scene
  41256. */
  41257. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41258. /**
  41259. * Use this function to restart evaluating active meshes on every frame
  41260. * @returns the current scene
  41261. */
  41262. unfreezeActiveMeshes(): Scene;
  41263. private _evaluateActiveMeshes;
  41264. private _activeMesh;
  41265. /**
  41266. * Update the transform matrix to update from the current active camera
  41267. * @param force defines a boolean used to force the update even if cache is up to date
  41268. */
  41269. updateTransformMatrix(force?: boolean): void;
  41270. private _bindFrameBuffer;
  41271. /** @hidden */
  41272. _allowPostProcessClearColor: boolean;
  41273. /** @hidden */
  41274. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41275. private _processSubCameras;
  41276. private _checkIntersections;
  41277. /** @hidden */
  41278. _advancePhysicsEngineStep(step: number): void;
  41279. /**
  41280. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41281. */
  41282. getDeterministicFrameTime: () => number;
  41283. /** @hidden */
  41284. _animate(): void;
  41285. /** Execute all animations (for a frame) */
  41286. animate(): void;
  41287. /**
  41288. * Render the scene
  41289. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41290. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41291. */
  41292. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41293. /**
  41294. * Freeze all materials
  41295. * A frozen material will not be updatable but should be faster to render
  41296. */
  41297. freezeMaterials(): void;
  41298. /**
  41299. * Unfreeze all materials
  41300. * A frozen material will not be updatable but should be faster to render
  41301. */
  41302. unfreezeMaterials(): void;
  41303. /**
  41304. * Releases all held ressources
  41305. */
  41306. dispose(): void;
  41307. /**
  41308. * Gets if the scene is already disposed
  41309. */
  41310. get isDisposed(): boolean;
  41311. /**
  41312. * Call this function to reduce memory footprint of the scene.
  41313. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41314. */
  41315. clearCachedVertexData(): void;
  41316. /**
  41317. * This function will remove the local cached buffer data from texture.
  41318. * It will save memory but will prevent the texture from being rebuilt
  41319. */
  41320. cleanCachedTextureBuffer(): void;
  41321. /**
  41322. * Get the world extend vectors with an optional filter
  41323. *
  41324. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41325. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41326. */
  41327. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41328. min: Vector3;
  41329. max: Vector3;
  41330. };
  41331. /**
  41332. * Creates a ray that can be used to pick in the scene
  41333. * @param x defines the x coordinate of the origin (on-screen)
  41334. * @param y defines the y coordinate of the origin (on-screen)
  41335. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41336. * @param camera defines the camera to use for the picking
  41337. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41338. * @returns a Ray
  41339. */
  41340. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41341. /**
  41342. * Creates a ray that can be used to pick in the scene
  41343. * @param x defines the x coordinate of the origin (on-screen)
  41344. * @param y defines the y coordinate of the origin (on-screen)
  41345. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41346. * @param result defines the ray where to store the picking ray
  41347. * @param camera defines the camera to use for the picking
  41348. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41349. * @returns the current scene
  41350. */
  41351. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41352. /**
  41353. * Creates a ray that can be used to pick in the scene
  41354. * @param x defines the x coordinate of the origin (on-screen)
  41355. * @param y defines the y coordinate of the origin (on-screen)
  41356. * @param camera defines the camera to use for the picking
  41357. * @returns a Ray
  41358. */
  41359. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41360. /**
  41361. * Creates a ray that can be used to pick in the scene
  41362. * @param x defines the x coordinate of the origin (on-screen)
  41363. * @param y defines the y coordinate of the origin (on-screen)
  41364. * @param result defines the ray where to store the picking ray
  41365. * @param camera defines the camera to use for the picking
  41366. * @returns the current scene
  41367. */
  41368. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41369. /** Launch a ray to try to pick a mesh in the scene
  41370. * @param x position on screen
  41371. * @param y position on screen
  41372. * @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
  41373. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41374. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41375. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41376. * @returns a PickingInfo
  41377. */
  41378. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41379. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41380. * @param x position on screen
  41381. * @param y position on screen
  41382. * @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
  41383. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41384. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41385. * @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)
  41386. */
  41387. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41388. /** Use the given ray to pick a mesh in the scene
  41389. * @param ray The ray to use to pick meshes
  41390. * @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
  41391. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41392. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41393. * @returns a PickingInfo
  41394. */
  41395. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41396. /**
  41397. * Launch a ray to try to pick a mesh in the scene
  41398. * @param x X position on screen
  41399. * @param y Y position on screen
  41400. * @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
  41401. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41402. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41403. * @returns an array of PickingInfo
  41404. */
  41405. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41406. /**
  41407. * Launch a ray to try to pick a mesh in the scene
  41408. * @param ray Ray to use
  41409. * @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
  41410. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41411. * @returns an array of PickingInfo
  41412. */
  41413. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41414. /**
  41415. * Force the value of meshUnderPointer
  41416. * @param mesh defines the mesh to use
  41417. */
  41418. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41419. /**
  41420. * Gets the mesh under the pointer
  41421. * @returns a Mesh or null if no mesh is under the pointer
  41422. */
  41423. getPointerOverMesh(): Nullable<AbstractMesh>;
  41424. /** @hidden */
  41425. _rebuildGeometries(): void;
  41426. /** @hidden */
  41427. _rebuildTextures(): void;
  41428. private _getByTags;
  41429. /**
  41430. * Get a list of meshes by tags
  41431. * @param tagsQuery defines the tags query to use
  41432. * @param forEach defines a predicate used to filter results
  41433. * @returns an array of Mesh
  41434. */
  41435. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41436. /**
  41437. * Get a list of cameras by tags
  41438. * @param tagsQuery defines the tags query to use
  41439. * @param forEach defines a predicate used to filter results
  41440. * @returns an array of Camera
  41441. */
  41442. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41443. /**
  41444. * Get a list of lights by tags
  41445. * @param tagsQuery defines the tags query to use
  41446. * @param forEach defines a predicate used to filter results
  41447. * @returns an array of Light
  41448. */
  41449. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41450. /**
  41451. * Get a list of materials by tags
  41452. * @param tagsQuery defines the tags query to use
  41453. * @param forEach defines a predicate used to filter results
  41454. * @returns an array of Material
  41455. */
  41456. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41457. /**
  41458. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41459. * This allowed control for front to back rendering or reversly depending of the special needs.
  41460. *
  41461. * @param renderingGroupId The rendering group id corresponding to its index
  41462. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41463. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41464. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41465. */
  41466. 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;
  41467. /**
  41468. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41469. *
  41470. * @param renderingGroupId The rendering group id corresponding to its index
  41471. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41472. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41473. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41474. */
  41475. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41476. /**
  41477. * Gets the current auto clear configuration for one rendering group of the rendering
  41478. * manager.
  41479. * @param index the rendering group index to get the information for
  41480. * @returns The auto clear setup for the requested rendering group
  41481. */
  41482. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41483. private _blockMaterialDirtyMechanism;
  41484. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41485. get blockMaterialDirtyMechanism(): boolean;
  41486. set blockMaterialDirtyMechanism(value: boolean);
  41487. /**
  41488. * Will flag all materials as dirty to trigger new shader compilation
  41489. * @param flag defines the flag used to specify which material part must be marked as dirty
  41490. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41491. */
  41492. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41493. /** @hidden */
  41494. _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;
  41495. /** @hidden */
  41496. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41497. /** @hidden */
  41498. _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;
  41499. /** @hidden */
  41500. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41501. /** @hidden */
  41502. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41503. /** @hidden */
  41504. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41505. }
  41506. }
  41507. declare module "babylonjs/assetContainer" {
  41508. import { AbstractScene } from "babylonjs/abstractScene";
  41509. import { Scene } from "babylonjs/scene";
  41510. import { Mesh } from "babylonjs/Meshes/mesh";
  41511. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41512. import { Skeleton } from "babylonjs/Bones/skeleton";
  41513. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41514. import { Animatable } from "babylonjs/Animations/animatable";
  41515. import { Nullable } from "babylonjs/types";
  41516. import { Node } from "babylonjs/node";
  41517. /**
  41518. * Set of assets to keep when moving a scene into an asset container.
  41519. */
  41520. export class KeepAssets extends AbstractScene {
  41521. }
  41522. /**
  41523. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41524. */
  41525. export class InstantiatedEntries {
  41526. /**
  41527. * List of new root nodes (eg. nodes with no parent)
  41528. */
  41529. rootNodes: TransformNode[];
  41530. /**
  41531. * List of new skeletons
  41532. */
  41533. skeletons: Skeleton[];
  41534. /**
  41535. * List of new animation groups
  41536. */
  41537. animationGroups: AnimationGroup[];
  41538. }
  41539. /**
  41540. * Container with a set of assets that can be added or removed from a scene.
  41541. */
  41542. export class AssetContainer extends AbstractScene {
  41543. private _wasAddedToScene;
  41544. /**
  41545. * The scene the AssetContainer belongs to.
  41546. */
  41547. scene: Scene;
  41548. /**
  41549. * Instantiates an AssetContainer.
  41550. * @param scene The scene the AssetContainer belongs to.
  41551. */
  41552. constructor(scene: Scene);
  41553. /**
  41554. * Instantiate or clone all meshes and add the new ones to the scene.
  41555. * Skeletons and animation groups will all be cloned
  41556. * @param nameFunction defines an optional function used to get new names for clones
  41557. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41558. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41559. */
  41560. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41561. /**
  41562. * Adds all the assets from the container to the scene.
  41563. */
  41564. addAllToScene(): void;
  41565. /**
  41566. * Removes all the assets in the container from the scene
  41567. */
  41568. removeAllFromScene(): void;
  41569. /**
  41570. * Disposes all the assets in the container
  41571. */
  41572. dispose(): void;
  41573. private _moveAssets;
  41574. /**
  41575. * Removes all the assets contained in the scene and adds them to the container.
  41576. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41577. */
  41578. moveAllFromScene(keepAssets?: KeepAssets): void;
  41579. /**
  41580. * 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.
  41581. * @returns the root mesh
  41582. */
  41583. createRootMesh(): Mesh;
  41584. /**
  41585. * Merge animations (direct and animation groups) from this asset container into a scene
  41586. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41587. * @param animatables set of animatables to retarget to a node from the scene
  41588. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41589. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41590. */
  41591. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41592. }
  41593. }
  41594. declare module "babylonjs/abstractScene" {
  41595. import { Scene } from "babylonjs/scene";
  41596. import { Nullable } from "babylonjs/types";
  41597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41598. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41599. import { Geometry } from "babylonjs/Meshes/geometry";
  41600. import { Skeleton } from "babylonjs/Bones/skeleton";
  41601. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41602. import { AssetContainer } from "babylonjs/assetContainer";
  41603. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41604. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41606. import { Material } from "babylonjs/Materials/material";
  41607. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41608. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41609. import { Camera } from "babylonjs/Cameras/camera";
  41610. import { Light } from "babylonjs/Lights/light";
  41611. import { Node } from "babylonjs/node";
  41612. import { Animation } from "babylonjs/Animations/animation";
  41613. /**
  41614. * Defines how the parser contract is defined.
  41615. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41616. */
  41617. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41618. /**
  41619. * Defines how the individual parser contract is defined.
  41620. * These parser can parse an individual asset
  41621. */
  41622. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41623. /**
  41624. * Base class of the scene acting as a container for the different elements composing a scene.
  41625. * This class is dynamically extended by the different components of the scene increasing
  41626. * flexibility and reducing coupling
  41627. */
  41628. export abstract class AbstractScene {
  41629. /**
  41630. * Stores the list of available parsers in the application.
  41631. */
  41632. private static _BabylonFileParsers;
  41633. /**
  41634. * Stores the list of available individual parsers in the application.
  41635. */
  41636. private static _IndividualBabylonFileParsers;
  41637. /**
  41638. * Adds a parser in the list of available ones
  41639. * @param name Defines the name of the parser
  41640. * @param parser Defines the parser to add
  41641. */
  41642. static AddParser(name: string, parser: BabylonFileParser): void;
  41643. /**
  41644. * Gets a general parser from the list of avaialble ones
  41645. * @param name Defines the name of the parser
  41646. * @returns the requested parser or null
  41647. */
  41648. static GetParser(name: string): Nullable<BabylonFileParser>;
  41649. /**
  41650. * Adds n individual parser in the list of available ones
  41651. * @param name Defines the name of the parser
  41652. * @param parser Defines the parser to add
  41653. */
  41654. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41655. /**
  41656. * Gets an individual parser from the list of avaialble ones
  41657. * @param name Defines the name of the parser
  41658. * @returns the requested parser or null
  41659. */
  41660. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41661. /**
  41662. * Parser json data and populate both a scene and its associated container object
  41663. * @param jsonData Defines the data to parse
  41664. * @param scene Defines the scene to parse the data for
  41665. * @param container Defines the container attached to the parsing sequence
  41666. * @param rootUrl Defines the root url of the data
  41667. */
  41668. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41669. /**
  41670. * Gets the list of root nodes (ie. nodes with no parent)
  41671. */
  41672. rootNodes: Node[];
  41673. /** All of the cameras added to this scene
  41674. * @see http://doc.babylonjs.com/babylon101/cameras
  41675. */
  41676. cameras: Camera[];
  41677. /**
  41678. * All of the lights added to this scene
  41679. * @see http://doc.babylonjs.com/babylon101/lights
  41680. */
  41681. lights: Light[];
  41682. /**
  41683. * All of the (abstract) meshes added to this scene
  41684. */
  41685. meshes: AbstractMesh[];
  41686. /**
  41687. * The list of skeletons added to the scene
  41688. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41689. */
  41690. skeletons: Skeleton[];
  41691. /**
  41692. * All of the particle systems added to this scene
  41693. * @see http://doc.babylonjs.com/babylon101/particles
  41694. */
  41695. particleSystems: IParticleSystem[];
  41696. /**
  41697. * Gets a list of Animations associated with the scene
  41698. */
  41699. animations: Animation[];
  41700. /**
  41701. * All of the animation groups added to this scene
  41702. * @see http://doc.babylonjs.com/how_to/group
  41703. */
  41704. animationGroups: AnimationGroup[];
  41705. /**
  41706. * All of the multi-materials added to this scene
  41707. * @see http://doc.babylonjs.com/how_to/multi_materials
  41708. */
  41709. multiMaterials: MultiMaterial[];
  41710. /**
  41711. * All of the materials added to this scene
  41712. * In the context of a Scene, it is not supposed to be modified manually.
  41713. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41714. * Note also that the order of the Material within the array is not significant and might change.
  41715. * @see http://doc.babylonjs.com/babylon101/materials
  41716. */
  41717. materials: Material[];
  41718. /**
  41719. * The list of morph target managers added to the scene
  41720. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41721. */
  41722. morphTargetManagers: MorphTargetManager[];
  41723. /**
  41724. * The list of geometries used in the scene.
  41725. */
  41726. geometries: Geometry[];
  41727. /**
  41728. * All of the tranform nodes added to this scene
  41729. * In the context of a Scene, it is not supposed to be modified manually.
  41730. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41731. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41732. * @see http://doc.babylonjs.com/how_to/transformnode
  41733. */
  41734. transformNodes: TransformNode[];
  41735. /**
  41736. * ActionManagers available on the scene.
  41737. */
  41738. actionManagers: AbstractActionManager[];
  41739. /**
  41740. * Textures to keep.
  41741. */
  41742. textures: BaseTexture[];
  41743. /**
  41744. * Environment texture for the scene
  41745. */
  41746. environmentTexture: Nullable<BaseTexture>;
  41747. /**
  41748. * @returns all meshes, lights, cameras, transformNodes and bones
  41749. */
  41750. getNodes(): Array<Node>;
  41751. }
  41752. }
  41753. declare module "babylonjs/Audio/sound" {
  41754. import { Observable } from "babylonjs/Misc/observable";
  41755. import { Vector3 } from "babylonjs/Maths/math.vector";
  41756. import { Nullable } from "babylonjs/types";
  41757. import { Scene } from "babylonjs/scene";
  41758. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41759. /**
  41760. * Interface used to define options for Sound class
  41761. */
  41762. export interface ISoundOptions {
  41763. /**
  41764. * Does the sound autoplay once loaded.
  41765. */
  41766. autoplay?: boolean;
  41767. /**
  41768. * Does the sound loop after it finishes playing once.
  41769. */
  41770. loop?: boolean;
  41771. /**
  41772. * Sound's volume
  41773. */
  41774. volume?: number;
  41775. /**
  41776. * Is it a spatial sound?
  41777. */
  41778. spatialSound?: boolean;
  41779. /**
  41780. * Maximum distance to hear that sound
  41781. */
  41782. maxDistance?: number;
  41783. /**
  41784. * Uses user defined attenuation function
  41785. */
  41786. useCustomAttenuation?: boolean;
  41787. /**
  41788. * Define the roll off factor of spatial sounds.
  41789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41790. */
  41791. rolloffFactor?: number;
  41792. /**
  41793. * Define the reference distance the sound should be heard perfectly.
  41794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41795. */
  41796. refDistance?: number;
  41797. /**
  41798. * Define the distance attenuation model the sound will follow.
  41799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41800. */
  41801. distanceModel?: string;
  41802. /**
  41803. * Defines the playback speed (1 by default)
  41804. */
  41805. playbackRate?: number;
  41806. /**
  41807. * Defines if the sound is from a streaming source
  41808. */
  41809. streaming?: boolean;
  41810. /**
  41811. * Defines an optional length (in seconds) inside the sound file
  41812. */
  41813. length?: number;
  41814. /**
  41815. * Defines an optional offset (in seconds) inside the sound file
  41816. */
  41817. offset?: number;
  41818. /**
  41819. * If true, URLs will not be required to state the audio file codec to use.
  41820. */
  41821. skipCodecCheck?: boolean;
  41822. }
  41823. /**
  41824. * Defines a sound that can be played in the application.
  41825. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41827. */
  41828. export class Sound {
  41829. /**
  41830. * The name of the sound in the scene.
  41831. */
  41832. name: string;
  41833. /**
  41834. * Does the sound autoplay once loaded.
  41835. */
  41836. autoplay: boolean;
  41837. /**
  41838. * Does the sound loop after it finishes playing once.
  41839. */
  41840. loop: boolean;
  41841. /**
  41842. * Does the sound use a custom attenuation curve to simulate the falloff
  41843. * happening when the source gets further away from the camera.
  41844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41845. */
  41846. useCustomAttenuation: boolean;
  41847. /**
  41848. * The sound track id this sound belongs to.
  41849. */
  41850. soundTrackId: number;
  41851. /**
  41852. * Is this sound currently played.
  41853. */
  41854. isPlaying: boolean;
  41855. /**
  41856. * Is this sound currently paused.
  41857. */
  41858. isPaused: boolean;
  41859. /**
  41860. * Does this sound enables spatial sound.
  41861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41862. */
  41863. spatialSound: boolean;
  41864. /**
  41865. * Define the reference distance the sound should be heard perfectly.
  41866. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41867. */
  41868. refDistance: number;
  41869. /**
  41870. * Define the roll off factor of spatial sounds.
  41871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41872. */
  41873. rolloffFactor: number;
  41874. /**
  41875. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41877. */
  41878. maxDistance: number;
  41879. /**
  41880. * Define the distance attenuation model the sound will follow.
  41881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41882. */
  41883. distanceModel: string;
  41884. /**
  41885. * @hidden
  41886. * Back Compat
  41887. **/
  41888. onended: () => any;
  41889. /**
  41890. * Gets or sets an object used to store user defined information for the sound.
  41891. */
  41892. metadata: any;
  41893. /**
  41894. * Observable event when the current playing sound finishes.
  41895. */
  41896. onEndedObservable: Observable<Sound>;
  41897. private _panningModel;
  41898. private _playbackRate;
  41899. private _streaming;
  41900. private _startTime;
  41901. private _startOffset;
  41902. private _position;
  41903. /** @hidden */
  41904. _positionInEmitterSpace: boolean;
  41905. private _localDirection;
  41906. private _volume;
  41907. private _isReadyToPlay;
  41908. private _isDirectional;
  41909. private _readyToPlayCallback;
  41910. private _audioBuffer;
  41911. private _soundSource;
  41912. private _streamingSource;
  41913. private _soundPanner;
  41914. private _soundGain;
  41915. private _inputAudioNode;
  41916. private _outputAudioNode;
  41917. private _coneInnerAngle;
  41918. private _coneOuterAngle;
  41919. private _coneOuterGain;
  41920. private _scene;
  41921. private _connectedTransformNode;
  41922. private _customAttenuationFunction;
  41923. private _registerFunc;
  41924. private _isOutputConnected;
  41925. private _htmlAudioElement;
  41926. private _urlType;
  41927. private _length?;
  41928. private _offset?;
  41929. /** @hidden */
  41930. static _SceneComponentInitialization: (scene: Scene) => void;
  41931. /**
  41932. * Create a sound and attach it to a scene
  41933. * @param name Name of your sound
  41934. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41935. * @param scene defines the scene the sound belongs to
  41936. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41937. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41938. */
  41939. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41940. /**
  41941. * Release the sound and its associated resources
  41942. */
  41943. dispose(): void;
  41944. /**
  41945. * Gets if the sounds is ready to be played or not.
  41946. * @returns true if ready, otherwise false
  41947. */
  41948. isReady(): boolean;
  41949. private _soundLoaded;
  41950. /**
  41951. * Sets the data of the sound from an audiobuffer
  41952. * @param audioBuffer The audioBuffer containing the data
  41953. */
  41954. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41955. /**
  41956. * Updates the current sounds options such as maxdistance, loop...
  41957. * @param options A JSON object containing values named as the object properties
  41958. */
  41959. updateOptions(options: ISoundOptions): void;
  41960. private _createSpatialParameters;
  41961. private _updateSpatialParameters;
  41962. /**
  41963. * Switch the panning model to HRTF:
  41964. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41966. */
  41967. switchPanningModelToHRTF(): void;
  41968. /**
  41969. * Switch the panning model to Equal Power:
  41970. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41971. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41972. */
  41973. switchPanningModelToEqualPower(): void;
  41974. private _switchPanningModel;
  41975. /**
  41976. * Connect this sound to a sound track audio node like gain...
  41977. * @param soundTrackAudioNode the sound track audio node to connect to
  41978. */
  41979. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41980. /**
  41981. * Transform this sound into a directional source
  41982. * @param coneInnerAngle Size of the inner cone in degree
  41983. * @param coneOuterAngle Size of the outer cone in degree
  41984. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41985. */
  41986. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41987. /**
  41988. * Gets or sets the inner angle for the directional cone.
  41989. */
  41990. get directionalConeInnerAngle(): number;
  41991. /**
  41992. * Gets or sets the inner angle for the directional cone.
  41993. */
  41994. set directionalConeInnerAngle(value: number);
  41995. /**
  41996. * Gets or sets the outer angle for the directional cone.
  41997. */
  41998. get directionalConeOuterAngle(): number;
  41999. /**
  42000. * Gets or sets the outer angle for the directional cone.
  42001. */
  42002. set directionalConeOuterAngle(value: number);
  42003. /**
  42004. * Sets the position of the emitter if spatial sound is enabled
  42005. * @param newPosition Defines the new posisiton
  42006. */
  42007. setPosition(newPosition: Vector3): void;
  42008. /**
  42009. * Sets the local direction of the emitter if spatial sound is enabled
  42010. * @param newLocalDirection Defines the new local direction
  42011. */
  42012. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42013. private _updateDirection;
  42014. /** @hidden */
  42015. updateDistanceFromListener(): void;
  42016. /**
  42017. * Sets a new custom attenuation function for the sound.
  42018. * @param callback Defines the function used for the attenuation
  42019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42020. */
  42021. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42022. /**
  42023. * Play the sound
  42024. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42025. * @param offset (optional) Start the sound at a specific time in seconds
  42026. * @param length (optional) Sound duration (in seconds)
  42027. */
  42028. play(time?: number, offset?: number, length?: number): void;
  42029. private _onended;
  42030. /**
  42031. * Stop the sound
  42032. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42033. */
  42034. stop(time?: number): void;
  42035. /**
  42036. * Put the sound in pause
  42037. */
  42038. pause(): void;
  42039. /**
  42040. * Sets a dedicated volume for this sounds
  42041. * @param newVolume Define the new volume of the sound
  42042. * @param time Define time for gradual change to new volume
  42043. */
  42044. setVolume(newVolume: number, time?: number): void;
  42045. /**
  42046. * Set the sound play back rate
  42047. * @param newPlaybackRate Define the playback rate the sound should be played at
  42048. */
  42049. setPlaybackRate(newPlaybackRate: number): void;
  42050. /**
  42051. * Gets the volume of the sound.
  42052. * @returns the volume of the sound
  42053. */
  42054. getVolume(): number;
  42055. /**
  42056. * Attach the sound to a dedicated mesh
  42057. * @param transformNode The transform node to connect the sound with
  42058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42059. */
  42060. attachToMesh(transformNode: TransformNode): void;
  42061. /**
  42062. * Detach the sound from the previously attached mesh
  42063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42064. */
  42065. detachFromMesh(): void;
  42066. private _onRegisterAfterWorldMatrixUpdate;
  42067. /**
  42068. * Clone the current sound in the scene.
  42069. * @returns the new sound clone
  42070. */
  42071. clone(): Nullable<Sound>;
  42072. /**
  42073. * Gets the current underlying audio buffer containing the data
  42074. * @returns the audio buffer
  42075. */
  42076. getAudioBuffer(): Nullable<AudioBuffer>;
  42077. /**
  42078. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42079. * @returns the source node
  42080. */
  42081. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42082. /**
  42083. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42084. * @returns the gain node
  42085. */
  42086. getSoundGain(): Nullable<GainNode>;
  42087. /**
  42088. * Serializes the Sound in a JSON representation
  42089. * @returns the JSON representation of the sound
  42090. */
  42091. serialize(): any;
  42092. /**
  42093. * Parse a JSON representation of a sound to innstantiate in a given scene
  42094. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42095. * @param scene Define the scene the new parsed sound should be created in
  42096. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42097. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42098. * @returns the newly parsed sound
  42099. */
  42100. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42101. }
  42102. }
  42103. declare module "babylonjs/Actions/directAudioActions" {
  42104. import { Action } from "babylonjs/Actions/action";
  42105. import { Condition } from "babylonjs/Actions/condition";
  42106. import { Sound } from "babylonjs/Audio/sound";
  42107. /**
  42108. * This defines an action helpful to play a defined sound on a triggered action.
  42109. */
  42110. export class PlaySoundAction extends Action {
  42111. private _sound;
  42112. /**
  42113. * Instantiate the action
  42114. * @param triggerOptions defines the trigger options
  42115. * @param sound defines the sound to play
  42116. * @param condition defines the trigger related conditions
  42117. */
  42118. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42119. /** @hidden */
  42120. _prepare(): void;
  42121. /**
  42122. * Execute the action and play the sound.
  42123. */
  42124. execute(): void;
  42125. /**
  42126. * Serializes the actions and its related information.
  42127. * @param parent defines the object to serialize in
  42128. * @returns the serialized object
  42129. */
  42130. serialize(parent: any): any;
  42131. }
  42132. /**
  42133. * This defines an action helpful to stop a defined sound on a triggered action.
  42134. */
  42135. export class StopSoundAction extends Action {
  42136. private _sound;
  42137. /**
  42138. * Instantiate the action
  42139. * @param triggerOptions defines the trigger options
  42140. * @param sound defines the sound to stop
  42141. * @param condition defines the trigger related conditions
  42142. */
  42143. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42144. /** @hidden */
  42145. _prepare(): void;
  42146. /**
  42147. * Execute the action and stop the sound.
  42148. */
  42149. execute(): void;
  42150. /**
  42151. * Serializes the actions and its related information.
  42152. * @param parent defines the object to serialize in
  42153. * @returns the serialized object
  42154. */
  42155. serialize(parent: any): any;
  42156. }
  42157. }
  42158. declare module "babylonjs/Actions/interpolateValueAction" {
  42159. import { Action } from "babylonjs/Actions/action";
  42160. import { Condition } from "babylonjs/Actions/condition";
  42161. import { Observable } from "babylonjs/Misc/observable";
  42162. /**
  42163. * This defines an action responsible to change the value of a property
  42164. * by interpolating between its current value and the newly set one once triggered.
  42165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  42166. */
  42167. export class InterpolateValueAction extends Action {
  42168. /**
  42169. * Defines the path of the property where the value should be interpolated
  42170. */
  42171. propertyPath: string;
  42172. /**
  42173. * Defines the target value at the end of the interpolation.
  42174. */
  42175. value: any;
  42176. /**
  42177. * Defines the time it will take for the property to interpolate to the value.
  42178. */
  42179. duration: number;
  42180. /**
  42181. * Defines if the other scene animations should be stopped when the action has been triggered
  42182. */
  42183. stopOtherAnimations?: boolean;
  42184. /**
  42185. * Defines a callback raised once the interpolation animation has been done.
  42186. */
  42187. onInterpolationDone?: () => void;
  42188. /**
  42189. * Observable triggered once the interpolation animation has been done.
  42190. */
  42191. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42192. private _target;
  42193. private _effectiveTarget;
  42194. private _property;
  42195. /**
  42196. * Instantiate the action
  42197. * @param triggerOptions defines the trigger options
  42198. * @param target defines the object containing the value to interpolate
  42199. * @param propertyPath defines the path to the property in the target object
  42200. * @param value defines the target value at the end of the interpolation
  42201. * @param duration deines the time it will take for the property to interpolate to the value.
  42202. * @param condition defines the trigger related conditions
  42203. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42204. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42205. */
  42206. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42207. /** @hidden */
  42208. _prepare(): void;
  42209. /**
  42210. * Execute the action starts the value interpolation.
  42211. */
  42212. execute(): void;
  42213. /**
  42214. * Serializes the actions and its related information.
  42215. * @param parent defines the object to serialize in
  42216. * @returns the serialized object
  42217. */
  42218. serialize(parent: any): any;
  42219. }
  42220. }
  42221. declare module "babylonjs/Actions/index" {
  42222. export * from "babylonjs/Actions/abstractActionManager";
  42223. export * from "babylonjs/Actions/action";
  42224. export * from "babylonjs/Actions/actionEvent";
  42225. export * from "babylonjs/Actions/actionManager";
  42226. export * from "babylonjs/Actions/condition";
  42227. export * from "babylonjs/Actions/directActions";
  42228. export * from "babylonjs/Actions/directAudioActions";
  42229. export * from "babylonjs/Actions/interpolateValueAction";
  42230. }
  42231. declare module "babylonjs/Animations/index" {
  42232. export * from "babylonjs/Animations/animatable";
  42233. export * from "babylonjs/Animations/animation";
  42234. export * from "babylonjs/Animations/animationGroup";
  42235. export * from "babylonjs/Animations/animationPropertiesOverride";
  42236. export * from "babylonjs/Animations/easing";
  42237. export * from "babylonjs/Animations/runtimeAnimation";
  42238. export * from "babylonjs/Animations/animationEvent";
  42239. export * from "babylonjs/Animations/animationGroup";
  42240. export * from "babylonjs/Animations/animationKey";
  42241. export * from "babylonjs/Animations/animationRange";
  42242. export * from "babylonjs/Animations/animatable.interface";
  42243. }
  42244. declare module "babylonjs/Audio/soundTrack" {
  42245. import { Sound } from "babylonjs/Audio/sound";
  42246. import { Analyser } from "babylonjs/Audio/analyser";
  42247. import { Scene } from "babylonjs/scene";
  42248. /**
  42249. * Options allowed during the creation of a sound track.
  42250. */
  42251. export interface ISoundTrackOptions {
  42252. /**
  42253. * The volume the sound track should take during creation
  42254. */
  42255. volume?: number;
  42256. /**
  42257. * Define if the sound track is the main sound track of the scene
  42258. */
  42259. mainTrack?: boolean;
  42260. }
  42261. /**
  42262. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42263. * It will be also used in a future release to apply effects on a specific track.
  42264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42265. */
  42266. export class SoundTrack {
  42267. /**
  42268. * The unique identifier of the sound track in the scene.
  42269. */
  42270. id: number;
  42271. /**
  42272. * The list of sounds included in the sound track.
  42273. */
  42274. soundCollection: Array<Sound>;
  42275. private _outputAudioNode;
  42276. private _scene;
  42277. private _connectedAnalyser;
  42278. private _options;
  42279. private _isInitialized;
  42280. /**
  42281. * Creates a new sound track.
  42282. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42283. * @param scene Define the scene the sound track belongs to
  42284. * @param options
  42285. */
  42286. constructor(scene: Scene, options?: ISoundTrackOptions);
  42287. private _initializeSoundTrackAudioGraph;
  42288. /**
  42289. * Release the sound track and its associated resources
  42290. */
  42291. dispose(): void;
  42292. /**
  42293. * Adds a sound to this sound track
  42294. * @param sound define the cound to add
  42295. * @ignoreNaming
  42296. */
  42297. AddSound(sound: Sound): void;
  42298. /**
  42299. * Removes a sound to this sound track
  42300. * @param sound define the cound to remove
  42301. * @ignoreNaming
  42302. */
  42303. RemoveSound(sound: Sound): void;
  42304. /**
  42305. * Set a global volume for the full sound track.
  42306. * @param newVolume Define the new volume of the sound track
  42307. */
  42308. setVolume(newVolume: number): void;
  42309. /**
  42310. * Switch the panning model to HRTF:
  42311. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42313. */
  42314. switchPanningModelToHRTF(): void;
  42315. /**
  42316. * Switch the panning model to Equal Power:
  42317. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42319. */
  42320. switchPanningModelToEqualPower(): void;
  42321. /**
  42322. * Connect the sound track to an audio analyser allowing some amazing
  42323. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42325. * @param analyser The analyser to connect to the engine
  42326. */
  42327. connectToAnalyser(analyser: Analyser): void;
  42328. }
  42329. }
  42330. declare module "babylonjs/Audio/audioSceneComponent" {
  42331. import { Sound } from "babylonjs/Audio/sound";
  42332. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42333. import { Nullable } from "babylonjs/types";
  42334. import { Vector3 } from "babylonjs/Maths/math.vector";
  42335. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42336. import { Scene } from "babylonjs/scene";
  42337. import { AbstractScene } from "babylonjs/abstractScene";
  42338. import "babylonjs/Audio/audioEngine";
  42339. module "babylonjs/abstractScene" {
  42340. interface AbstractScene {
  42341. /**
  42342. * The list of sounds used in the scene.
  42343. */
  42344. sounds: Nullable<Array<Sound>>;
  42345. }
  42346. }
  42347. module "babylonjs/scene" {
  42348. interface Scene {
  42349. /**
  42350. * @hidden
  42351. * Backing field
  42352. */
  42353. _mainSoundTrack: SoundTrack;
  42354. /**
  42355. * The main sound track played by the scene.
  42356. * It cotains your primary collection of sounds.
  42357. */
  42358. mainSoundTrack: SoundTrack;
  42359. /**
  42360. * The list of sound tracks added to the scene
  42361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42362. */
  42363. soundTracks: Nullable<Array<SoundTrack>>;
  42364. /**
  42365. * Gets a sound using a given name
  42366. * @param name defines the name to search for
  42367. * @return the found sound or null if not found at all.
  42368. */
  42369. getSoundByName(name: string): Nullable<Sound>;
  42370. /**
  42371. * Gets or sets if audio support is enabled
  42372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42373. */
  42374. audioEnabled: boolean;
  42375. /**
  42376. * Gets or sets if audio will be output to headphones
  42377. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42378. */
  42379. headphone: boolean;
  42380. /**
  42381. * Gets or sets custom audio listener position provider
  42382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  42383. */
  42384. audioListenerPositionProvider: Nullable<() => Vector3>;
  42385. /**
  42386. * Gets or sets a refresh rate when using 3D audio positioning
  42387. */
  42388. audioPositioningRefreshRate: number;
  42389. }
  42390. }
  42391. /**
  42392. * Defines the sound scene component responsible to manage any sounds
  42393. * in a given scene.
  42394. */
  42395. export class AudioSceneComponent implements ISceneSerializableComponent {
  42396. /**
  42397. * The component name helpfull to identify the component in the list of scene components.
  42398. */
  42399. readonly name: string;
  42400. /**
  42401. * The scene the component belongs to.
  42402. */
  42403. scene: Scene;
  42404. private _audioEnabled;
  42405. /**
  42406. * Gets whether audio is enabled or not.
  42407. * Please use related enable/disable method to switch state.
  42408. */
  42409. get audioEnabled(): boolean;
  42410. private _headphone;
  42411. /**
  42412. * Gets whether audio is outputing to headphone or not.
  42413. * Please use the according Switch methods to change output.
  42414. */
  42415. get headphone(): boolean;
  42416. /**
  42417. * Gets or sets a refresh rate when using 3D audio positioning
  42418. */
  42419. audioPositioningRefreshRate: number;
  42420. private _audioListenerPositionProvider;
  42421. /**
  42422. * Gets the current audio listener position provider
  42423. */
  42424. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42425. /**
  42426. * Sets a custom listener position for all sounds in the scene
  42427. * By default, this is the position of the first active camera
  42428. */
  42429. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42430. /**
  42431. * Creates a new instance of the component for the given scene
  42432. * @param scene Defines the scene to register the component in
  42433. */
  42434. constructor(scene: Scene);
  42435. /**
  42436. * Registers the component in a given scene
  42437. */
  42438. register(): void;
  42439. /**
  42440. * Rebuilds the elements related to this component in case of
  42441. * context lost for instance.
  42442. */
  42443. rebuild(): void;
  42444. /**
  42445. * Serializes the component data to the specified json object
  42446. * @param serializationObject The object to serialize to
  42447. */
  42448. serialize(serializationObject: any): void;
  42449. /**
  42450. * Adds all the elements from the container to the scene
  42451. * @param container the container holding the elements
  42452. */
  42453. addFromContainer(container: AbstractScene): void;
  42454. /**
  42455. * Removes all the elements in the container from the scene
  42456. * @param container contains the elements to remove
  42457. * @param dispose if the removed element should be disposed (default: false)
  42458. */
  42459. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42460. /**
  42461. * Disposes the component and the associated ressources.
  42462. */
  42463. dispose(): void;
  42464. /**
  42465. * Disables audio in the associated scene.
  42466. */
  42467. disableAudio(): void;
  42468. /**
  42469. * Enables audio in the associated scene.
  42470. */
  42471. enableAudio(): void;
  42472. /**
  42473. * Switch audio to headphone output.
  42474. */
  42475. switchAudioModeForHeadphones(): void;
  42476. /**
  42477. * Switch audio to normal speakers.
  42478. */
  42479. switchAudioModeForNormalSpeakers(): void;
  42480. private _cachedCameraDirection;
  42481. private _cachedCameraPosition;
  42482. private _lastCheck;
  42483. private _afterRender;
  42484. }
  42485. }
  42486. declare module "babylonjs/Audio/weightedsound" {
  42487. import { Sound } from "babylonjs/Audio/sound";
  42488. /**
  42489. * Wraps one or more Sound objects and selects one with random weight for playback.
  42490. */
  42491. export class WeightedSound {
  42492. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42493. loop: boolean;
  42494. private _coneInnerAngle;
  42495. private _coneOuterAngle;
  42496. private _volume;
  42497. /** A Sound is currently playing. */
  42498. isPlaying: boolean;
  42499. /** A Sound is currently paused. */
  42500. isPaused: boolean;
  42501. private _sounds;
  42502. private _weights;
  42503. private _currentIndex?;
  42504. /**
  42505. * Creates a new WeightedSound from the list of sounds given.
  42506. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42507. * @param sounds Array of Sounds that will be selected from.
  42508. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42509. */
  42510. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42511. /**
  42512. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42513. */
  42514. get directionalConeInnerAngle(): number;
  42515. /**
  42516. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42517. */
  42518. set directionalConeInnerAngle(value: number);
  42519. /**
  42520. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42521. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42522. */
  42523. get directionalConeOuterAngle(): number;
  42524. /**
  42525. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42526. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42527. */
  42528. set directionalConeOuterAngle(value: number);
  42529. /**
  42530. * Playback volume.
  42531. */
  42532. get volume(): number;
  42533. /**
  42534. * Playback volume.
  42535. */
  42536. set volume(value: number);
  42537. private _onended;
  42538. /**
  42539. * Suspend playback
  42540. */
  42541. pause(): void;
  42542. /**
  42543. * Stop playback
  42544. */
  42545. stop(): void;
  42546. /**
  42547. * Start playback.
  42548. * @param startOffset Position the clip head at a specific time in seconds.
  42549. */
  42550. play(startOffset?: number): void;
  42551. }
  42552. }
  42553. declare module "babylonjs/Audio/index" {
  42554. export * from "babylonjs/Audio/analyser";
  42555. export * from "babylonjs/Audio/audioEngine";
  42556. export * from "babylonjs/Audio/audioSceneComponent";
  42557. export * from "babylonjs/Audio/sound";
  42558. export * from "babylonjs/Audio/soundTrack";
  42559. export * from "babylonjs/Audio/weightedsound";
  42560. }
  42561. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42562. import { Behavior } from "babylonjs/Behaviors/behavior";
  42563. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42564. import { BackEase } from "babylonjs/Animations/easing";
  42565. /**
  42566. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42567. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42568. */
  42569. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42570. /**
  42571. * Gets the name of the behavior.
  42572. */
  42573. get name(): string;
  42574. /**
  42575. * The easing function used by animations
  42576. */
  42577. static EasingFunction: BackEase;
  42578. /**
  42579. * The easing mode used by animations
  42580. */
  42581. static EasingMode: number;
  42582. /**
  42583. * The duration of the animation, in milliseconds
  42584. */
  42585. transitionDuration: number;
  42586. /**
  42587. * Length of the distance animated by the transition when lower radius is reached
  42588. */
  42589. lowerRadiusTransitionRange: number;
  42590. /**
  42591. * Length of the distance animated by the transition when upper radius is reached
  42592. */
  42593. upperRadiusTransitionRange: number;
  42594. private _autoTransitionRange;
  42595. /**
  42596. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42597. */
  42598. get autoTransitionRange(): boolean;
  42599. /**
  42600. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42601. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42602. */
  42603. set autoTransitionRange(value: boolean);
  42604. private _attachedCamera;
  42605. private _onAfterCheckInputsObserver;
  42606. private _onMeshTargetChangedObserver;
  42607. /**
  42608. * Initializes the behavior.
  42609. */
  42610. init(): void;
  42611. /**
  42612. * Attaches the behavior to its arc rotate camera.
  42613. * @param camera Defines the camera to attach the behavior to
  42614. */
  42615. attach(camera: ArcRotateCamera): void;
  42616. /**
  42617. * Detaches the behavior from its current arc rotate camera.
  42618. */
  42619. detach(): void;
  42620. private _radiusIsAnimating;
  42621. private _radiusBounceTransition;
  42622. private _animatables;
  42623. private _cachedWheelPrecision;
  42624. /**
  42625. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42626. * @param radiusLimit The limit to check against.
  42627. * @return Bool to indicate if at limit.
  42628. */
  42629. private _isRadiusAtLimit;
  42630. /**
  42631. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42632. * @param radiusDelta The delta by which to animate to. Can be negative.
  42633. */
  42634. private _applyBoundRadiusAnimation;
  42635. /**
  42636. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42637. */
  42638. protected _clearAnimationLocks(): void;
  42639. /**
  42640. * Stops and removes all animations that have been applied to the camera
  42641. */
  42642. stopAllAnimations(): void;
  42643. }
  42644. }
  42645. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42646. import { Behavior } from "babylonjs/Behaviors/behavior";
  42647. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42648. import { ExponentialEase } from "babylonjs/Animations/easing";
  42649. import { Nullable } from "babylonjs/types";
  42650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42651. import { Vector3 } from "babylonjs/Maths/math.vector";
  42652. /**
  42653. * 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.
  42654. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42655. */
  42656. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42657. /**
  42658. * Gets the name of the behavior.
  42659. */
  42660. get name(): string;
  42661. private _mode;
  42662. private _radiusScale;
  42663. private _positionScale;
  42664. private _defaultElevation;
  42665. private _elevationReturnTime;
  42666. private _elevationReturnWaitTime;
  42667. private _zoomStopsAnimation;
  42668. private _framingTime;
  42669. /**
  42670. * The easing function used by animations
  42671. */
  42672. static EasingFunction: ExponentialEase;
  42673. /**
  42674. * The easing mode used by animations
  42675. */
  42676. static EasingMode: number;
  42677. /**
  42678. * Sets the current mode used by the behavior
  42679. */
  42680. set mode(mode: number);
  42681. /**
  42682. * Gets current mode used by the behavior.
  42683. */
  42684. get mode(): number;
  42685. /**
  42686. * Sets the scale applied to the radius (1 by default)
  42687. */
  42688. set radiusScale(radius: number);
  42689. /**
  42690. * Gets the scale applied to the radius
  42691. */
  42692. get radiusScale(): number;
  42693. /**
  42694. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42695. */
  42696. set positionScale(scale: number);
  42697. /**
  42698. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42699. */
  42700. get positionScale(): number;
  42701. /**
  42702. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42703. * behaviour is triggered, in radians.
  42704. */
  42705. set defaultElevation(elevation: number);
  42706. /**
  42707. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42708. * behaviour is triggered, in radians.
  42709. */
  42710. get defaultElevation(): number;
  42711. /**
  42712. * Sets the time (in milliseconds) taken to return to the default beta position.
  42713. * Negative value indicates camera should not return to default.
  42714. */
  42715. set elevationReturnTime(speed: number);
  42716. /**
  42717. * Gets the time (in milliseconds) taken to return to the default beta position.
  42718. * Negative value indicates camera should not return to default.
  42719. */
  42720. get elevationReturnTime(): number;
  42721. /**
  42722. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42723. */
  42724. set elevationReturnWaitTime(time: number);
  42725. /**
  42726. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42727. */
  42728. get elevationReturnWaitTime(): number;
  42729. /**
  42730. * Sets the flag that indicates if user zooming should stop animation.
  42731. */
  42732. set zoomStopsAnimation(flag: boolean);
  42733. /**
  42734. * Gets the flag that indicates if user zooming should stop animation.
  42735. */
  42736. get zoomStopsAnimation(): boolean;
  42737. /**
  42738. * Sets the transition time when framing the mesh, in milliseconds
  42739. */
  42740. set framingTime(time: number);
  42741. /**
  42742. * Gets the transition time when framing the mesh, in milliseconds
  42743. */
  42744. get framingTime(): number;
  42745. /**
  42746. * Define if the behavior should automatically change the configured
  42747. * camera limits and sensibilities.
  42748. */
  42749. autoCorrectCameraLimitsAndSensibility: boolean;
  42750. private _onPrePointerObservableObserver;
  42751. private _onAfterCheckInputsObserver;
  42752. private _onMeshTargetChangedObserver;
  42753. private _attachedCamera;
  42754. private _isPointerDown;
  42755. private _lastInteractionTime;
  42756. /**
  42757. * Initializes the behavior.
  42758. */
  42759. init(): void;
  42760. /**
  42761. * Attaches the behavior to its arc rotate camera.
  42762. * @param camera Defines the camera to attach the behavior to
  42763. */
  42764. attach(camera: ArcRotateCamera): void;
  42765. /**
  42766. * Detaches the behavior from its current arc rotate camera.
  42767. */
  42768. detach(): void;
  42769. private _animatables;
  42770. private _betaIsAnimating;
  42771. private _betaTransition;
  42772. private _radiusTransition;
  42773. private _vectorTransition;
  42774. /**
  42775. * Targets the given mesh and updates zoom level accordingly.
  42776. * @param mesh The mesh to target.
  42777. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42778. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42779. */
  42780. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42781. /**
  42782. * Targets the given mesh with its children and updates zoom level accordingly.
  42783. * @param mesh The mesh to target.
  42784. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42785. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42786. */
  42787. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42788. /**
  42789. * Targets the given meshes with their children and updates zoom level accordingly.
  42790. * @param meshes The mesh to target.
  42791. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42792. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42793. */
  42794. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42795. /**
  42796. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42797. * @param minimumWorld Determines the smaller position of the bounding box extend
  42798. * @param maximumWorld Determines the bigger position of the bounding box extend
  42799. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42800. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42801. */
  42802. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42803. /**
  42804. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42805. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42806. * frustum width.
  42807. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42808. * to fully enclose the mesh in the viewing frustum.
  42809. */
  42810. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42811. /**
  42812. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42813. * is automatically returned to its default position (expected to be above ground plane).
  42814. */
  42815. private _maintainCameraAboveGround;
  42816. /**
  42817. * Returns the frustum slope based on the canvas ratio and camera FOV
  42818. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42819. */
  42820. private _getFrustumSlope;
  42821. /**
  42822. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42823. */
  42824. private _clearAnimationLocks;
  42825. /**
  42826. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42827. */
  42828. private _applyUserInteraction;
  42829. /**
  42830. * Stops and removes all animations that have been applied to the camera
  42831. */
  42832. stopAllAnimations(): void;
  42833. /**
  42834. * Gets a value indicating if the user is moving the camera
  42835. */
  42836. get isUserIsMoving(): boolean;
  42837. /**
  42838. * The camera can move all the way towards the mesh.
  42839. */
  42840. static IgnoreBoundsSizeMode: number;
  42841. /**
  42842. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42843. */
  42844. static FitFrustumSidesMode: number;
  42845. }
  42846. }
  42847. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42848. import { Nullable } from "babylonjs/types";
  42849. import { Camera } from "babylonjs/Cameras/camera";
  42850. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42851. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42852. /**
  42853. * Base class for Camera Pointer Inputs.
  42854. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42855. * for example usage.
  42856. */
  42857. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42858. /**
  42859. * Defines the camera the input is attached to.
  42860. */
  42861. abstract camera: Camera;
  42862. /**
  42863. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42864. */
  42865. protected _altKey: boolean;
  42866. protected _ctrlKey: boolean;
  42867. protected _metaKey: boolean;
  42868. protected _shiftKey: boolean;
  42869. /**
  42870. * Which mouse buttons were pressed at time of last mouse event.
  42871. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42872. */
  42873. protected _buttonsPressed: number;
  42874. /**
  42875. * Defines the buttons associated with the input to handle camera move.
  42876. */
  42877. buttons: number[];
  42878. /**
  42879. * Attach the input controls to a specific dom element to get the input from.
  42880. * @param element Defines the element the controls should be listened from
  42881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42882. */
  42883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42884. /**
  42885. * Detach the current controls from the specified dom element.
  42886. * @param element Defines the element to stop listening the inputs from
  42887. */
  42888. detachControl(element: Nullable<HTMLElement>): void;
  42889. /**
  42890. * Gets the class name of the current input.
  42891. * @returns the class name
  42892. */
  42893. getClassName(): string;
  42894. /**
  42895. * Get the friendly name associated with the input class.
  42896. * @returns the input friendly name
  42897. */
  42898. getSimpleName(): string;
  42899. /**
  42900. * Called on pointer POINTERDOUBLETAP event.
  42901. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42902. */
  42903. protected onDoubleTap(type: string): void;
  42904. /**
  42905. * Called on pointer POINTERMOVE event if only a single touch is active.
  42906. * Override this method to provide functionality.
  42907. */
  42908. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42909. /**
  42910. * Called on pointer POINTERMOVE event if multiple touches are active.
  42911. * Override this method to provide functionality.
  42912. */
  42913. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42914. /**
  42915. * Called on JS contextmenu event.
  42916. * Override this method to provide functionality.
  42917. */
  42918. protected onContextMenu(evt: PointerEvent): void;
  42919. /**
  42920. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42921. * press.
  42922. * Override this method to provide functionality.
  42923. */
  42924. protected onButtonDown(evt: PointerEvent): void;
  42925. /**
  42926. * Called each time a new POINTERUP event occurs. Ie, for each button
  42927. * release.
  42928. * Override this method to provide functionality.
  42929. */
  42930. protected onButtonUp(evt: PointerEvent): void;
  42931. /**
  42932. * Called when window becomes inactive.
  42933. * Override this method to provide functionality.
  42934. */
  42935. protected onLostFocus(): void;
  42936. private _pointerInput;
  42937. private _observer;
  42938. private _onLostFocus;
  42939. private pointA;
  42940. private pointB;
  42941. }
  42942. }
  42943. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  42944. import { Nullable } from "babylonjs/types";
  42945. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42946. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  42947. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42948. /**
  42949. * Manage the pointers inputs to control an arc rotate camera.
  42950. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42951. */
  42952. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42953. /**
  42954. * Defines the camera the input is attached to.
  42955. */
  42956. camera: ArcRotateCamera;
  42957. /**
  42958. * Gets the class name of the current input.
  42959. * @returns the class name
  42960. */
  42961. getClassName(): string;
  42962. /**
  42963. * Defines the buttons associated with the input to handle camera move.
  42964. */
  42965. buttons: number[];
  42966. /**
  42967. * Defines the pointer angular sensibility along the X axis or how fast is
  42968. * the camera rotating.
  42969. */
  42970. angularSensibilityX: number;
  42971. /**
  42972. * Defines the pointer angular sensibility along the Y axis or how fast is
  42973. * the camera rotating.
  42974. */
  42975. angularSensibilityY: number;
  42976. /**
  42977. * Defines the pointer pinch precision or how fast is the camera zooming.
  42978. */
  42979. pinchPrecision: number;
  42980. /**
  42981. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42982. * from 0.
  42983. * It defines the percentage of current camera.radius to use as delta when
  42984. * pinch zoom is used.
  42985. */
  42986. pinchDeltaPercentage: number;
  42987. /**
  42988. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42989. * that any object in the plane at the camera's target point will scale
  42990. * perfectly with finger motion.
  42991. * Overrides pinchDeltaPercentage and pinchPrecision.
  42992. */
  42993. useNaturalPinchZoom: boolean;
  42994. /**
  42995. * Defines the pointer panning sensibility or how fast is the camera moving.
  42996. */
  42997. panningSensibility: number;
  42998. /**
  42999. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43000. */
  43001. multiTouchPanning: boolean;
  43002. /**
  43003. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43004. * zoom (pinch) through multitouch.
  43005. */
  43006. multiTouchPanAndZoom: boolean;
  43007. /**
  43008. * Revers pinch action direction.
  43009. */
  43010. pinchInwards: boolean;
  43011. private _isPanClick;
  43012. private _twoFingerActivityCount;
  43013. private _isPinching;
  43014. /**
  43015. * Called on pointer POINTERMOVE event if only a single touch is active.
  43016. */
  43017. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43018. /**
  43019. * Called on pointer POINTERDOUBLETAP event.
  43020. */
  43021. protected onDoubleTap(type: string): void;
  43022. /**
  43023. * Called on pointer POINTERMOVE event if multiple touches are active.
  43024. */
  43025. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43026. /**
  43027. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43028. * press.
  43029. */
  43030. protected onButtonDown(evt: PointerEvent): void;
  43031. /**
  43032. * Called each time a new POINTERUP event occurs. Ie, for each button
  43033. * release.
  43034. */
  43035. protected onButtonUp(evt: PointerEvent): void;
  43036. /**
  43037. * Called when window becomes inactive.
  43038. */
  43039. protected onLostFocus(): void;
  43040. }
  43041. }
  43042. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43043. import { Nullable } from "babylonjs/types";
  43044. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43045. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43046. /**
  43047. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43049. */
  43050. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43051. /**
  43052. * Defines the camera the input is attached to.
  43053. */
  43054. camera: ArcRotateCamera;
  43055. /**
  43056. * Defines the list of key codes associated with the up action (increase alpha)
  43057. */
  43058. keysUp: number[];
  43059. /**
  43060. * Defines the list of key codes associated with the down action (decrease alpha)
  43061. */
  43062. keysDown: number[];
  43063. /**
  43064. * Defines the list of key codes associated with the left action (increase beta)
  43065. */
  43066. keysLeft: number[];
  43067. /**
  43068. * Defines the list of key codes associated with the right action (decrease beta)
  43069. */
  43070. keysRight: number[];
  43071. /**
  43072. * Defines the list of key codes associated with the reset action.
  43073. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43074. */
  43075. keysReset: number[];
  43076. /**
  43077. * Defines the panning sensibility of the inputs.
  43078. * (How fast is the camera panning)
  43079. */
  43080. panningSensibility: number;
  43081. /**
  43082. * Defines the zooming sensibility of the inputs.
  43083. * (How fast is the camera zooming)
  43084. */
  43085. zoomingSensibility: number;
  43086. /**
  43087. * Defines whether maintaining the alt key down switch the movement mode from
  43088. * orientation to zoom.
  43089. */
  43090. useAltToZoom: boolean;
  43091. /**
  43092. * Rotation speed of the camera
  43093. */
  43094. angularSpeed: number;
  43095. private _keys;
  43096. private _ctrlPressed;
  43097. private _altPressed;
  43098. private _onCanvasBlurObserver;
  43099. private _onKeyboardObserver;
  43100. private _engine;
  43101. private _scene;
  43102. /**
  43103. * Attach the input controls to a specific dom element to get the input from.
  43104. * @param element Defines the element the controls should be listened from
  43105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43106. */
  43107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43108. /**
  43109. * Detach the current controls from the specified dom element.
  43110. * @param element Defines the element to stop listening the inputs from
  43111. */
  43112. detachControl(element: Nullable<HTMLElement>): void;
  43113. /**
  43114. * Update the current camera state depending on the inputs that have been used this frame.
  43115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43116. */
  43117. checkInputs(): void;
  43118. /**
  43119. * Gets the class name of the current intput.
  43120. * @returns the class name
  43121. */
  43122. getClassName(): string;
  43123. /**
  43124. * Get the friendly name associated with the input class.
  43125. * @returns the input friendly name
  43126. */
  43127. getSimpleName(): string;
  43128. }
  43129. }
  43130. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43131. import { Nullable } from "babylonjs/types";
  43132. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43133. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43134. /**
  43135. * Manage the mouse wheel inputs to control an arc rotate camera.
  43136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43137. */
  43138. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43139. /**
  43140. * Defines the camera the input is attached to.
  43141. */
  43142. camera: ArcRotateCamera;
  43143. /**
  43144. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43145. */
  43146. wheelPrecision: number;
  43147. /**
  43148. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43149. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43150. */
  43151. wheelDeltaPercentage: number;
  43152. private _wheel;
  43153. private _observer;
  43154. private computeDeltaFromMouseWheelLegacyEvent;
  43155. /**
  43156. * Attach the input controls to a specific dom element to get the input from.
  43157. * @param element Defines the element the controls should be listened from
  43158. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43159. */
  43160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43161. /**
  43162. * Detach the current controls from the specified dom element.
  43163. * @param element Defines the element to stop listening the inputs from
  43164. */
  43165. detachControl(element: Nullable<HTMLElement>): void;
  43166. /**
  43167. * Gets the class name of the current intput.
  43168. * @returns the class name
  43169. */
  43170. getClassName(): string;
  43171. /**
  43172. * Get the friendly name associated with the input class.
  43173. * @returns the input friendly name
  43174. */
  43175. getSimpleName(): string;
  43176. }
  43177. }
  43178. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43179. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43180. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43181. /**
  43182. * Default Inputs manager for the ArcRotateCamera.
  43183. * It groups all the default supported inputs for ease of use.
  43184. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43185. */
  43186. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43187. /**
  43188. * Instantiates a new ArcRotateCameraInputsManager.
  43189. * @param camera Defines the camera the inputs belong to
  43190. */
  43191. constructor(camera: ArcRotateCamera);
  43192. /**
  43193. * Add mouse wheel input support to the input manager.
  43194. * @returns the current input manager
  43195. */
  43196. addMouseWheel(): ArcRotateCameraInputsManager;
  43197. /**
  43198. * Add pointers input support to the input manager.
  43199. * @returns the current input manager
  43200. */
  43201. addPointers(): ArcRotateCameraInputsManager;
  43202. /**
  43203. * Add keyboard input support to the input manager.
  43204. * @returns the current input manager
  43205. */
  43206. addKeyboard(): ArcRotateCameraInputsManager;
  43207. }
  43208. }
  43209. declare module "babylonjs/Cameras/arcRotateCamera" {
  43210. import { Observable } from "babylonjs/Misc/observable";
  43211. import { Nullable } from "babylonjs/types";
  43212. import { Scene } from "babylonjs/scene";
  43213. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43214. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43215. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43216. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43217. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43218. import { Camera } from "babylonjs/Cameras/camera";
  43219. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43220. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43221. import { Collider } from "babylonjs/Collisions/collider";
  43222. /**
  43223. * This represents an orbital type of camera.
  43224. *
  43225. * 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.
  43226. * 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.
  43227. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43228. */
  43229. export class ArcRotateCamera extends TargetCamera {
  43230. /**
  43231. * Defines the rotation angle of the camera along the longitudinal axis.
  43232. */
  43233. alpha: number;
  43234. /**
  43235. * Defines the rotation angle of the camera along the latitudinal axis.
  43236. */
  43237. beta: number;
  43238. /**
  43239. * Defines the radius of the camera from it s target point.
  43240. */
  43241. radius: number;
  43242. protected _target: Vector3;
  43243. protected _targetHost: Nullable<AbstractMesh>;
  43244. /**
  43245. * Defines the target point of the camera.
  43246. * The camera looks towards it form the radius distance.
  43247. */
  43248. get target(): Vector3;
  43249. set target(value: Vector3);
  43250. /**
  43251. * Define the current local position of the camera in the scene
  43252. */
  43253. get position(): Vector3;
  43254. set position(newPosition: Vector3);
  43255. protected _upVector: Vector3;
  43256. protected _upToYMatrix: Matrix;
  43257. protected _YToUpMatrix: Matrix;
  43258. /**
  43259. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43260. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43261. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43262. */
  43263. set upVector(vec: Vector3);
  43264. get upVector(): Vector3;
  43265. /**
  43266. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43267. */
  43268. setMatUp(): void;
  43269. /**
  43270. * Current inertia value on the longitudinal axis.
  43271. * The bigger this number the longer it will take for the camera to stop.
  43272. */
  43273. inertialAlphaOffset: number;
  43274. /**
  43275. * Current inertia value on the latitudinal axis.
  43276. * The bigger this number the longer it will take for the camera to stop.
  43277. */
  43278. inertialBetaOffset: number;
  43279. /**
  43280. * Current inertia value on the radius axis.
  43281. * The bigger this number the longer it will take for the camera to stop.
  43282. */
  43283. inertialRadiusOffset: number;
  43284. /**
  43285. * Minimum allowed angle on the longitudinal axis.
  43286. * This can help limiting how the Camera is able to move in the scene.
  43287. */
  43288. lowerAlphaLimit: Nullable<number>;
  43289. /**
  43290. * Maximum allowed angle on the longitudinal axis.
  43291. * This can help limiting how the Camera is able to move in the scene.
  43292. */
  43293. upperAlphaLimit: Nullable<number>;
  43294. /**
  43295. * Minimum allowed angle on the latitudinal axis.
  43296. * This can help limiting how the Camera is able to move in the scene.
  43297. */
  43298. lowerBetaLimit: number;
  43299. /**
  43300. * Maximum allowed angle on the latitudinal axis.
  43301. * This can help limiting how the Camera is able to move in the scene.
  43302. */
  43303. upperBetaLimit: number;
  43304. /**
  43305. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43306. * This can help limiting how the Camera is able to move in the scene.
  43307. */
  43308. lowerRadiusLimit: Nullable<number>;
  43309. /**
  43310. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43311. * This can help limiting how the Camera is able to move in the scene.
  43312. */
  43313. upperRadiusLimit: Nullable<number>;
  43314. /**
  43315. * Defines the current inertia value used during panning of the camera along the X axis.
  43316. */
  43317. inertialPanningX: number;
  43318. /**
  43319. * Defines the current inertia value used during panning of the camera along the Y axis.
  43320. */
  43321. inertialPanningY: number;
  43322. /**
  43323. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43324. * Basically if your fingers moves away from more than this distance you will be considered
  43325. * in pinch mode.
  43326. */
  43327. pinchToPanMaxDistance: number;
  43328. /**
  43329. * Defines the maximum distance the camera can pan.
  43330. * This could help keeping the cammera always in your scene.
  43331. */
  43332. panningDistanceLimit: Nullable<number>;
  43333. /**
  43334. * Defines the target of the camera before paning.
  43335. */
  43336. panningOriginTarget: Vector3;
  43337. /**
  43338. * Defines the value of the inertia used during panning.
  43339. * 0 would mean stop inertia and one would mean no decelleration at all.
  43340. */
  43341. panningInertia: number;
  43342. /**
  43343. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43344. */
  43345. get angularSensibilityX(): number;
  43346. set angularSensibilityX(value: number);
  43347. /**
  43348. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43349. */
  43350. get angularSensibilityY(): number;
  43351. set angularSensibilityY(value: number);
  43352. /**
  43353. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43354. */
  43355. get pinchPrecision(): number;
  43356. set pinchPrecision(value: number);
  43357. /**
  43358. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43359. * It will be used instead of pinchDeltaPrecision if different from 0.
  43360. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43361. */
  43362. get pinchDeltaPercentage(): number;
  43363. set pinchDeltaPercentage(value: number);
  43364. /**
  43365. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43366. * and pinch delta percentage.
  43367. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43368. * that any object in the plane at the camera's target point will scale
  43369. * perfectly with finger motion.
  43370. */
  43371. get useNaturalPinchZoom(): boolean;
  43372. set useNaturalPinchZoom(value: boolean);
  43373. /**
  43374. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43375. */
  43376. get panningSensibility(): number;
  43377. set panningSensibility(value: number);
  43378. /**
  43379. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43380. */
  43381. get keysUp(): number[];
  43382. set keysUp(value: number[]);
  43383. /**
  43384. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43385. */
  43386. get keysDown(): number[];
  43387. set keysDown(value: number[]);
  43388. /**
  43389. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43390. */
  43391. get keysLeft(): number[];
  43392. set keysLeft(value: number[]);
  43393. /**
  43394. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43395. */
  43396. get keysRight(): number[];
  43397. set keysRight(value: number[]);
  43398. /**
  43399. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43400. */
  43401. get wheelPrecision(): number;
  43402. set wheelPrecision(value: number);
  43403. /**
  43404. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43405. * It will be used instead of pinchDeltaPrecision if different from 0.
  43406. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43407. */
  43408. get wheelDeltaPercentage(): number;
  43409. set wheelDeltaPercentage(value: number);
  43410. /**
  43411. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43412. */
  43413. zoomOnFactor: number;
  43414. /**
  43415. * Defines a screen offset for the camera position.
  43416. */
  43417. targetScreenOffset: Vector2;
  43418. /**
  43419. * Allows the camera to be completely reversed.
  43420. * If false the camera can not arrive upside down.
  43421. */
  43422. allowUpsideDown: boolean;
  43423. /**
  43424. * Define if double tap/click is used to restore the previously saved state of the camera.
  43425. */
  43426. useInputToRestoreState: boolean;
  43427. /** @hidden */
  43428. _viewMatrix: Matrix;
  43429. /** @hidden */
  43430. _useCtrlForPanning: boolean;
  43431. /** @hidden */
  43432. _panningMouseButton: number;
  43433. /**
  43434. * Defines the input associated to the camera.
  43435. */
  43436. inputs: ArcRotateCameraInputsManager;
  43437. /** @hidden */
  43438. _reset: () => void;
  43439. /**
  43440. * Defines the allowed panning axis.
  43441. */
  43442. panningAxis: Vector3;
  43443. protected _localDirection: Vector3;
  43444. protected _transformedDirection: Vector3;
  43445. private _bouncingBehavior;
  43446. /**
  43447. * Gets the bouncing behavior of the camera if it has been enabled.
  43448. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43449. */
  43450. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43451. /**
  43452. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43453. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43454. */
  43455. get useBouncingBehavior(): boolean;
  43456. set useBouncingBehavior(value: boolean);
  43457. private _framingBehavior;
  43458. /**
  43459. * Gets the framing behavior of the camera if it has been enabled.
  43460. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43461. */
  43462. get framingBehavior(): Nullable<FramingBehavior>;
  43463. /**
  43464. * Defines if the framing behavior of the camera is enabled on the camera.
  43465. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43466. */
  43467. get useFramingBehavior(): boolean;
  43468. set useFramingBehavior(value: boolean);
  43469. private _autoRotationBehavior;
  43470. /**
  43471. * Gets the auto rotation behavior of the camera if it has been enabled.
  43472. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43473. */
  43474. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43475. /**
  43476. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43477. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43478. */
  43479. get useAutoRotationBehavior(): boolean;
  43480. set useAutoRotationBehavior(value: boolean);
  43481. /**
  43482. * Observable triggered when the mesh target has been changed on the camera.
  43483. */
  43484. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43485. /**
  43486. * Event raised when the camera is colliding with a mesh.
  43487. */
  43488. onCollide: (collidedMesh: AbstractMesh) => void;
  43489. /**
  43490. * Defines whether the camera should check collision with the objects oh the scene.
  43491. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43492. */
  43493. checkCollisions: boolean;
  43494. /**
  43495. * Defines the collision radius of the camera.
  43496. * This simulates a sphere around the camera.
  43497. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43498. */
  43499. collisionRadius: Vector3;
  43500. protected _collider: Collider;
  43501. protected _previousPosition: Vector3;
  43502. protected _collisionVelocity: Vector3;
  43503. protected _newPosition: Vector3;
  43504. protected _previousAlpha: number;
  43505. protected _previousBeta: number;
  43506. protected _previousRadius: number;
  43507. protected _collisionTriggered: boolean;
  43508. protected _targetBoundingCenter: Nullable<Vector3>;
  43509. private _computationVector;
  43510. /**
  43511. * Instantiates a new ArcRotateCamera in a given scene
  43512. * @param name Defines the name of the camera
  43513. * @param alpha Defines the camera rotation along the logitudinal axis
  43514. * @param beta Defines the camera rotation along the latitudinal axis
  43515. * @param radius Defines the camera distance from its target
  43516. * @param target Defines the camera target
  43517. * @param scene Defines the scene the camera belongs to
  43518. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43519. */
  43520. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43521. /** @hidden */
  43522. _initCache(): void;
  43523. /** @hidden */
  43524. _updateCache(ignoreParentClass?: boolean): void;
  43525. protected _getTargetPosition(): Vector3;
  43526. private _storedAlpha;
  43527. private _storedBeta;
  43528. private _storedRadius;
  43529. private _storedTarget;
  43530. private _storedTargetScreenOffset;
  43531. /**
  43532. * Stores the current state of the camera (alpha, beta, radius and target)
  43533. * @returns the camera itself
  43534. */
  43535. storeState(): Camera;
  43536. /**
  43537. * @hidden
  43538. * Restored camera state. You must call storeState() first
  43539. */
  43540. _restoreStateValues(): boolean;
  43541. /** @hidden */
  43542. _isSynchronizedViewMatrix(): boolean;
  43543. /**
  43544. * Attached controls to the current camera.
  43545. * @param element Defines the element the controls should be listened from
  43546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43547. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43548. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43549. */
  43550. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43551. /**
  43552. * Detach the current controls from the camera.
  43553. * The camera will stop reacting to inputs.
  43554. * @param element Defines the element to stop listening the inputs from
  43555. */
  43556. detachControl(element: HTMLElement): void;
  43557. /** @hidden */
  43558. _checkInputs(): void;
  43559. protected _checkLimits(): void;
  43560. /**
  43561. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43562. */
  43563. rebuildAnglesAndRadius(): void;
  43564. /**
  43565. * Use a position to define the current camera related information like alpha, beta and radius
  43566. * @param position Defines the position to set the camera at
  43567. */
  43568. setPosition(position: Vector3): void;
  43569. /**
  43570. * Defines the target the camera should look at.
  43571. * This will automatically adapt alpha beta and radius to fit within the new target.
  43572. * @param target Defines the new target as a Vector or a mesh
  43573. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43574. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43575. */
  43576. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43577. /** @hidden */
  43578. _getViewMatrix(): Matrix;
  43579. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43580. /**
  43581. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43582. * @param meshes Defines the mesh to zoom on
  43583. * @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)
  43584. */
  43585. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43586. /**
  43587. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43588. * The target will be changed but the radius
  43589. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43590. * @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)
  43591. */
  43592. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43593. min: Vector3;
  43594. max: Vector3;
  43595. distance: number;
  43596. }, doNotUpdateMaxZ?: boolean): void;
  43597. /**
  43598. * @override
  43599. * Override Camera.createRigCamera
  43600. */
  43601. createRigCamera(name: string, cameraIndex: number): Camera;
  43602. /**
  43603. * @hidden
  43604. * @override
  43605. * Override Camera._updateRigCameras
  43606. */
  43607. _updateRigCameras(): void;
  43608. /**
  43609. * Destroy the camera and release the current resources hold by it.
  43610. */
  43611. dispose(): void;
  43612. /**
  43613. * Gets the current object class name.
  43614. * @return the class name
  43615. */
  43616. getClassName(): string;
  43617. }
  43618. }
  43619. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43620. import { Behavior } from "babylonjs/Behaviors/behavior";
  43621. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43622. /**
  43623. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43624. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43625. */
  43626. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43627. /**
  43628. * Gets the name of the behavior.
  43629. */
  43630. get name(): string;
  43631. private _zoomStopsAnimation;
  43632. private _idleRotationSpeed;
  43633. private _idleRotationWaitTime;
  43634. private _idleRotationSpinupTime;
  43635. /**
  43636. * Sets the flag that indicates if user zooming should stop animation.
  43637. */
  43638. set zoomStopsAnimation(flag: boolean);
  43639. /**
  43640. * Gets the flag that indicates if user zooming should stop animation.
  43641. */
  43642. get zoomStopsAnimation(): boolean;
  43643. /**
  43644. * Sets the default speed at which the camera rotates around the model.
  43645. */
  43646. set idleRotationSpeed(speed: number);
  43647. /**
  43648. * Gets the default speed at which the camera rotates around the model.
  43649. */
  43650. get idleRotationSpeed(): number;
  43651. /**
  43652. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43653. */
  43654. set idleRotationWaitTime(time: number);
  43655. /**
  43656. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43657. */
  43658. get idleRotationWaitTime(): number;
  43659. /**
  43660. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43661. */
  43662. set idleRotationSpinupTime(time: number);
  43663. /**
  43664. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43665. */
  43666. get idleRotationSpinupTime(): number;
  43667. /**
  43668. * Gets a value indicating if the camera is currently rotating because of this behavior
  43669. */
  43670. get rotationInProgress(): boolean;
  43671. private _onPrePointerObservableObserver;
  43672. private _onAfterCheckInputsObserver;
  43673. private _attachedCamera;
  43674. private _isPointerDown;
  43675. private _lastFrameTime;
  43676. private _lastInteractionTime;
  43677. private _cameraRotationSpeed;
  43678. /**
  43679. * Initializes the behavior.
  43680. */
  43681. init(): void;
  43682. /**
  43683. * Attaches the behavior to its arc rotate camera.
  43684. * @param camera Defines the camera to attach the behavior to
  43685. */
  43686. attach(camera: ArcRotateCamera): void;
  43687. /**
  43688. * Detaches the behavior from its current arc rotate camera.
  43689. */
  43690. detach(): void;
  43691. /**
  43692. * Returns true if user is scrolling.
  43693. * @return true if user is scrolling.
  43694. */
  43695. private _userIsZooming;
  43696. private _lastFrameRadius;
  43697. private _shouldAnimationStopForInteraction;
  43698. /**
  43699. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43700. */
  43701. private _applyUserInteraction;
  43702. private _userIsMoving;
  43703. }
  43704. }
  43705. declare module "babylonjs/Behaviors/Cameras/index" {
  43706. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43707. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43708. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43709. }
  43710. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43711. import { Mesh } from "babylonjs/Meshes/mesh";
  43712. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43713. import { Behavior } from "babylonjs/Behaviors/behavior";
  43714. /**
  43715. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43716. */
  43717. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43718. private ui;
  43719. /**
  43720. * The name of the behavior
  43721. */
  43722. name: string;
  43723. /**
  43724. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43725. */
  43726. distanceAwayFromFace: number;
  43727. /**
  43728. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43729. */
  43730. distanceAwayFromBottomOfFace: number;
  43731. private _faceVectors;
  43732. private _target;
  43733. private _scene;
  43734. private _onRenderObserver;
  43735. private _tmpMatrix;
  43736. private _tmpVector;
  43737. /**
  43738. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43739. * @param ui The transform node that should be attched to the mesh
  43740. */
  43741. constructor(ui: TransformNode);
  43742. /**
  43743. * Initializes the behavior
  43744. */
  43745. init(): void;
  43746. private _closestFace;
  43747. private _zeroVector;
  43748. private _lookAtTmpMatrix;
  43749. private _lookAtToRef;
  43750. /**
  43751. * Attaches the AttachToBoxBehavior to the passed in mesh
  43752. * @param target The mesh that the specified node will be attached to
  43753. */
  43754. attach(target: Mesh): void;
  43755. /**
  43756. * Detaches the behavior from the mesh
  43757. */
  43758. detach(): void;
  43759. }
  43760. }
  43761. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43762. import { Behavior } from "babylonjs/Behaviors/behavior";
  43763. import { Mesh } from "babylonjs/Meshes/mesh";
  43764. /**
  43765. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43766. */
  43767. export class FadeInOutBehavior implements Behavior<Mesh> {
  43768. /**
  43769. * Time in milliseconds to delay before fading in (Default: 0)
  43770. */
  43771. delay: number;
  43772. /**
  43773. * Time in milliseconds for the mesh to fade in (Default: 300)
  43774. */
  43775. fadeInTime: number;
  43776. private _millisecondsPerFrame;
  43777. private _hovered;
  43778. private _hoverValue;
  43779. private _ownerNode;
  43780. /**
  43781. * Instatiates the FadeInOutBehavior
  43782. */
  43783. constructor();
  43784. /**
  43785. * The name of the behavior
  43786. */
  43787. get name(): string;
  43788. /**
  43789. * Initializes the behavior
  43790. */
  43791. init(): void;
  43792. /**
  43793. * Attaches the fade behavior on the passed in mesh
  43794. * @param ownerNode The mesh that will be faded in/out once attached
  43795. */
  43796. attach(ownerNode: Mesh): void;
  43797. /**
  43798. * Detaches the behavior from the mesh
  43799. */
  43800. detach(): void;
  43801. /**
  43802. * Triggers the mesh to begin fading in or out
  43803. * @param value if the object should fade in or out (true to fade in)
  43804. */
  43805. fadeIn(value: boolean): void;
  43806. private _update;
  43807. private _setAllVisibility;
  43808. }
  43809. }
  43810. declare module "babylonjs/Misc/pivotTools" {
  43811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43812. /**
  43813. * Class containing a set of static utilities functions for managing Pivots
  43814. * @hidden
  43815. */
  43816. export class PivotTools {
  43817. private static _PivotCached;
  43818. private static _OldPivotPoint;
  43819. private static _PivotTranslation;
  43820. private static _PivotTmpVector;
  43821. /** @hidden */
  43822. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43823. /** @hidden */
  43824. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43825. }
  43826. }
  43827. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43828. import { Scene } from "babylonjs/scene";
  43829. import { Vector4 } from "babylonjs/Maths/math.vector";
  43830. import { Mesh } from "babylonjs/Meshes/mesh";
  43831. import { Nullable } from "babylonjs/types";
  43832. import { Plane } from "babylonjs/Maths/math.plane";
  43833. /**
  43834. * Class containing static functions to help procedurally build meshes
  43835. */
  43836. export class PlaneBuilder {
  43837. /**
  43838. * Creates a plane mesh
  43839. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43840. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43841. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43843. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43845. * @param name defines the name of the mesh
  43846. * @param options defines the options used to create the mesh
  43847. * @param scene defines the hosting scene
  43848. * @returns the plane mesh
  43849. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43850. */
  43851. static CreatePlane(name: string, options: {
  43852. size?: number;
  43853. width?: number;
  43854. height?: number;
  43855. sideOrientation?: number;
  43856. frontUVs?: Vector4;
  43857. backUVs?: Vector4;
  43858. updatable?: boolean;
  43859. sourcePlane?: Plane;
  43860. }, scene?: Nullable<Scene>): Mesh;
  43861. }
  43862. }
  43863. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43864. import { Behavior } from "babylonjs/Behaviors/behavior";
  43865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43866. import { Observable } from "babylonjs/Misc/observable";
  43867. import { Vector3 } from "babylonjs/Maths/math.vector";
  43868. import { Ray } from "babylonjs/Culling/ray";
  43869. import "babylonjs/Meshes/Builders/planeBuilder";
  43870. /**
  43871. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43872. */
  43873. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43874. private static _AnyMouseID;
  43875. /**
  43876. * Abstract mesh the behavior is set on
  43877. */
  43878. attachedNode: AbstractMesh;
  43879. private _dragPlane;
  43880. private _scene;
  43881. private _pointerObserver;
  43882. private _beforeRenderObserver;
  43883. private static _planeScene;
  43884. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43885. /**
  43886. * 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)
  43887. */
  43888. maxDragAngle: number;
  43889. /**
  43890. * @hidden
  43891. */
  43892. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43893. /**
  43894. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43895. */
  43896. currentDraggingPointerID: number;
  43897. /**
  43898. * The last position where the pointer hit the drag plane in world space
  43899. */
  43900. lastDragPosition: Vector3;
  43901. /**
  43902. * If the behavior is currently in a dragging state
  43903. */
  43904. dragging: boolean;
  43905. /**
  43906. * 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)
  43907. */
  43908. dragDeltaRatio: number;
  43909. /**
  43910. * If the drag plane orientation should be updated during the dragging (Default: true)
  43911. */
  43912. updateDragPlane: boolean;
  43913. private _debugMode;
  43914. private _moving;
  43915. /**
  43916. * Fires each time the attached mesh is dragged with the pointer
  43917. * * delta between last drag position and current drag position in world space
  43918. * * dragDistance along the drag axis
  43919. * * dragPlaneNormal normal of the current drag plane used during the drag
  43920. * * dragPlanePoint in world space where the drag intersects the drag plane
  43921. */
  43922. onDragObservable: Observable<{
  43923. delta: Vector3;
  43924. dragPlanePoint: Vector3;
  43925. dragPlaneNormal: Vector3;
  43926. dragDistance: number;
  43927. pointerId: number;
  43928. }>;
  43929. /**
  43930. * Fires each time a drag begins (eg. mouse down on mesh)
  43931. */
  43932. onDragStartObservable: Observable<{
  43933. dragPlanePoint: Vector3;
  43934. pointerId: number;
  43935. }>;
  43936. /**
  43937. * Fires each time a drag ends (eg. mouse release after drag)
  43938. */
  43939. onDragEndObservable: Observable<{
  43940. dragPlanePoint: Vector3;
  43941. pointerId: number;
  43942. }>;
  43943. /**
  43944. * If the attached mesh should be moved when dragged
  43945. */
  43946. moveAttached: boolean;
  43947. /**
  43948. * If the drag behavior will react to drag events (Default: true)
  43949. */
  43950. enabled: boolean;
  43951. /**
  43952. * If pointer events should start and release the drag (Default: true)
  43953. */
  43954. startAndReleaseDragOnPointerEvents: boolean;
  43955. /**
  43956. * If camera controls should be detached during the drag
  43957. */
  43958. detachCameraControls: boolean;
  43959. /**
  43960. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43961. */
  43962. useObjectOrientationForDragging: boolean;
  43963. private _options;
  43964. /**
  43965. * Gets the options used by the behavior
  43966. */
  43967. get options(): {
  43968. dragAxis?: Vector3;
  43969. dragPlaneNormal?: Vector3;
  43970. };
  43971. /**
  43972. * Sets the options used by the behavior
  43973. */
  43974. set options(options: {
  43975. dragAxis?: Vector3;
  43976. dragPlaneNormal?: Vector3;
  43977. });
  43978. /**
  43979. * Creates a pointer drag behavior that can be attached to a mesh
  43980. * @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)
  43981. */
  43982. constructor(options?: {
  43983. dragAxis?: Vector3;
  43984. dragPlaneNormal?: Vector3;
  43985. });
  43986. /**
  43987. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43988. */
  43989. validateDrag: (targetPosition: Vector3) => boolean;
  43990. /**
  43991. * The name of the behavior
  43992. */
  43993. get name(): string;
  43994. /**
  43995. * Initializes the behavior
  43996. */
  43997. init(): void;
  43998. private _tmpVector;
  43999. private _alternatePickedPoint;
  44000. private _worldDragAxis;
  44001. private _targetPosition;
  44002. private _attachedElement;
  44003. /**
  44004. * Attaches the drag behavior the passed in mesh
  44005. * @param ownerNode The mesh that will be dragged around once attached
  44006. * @param predicate Predicate to use for pick filtering
  44007. */
  44008. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44009. /**
  44010. * Force relase the drag action by code.
  44011. */
  44012. releaseDrag(): void;
  44013. private _startDragRay;
  44014. private _lastPointerRay;
  44015. /**
  44016. * Simulates the start of a pointer drag event on the behavior
  44017. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44018. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44019. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44020. */
  44021. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44022. private _startDrag;
  44023. private _dragDelta;
  44024. private _moveDrag;
  44025. private _pickWithRayOnDragPlane;
  44026. private _pointA;
  44027. private _pointB;
  44028. private _pointC;
  44029. private _lineA;
  44030. private _lineB;
  44031. private _localAxis;
  44032. private _lookAt;
  44033. private _updateDragPlanePosition;
  44034. /**
  44035. * Detaches the behavior from the mesh
  44036. */
  44037. detach(): void;
  44038. }
  44039. }
  44040. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44041. import { Mesh } from "babylonjs/Meshes/mesh";
  44042. import { Behavior } from "babylonjs/Behaviors/behavior";
  44043. /**
  44044. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44045. */
  44046. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44047. private _dragBehaviorA;
  44048. private _dragBehaviorB;
  44049. private _startDistance;
  44050. private _initialScale;
  44051. private _targetScale;
  44052. private _ownerNode;
  44053. private _sceneRenderObserver;
  44054. /**
  44055. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44056. */
  44057. constructor();
  44058. /**
  44059. * The name of the behavior
  44060. */
  44061. get name(): string;
  44062. /**
  44063. * Initializes the behavior
  44064. */
  44065. init(): void;
  44066. private _getCurrentDistance;
  44067. /**
  44068. * Attaches the scale behavior the passed in mesh
  44069. * @param ownerNode The mesh that will be scaled around once attached
  44070. */
  44071. attach(ownerNode: Mesh): void;
  44072. /**
  44073. * Detaches the behavior from the mesh
  44074. */
  44075. detach(): void;
  44076. }
  44077. }
  44078. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44079. import { Behavior } from "babylonjs/Behaviors/behavior";
  44080. import { Mesh } from "babylonjs/Meshes/mesh";
  44081. import { Observable } from "babylonjs/Misc/observable";
  44082. /**
  44083. * 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
  44084. */
  44085. export class SixDofDragBehavior implements Behavior<Mesh> {
  44086. private static _virtualScene;
  44087. private _ownerNode;
  44088. private _sceneRenderObserver;
  44089. private _scene;
  44090. private _targetPosition;
  44091. private _virtualOriginMesh;
  44092. private _virtualDragMesh;
  44093. private _pointerObserver;
  44094. private _moving;
  44095. private _startingOrientation;
  44096. private _attachedElement;
  44097. /**
  44098. * 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)
  44099. */
  44100. private zDragFactor;
  44101. /**
  44102. * If the object should rotate to face the drag origin
  44103. */
  44104. rotateDraggedObject: boolean;
  44105. /**
  44106. * If the behavior is currently in a dragging state
  44107. */
  44108. dragging: boolean;
  44109. /**
  44110. * 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)
  44111. */
  44112. dragDeltaRatio: number;
  44113. /**
  44114. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44115. */
  44116. currentDraggingPointerID: number;
  44117. /**
  44118. * If camera controls should be detached during the drag
  44119. */
  44120. detachCameraControls: boolean;
  44121. /**
  44122. * Fires each time a drag starts
  44123. */
  44124. onDragStartObservable: Observable<{}>;
  44125. /**
  44126. * Fires each time a drag ends (eg. mouse release after drag)
  44127. */
  44128. onDragEndObservable: Observable<{}>;
  44129. /**
  44130. * 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
  44131. */
  44132. constructor();
  44133. /**
  44134. * The name of the behavior
  44135. */
  44136. get name(): string;
  44137. /**
  44138. * Initializes the behavior
  44139. */
  44140. init(): void;
  44141. /**
  44142. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44143. */
  44144. private get _pointerCamera();
  44145. /**
  44146. * Attaches the scale behavior the passed in mesh
  44147. * @param ownerNode The mesh that will be scaled around once attached
  44148. */
  44149. attach(ownerNode: Mesh): void;
  44150. /**
  44151. * Detaches the behavior from the mesh
  44152. */
  44153. detach(): void;
  44154. }
  44155. }
  44156. declare module "babylonjs/Behaviors/Meshes/index" {
  44157. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44158. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44159. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44160. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44161. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44162. }
  44163. declare module "babylonjs/Behaviors/index" {
  44164. export * from "babylonjs/Behaviors/behavior";
  44165. export * from "babylonjs/Behaviors/Cameras/index";
  44166. export * from "babylonjs/Behaviors/Meshes/index";
  44167. }
  44168. declare module "babylonjs/Bones/boneIKController" {
  44169. import { Bone } from "babylonjs/Bones/bone";
  44170. import { Vector3 } from "babylonjs/Maths/math.vector";
  44171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44172. import { Nullable } from "babylonjs/types";
  44173. /**
  44174. * Class used to apply inverse kinematics to bones
  44175. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44176. */
  44177. export class BoneIKController {
  44178. private static _tmpVecs;
  44179. private static _tmpQuat;
  44180. private static _tmpMats;
  44181. /**
  44182. * Gets or sets the target mesh
  44183. */
  44184. targetMesh: AbstractMesh;
  44185. /** Gets or sets the mesh used as pole */
  44186. poleTargetMesh: AbstractMesh;
  44187. /**
  44188. * Gets or sets the bone used as pole
  44189. */
  44190. poleTargetBone: Nullable<Bone>;
  44191. /**
  44192. * Gets or sets the target position
  44193. */
  44194. targetPosition: Vector3;
  44195. /**
  44196. * Gets or sets the pole target position
  44197. */
  44198. poleTargetPosition: Vector3;
  44199. /**
  44200. * Gets or sets the pole target local offset
  44201. */
  44202. poleTargetLocalOffset: Vector3;
  44203. /**
  44204. * Gets or sets the pole angle
  44205. */
  44206. poleAngle: number;
  44207. /**
  44208. * Gets or sets the mesh associated with the controller
  44209. */
  44210. mesh: AbstractMesh;
  44211. /**
  44212. * 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)
  44213. */
  44214. slerpAmount: number;
  44215. private _bone1Quat;
  44216. private _bone1Mat;
  44217. private _bone2Ang;
  44218. private _bone1;
  44219. private _bone2;
  44220. private _bone1Length;
  44221. private _bone2Length;
  44222. private _maxAngle;
  44223. private _maxReach;
  44224. private _rightHandedSystem;
  44225. private _bendAxis;
  44226. private _slerping;
  44227. private _adjustRoll;
  44228. /**
  44229. * Gets or sets maximum allowed angle
  44230. */
  44231. get maxAngle(): number;
  44232. set maxAngle(value: number);
  44233. /**
  44234. * Creates a new BoneIKController
  44235. * @param mesh defines the mesh to control
  44236. * @param bone defines the bone to control
  44237. * @param options defines options to set up the controller
  44238. */
  44239. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44240. targetMesh?: AbstractMesh;
  44241. poleTargetMesh?: AbstractMesh;
  44242. poleTargetBone?: Bone;
  44243. poleTargetLocalOffset?: Vector3;
  44244. poleAngle?: number;
  44245. bendAxis?: Vector3;
  44246. maxAngle?: number;
  44247. slerpAmount?: number;
  44248. });
  44249. private _setMaxAngle;
  44250. /**
  44251. * Force the controller to update the bones
  44252. */
  44253. update(): void;
  44254. }
  44255. }
  44256. declare module "babylonjs/Bones/boneLookController" {
  44257. import { Vector3 } from "babylonjs/Maths/math.vector";
  44258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44259. import { Bone } from "babylonjs/Bones/bone";
  44260. import { Space } from "babylonjs/Maths/math.axis";
  44261. /**
  44262. * Class used to make a bone look toward a point in space
  44263. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44264. */
  44265. export class BoneLookController {
  44266. private static _tmpVecs;
  44267. private static _tmpQuat;
  44268. private static _tmpMats;
  44269. /**
  44270. * The target Vector3 that the bone will look at
  44271. */
  44272. target: Vector3;
  44273. /**
  44274. * The mesh that the bone is attached to
  44275. */
  44276. mesh: AbstractMesh;
  44277. /**
  44278. * The bone that will be looking to the target
  44279. */
  44280. bone: Bone;
  44281. /**
  44282. * The up axis of the coordinate system that is used when the bone is rotated
  44283. */
  44284. upAxis: Vector3;
  44285. /**
  44286. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44287. */
  44288. upAxisSpace: Space;
  44289. /**
  44290. * Used to make an adjustment to the yaw of the bone
  44291. */
  44292. adjustYaw: number;
  44293. /**
  44294. * Used to make an adjustment to the pitch of the bone
  44295. */
  44296. adjustPitch: number;
  44297. /**
  44298. * Used to make an adjustment to the roll of the bone
  44299. */
  44300. adjustRoll: number;
  44301. /**
  44302. * 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)
  44303. */
  44304. slerpAmount: number;
  44305. private _minYaw;
  44306. private _maxYaw;
  44307. private _minPitch;
  44308. private _maxPitch;
  44309. private _minYawSin;
  44310. private _minYawCos;
  44311. private _maxYawSin;
  44312. private _maxYawCos;
  44313. private _midYawConstraint;
  44314. private _minPitchTan;
  44315. private _maxPitchTan;
  44316. private _boneQuat;
  44317. private _slerping;
  44318. private _transformYawPitch;
  44319. private _transformYawPitchInv;
  44320. private _firstFrameSkipped;
  44321. private _yawRange;
  44322. private _fowardAxis;
  44323. /**
  44324. * Gets or sets the minimum yaw angle that the bone can look to
  44325. */
  44326. get minYaw(): number;
  44327. set minYaw(value: number);
  44328. /**
  44329. * Gets or sets the maximum yaw angle that the bone can look to
  44330. */
  44331. get maxYaw(): number;
  44332. set maxYaw(value: number);
  44333. /**
  44334. * Gets or sets the minimum pitch angle that the bone can look to
  44335. */
  44336. get minPitch(): number;
  44337. set minPitch(value: number);
  44338. /**
  44339. * Gets or sets the maximum pitch angle that the bone can look to
  44340. */
  44341. get maxPitch(): number;
  44342. set maxPitch(value: number);
  44343. /**
  44344. * Create a BoneLookController
  44345. * @param mesh the mesh that the bone belongs to
  44346. * @param bone the bone that will be looking to the target
  44347. * @param target the target Vector3 to look at
  44348. * @param options optional settings:
  44349. * * maxYaw: the maximum angle the bone will yaw to
  44350. * * minYaw: the minimum angle the bone will yaw to
  44351. * * maxPitch: the maximum angle the bone will pitch to
  44352. * * minPitch: the minimum angle the bone will yaw to
  44353. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44354. * * upAxis: the up axis of the coordinate system
  44355. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44356. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44357. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44358. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44359. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44360. * * adjustRoll: used to make an adjustment to the roll of the bone
  44361. **/
  44362. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44363. maxYaw?: number;
  44364. minYaw?: number;
  44365. maxPitch?: number;
  44366. minPitch?: number;
  44367. slerpAmount?: number;
  44368. upAxis?: Vector3;
  44369. upAxisSpace?: Space;
  44370. yawAxis?: Vector3;
  44371. pitchAxis?: Vector3;
  44372. adjustYaw?: number;
  44373. adjustPitch?: number;
  44374. adjustRoll?: number;
  44375. });
  44376. /**
  44377. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44378. */
  44379. update(): void;
  44380. private _getAngleDiff;
  44381. private _getAngleBetween;
  44382. private _isAngleBetween;
  44383. }
  44384. }
  44385. declare module "babylonjs/Bones/index" {
  44386. export * from "babylonjs/Bones/bone";
  44387. export * from "babylonjs/Bones/boneIKController";
  44388. export * from "babylonjs/Bones/boneLookController";
  44389. export * from "babylonjs/Bones/skeleton";
  44390. }
  44391. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44392. import { Nullable } from "babylonjs/types";
  44393. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44394. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44395. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44396. /**
  44397. * Manage the gamepad inputs to control an arc rotate camera.
  44398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44399. */
  44400. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44401. /**
  44402. * Defines the camera the input is attached to.
  44403. */
  44404. camera: ArcRotateCamera;
  44405. /**
  44406. * Defines the gamepad the input is gathering event from.
  44407. */
  44408. gamepad: Nullable<Gamepad>;
  44409. /**
  44410. * Defines the gamepad rotation sensiblity.
  44411. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44412. */
  44413. gamepadRotationSensibility: number;
  44414. /**
  44415. * Defines the gamepad move sensiblity.
  44416. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44417. */
  44418. gamepadMoveSensibility: number;
  44419. private _yAxisScale;
  44420. /**
  44421. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44422. */
  44423. get invertYAxis(): boolean;
  44424. set invertYAxis(value: boolean);
  44425. private _onGamepadConnectedObserver;
  44426. private _onGamepadDisconnectedObserver;
  44427. /**
  44428. * Attach the input controls to a specific dom element to get the input from.
  44429. * @param element Defines the element the controls should be listened from
  44430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44431. */
  44432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44433. /**
  44434. * Detach the current controls from the specified dom element.
  44435. * @param element Defines the element to stop listening the inputs from
  44436. */
  44437. detachControl(element: Nullable<HTMLElement>): void;
  44438. /**
  44439. * Update the current camera state depending on the inputs that have been used this frame.
  44440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44441. */
  44442. checkInputs(): void;
  44443. /**
  44444. * Gets the class name of the current intput.
  44445. * @returns the class name
  44446. */
  44447. getClassName(): string;
  44448. /**
  44449. * Get the friendly name associated with the input class.
  44450. * @returns the input friendly name
  44451. */
  44452. getSimpleName(): string;
  44453. }
  44454. }
  44455. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44456. import { Nullable } from "babylonjs/types";
  44457. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44458. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44459. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44460. interface ArcRotateCameraInputsManager {
  44461. /**
  44462. * Add orientation input support to the input manager.
  44463. * @returns the current input manager
  44464. */
  44465. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44466. }
  44467. }
  44468. /**
  44469. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44470. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44471. */
  44472. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44473. /**
  44474. * Defines the camera the input is attached to.
  44475. */
  44476. camera: ArcRotateCamera;
  44477. /**
  44478. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44479. */
  44480. alphaCorrection: number;
  44481. /**
  44482. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44483. */
  44484. gammaCorrection: number;
  44485. private _alpha;
  44486. private _gamma;
  44487. private _dirty;
  44488. private _deviceOrientationHandler;
  44489. /**
  44490. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44491. */
  44492. constructor();
  44493. /**
  44494. * Attach the input controls to a specific dom element to get the input from.
  44495. * @param element Defines the element the controls should be listened from
  44496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44497. */
  44498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44499. /** @hidden */
  44500. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44501. /**
  44502. * Update the current camera state depending on the inputs that have been used this frame.
  44503. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44504. */
  44505. checkInputs(): void;
  44506. /**
  44507. * Detach the current controls from the specified dom element.
  44508. * @param element Defines the element to stop listening the inputs from
  44509. */
  44510. detachControl(element: Nullable<HTMLElement>): void;
  44511. /**
  44512. * Gets the class name of the current intput.
  44513. * @returns the class name
  44514. */
  44515. getClassName(): string;
  44516. /**
  44517. * Get the friendly name associated with the input class.
  44518. * @returns the input friendly name
  44519. */
  44520. getSimpleName(): string;
  44521. }
  44522. }
  44523. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44524. import { Nullable } from "babylonjs/types";
  44525. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44526. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44527. /**
  44528. * Listen to mouse events to control the camera.
  44529. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44530. */
  44531. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44532. /**
  44533. * Defines the camera the input is attached to.
  44534. */
  44535. camera: FlyCamera;
  44536. /**
  44537. * Defines if touch is enabled. (Default is true.)
  44538. */
  44539. touchEnabled: boolean;
  44540. /**
  44541. * Defines the buttons associated with the input to handle camera rotation.
  44542. */
  44543. buttons: number[];
  44544. /**
  44545. * Assign buttons for Yaw control.
  44546. */
  44547. buttonsYaw: number[];
  44548. /**
  44549. * Assign buttons for Pitch control.
  44550. */
  44551. buttonsPitch: number[];
  44552. /**
  44553. * Assign buttons for Roll control.
  44554. */
  44555. buttonsRoll: number[];
  44556. /**
  44557. * Detect if any button is being pressed while mouse is moved.
  44558. * -1 = Mouse locked.
  44559. * 0 = Left button.
  44560. * 1 = Middle Button.
  44561. * 2 = Right Button.
  44562. */
  44563. activeButton: number;
  44564. /**
  44565. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44566. * Higher values reduce its sensitivity.
  44567. */
  44568. angularSensibility: number;
  44569. private _mousemoveCallback;
  44570. private _observer;
  44571. private _rollObserver;
  44572. private previousPosition;
  44573. private noPreventDefault;
  44574. private element;
  44575. /**
  44576. * Listen to mouse events to control the camera.
  44577. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44579. */
  44580. constructor(touchEnabled?: boolean);
  44581. /**
  44582. * Attach the mouse control to the HTML DOM element.
  44583. * @param element Defines the element that listens to the input events.
  44584. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44585. */
  44586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44587. /**
  44588. * Detach the current controls from the specified dom element.
  44589. * @param element Defines the element to stop listening the inputs from
  44590. */
  44591. detachControl(element: Nullable<HTMLElement>): void;
  44592. /**
  44593. * Gets the class name of the current input.
  44594. * @returns the class name.
  44595. */
  44596. getClassName(): string;
  44597. /**
  44598. * Get the friendly name associated with the input class.
  44599. * @returns the input's friendly name.
  44600. */
  44601. getSimpleName(): string;
  44602. private _pointerInput;
  44603. private _onMouseMove;
  44604. /**
  44605. * Rotate camera by mouse offset.
  44606. */
  44607. private rotateCamera;
  44608. }
  44609. }
  44610. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44611. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44612. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44613. /**
  44614. * Default Inputs manager for the FlyCamera.
  44615. * It groups all the default supported inputs for ease of use.
  44616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44617. */
  44618. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44619. /**
  44620. * Instantiates a new FlyCameraInputsManager.
  44621. * @param camera Defines the camera the inputs belong to.
  44622. */
  44623. constructor(camera: FlyCamera);
  44624. /**
  44625. * Add keyboard input support to the input manager.
  44626. * @returns the new FlyCameraKeyboardMoveInput().
  44627. */
  44628. addKeyboard(): FlyCameraInputsManager;
  44629. /**
  44630. * Add mouse input support to the input manager.
  44631. * @param touchEnabled Enable touch screen support.
  44632. * @returns the new FlyCameraMouseInput().
  44633. */
  44634. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44635. }
  44636. }
  44637. declare module "babylonjs/Cameras/flyCamera" {
  44638. import { Scene } from "babylonjs/scene";
  44639. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44641. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44642. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44643. /**
  44644. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44645. * such as in a 3D Space Shooter or a Flight Simulator.
  44646. */
  44647. export class FlyCamera extends TargetCamera {
  44648. /**
  44649. * Define the collision ellipsoid of the camera.
  44650. * This is helpful for simulating a camera body, like a player's body.
  44651. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44652. */
  44653. ellipsoid: Vector3;
  44654. /**
  44655. * Define an offset for the position of the ellipsoid around the camera.
  44656. * This can be helpful if the camera is attached away from the player's body center,
  44657. * such as at its head.
  44658. */
  44659. ellipsoidOffset: Vector3;
  44660. /**
  44661. * Enable or disable collisions of the camera with the rest of the scene objects.
  44662. */
  44663. checkCollisions: boolean;
  44664. /**
  44665. * Enable or disable gravity on the camera.
  44666. */
  44667. applyGravity: boolean;
  44668. /**
  44669. * Define the current direction the camera is moving to.
  44670. */
  44671. cameraDirection: Vector3;
  44672. /**
  44673. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44674. * This overrides and empties cameraRotation.
  44675. */
  44676. rotationQuaternion: Quaternion;
  44677. /**
  44678. * Track Roll to maintain the wanted Rolling when looking around.
  44679. */
  44680. _trackRoll: number;
  44681. /**
  44682. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44683. */
  44684. rollCorrect: number;
  44685. /**
  44686. * Mimic a banked turn, Rolling the camera when Yawing.
  44687. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44688. */
  44689. bankedTurn: boolean;
  44690. /**
  44691. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44692. */
  44693. bankedTurnLimit: number;
  44694. /**
  44695. * Value of 0 disables the banked Roll.
  44696. * Value of 1 is equal to the Yaw angle in radians.
  44697. */
  44698. bankedTurnMultiplier: number;
  44699. /**
  44700. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44701. */
  44702. inputs: FlyCameraInputsManager;
  44703. /**
  44704. * Gets the input sensibility for mouse input.
  44705. * Higher values reduce sensitivity.
  44706. */
  44707. get angularSensibility(): number;
  44708. /**
  44709. * Sets the input sensibility for a mouse input.
  44710. * Higher values reduce sensitivity.
  44711. */
  44712. set angularSensibility(value: number);
  44713. /**
  44714. * Get the keys for camera movement forward.
  44715. */
  44716. get keysForward(): number[];
  44717. /**
  44718. * Set the keys for camera movement forward.
  44719. */
  44720. set keysForward(value: number[]);
  44721. /**
  44722. * Get the keys for camera movement backward.
  44723. */
  44724. get keysBackward(): number[];
  44725. set keysBackward(value: number[]);
  44726. /**
  44727. * Get the keys for camera movement up.
  44728. */
  44729. get keysUp(): number[];
  44730. /**
  44731. * Set the keys for camera movement up.
  44732. */
  44733. set keysUp(value: number[]);
  44734. /**
  44735. * Get the keys for camera movement down.
  44736. */
  44737. get keysDown(): number[];
  44738. /**
  44739. * Set the keys for camera movement down.
  44740. */
  44741. set keysDown(value: number[]);
  44742. /**
  44743. * Get the keys for camera movement left.
  44744. */
  44745. get keysLeft(): number[];
  44746. /**
  44747. * Set the keys for camera movement left.
  44748. */
  44749. set keysLeft(value: number[]);
  44750. /**
  44751. * Set the keys for camera movement right.
  44752. */
  44753. get keysRight(): number[];
  44754. /**
  44755. * Set the keys for camera movement right.
  44756. */
  44757. set keysRight(value: number[]);
  44758. /**
  44759. * Event raised when the camera collides with a mesh in the scene.
  44760. */
  44761. onCollide: (collidedMesh: AbstractMesh) => void;
  44762. private _collider;
  44763. private _needMoveForGravity;
  44764. private _oldPosition;
  44765. private _diffPosition;
  44766. private _newPosition;
  44767. /** @hidden */
  44768. _localDirection: Vector3;
  44769. /** @hidden */
  44770. _transformedDirection: Vector3;
  44771. /**
  44772. * Instantiates a FlyCamera.
  44773. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44774. * such as in a 3D Space Shooter or a Flight Simulator.
  44775. * @param name Define the name of the camera in the scene.
  44776. * @param position Define the starting position of the camera in the scene.
  44777. * @param scene Define the scene the camera belongs to.
  44778. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44779. */
  44780. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44781. /**
  44782. * Attach a control to the HTML DOM element.
  44783. * @param element Defines the element that listens to the input events.
  44784. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44785. */
  44786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44787. /**
  44788. * Detach a control from the HTML DOM element.
  44789. * The camera will stop reacting to that input.
  44790. * @param element Defines the element that listens to the input events.
  44791. */
  44792. detachControl(element: HTMLElement): void;
  44793. private _collisionMask;
  44794. /**
  44795. * Get the mask that the camera ignores in collision events.
  44796. */
  44797. get collisionMask(): number;
  44798. /**
  44799. * Set the mask that the camera ignores in collision events.
  44800. */
  44801. set collisionMask(mask: number);
  44802. /** @hidden */
  44803. _collideWithWorld(displacement: Vector3): void;
  44804. /** @hidden */
  44805. private _onCollisionPositionChange;
  44806. /** @hidden */
  44807. _checkInputs(): void;
  44808. /** @hidden */
  44809. _decideIfNeedsToMove(): boolean;
  44810. /** @hidden */
  44811. _updatePosition(): void;
  44812. /**
  44813. * Restore the Roll to its target value at the rate specified.
  44814. * @param rate - Higher means slower restoring.
  44815. * @hidden
  44816. */
  44817. restoreRoll(rate: number): void;
  44818. /**
  44819. * Destroy the camera and release the current resources held by it.
  44820. */
  44821. dispose(): void;
  44822. /**
  44823. * Get the current object class name.
  44824. * @returns the class name.
  44825. */
  44826. getClassName(): string;
  44827. }
  44828. }
  44829. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44830. import { Nullable } from "babylonjs/types";
  44831. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44832. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44833. /**
  44834. * Listen to keyboard events to control the camera.
  44835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44836. */
  44837. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44838. /**
  44839. * Defines the camera the input is attached to.
  44840. */
  44841. camera: FlyCamera;
  44842. /**
  44843. * The list of keyboard keys used to control the forward move of the camera.
  44844. */
  44845. keysForward: number[];
  44846. /**
  44847. * The list of keyboard keys used to control the backward move of the camera.
  44848. */
  44849. keysBackward: number[];
  44850. /**
  44851. * The list of keyboard keys used to control the forward move of the camera.
  44852. */
  44853. keysUp: number[];
  44854. /**
  44855. * The list of keyboard keys used to control the backward move of the camera.
  44856. */
  44857. keysDown: number[];
  44858. /**
  44859. * The list of keyboard keys used to control the right strafe move of the camera.
  44860. */
  44861. keysRight: number[];
  44862. /**
  44863. * The list of keyboard keys used to control the left strafe move of the camera.
  44864. */
  44865. keysLeft: number[];
  44866. private _keys;
  44867. private _onCanvasBlurObserver;
  44868. private _onKeyboardObserver;
  44869. private _engine;
  44870. private _scene;
  44871. /**
  44872. * Attach the input controls to a specific dom element to get the input from.
  44873. * @param element Defines the element the controls should be listened from
  44874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44875. */
  44876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44877. /**
  44878. * Detach the current controls from the specified dom element.
  44879. * @param element Defines the element to stop listening the inputs from
  44880. */
  44881. detachControl(element: Nullable<HTMLElement>): void;
  44882. /**
  44883. * Gets the class name of the current intput.
  44884. * @returns the class name
  44885. */
  44886. getClassName(): string;
  44887. /** @hidden */
  44888. _onLostFocus(e: FocusEvent): void;
  44889. /**
  44890. * Get the friendly name associated with the input class.
  44891. * @returns the input friendly name
  44892. */
  44893. getSimpleName(): string;
  44894. /**
  44895. * Update the current camera state depending on the inputs that have been used this frame.
  44896. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44897. */
  44898. checkInputs(): void;
  44899. }
  44900. }
  44901. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  44902. import { Nullable } from "babylonjs/types";
  44903. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44904. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44905. /**
  44906. * Manage the mouse wheel inputs to control a follow camera.
  44907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44908. */
  44909. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44910. /**
  44911. * Defines the camera the input is attached to.
  44912. */
  44913. camera: FollowCamera;
  44914. /**
  44915. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44916. */
  44917. axisControlRadius: boolean;
  44918. /**
  44919. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44920. */
  44921. axisControlHeight: boolean;
  44922. /**
  44923. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44924. */
  44925. axisControlRotation: boolean;
  44926. /**
  44927. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44928. * relation to mouseWheel events.
  44929. */
  44930. wheelPrecision: number;
  44931. /**
  44932. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44933. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44934. */
  44935. wheelDeltaPercentage: number;
  44936. private _wheel;
  44937. private _observer;
  44938. /**
  44939. * Attach the input controls to a specific dom element to get the input from.
  44940. * @param element Defines the element the controls should be listened from
  44941. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44942. */
  44943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44944. /**
  44945. * Detach the current controls from the specified dom element.
  44946. * @param element Defines the element to stop listening the inputs from
  44947. */
  44948. detachControl(element: Nullable<HTMLElement>): void;
  44949. /**
  44950. * Gets the class name of the current intput.
  44951. * @returns the class name
  44952. */
  44953. getClassName(): string;
  44954. /**
  44955. * Get the friendly name associated with the input class.
  44956. * @returns the input friendly name
  44957. */
  44958. getSimpleName(): string;
  44959. }
  44960. }
  44961. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  44962. import { Nullable } from "babylonjs/types";
  44963. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  44964. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44965. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44966. /**
  44967. * Manage the pointers inputs to control an follow camera.
  44968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44969. */
  44970. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44971. /**
  44972. * Defines the camera the input is attached to.
  44973. */
  44974. camera: FollowCamera;
  44975. /**
  44976. * Gets the class name of the current input.
  44977. * @returns the class name
  44978. */
  44979. getClassName(): string;
  44980. /**
  44981. * Defines the pointer angular sensibility along the X axis or how fast is
  44982. * the camera rotating.
  44983. * A negative number will reverse the axis direction.
  44984. */
  44985. angularSensibilityX: number;
  44986. /**
  44987. * Defines the pointer angular sensibility along the Y axis or how fast is
  44988. * the camera rotating.
  44989. * A negative number will reverse the axis direction.
  44990. */
  44991. angularSensibilityY: number;
  44992. /**
  44993. * Defines the pointer pinch precision or how fast is the camera zooming.
  44994. * A negative number will reverse the axis direction.
  44995. */
  44996. pinchPrecision: number;
  44997. /**
  44998. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44999. * from 0.
  45000. * It defines the percentage of current camera.radius to use as delta when
  45001. * pinch zoom is used.
  45002. */
  45003. pinchDeltaPercentage: number;
  45004. /**
  45005. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45006. */
  45007. axisXControlRadius: boolean;
  45008. /**
  45009. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45010. */
  45011. axisXControlHeight: boolean;
  45012. /**
  45013. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45014. */
  45015. axisXControlRotation: boolean;
  45016. /**
  45017. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45018. */
  45019. axisYControlRadius: boolean;
  45020. /**
  45021. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45022. */
  45023. axisYControlHeight: boolean;
  45024. /**
  45025. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45026. */
  45027. axisYControlRotation: boolean;
  45028. /**
  45029. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45030. */
  45031. axisPinchControlRadius: boolean;
  45032. /**
  45033. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45034. */
  45035. axisPinchControlHeight: boolean;
  45036. /**
  45037. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45038. */
  45039. axisPinchControlRotation: boolean;
  45040. /**
  45041. * Log error messages if basic misconfiguration has occurred.
  45042. */
  45043. warningEnable: boolean;
  45044. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45045. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45046. private _warningCounter;
  45047. private _warning;
  45048. }
  45049. }
  45050. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45051. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45052. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45053. /**
  45054. * Default Inputs manager for the FollowCamera.
  45055. * It groups all the default supported inputs for ease of use.
  45056. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45057. */
  45058. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45059. /**
  45060. * Instantiates a new FollowCameraInputsManager.
  45061. * @param camera Defines the camera the inputs belong to
  45062. */
  45063. constructor(camera: FollowCamera);
  45064. /**
  45065. * Add keyboard input support to the input manager.
  45066. * @returns the current input manager
  45067. */
  45068. addKeyboard(): FollowCameraInputsManager;
  45069. /**
  45070. * Add mouse wheel input support to the input manager.
  45071. * @returns the current input manager
  45072. */
  45073. addMouseWheel(): FollowCameraInputsManager;
  45074. /**
  45075. * Add pointers input support to the input manager.
  45076. * @returns the current input manager
  45077. */
  45078. addPointers(): FollowCameraInputsManager;
  45079. /**
  45080. * Add orientation input support to the input manager.
  45081. * @returns the current input manager
  45082. */
  45083. addVRDeviceOrientation(): FollowCameraInputsManager;
  45084. }
  45085. }
  45086. declare module "babylonjs/Cameras/followCamera" {
  45087. import { Nullable } from "babylonjs/types";
  45088. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45089. import { Scene } from "babylonjs/scene";
  45090. import { Vector3 } from "babylonjs/Maths/math.vector";
  45091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45092. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45093. /**
  45094. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45095. * an arc rotate version arcFollowCamera are available.
  45096. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45097. */
  45098. export class FollowCamera extends TargetCamera {
  45099. /**
  45100. * Distance the follow camera should follow an object at
  45101. */
  45102. radius: number;
  45103. /**
  45104. * Minimum allowed distance of the camera to the axis of rotation
  45105. * (The camera can not get closer).
  45106. * This can help limiting how the Camera is able to move in the scene.
  45107. */
  45108. lowerRadiusLimit: Nullable<number>;
  45109. /**
  45110. * Maximum allowed distance of the camera to the axis of rotation
  45111. * (The camera can not get further).
  45112. * This can help limiting how the Camera is able to move in the scene.
  45113. */
  45114. upperRadiusLimit: Nullable<number>;
  45115. /**
  45116. * Define a rotation offset between the camera and the object it follows
  45117. */
  45118. rotationOffset: number;
  45119. /**
  45120. * Minimum allowed angle to camera position relative to target object.
  45121. * This can help limiting how the Camera is able to move in the scene.
  45122. */
  45123. lowerRotationOffsetLimit: Nullable<number>;
  45124. /**
  45125. * Maximum allowed angle to camera position relative to target object.
  45126. * This can help limiting how the Camera is able to move in the scene.
  45127. */
  45128. upperRotationOffsetLimit: Nullable<number>;
  45129. /**
  45130. * Define a height offset between the camera and the object it follows.
  45131. * It can help following an object from the top (like a car chaing a plane)
  45132. */
  45133. heightOffset: number;
  45134. /**
  45135. * Minimum allowed height of camera position relative to target object.
  45136. * This can help limiting how the Camera is able to move in the scene.
  45137. */
  45138. lowerHeightOffsetLimit: Nullable<number>;
  45139. /**
  45140. * Maximum allowed height of camera position relative to target object.
  45141. * This can help limiting how the Camera is able to move in the scene.
  45142. */
  45143. upperHeightOffsetLimit: Nullable<number>;
  45144. /**
  45145. * Define how fast the camera can accelerate to follow it s target.
  45146. */
  45147. cameraAcceleration: number;
  45148. /**
  45149. * Define the speed limit of the camera following an object.
  45150. */
  45151. maxCameraSpeed: number;
  45152. /**
  45153. * Define the target of the camera.
  45154. */
  45155. lockedTarget: Nullable<AbstractMesh>;
  45156. /**
  45157. * Defines the input associated with the camera.
  45158. */
  45159. inputs: FollowCameraInputsManager;
  45160. /**
  45161. * Instantiates the follow camera.
  45162. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45163. * @param name Define the name of the camera in the scene
  45164. * @param position Define the position of the camera
  45165. * @param scene Define the scene the camera belong to
  45166. * @param lockedTarget Define the target of the camera
  45167. */
  45168. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45169. private _follow;
  45170. /**
  45171. * Attached controls to the current camera.
  45172. * @param element Defines the element the controls should be listened from
  45173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45174. */
  45175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45176. /**
  45177. * Detach the current controls from the camera.
  45178. * The camera will stop reacting to inputs.
  45179. * @param element Defines the element to stop listening the inputs from
  45180. */
  45181. detachControl(element: HTMLElement): void;
  45182. /** @hidden */
  45183. _checkInputs(): void;
  45184. private _checkLimits;
  45185. /**
  45186. * Gets the camera class name.
  45187. * @returns the class name
  45188. */
  45189. getClassName(): string;
  45190. }
  45191. /**
  45192. * Arc Rotate version of the follow camera.
  45193. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45194. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45195. */
  45196. export class ArcFollowCamera extends TargetCamera {
  45197. /** The longitudinal angle of the camera */
  45198. alpha: number;
  45199. /** The latitudinal angle of the camera */
  45200. beta: number;
  45201. /** The radius of the camera from its target */
  45202. radius: number;
  45203. /** Define the camera target (the mesh it should follow) */
  45204. target: Nullable<AbstractMesh>;
  45205. private _cartesianCoordinates;
  45206. /**
  45207. * Instantiates a new ArcFollowCamera
  45208. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  45209. * @param name Define the name of the camera
  45210. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45211. * @param beta Define the rotation angle of the camera around the elevation axis
  45212. * @param radius Define the radius of the camera from its target point
  45213. * @param target Define the target of the camera
  45214. * @param scene Define the scene the camera belongs to
  45215. */
  45216. constructor(name: string,
  45217. /** The longitudinal angle of the camera */
  45218. alpha: number,
  45219. /** The latitudinal angle of the camera */
  45220. beta: number,
  45221. /** The radius of the camera from its target */
  45222. radius: number,
  45223. /** Define the camera target (the mesh it should follow) */
  45224. target: Nullable<AbstractMesh>, scene: Scene);
  45225. private _follow;
  45226. /** @hidden */
  45227. _checkInputs(): void;
  45228. /**
  45229. * Returns the class name of the object.
  45230. * It is mostly used internally for serialization purposes.
  45231. */
  45232. getClassName(): string;
  45233. }
  45234. }
  45235. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45236. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45237. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45238. import { Nullable } from "babylonjs/types";
  45239. /**
  45240. * Manage the keyboard inputs to control the movement of a follow camera.
  45241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45242. */
  45243. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45244. /**
  45245. * Defines the camera the input is attached to.
  45246. */
  45247. camera: FollowCamera;
  45248. /**
  45249. * Defines the list of key codes associated with the up action (increase heightOffset)
  45250. */
  45251. keysHeightOffsetIncr: number[];
  45252. /**
  45253. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45254. */
  45255. keysHeightOffsetDecr: number[];
  45256. /**
  45257. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45258. */
  45259. keysHeightOffsetModifierAlt: boolean;
  45260. /**
  45261. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45262. */
  45263. keysHeightOffsetModifierCtrl: boolean;
  45264. /**
  45265. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45266. */
  45267. keysHeightOffsetModifierShift: boolean;
  45268. /**
  45269. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45270. */
  45271. keysRotationOffsetIncr: number[];
  45272. /**
  45273. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45274. */
  45275. keysRotationOffsetDecr: number[];
  45276. /**
  45277. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45278. */
  45279. keysRotationOffsetModifierAlt: boolean;
  45280. /**
  45281. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45282. */
  45283. keysRotationOffsetModifierCtrl: boolean;
  45284. /**
  45285. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45286. */
  45287. keysRotationOffsetModifierShift: boolean;
  45288. /**
  45289. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45290. */
  45291. keysRadiusIncr: number[];
  45292. /**
  45293. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45294. */
  45295. keysRadiusDecr: number[];
  45296. /**
  45297. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45298. */
  45299. keysRadiusModifierAlt: boolean;
  45300. /**
  45301. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45302. */
  45303. keysRadiusModifierCtrl: boolean;
  45304. /**
  45305. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45306. */
  45307. keysRadiusModifierShift: boolean;
  45308. /**
  45309. * Defines the rate of change of heightOffset.
  45310. */
  45311. heightSensibility: number;
  45312. /**
  45313. * Defines the rate of change of rotationOffset.
  45314. */
  45315. rotationSensibility: number;
  45316. /**
  45317. * Defines the rate of change of radius.
  45318. */
  45319. radiusSensibility: number;
  45320. private _keys;
  45321. private _ctrlPressed;
  45322. private _altPressed;
  45323. private _shiftPressed;
  45324. private _onCanvasBlurObserver;
  45325. private _onKeyboardObserver;
  45326. private _engine;
  45327. private _scene;
  45328. /**
  45329. * Attach the input controls to a specific dom element to get the input from.
  45330. * @param element Defines the element the controls should be listened from
  45331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45332. */
  45333. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45334. /**
  45335. * Detach the current controls from the specified dom element.
  45336. * @param element Defines the element to stop listening the inputs from
  45337. */
  45338. detachControl(element: Nullable<HTMLElement>): void;
  45339. /**
  45340. * Update the current camera state depending on the inputs that have been used this frame.
  45341. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45342. */
  45343. checkInputs(): void;
  45344. /**
  45345. * Gets the class name of the current input.
  45346. * @returns the class name
  45347. */
  45348. getClassName(): string;
  45349. /**
  45350. * Get the friendly name associated with the input class.
  45351. * @returns the input friendly name
  45352. */
  45353. getSimpleName(): string;
  45354. /**
  45355. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45356. * allow modification of the heightOffset value.
  45357. */
  45358. private _modifierHeightOffset;
  45359. /**
  45360. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45361. * allow modification of the rotationOffset value.
  45362. */
  45363. private _modifierRotationOffset;
  45364. /**
  45365. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45366. * allow modification of the radius value.
  45367. */
  45368. private _modifierRadius;
  45369. }
  45370. }
  45371. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45372. import { Nullable } from "babylonjs/types";
  45373. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45374. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45375. import { Observable } from "babylonjs/Misc/observable";
  45376. module "babylonjs/Cameras/freeCameraInputsManager" {
  45377. interface FreeCameraInputsManager {
  45378. /**
  45379. * @hidden
  45380. */
  45381. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45382. /**
  45383. * Add orientation input support to the input manager.
  45384. * @returns the current input manager
  45385. */
  45386. addDeviceOrientation(): FreeCameraInputsManager;
  45387. }
  45388. }
  45389. /**
  45390. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45391. * Screen rotation is taken into account.
  45392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45393. */
  45394. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45395. private _camera;
  45396. private _screenOrientationAngle;
  45397. private _constantTranform;
  45398. private _screenQuaternion;
  45399. private _alpha;
  45400. private _beta;
  45401. private _gamma;
  45402. /**
  45403. * Can be used to detect if a device orientation sensor is available on a device
  45404. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45405. * @returns a promise that will resolve on orientation change
  45406. */
  45407. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45408. /**
  45409. * @hidden
  45410. */
  45411. _onDeviceOrientationChangedObservable: Observable<void>;
  45412. /**
  45413. * Instantiates a new input
  45414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45415. */
  45416. constructor();
  45417. /**
  45418. * Define the camera controlled by the input.
  45419. */
  45420. get camera(): FreeCamera;
  45421. set camera(camera: FreeCamera);
  45422. /**
  45423. * Attach the input controls to a specific dom element to get the input from.
  45424. * @param element Defines the element the controls should be listened from
  45425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45426. */
  45427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45428. private _orientationChanged;
  45429. private _deviceOrientation;
  45430. /**
  45431. * Detach the current controls from the specified dom element.
  45432. * @param element Defines the element to stop listening the inputs from
  45433. */
  45434. detachControl(element: Nullable<HTMLElement>): void;
  45435. /**
  45436. * Update the current camera state depending on the inputs that have been used this frame.
  45437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45438. */
  45439. checkInputs(): void;
  45440. /**
  45441. * Gets the class name of the current intput.
  45442. * @returns the class name
  45443. */
  45444. getClassName(): string;
  45445. /**
  45446. * Get the friendly name associated with the input class.
  45447. * @returns the input friendly name
  45448. */
  45449. getSimpleName(): string;
  45450. }
  45451. }
  45452. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45453. import { Nullable } from "babylonjs/types";
  45454. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45455. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45456. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45457. /**
  45458. * Manage the gamepad inputs to control a free camera.
  45459. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45460. */
  45461. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45462. /**
  45463. * Define the camera the input is attached to.
  45464. */
  45465. camera: FreeCamera;
  45466. /**
  45467. * Define the Gamepad controlling the input
  45468. */
  45469. gamepad: Nullable<Gamepad>;
  45470. /**
  45471. * Defines the gamepad rotation sensiblity.
  45472. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45473. */
  45474. gamepadAngularSensibility: number;
  45475. /**
  45476. * Defines the gamepad move sensiblity.
  45477. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45478. */
  45479. gamepadMoveSensibility: number;
  45480. private _yAxisScale;
  45481. /**
  45482. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45483. */
  45484. get invertYAxis(): boolean;
  45485. set invertYAxis(value: boolean);
  45486. private _onGamepadConnectedObserver;
  45487. private _onGamepadDisconnectedObserver;
  45488. private _cameraTransform;
  45489. private _deltaTransform;
  45490. private _vector3;
  45491. private _vector2;
  45492. /**
  45493. * Attach the input controls to a specific dom element to get the input from.
  45494. * @param element Defines the element the controls should be listened from
  45495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45496. */
  45497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45498. /**
  45499. * Detach the current controls from the specified dom element.
  45500. * @param element Defines the element to stop listening the inputs from
  45501. */
  45502. detachControl(element: Nullable<HTMLElement>): void;
  45503. /**
  45504. * Update the current camera state depending on the inputs that have been used this frame.
  45505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45506. */
  45507. checkInputs(): void;
  45508. /**
  45509. * Gets the class name of the current intput.
  45510. * @returns the class name
  45511. */
  45512. getClassName(): string;
  45513. /**
  45514. * Get the friendly name associated with the input class.
  45515. * @returns the input friendly name
  45516. */
  45517. getSimpleName(): string;
  45518. }
  45519. }
  45520. declare module "babylonjs/Misc/virtualJoystick" {
  45521. import { Nullable } from "babylonjs/types";
  45522. import { Vector3 } from "babylonjs/Maths/math.vector";
  45523. /**
  45524. * Defines the potential axis of a Joystick
  45525. */
  45526. export enum JoystickAxis {
  45527. /** X axis */
  45528. X = 0,
  45529. /** Y axis */
  45530. Y = 1,
  45531. /** Z axis */
  45532. Z = 2
  45533. }
  45534. /**
  45535. * Class used to define virtual joystick (used in touch mode)
  45536. */
  45537. export class VirtualJoystick {
  45538. /**
  45539. * Gets or sets a boolean indicating that left and right values must be inverted
  45540. */
  45541. reverseLeftRight: boolean;
  45542. /**
  45543. * Gets or sets a boolean indicating that up and down values must be inverted
  45544. */
  45545. reverseUpDown: boolean;
  45546. /**
  45547. * Gets the offset value for the position (ie. the change of the position value)
  45548. */
  45549. deltaPosition: Vector3;
  45550. /**
  45551. * Gets a boolean indicating if the virtual joystick was pressed
  45552. */
  45553. pressed: boolean;
  45554. /**
  45555. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45556. */
  45557. static Canvas: Nullable<HTMLCanvasElement>;
  45558. private static _globalJoystickIndex;
  45559. private static vjCanvasContext;
  45560. private static vjCanvasWidth;
  45561. private static vjCanvasHeight;
  45562. private static halfWidth;
  45563. private _action;
  45564. private _axisTargetedByLeftAndRight;
  45565. private _axisTargetedByUpAndDown;
  45566. private _joystickSensibility;
  45567. private _inversedSensibility;
  45568. private _joystickPointerID;
  45569. private _joystickColor;
  45570. private _joystickPointerPos;
  45571. private _joystickPreviousPointerPos;
  45572. private _joystickPointerStartPos;
  45573. private _deltaJoystickVector;
  45574. private _leftJoystick;
  45575. private _touches;
  45576. private _onPointerDownHandlerRef;
  45577. private _onPointerMoveHandlerRef;
  45578. private _onPointerUpHandlerRef;
  45579. private _onResize;
  45580. /**
  45581. * Creates a new virtual joystick
  45582. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45583. */
  45584. constructor(leftJoystick?: boolean);
  45585. /**
  45586. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45587. * @param newJoystickSensibility defines the new sensibility
  45588. */
  45589. setJoystickSensibility(newJoystickSensibility: number): void;
  45590. private _onPointerDown;
  45591. private _onPointerMove;
  45592. private _onPointerUp;
  45593. /**
  45594. * Change the color of the virtual joystick
  45595. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45596. */
  45597. setJoystickColor(newColor: string): void;
  45598. /**
  45599. * Defines a callback to call when the joystick is touched
  45600. * @param action defines the callback
  45601. */
  45602. setActionOnTouch(action: () => any): void;
  45603. /**
  45604. * Defines which axis you'd like to control for left & right
  45605. * @param axis defines the axis to use
  45606. */
  45607. setAxisForLeftRight(axis: JoystickAxis): void;
  45608. /**
  45609. * Defines which axis you'd like to control for up & down
  45610. * @param axis defines the axis to use
  45611. */
  45612. setAxisForUpDown(axis: JoystickAxis): void;
  45613. private _drawVirtualJoystick;
  45614. /**
  45615. * Release internal HTML canvas
  45616. */
  45617. releaseCanvas(): void;
  45618. }
  45619. }
  45620. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45621. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45622. import { Nullable } from "babylonjs/types";
  45623. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45624. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45625. module "babylonjs/Cameras/freeCameraInputsManager" {
  45626. interface FreeCameraInputsManager {
  45627. /**
  45628. * Add virtual joystick input support to the input manager.
  45629. * @returns the current input manager
  45630. */
  45631. addVirtualJoystick(): FreeCameraInputsManager;
  45632. }
  45633. }
  45634. /**
  45635. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  45637. */
  45638. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45639. /**
  45640. * Defines the camera the input is attached to.
  45641. */
  45642. camera: FreeCamera;
  45643. private _leftjoystick;
  45644. private _rightjoystick;
  45645. /**
  45646. * Gets the left stick of the virtual joystick.
  45647. * @returns The virtual Joystick
  45648. */
  45649. getLeftJoystick(): VirtualJoystick;
  45650. /**
  45651. * Gets the right stick of the virtual joystick.
  45652. * @returns The virtual Joystick
  45653. */
  45654. getRightJoystick(): VirtualJoystick;
  45655. /**
  45656. * Update the current camera state depending on the inputs that have been used this frame.
  45657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45658. */
  45659. checkInputs(): void;
  45660. /**
  45661. * Attach the input controls to a specific dom element to get the input from.
  45662. * @param element Defines the element the controls should be listened from
  45663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45664. */
  45665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45666. /**
  45667. * Detach the current controls from the specified dom element.
  45668. * @param element Defines the element to stop listening the inputs from
  45669. */
  45670. detachControl(element: Nullable<HTMLElement>): void;
  45671. /**
  45672. * Gets the class name of the current intput.
  45673. * @returns the class name
  45674. */
  45675. getClassName(): string;
  45676. /**
  45677. * Get the friendly name associated with the input class.
  45678. * @returns the input friendly name
  45679. */
  45680. getSimpleName(): string;
  45681. }
  45682. }
  45683. declare module "babylonjs/Cameras/Inputs/index" {
  45684. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45685. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45686. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45687. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45688. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45689. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45690. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45691. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45692. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45693. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45694. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45695. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45696. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45697. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45698. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45699. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45700. }
  45701. declare module "babylonjs/Cameras/touchCamera" {
  45702. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45703. import { Scene } from "babylonjs/scene";
  45704. import { Vector3 } from "babylonjs/Maths/math.vector";
  45705. /**
  45706. * This represents a FPS type of camera controlled by touch.
  45707. * This is like a universal camera minus the Gamepad controls.
  45708. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45709. */
  45710. export class TouchCamera extends FreeCamera {
  45711. /**
  45712. * Defines the touch sensibility for rotation.
  45713. * The higher the faster.
  45714. */
  45715. get touchAngularSensibility(): number;
  45716. set touchAngularSensibility(value: number);
  45717. /**
  45718. * Defines the touch sensibility for move.
  45719. * The higher the faster.
  45720. */
  45721. get touchMoveSensibility(): number;
  45722. set touchMoveSensibility(value: number);
  45723. /**
  45724. * Instantiates a new touch camera.
  45725. * This represents a FPS type of camera controlled by touch.
  45726. * This is like a universal camera minus the Gamepad controls.
  45727. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  45728. * @param name Define the name of the camera in the scene
  45729. * @param position Define the start position of the camera in the scene
  45730. * @param scene Define the scene the camera belongs to
  45731. */
  45732. constructor(name: string, position: Vector3, scene: Scene);
  45733. /**
  45734. * Gets the current object class name.
  45735. * @return the class name
  45736. */
  45737. getClassName(): string;
  45738. /** @hidden */
  45739. _setupInputs(): void;
  45740. }
  45741. }
  45742. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45743. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45744. import { Scene } from "babylonjs/scene";
  45745. import { Vector3 } from "babylonjs/Maths/math.vector";
  45746. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45747. import { Axis } from "babylonjs/Maths/math.axis";
  45748. /**
  45749. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45750. * being tilted forward or back and left or right.
  45751. */
  45752. export class DeviceOrientationCamera extends FreeCamera {
  45753. private _initialQuaternion;
  45754. private _quaternionCache;
  45755. private _tmpDragQuaternion;
  45756. private _disablePointerInputWhenUsingDeviceOrientation;
  45757. /**
  45758. * Creates a new device orientation camera
  45759. * @param name The name of the camera
  45760. * @param position The start position camera
  45761. * @param scene The scene the camera belongs to
  45762. */
  45763. constructor(name: string, position: Vector3, scene: Scene);
  45764. /**
  45765. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45766. */
  45767. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45768. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45769. private _dragFactor;
  45770. /**
  45771. * Enabled turning on the y axis when the orientation sensor is active
  45772. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45773. */
  45774. enableHorizontalDragging(dragFactor?: number): void;
  45775. /**
  45776. * Gets the current instance class name ("DeviceOrientationCamera").
  45777. * This helps avoiding instanceof at run time.
  45778. * @returns the class name
  45779. */
  45780. getClassName(): string;
  45781. /**
  45782. * @hidden
  45783. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45784. */
  45785. _checkInputs(): void;
  45786. /**
  45787. * Reset the camera to its default orientation on the specified axis only.
  45788. * @param axis The axis to reset
  45789. */
  45790. resetToCurrentRotation(axis?: Axis): void;
  45791. }
  45792. }
  45793. declare module "babylonjs/Gamepads/xboxGamepad" {
  45794. import { Observable } from "babylonjs/Misc/observable";
  45795. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45796. /**
  45797. * Defines supported buttons for XBox360 compatible gamepads
  45798. */
  45799. export enum Xbox360Button {
  45800. /** A */
  45801. A = 0,
  45802. /** B */
  45803. B = 1,
  45804. /** X */
  45805. X = 2,
  45806. /** Y */
  45807. Y = 3,
  45808. /** Left button */
  45809. LB = 4,
  45810. /** Right button */
  45811. RB = 5,
  45812. /** Back */
  45813. Back = 8,
  45814. /** Start */
  45815. Start = 9,
  45816. /** Left stick */
  45817. LeftStick = 10,
  45818. /** Right stick */
  45819. RightStick = 11
  45820. }
  45821. /** Defines values for XBox360 DPad */
  45822. export enum Xbox360Dpad {
  45823. /** Up */
  45824. Up = 12,
  45825. /** Down */
  45826. Down = 13,
  45827. /** Left */
  45828. Left = 14,
  45829. /** Right */
  45830. Right = 15
  45831. }
  45832. /**
  45833. * Defines a XBox360 gamepad
  45834. */
  45835. export class Xbox360Pad extends Gamepad {
  45836. private _leftTrigger;
  45837. private _rightTrigger;
  45838. private _onlefttriggerchanged;
  45839. private _onrighttriggerchanged;
  45840. private _onbuttondown;
  45841. private _onbuttonup;
  45842. private _ondpaddown;
  45843. private _ondpadup;
  45844. /** Observable raised when a button is pressed */
  45845. onButtonDownObservable: Observable<Xbox360Button>;
  45846. /** Observable raised when a button is released */
  45847. onButtonUpObservable: Observable<Xbox360Button>;
  45848. /** Observable raised when a pad is pressed */
  45849. onPadDownObservable: Observable<Xbox360Dpad>;
  45850. /** Observable raised when a pad is released */
  45851. onPadUpObservable: Observable<Xbox360Dpad>;
  45852. private _buttonA;
  45853. private _buttonB;
  45854. private _buttonX;
  45855. private _buttonY;
  45856. private _buttonBack;
  45857. private _buttonStart;
  45858. private _buttonLB;
  45859. private _buttonRB;
  45860. private _buttonLeftStick;
  45861. private _buttonRightStick;
  45862. private _dPadUp;
  45863. private _dPadDown;
  45864. private _dPadLeft;
  45865. private _dPadRight;
  45866. private _isXboxOnePad;
  45867. /**
  45868. * Creates a new XBox360 gamepad object
  45869. * @param id defines the id of this gamepad
  45870. * @param index defines its index
  45871. * @param gamepad defines the internal HTML gamepad object
  45872. * @param xboxOne defines if it is a XBox One gamepad
  45873. */
  45874. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45875. /**
  45876. * Defines the callback to call when left trigger is pressed
  45877. * @param callback defines the callback to use
  45878. */
  45879. onlefttriggerchanged(callback: (value: number) => void): void;
  45880. /**
  45881. * Defines the callback to call when right trigger is pressed
  45882. * @param callback defines the callback to use
  45883. */
  45884. onrighttriggerchanged(callback: (value: number) => void): void;
  45885. /**
  45886. * Gets the left trigger value
  45887. */
  45888. get leftTrigger(): number;
  45889. /**
  45890. * Sets the left trigger value
  45891. */
  45892. set leftTrigger(newValue: number);
  45893. /**
  45894. * Gets the right trigger value
  45895. */
  45896. get rightTrigger(): number;
  45897. /**
  45898. * Sets the right trigger value
  45899. */
  45900. set rightTrigger(newValue: number);
  45901. /**
  45902. * Defines the callback to call when a button is pressed
  45903. * @param callback defines the callback to use
  45904. */
  45905. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45906. /**
  45907. * Defines the callback to call when a button is released
  45908. * @param callback defines the callback to use
  45909. */
  45910. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45911. /**
  45912. * Defines the callback to call when a pad is pressed
  45913. * @param callback defines the callback to use
  45914. */
  45915. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45916. /**
  45917. * Defines the callback to call when a pad is released
  45918. * @param callback defines the callback to use
  45919. */
  45920. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45921. private _setButtonValue;
  45922. private _setDPadValue;
  45923. /**
  45924. * Gets the value of the `A` button
  45925. */
  45926. get buttonA(): number;
  45927. /**
  45928. * Sets the value of the `A` button
  45929. */
  45930. set buttonA(value: number);
  45931. /**
  45932. * Gets the value of the `B` button
  45933. */
  45934. get buttonB(): number;
  45935. /**
  45936. * Sets the value of the `B` button
  45937. */
  45938. set buttonB(value: number);
  45939. /**
  45940. * Gets the value of the `X` button
  45941. */
  45942. get buttonX(): number;
  45943. /**
  45944. * Sets the value of the `X` button
  45945. */
  45946. set buttonX(value: number);
  45947. /**
  45948. * Gets the value of the `Y` button
  45949. */
  45950. get buttonY(): number;
  45951. /**
  45952. * Sets the value of the `Y` button
  45953. */
  45954. set buttonY(value: number);
  45955. /**
  45956. * Gets the value of the `Start` button
  45957. */
  45958. get buttonStart(): number;
  45959. /**
  45960. * Sets the value of the `Start` button
  45961. */
  45962. set buttonStart(value: number);
  45963. /**
  45964. * Gets the value of the `Back` button
  45965. */
  45966. get buttonBack(): number;
  45967. /**
  45968. * Sets the value of the `Back` button
  45969. */
  45970. set buttonBack(value: number);
  45971. /**
  45972. * Gets the value of the `Left` button
  45973. */
  45974. get buttonLB(): number;
  45975. /**
  45976. * Sets the value of the `Left` button
  45977. */
  45978. set buttonLB(value: number);
  45979. /**
  45980. * Gets the value of the `Right` button
  45981. */
  45982. get buttonRB(): number;
  45983. /**
  45984. * Sets the value of the `Right` button
  45985. */
  45986. set buttonRB(value: number);
  45987. /**
  45988. * Gets the value of the Left joystick
  45989. */
  45990. get buttonLeftStick(): number;
  45991. /**
  45992. * Sets the value of the Left joystick
  45993. */
  45994. set buttonLeftStick(value: number);
  45995. /**
  45996. * Gets the value of the Right joystick
  45997. */
  45998. get buttonRightStick(): number;
  45999. /**
  46000. * Sets the value of the Right joystick
  46001. */
  46002. set buttonRightStick(value: number);
  46003. /**
  46004. * Gets the value of D-pad up
  46005. */
  46006. get dPadUp(): number;
  46007. /**
  46008. * Sets the value of D-pad up
  46009. */
  46010. set dPadUp(value: number);
  46011. /**
  46012. * Gets the value of D-pad down
  46013. */
  46014. get dPadDown(): number;
  46015. /**
  46016. * Sets the value of D-pad down
  46017. */
  46018. set dPadDown(value: number);
  46019. /**
  46020. * Gets the value of D-pad left
  46021. */
  46022. get dPadLeft(): number;
  46023. /**
  46024. * Sets the value of D-pad left
  46025. */
  46026. set dPadLeft(value: number);
  46027. /**
  46028. * Gets the value of D-pad right
  46029. */
  46030. get dPadRight(): number;
  46031. /**
  46032. * Sets the value of D-pad right
  46033. */
  46034. set dPadRight(value: number);
  46035. /**
  46036. * Force the gamepad to synchronize with device values
  46037. */
  46038. update(): void;
  46039. /**
  46040. * Disposes the gamepad
  46041. */
  46042. dispose(): void;
  46043. }
  46044. }
  46045. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46046. import { Observable } from "babylonjs/Misc/observable";
  46047. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46048. /**
  46049. * Defines supported buttons for DualShock compatible gamepads
  46050. */
  46051. export enum DualShockButton {
  46052. /** Cross */
  46053. Cross = 0,
  46054. /** Circle */
  46055. Circle = 1,
  46056. /** Square */
  46057. Square = 2,
  46058. /** Triangle */
  46059. Triangle = 3,
  46060. /** L1 */
  46061. L1 = 4,
  46062. /** R1 */
  46063. R1 = 5,
  46064. /** Share */
  46065. Share = 8,
  46066. /** Options */
  46067. Options = 9,
  46068. /** Left stick */
  46069. LeftStick = 10,
  46070. /** Right stick */
  46071. RightStick = 11
  46072. }
  46073. /** Defines values for DualShock DPad */
  46074. export enum DualShockDpad {
  46075. /** Up */
  46076. Up = 12,
  46077. /** Down */
  46078. Down = 13,
  46079. /** Left */
  46080. Left = 14,
  46081. /** Right */
  46082. Right = 15
  46083. }
  46084. /**
  46085. * Defines a DualShock gamepad
  46086. */
  46087. export class DualShockPad extends Gamepad {
  46088. private _leftTrigger;
  46089. private _rightTrigger;
  46090. private _onlefttriggerchanged;
  46091. private _onrighttriggerchanged;
  46092. private _onbuttondown;
  46093. private _onbuttonup;
  46094. private _ondpaddown;
  46095. private _ondpadup;
  46096. /** Observable raised when a button is pressed */
  46097. onButtonDownObservable: Observable<DualShockButton>;
  46098. /** Observable raised when a button is released */
  46099. onButtonUpObservable: Observable<DualShockButton>;
  46100. /** Observable raised when a pad is pressed */
  46101. onPadDownObservable: Observable<DualShockDpad>;
  46102. /** Observable raised when a pad is released */
  46103. onPadUpObservable: Observable<DualShockDpad>;
  46104. private _buttonCross;
  46105. private _buttonCircle;
  46106. private _buttonSquare;
  46107. private _buttonTriangle;
  46108. private _buttonShare;
  46109. private _buttonOptions;
  46110. private _buttonL1;
  46111. private _buttonR1;
  46112. private _buttonLeftStick;
  46113. private _buttonRightStick;
  46114. private _dPadUp;
  46115. private _dPadDown;
  46116. private _dPadLeft;
  46117. private _dPadRight;
  46118. /**
  46119. * Creates a new DualShock gamepad object
  46120. * @param id defines the id of this gamepad
  46121. * @param index defines its index
  46122. * @param gamepad defines the internal HTML gamepad object
  46123. */
  46124. constructor(id: string, index: number, gamepad: any);
  46125. /**
  46126. * Defines the callback to call when left trigger is pressed
  46127. * @param callback defines the callback to use
  46128. */
  46129. onlefttriggerchanged(callback: (value: number) => void): void;
  46130. /**
  46131. * Defines the callback to call when right trigger is pressed
  46132. * @param callback defines the callback to use
  46133. */
  46134. onrighttriggerchanged(callback: (value: number) => void): void;
  46135. /**
  46136. * Gets the left trigger value
  46137. */
  46138. get leftTrigger(): number;
  46139. /**
  46140. * Sets the left trigger value
  46141. */
  46142. set leftTrigger(newValue: number);
  46143. /**
  46144. * Gets the right trigger value
  46145. */
  46146. get rightTrigger(): number;
  46147. /**
  46148. * Sets the right trigger value
  46149. */
  46150. set rightTrigger(newValue: number);
  46151. /**
  46152. * Defines the callback to call when a button is pressed
  46153. * @param callback defines the callback to use
  46154. */
  46155. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46156. /**
  46157. * Defines the callback to call when a button is released
  46158. * @param callback defines the callback to use
  46159. */
  46160. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46161. /**
  46162. * Defines the callback to call when a pad is pressed
  46163. * @param callback defines the callback to use
  46164. */
  46165. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46166. /**
  46167. * Defines the callback to call when a pad is released
  46168. * @param callback defines the callback to use
  46169. */
  46170. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46171. private _setButtonValue;
  46172. private _setDPadValue;
  46173. /**
  46174. * Gets the value of the `Cross` button
  46175. */
  46176. get buttonCross(): number;
  46177. /**
  46178. * Sets the value of the `Cross` button
  46179. */
  46180. set buttonCross(value: number);
  46181. /**
  46182. * Gets the value of the `Circle` button
  46183. */
  46184. get buttonCircle(): number;
  46185. /**
  46186. * Sets the value of the `Circle` button
  46187. */
  46188. set buttonCircle(value: number);
  46189. /**
  46190. * Gets the value of the `Square` button
  46191. */
  46192. get buttonSquare(): number;
  46193. /**
  46194. * Sets the value of the `Square` button
  46195. */
  46196. set buttonSquare(value: number);
  46197. /**
  46198. * Gets the value of the `Triangle` button
  46199. */
  46200. get buttonTriangle(): number;
  46201. /**
  46202. * Sets the value of the `Triangle` button
  46203. */
  46204. set buttonTriangle(value: number);
  46205. /**
  46206. * Gets the value of the `Options` button
  46207. */
  46208. get buttonOptions(): number;
  46209. /**
  46210. * Sets the value of the `Options` button
  46211. */
  46212. set buttonOptions(value: number);
  46213. /**
  46214. * Gets the value of the `Share` button
  46215. */
  46216. get buttonShare(): number;
  46217. /**
  46218. * Sets the value of the `Share` button
  46219. */
  46220. set buttonShare(value: number);
  46221. /**
  46222. * Gets the value of the `L1` button
  46223. */
  46224. get buttonL1(): number;
  46225. /**
  46226. * Sets the value of the `L1` button
  46227. */
  46228. set buttonL1(value: number);
  46229. /**
  46230. * Gets the value of the `R1` button
  46231. */
  46232. get buttonR1(): number;
  46233. /**
  46234. * Sets the value of the `R1` button
  46235. */
  46236. set buttonR1(value: number);
  46237. /**
  46238. * Gets the value of the Left joystick
  46239. */
  46240. get buttonLeftStick(): number;
  46241. /**
  46242. * Sets the value of the Left joystick
  46243. */
  46244. set buttonLeftStick(value: number);
  46245. /**
  46246. * Gets the value of the Right joystick
  46247. */
  46248. get buttonRightStick(): number;
  46249. /**
  46250. * Sets the value of the Right joystick
  46251. */
  46252. set buttonRightStick(value: number);
  46253. /**
  46254. * Gets the value of D-pad up
  46255. */
  46256. get dPadUp(): number;
  46257. /**
  46258. * Sets the value of D-pad up
  46259. */
  46260. set dPadUp(value: number);
  46261. /**
  46262. * Gets the value of D-pad down
  46263. */
  46264. get dPadDown(): number;
  46265. /**
  46266. * Sets the value of D-pad down
  46267. */
  46268. set dPadDown(value: number);
  46269. /**
  46270. * Gets the value of D-pad left
  46271. */
  46272. get dPadLeft(): number;
  46273. /**
  46274. * Sets the value of D-pad left
  46275. */
  46276. set dPadLeft(value: number);
  46277. /**
  46278. * Gets the value of D-pad right
  46279. */
  46280. get dPadRight(): number;
  46281. /**
  46282. * Sets the value of D-pad right
  46283. */
  46284. set dPadRight(value: number);
  46285. /**
  46286. * Force the gamepad to synchronize with device values
  46287. */
  46288. update(): void;
  46289. /**
  46290. * Disposes the gamepad
  46291. */
  46292. dispose(): void;
  46293. }
  46294. }
  46295. declare module "babylonjs/Gamepads/gamepadManager" {
  46296. import { Observable } from "babylonjs/Misc/observable";
  46297. import { Nullable } from "babylonjs/types";
  46298. import { Scene } from "babylonjs/scene";
  46299. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46300. /**
  46301. * Manager for handling gamepads
  46302. */
  46303. export class GamepadManager {
  46304. private _scene?;
  46305. private _babylonGamepads;
  46306. private _oneGamepadConnected;
  46307. /** @hidden */
  46308. _isMonitoring: boolean;
  46309. private _gamepadEventSupported;
  46310. private _gamepadSupport?;
  46311. /**
  46312. * observable to be triggered when the gamepad controller has been connected
  46313. */
  46314. onGamepadConnectedObservable: Observable<Gamepad>;
  46315. /**
  46316. * observable to be triggered when the gamepad controller has been disconnected
  46317. */
  46318. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46319. private _onGamepadConnectedEvent;
  46320. private _onGamepadDisconnectedEvent;
  46321. /**
  46322. * Initializes the gamepad manager
  46323. * @param _scene BabylonJS scene
  46324. */
  46325. constructor(_scene?: Scene | undefined);
  46326. /**
  46327. * The gamepads in the game pad manager
  46328. */
  46329. get gamepads(): Gamepad[];
  46330. /**
  46331. * Get the gamepad controllers based on type
  46332. * @param type The type of gamepad controller
  46333. * @returns Nullable gamepad
  46334. */
  46335. getGamepadByType(type?: number): Nullable<Gamepad>;
  46336. /**
  46337. * Disposes the gamepad manager
  46338. */
  46339. dispose(): void;
  46340. private _addNewGamepad;
  46341. private _startMonitoringGamepads;
  46342. private _stopMonitoringGamepads;
  46343. /** @hidden */
  46344. _checkGamepadsStatus(): void;
  46345. private _updateGamepadObjects;
  46346. }
  46347. }
  46348. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46349. import { Nullable } from "babylonjs/types";
  46350. import { Scene } from "babylonjs/scene";
  46351. import { ISceneComponent } from "babylonjs/sceneComponent";
  46352. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46353. module "babylonjs/scene" {
  46354. interface Scene {
  46355. /** @hidden */
  46356. _gamepadManager: Nullable<GamepadManager>;
  46357. /**
  46358. * Gets the gamepad manager associated with the scene
  46359. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  46360. */
  46361. gamepadManager: GamepadManager;
  46362. }
  46363. }
  46364. module "babylonjs/Cameras/freeCameraInputsManager" {
  46365. /**
  46366. * Interface representing a free camera inputs manager
  46367. */
  46368. interface FreeCameraInputsManager {
  46369. /**
  46370. * Adds gamepad input support to the FreeCameraInputsManager.
  46371. * @returns the FreeCameraInputsManager
  46372. */
  46373. addGamepad(): FreeCameraInputsManager;
  46374. }
  46375. }
  46376. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46377. /**
  46378. * Interface representing an arc rotate camera inputs manager
  46379. */
  46380. interface ArcRotateCameraInputsManager {
  46381. /**
  46382. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46383. * @returns the camera inputs manager
  46384. */
  46385. addGamepad(): ArcRotateCameraInputsManager;
  46386. }
  46387. }
  46388. /**
  46389. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46390. */
  46391. export class GamepadSystemSceneComponent implements ISceneComponent {
  46392. /**
  46393. * The component name helpfull to identify the component in the list of scene components.
  46394. */
  46395. readonly name: string;
  46396. /**
  46397. * The scene the component belongs to.
  46398. */
  46399. scene: Scene;
  46400. /**
  46401. * Creates a new instance of the component for the given scene
  46402. * @param scene Defines the scene to register the component in
  46403. */
  46404. constructor(scene: Scene);
  46405. /**
  46406. * Registers the component in a given scene
  46407. */
  46408. register(): void;
  46409. /**
  46410. * Rebuilds the elements related to this component in case of
  46411. * context lost for instance.
  46412. */
  46413. rebuild(): void;
  46414. /**
  46415. * Disposes the component and the associated ressources
  46416. */
  46417. dispose(): void;
  46418. private _beforeCameraUpdate;
  46419. }
  46420. }
  46421. declare module "babylonjs/Cameras/universalCamera" {
  46422. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46423. import { Scene } from "babylonjs/scene";
  46424. import { Vector3 } from "babylonjs/Maths/math.vector";
  46425. import "babylonjs/Gamepads/gamepadSceneComponent";
  46426. /**
  46427. * 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,
  46428. * which still works and will still be found in many Playgrounds.
  46429. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46430. */
  46431. export class UniversalCamera extends TouchCamera {
  46432. /**
  46433. * Defines the gamepad rotation sensiblity.
  46434. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46435. */
  46436. get gamepadAngularSensibility(): number;
  46437. set gamepadAngularSensibility(value: number);
  46438. /**
  46439. * Defines the gamepad move sensiblity.
  46440. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46441. */
  46442. get gamepadMoveSensibility(): number;
  46443. set gamepadMoveSensibility(value: number);
  46444. /**
  46445. * 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,
  46446. * which still works and will still be found in many Playgrounds.
  46447. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46448. * @param name Define the name of the camera in the scene
  46449. * @param position Define the start position of the camera in the scene
  46450. * @param scene Define the scene the camera belongs to
  46451. */
  46452. constructor(name: string, position: Vector3, scene: Scene);
  46453. /**
  46454. * Gets the current object class name.
  46455. * @return the class name
  46456. */
  46457. getClassName(): string;
  46458. }
  46459. }
  46460. declare module "babylonjs/Cameras/gamepadCamera" {
  46461. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46462. import { Scene } from "babylonjs/scene";
  46463. import { Vector3 } from "babylonjs/Maths/math.vector";
  46464. /**
  46465. * This represents a FPS type of camera. This is only here for back compat purpose.
  46466. * Please use the UniversalCamera instead as both are identical.
  46467. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46468. */
  46469. export class GamepadCamera extends UniversalCamera {
  46470. /**
  46471. * Instantiates a new Gamepad Camera
  46472. * This represents a FPS type of camera. This is only here for back compat purpose.
  46473. * Please use the UniversalCamera instead as both are identical.
  46474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  46475. * @param name Define the name of the camera in the scene
  46476. * @param position Define the start position of the camera in the scene
  46477. * @param scene Define the scene the camera belongs to
  46478. */
  46479. constructor(name: string, position: Vector3, scene: Scene);
  46480. /**
  46481. * Gets the current object class name.
  46482. * @return the class name
  46483. */
  46484. getClassName(): string;
  46485. }
  46486. }
  46487. declare module "babylonjs/Shaders/pass.fragment" {
  46488. /** @hidden */
  46489. export var passPixelShader: {
  46490. name: string;
  46491. shader: string;
  46492. };
  46493. }
  46494. declare module "babylonjs/Shaders/passCube.fragment" {
  46495. /** @hidden */
  46496. export var passCubePixelShader: {
  46497. name: string;
  46498. shader: string;
  46499. };
  46500. }
  46501. declare module "babylonjs/PostProcesses/passPostProcess" {
  46502. import { Nullable } from "babylonjs/types";
  46503. import { Camera } from "babylonjs/Cameras/camera";
  46504. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46505. import { Engine } from "babylonjs/Engines/engine";
  46506. import "babylonjs/Shaders/pass.fragment";
  46507. import "babylonjs/Shaders/passCube.fragment";
  46508. /**
  46509. * PassPostProcess which produces an output the same as it's input
  46510. */
  46511. export class PassPostProcess extends PostProcess {
  46512. /**
  46513. * Creates the PassPostProcess
  46514. * @param name The name of the effect.
  46515. * @param options The required width/height ratio to downsize to before computing the render pass.
  46516. * @param camera The camera to apply the render pass to.
  46517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46518. * @param engine The engine which the post process will be applied. (default: current engine)
  46519. * @param reusable If the post process can be reused on the same frame. (default: false)
  46520. * @param textureType The type of texture to be used when performing the post processing.
  46521. * @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)
  46522. */
  46523. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46524. }
  46525. /**
  46526. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46527. */
  46528. export class PassCubePostProcess extends PostProcess {
  46529. private _face;
  46530. /**
  46531. * Gets or sets the cube face to display.
  46532. * * 0 is +X
  46533. * * 1 is -X
  46534. * * 2 is +Y
  46535. * * 3 is -Y
  46536. * * 4 is +Z
  46537. * * 5 is -Z
  46538. */
  46539. get face(): number;
  46540. set face(value: number);
  46541. /**
  46542. * Creates the PassCubePostProcess
  46543. * @param name The name of the effect.
  46544. * @param options The required width/height ratio to downsize to before computing the render pass.
  46545. * @param camera The camera to apply the render pass to.
  46546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46547. * @param engine The engine which the post process will be applied. (default: current engine)
  46548. * @param reusable If the post process can be reused on the same frame. (default: false)
  46549. * @param textureType The type of texture to be used when performing the post processing.
  46550. * @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)
  46551. */
  46552. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46553. }
  46554. }
  46555. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46556. /** @hidden */
  46557. export var anaglyphPixelShader: {
  46558. name: string;
  46559. shader: string;
  46560. };
  46561. }
  46562. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46563. import { Engine } from "babylonjs/Engines/engine";
  46564. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46565. import { Camera } from "babylonjs/Cameras/camera";
  46566. import "babylonjs/Shaders/anaglyph.fragment";
  46567. /**
  46568. * Postprocess used to generate anaglyphic rendering
  46569. */
  46570. export class AnaglyphPostProcess extends PostProcess {
  46571. private _passedProcess;
  46572. /**
  46573. * Creates a new AnaglyphPostProcess
  46574. * @param name defines postprocess name
  46575. * @param options defines creation options or target ratio scale
  46576. * @param rigCameras defines cameras using this postprocess
  46577. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46578. * @param engine defines hosting engine
  46579. * @param reusable defines if the postprocess will be reused multiple times per frame
  46580. */
  46581. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46582. }
  46583. }
  46584. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46585. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46586. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46587. import { Scene } from "babylonjs/scene";
  46588. import { Vector3 } from "babylonjs/Maths/math.vector";
  46589. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46590. /**
  46591. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46592. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46593. */
  46594. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46595. /**
  46596. * Creates a new AnaglyphArcRotateCamera
  46597. * @param name defines camera name
  46598. * @param alpha defines alpha angle (in radians)
  46599. * @param beta defines beta angle (in radians)
  46600. * @param radius defines radius
  46601. * @param target defines camera target
  46602. * @param interaxialDistance defines distance between each color axis
  46603. * @param scene defines the hosting scene
  46604. */
  46605. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46606. /**
  46607. * Gets camera class name
  46608. * @returns AnaglyphArcRotateCamera
  46609. */
  46610. getClassName(): string;
  46611. }
  46612. }
  46613. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46614. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46615. import { Scene } from "babylonjs/scene";
  46616. import { Vector3 } from "babylonjs/Maths/math.vector";
  46617. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46618. /**
  46619. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46620. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46621. */
  46622. export class AnaglyphFreeCamera extends FreeCamera {
  46623. /**
  46624. * Creates a new AnaglyphFreeCamera
  46625. * @param name defines camera name
  46626. * @param position defines initial position
  46627. * @param interaxialDistance defines distance between each color axis
  46628. * @param scene defines the hosting scene
  46629. */
  46630. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46631. /**
  46632. * Gets camera class name
  46633. * @returns AnaglyphFreeCamera
  46634. */
  46635. getClassName(): string;
  46636. }
  46637. }
  46638. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46639. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46640. import { Scene } from "babylonjs/scene";
  46641. import { Vector3 } from "babylonjs/Maths/math.vector";
  46642. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46643. /**
  46644. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46645. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46646. */
  46647. export class AnaglyphGamepadCamera extends GamepadCamera {
  46648. /**
  46649. * Creates a new AnaglyphGamepadCamera
  46650. * @param name defines camera name
  46651. * @param position defines initial position
  46652. * @param interaxialDistance defines distance between each color axis
  46653. * @param scene defines the hosting scene
  46654. */
  46655. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46656. /**
  46657. * Gets camera class name
  46658. * @returns AnaglyphGamepadCamera
  46659. */
  46660. getClassName(): string;
  46661. }
  46662. }
  46663. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46664. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46665. import { Scene } from "babylonjs/scene";
  46666. import { Vector3 } from "babylonjs/Maths/math.vector";
  46667. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46668. /**
  46669. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46670. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46671. */
  46672. export class AnaglyphUniversalCamera extends UniversalCamera {
  46673. /**
  46674. * Creates a new AnaglyphUniversalCamera
  46675. * @param name defines camera name
  46676. * @param position defines initial position
  46677. * @param interaxialDistance defines distance between each color axis
  46678. * @param scene defines the hosting scene
  46679. */
  46680. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46681. /**
  46682. * Gets camera class name
  46683. * @returns AnaglyphUniversalCamera
  46684. */
  46685. getClassName(): string;
  46686. }
  46687. }
  46688. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46689. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46690. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46691. import { Scene } from "babylonjs/scene";
  46692. import { Vector3 } from "babylonjs/Maths/math.vector";
  46693. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46694. /**
  46695. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46696. * @see http://doc.babylonjs.com/features/cameras
  46697. */
  46698. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46699. /**
  46700. * Creates a new StereoscopicArcRotateCamera
  46701. * @param name defines camera name
  46702. * @param alpha defines alpha angle (in radians)
  46703. * @param beta defines beta angle (in radians)
  46704. * @param radius defines radius
  46705. * @param target defines camera target
  46706. * @param interaxialDistance defines distance between each color axis
  46707. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46708. * @param scene defines the hosting scene
  46709. */
  46710. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46711. /**
  46712. * Gets camera class name
  46713. * @returns StereoscopicArcRotateCamera
  46714. */
  46715. getClassName(): string;
  46716. }
  46717. }
  46718. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46719. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46720. import { Scene } from "babylonjs/scene";
  46721. import { Vector3 } from "babylonjs/Maths/math.vector";
  46722. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46723. /**
  46724. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46725. * @see http://doc.babylonjs.com/features/cameras
  46726. */
  46727. export class StereoscopicFreeCamera extends FreeCamera {
  46728. /**
  46729. * Creates a new StereoscopicFreeCamera
  46730. * @param name defines camera name
  46731. * @param position defines initial position
  46732. * @param interaxialDistance defines distance between each color axis
  46733. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46734. * @param scene defines the hosting scene
  46735. */
  46736. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46737. /**
  46738. * Gets camera class name
  46739. * @returns StereoscopicFreeCamera
  46740. */
  46741. getClassName(): string;
  46742. }
  46743. }
  46744. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46745. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46746. import { Scene } from "babylonjs/scene";
  46747. import { Vector3 } from "babylonjs/Maths/math.vector";
  46748. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46749. /**
  46750. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46751. * @see http://doc.babylonjs.com/features/cameras
  46752. */
  46753. export class StereoscopicGamepadCamera extends GamepadCamera {
  46754. /**
  46755. * Creates a new StereoscopicGamepadCamera
  46756. * @param name defines camera name
  46757. * @param position defines initial position
  46758. * @param interaxialDistance defines distance between each color axis
  46759. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46760. * @param scene defines the hosting scene
  46761. */
  46762. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46763. /**
  46764. * Gets camera class name
  46765. * @returns StereoscopicGamepadCamera
  46766. */
  46767. getClassName(): string;
  46768. }
  46769. }
  46770. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  46771. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46772. import { Scene } from "babylonjs/scene";
  46773. import { Vector3 } from "babylonjs/Maths/math.vector";
  46774. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46775. /**
  46776. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46777. * @see http://doc.babylonjs.com/features/cameras
  46778. */
  46779. export class StereoscopicUniversalCamera extends UniversalCamera {
  46780. /**
  46781. * Creates a new StereoscopicUniversalCamera
  46782. * @param name defines camera name
  46783. * @param position defines initial position
  46784. * @param interaxialDistance defines distance between each color axis
  46785. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46786. * @param scene defines the hosting scene
  46787. */
  46788. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46789. /**
  46790. * Gets camera class name
  46791. * @returns StereoscopicUniversalCamera
  46792. */
  46793. getClassName(): string;
  46794. }
  46795. }
  46796. declare module "babylonjs/Cameras/Stereoscopic/index" {
  46797. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  46798. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  46799. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  46800. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  46801. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  46802. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  46803. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  46804. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  46805. }
  46806. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  46807. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46808. import { Scene } from "babylonjs/scene";
  46809. import { Vector3 } from "babylonjs/Maths/math.vector";
  46810. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  46811. /**
  46812. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46813. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46814. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46815. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46816. */
  46817. export class VirtualJoysticksCamera extends FreeCamera {
  46818. /**
  46819. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46820. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46821. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46822. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46823. * @param name Define the name of the camera in the scene
  46824. * @param position Define the start position of the camera in the scene
  46825. * @param scene Define the scene the camera belongs to
  46826. */
  46827. constructor(name: string, position: Vector3, scene: Scene);
  46828. /**
  46829. * Gets the current object class name.
  46830. * @return the class name
  46831. */
  46832. getClassName(): string;
  46833. }
  46834. }
  46835. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  46836. import { Matrix } from "babylonjs/Maths/math.vector";
  46837. /**
  46838. * This represents all the required metrics to create a VR camera.
  46839. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46840. */
  46841. export class VRCameraMetrics {
  46842. /**
  46843. * Define the horizontal resolution off the screen.
  46844. */
  46845. hResolution: number;
  46846. /**
  46847. * Define the vertical resolution off the screen.
  46848. */
  46849. vResolution: number;
  46850. /**
  46851. * Define the horizontal screen size.
  46852. */
  46853. hScreenSize: number;
  46854. /**
  46855. * Define the vertical screen size.
  46856. */
  46857. vScreenSize: number;
  46858. /**
  46859. * Define the vertical screen center position.
  46860. */
  46861. vScreenCenter: number;
  46862. /**
  46863. * Define the distance of the eyes to the screen.
  46864. */
  46865. eyeToScreenDistance: number;
  46866. /**
  46867. * Define the distance between both lenses
  46868. */
  46869. lensSeparationDistance: number;
  46870. /**
  46871. * Define the distance between both viewer's eyes.
  46872. */
  46873. interpupillaryDistance: number;
  46874. /**
  46875. * Define the distortion factor of the VR postprocess.
  46876. * Please, touch with care.
  46877. */
  46878. distortionK: number[];
  46879. /**
  46880. * Define the chromatic aberration correction factors for the VR post process.
  46881. */
  46882. chromaAbCorrection: number[];
  46883. /**
  46884. * Define the scale factor of the post process.
  46885. * The smaller the better but the slower.
  46886. */
  46887. postProcessScaleFactor: number;
  46888. /**
  46889. * Define an offset for the lens center.
  46890. */
  46891. lensCenterOffset: number;
  46892. /**
  46893. * Define if the current vr camera should compensate the distortion of the lense or not.
  46894. */
  46895. compensateDistortion: boolean;
  46896. /**
  46897. * Defines if multiview should be enabled when rendering (Default: false)
  46898. */
  46899. multiviewEnabled: boolean;
  46900. /**
  46901. * Gets the rendering aspect ratio based on the provided resolutions.
  46902. */
  46903. get aspectRatio(): number;
  46904. /**
  46905. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46906. */
  46907. get aspectRatioFov(): number;
  46908. /**
  46909. * @hidden
  46910. */
  46911. get leftHMatrix(): Matrix;
  46912. /**
  46913. * @hidden
  46914. */
  46915. get rightHMatrix(): Matrix;
  46916. /**
  46917. * @hidden
  46918. */
  46919. get leftPreViewMatrix(): Matrix;
  46920. /**
  46921. * @hidden
  46922. */
  46923. get rightPreViewMatrix(): Matrix;
  46924. /**
  46925. * Get the default VRMetrics based on the most generic setup.
  46926. * @returns the default vr metrics
  46927. */
  46928. static GetDefault(): VRCameraMetrics;
  46929. }
  46930. }
  46931. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  46932. /** @hidden */
  46933. export var vrDistortionCorrectionPixelShader: {
  46934. name: string;
  46935. shader: string;
  46936. };
  46937. }
  46938. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  46939. import { Camera } from "babylonjs/Cameras/camera";
  46940. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46941. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  46942. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  46943. /**
  46944. * VRDistortionCorrectionPostProcess used for mobile VR
  46945. */
  46946. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46947. private _isRightEye;
  46948. private _distortionFactors;
  46949. private _postProcessScaleFactor;
  46950. private _lensCenterOffset;
  46951. private _scaleIn;
  46952. private _scaleFactor;
  46953. private _lensCenter;
  46954. /**
  46955. * Initializes the VRDistortionCorrectionPostProcess
  46956. * @param name The name of the effect.
  46957. * @param camera The camera to apply the render pass to.
  46958. * @param isRightEye If this is for the right eye distortion
  46959. * @param vrMetrics All the required metrics for the VR camera
  46960. */
  46961. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46962. }
  46963. }
  46964. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  46965. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  46966. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46967. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46968. import { Scene } from "babylonjs/scene";
  46969. import { Vector3 } from "babylonjs/Maths/math.vector";
  46970. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  46971. import "babylonjs/Cameras/RigModes/vrRigMode";
  46972. /**
  46973. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46974. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46975. */
  46976. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46977. /**
  46978. * Creates a new VRDeviceOrientationArcRotateCamera
  46979. * @param name defines camera name
  46980. * @param alpha defines the camera rotation along the logitudinal axis
  46981. * @param beta defines the camera rotation along the latitudinal axis
  46982. * @param radius defines the camera distance from its target
  46983. * @param target defines the camera target
  46984. * @param scene defines the scene the camera belongs to
  46985. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46986. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46987. */
  46988. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46989. /**
  46990. * Gets camera class name
  46991. * @returns VRDeviceOrientationArcRotateCamera
  46992. */
  46993. getClassName(): string;
  46994. }
  46995. }
  46996. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  46997. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46998. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46999. import { Scene } from "babylonjs/scene";
  47000. import { Vector3 } from "babylonjs/Maths/math.vector";
  47001. import "babylonjs/Cameras/RigModes/vrRigMode";
  47002. /**
  47003. * Camera used to simulate VR rendering (based on FreeCamera)
  47004. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47005. */
  47006. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47007. /**
  47008. * Creates a new VRDeviceOrientationFreeCamera
  47009. * @param name defines camera name
  47010. * @param position defines the start position of the camera
  47011. * @param scene defines the scene the camera belongs to
  47012. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47013. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47014. */
  47015. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47016. /**
  47017. * Gets camera class name
  47018. * @returns VRDeviceOrientationFreeCamera
  47019. */
  47020. getClassName(): string;
  47021. }
  47022. }
  47023. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47024. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47025. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47026. import { Scene } from "babylonjs/scene";
  47027. import { Vector3 } from "babylonjs/Maths/math.vector";
  47028. import "babylonjs/Gamepads/gamepadSceneComponent";
  47029. /**
  47030. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47031. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47032. */
  47033. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47034. /**
  47035. * Creates a new VRDeviceOrientationGamepadCamera
  47036. * @param name defines camera name
  47037. * @param position defines the start position of the camera
  47038. * @param scene defines the scene the camera belongs to
  47039. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47040. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47041. */
  47042. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47043. /**
  47044. * Gets camera class name
  47045. * @returns VRDeviceOrientationGamepadCamera
  47046. */
  47047. getClassName(): string;
  47048. }
  47049. }
  47050. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  47051. import { Scene } from "babylonjs/scene";
  47052. import { Texture } from "babylonjs/Materials/Textures/texture";
  47053. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47054. /**
  47055. * A class extending Texture allowing drawing on a texture
  47056. * @see http://doc.babylonjs.com/how_to/dynamictexture
  47057. */
  47058. export class DynamicTexture extends Texture {
  47059. private _generateMipMaps;
  47060. private _canvas;
  47061. private _context;
  47062. /**
  47063. * Creates a DynamicTexture
  47064. * @param name defines the name of the texture
  47065. * @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
  47066. * @param scene defines the scene where you want the texture
  47067. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  47068. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  47069. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  47070. */
  47071. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  47072. /**
  47073. * Get the current class name of the texture useful for serialization or dynamic coding.
  47074. * @returns "DynamicTexture"
  47075. */
  47076. getClassName(): string;
  47077. /**
  47078. * Gets the current state of canRescale
  47079. */
  47080. get canRescale(): boolean;
  47081. private _recreate;
  47082. /**
  47083. * Scales the texture
  47084. * @param ratio the scale factor to apply to both width and height
  47085. */
  47086. scale(ratio: number): void;
  47087. /**
  47088. * Resizes the texture
  47089. * @param width the new width
  47090. * @param height the new height
  47091. */
  47092. scaleTo(width: number, height: number): void;
  47093. /**
  47094. * Gets the context of the canvas used by the texture
  47095. * @returns the canvas context of the dynamic texture
  47096. */
  47097. getContext(): CanvasRenderingContext2D;
  47098. /**
  47099. * Clears the texture
  47100. */
  47101. clear(): void;
  47102. /**
  47103. * Updates the texture
  47104. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47105. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47106. */
  47107. update(invertY?: boolean, premulAlpha?: boolean): void;
  47108. /**
  47109. * Draws text onto the texture
  47110. * @param text defines the text to be drawn
  47111. * @param x defines the placement of the text from the left
  47112. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47113. * @param font defines the font to be used with font-style, font-size, font-name
  47114. * @param color defines the color used for the text
  47115. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47116. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47117. * @param update defines whether texture is immediately update (default is true)
  47118. */
  47119. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  47120. /**
  47121. * Clones the texture
  47122. * @returns the clone of the texture.
  47123. */
  47124. clone(): DynamicTexture;
  47125. /**
  47126. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47127. * @returns a serialized dynamic texture object
  47128. */
  47129. serialize(): any;
  47130. private _IsCanvasElement;
  47131. /** @hidden */
  47132. _rebuild(): void;
  47133. }
  47134. }
  47135. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47136. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47137. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47138. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47139. /** @hidden */
  47140. export var imageProcessingPixelShader: {
  47141. name: string;
  47142. shader: string;
  47143. };
  47144. }
  47145. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47146. import { Nullable } from "babylonjs/types";
  47147. import { Color4 } from "babylonjs/Maths/math.color";
  47148. import { Camera } from "babylonjs/Cameras/camera";
  47149. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47150. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47151. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47152. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47153. import { Engine } from "babylonjs/Engines/engine";
  47154. import "babylonjs/Shaders/imageProcessing.fragment";
  47155. import "babylonjs/Shaders/postprocess.vertex";
  47156. /**
  47157. * ImageProcessingPostProcess
  47158. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47159. */
  47160. export class ImageProcessingPostProcess extends PostProcess {
  47161. /**
  47162. * Default configuration related to image processing available in the PBR Material.
  47163. */
  47164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47165. /**
  47166. * Gets the image processing configuration used either in this material.
  47167. */
  47168. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47169. /**
  47170. * Sets the Default image processing configuration used either in the this material.
  47171. *
  47172. * If sets to null, the scene one is in use.
  47173. */
  47174. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47175. /**
  47176. * Keep track of the image processing observer to allow dispose and replace.
  47177. */
  47178. private _imageProcessingObserver;
  47179. /**
  47180. * Attaches a new image processing configuration to the PBR Material.
  47181. * @param configuration
  47182. */
  47183. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47184. /**
  47185. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47186. */
  47187. get colorCurves(): Nullable<ColorCurves>;
  47188. /**
  47189. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47190. */
  47191. set colorCurves(value: Nullable<ColorCurves>);
  47192. /**
  47193. * Gets wether the color curves effect is enabled.
  47194. */
  47195. get colorCurvesEnabled(): boolean;
  47196. /**
  47197. * Sets wether the color curves effect is enabled.
  47198. */
  47199. set colorCurvesEnabled(value: boolean);
  47200. /**
  47201. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47202. */
  47203. get colorGradingTexture(): Nullable<BaseTexture>;
  47204. /**
  47205. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47206. */
  47207. set colorGradingTexture(value: Nullable<BaseTexture>);
  47208. /**
  47209. * Gets wether the color grading effect is enabled.
  47210. */
  47211. get colorGradingEnabled(): boolean;
  47212. /**
  47213. * Gets wether the color grading effect is enabled.
  47214. */
  47215. set colorGradingEnabled(value: boolean);
  47216. /**
  47217. * Gets exposure used in the effect.
  47218. */
  47219. get exposure(): number;
  47220. /**
  47221. * Sets exposure used in the effect.
  47222. */
  47223. set exposure(value: number);
  47224. /**
  47225. * Gets wether tonemapping is enabled or not.
  47226. */
  47227. get toneMappingEnabled(): boolean;
  47228. /**
  47229. * Sets wether tonemapping is enabled or not
  47230. */
  47231. set toneMappingEnabled(value: boolean);
  47232. /**
  47233. * Gets the type of tone mapping effect.
  47234. */
  47235. get toneMappingType(): number;
  47236. /**
  47237. * Sets the type of tone mapping effect.
  47238. */
  47239. set toneMappingType(value: number);
  47240. /**
  47241. * Gets contrast used in the effect.
  47242. */
  47243. get contrast(): number;
  47244. /**
  47245. * Sets contrast used in the effect.
  47246. */
  47247. set contrast(value: number);
  47248. /**
  47249. * Gets Vignette stretch size.
  47250. */
  47251. get vignetteStretch(): number;
  47252. /**
  47253. * Sets Vignette stretch size.
  47254. */
  47255. set vignetteStretch(value: number);
  47256. /**
  47257. * Gets Vignette centre X Offset.
  47258. */
  47259. get vignetteCentreX(): number;
  47260. /**
  47261. * Sets Vignette centre X Offset.
  47262. */
  47263. set vignetteCentreX(value: number);
  47264. /**
  47265. * Gets Vignette centre Y Offset.
  47266. */
  47267. get vignetteCentreY(): number;
  47268. /**
  47269. * Sets Vignette centre Y Offset.
  47270. */
  47271. set vignetteCentreY(value: number);
  47272. /**
  47273. * Gets Vignette weight or intensity of the vignette effect.
  47274. */
  47275. get vignetteWeight(): number;
  47276. /**
  47277. * Sets Vignette weight or intensity of the vignette effect.
  47278. */
  47279. set vignetteWeight(value: number);
  47280. /**
  47281. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47282. * if vignetteEnabled is set to true.
  47283. */
  47284. get vignetteColor(): Color4;
  47285. /**
  47286. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47287. * if vignetteEnabled is set to true.
  47288. */
  47289. set vignetteColor(value: Color4);
  47290. /**
  47291. * Gets Camera field of view used by the Vignette effect.
  47292. */
  47293. get vignetteCameraFov(): number;
  47294. /**
  47295. * Sets Camera field of view used by the Vignette effect.
  47296. */
  47297. set vignetteCameraFov(value: number);
  47298. /**
  47299. * Gets the vignette blend mode allowing different kind of effect.
  47300. */
  47301. get vignetteBlendMode(): number;
  47302. /**
  47303. * Sets the vignette blend mode allowing different kind of effect.
  47304. */
  47305. set vignetteBlendMode(value: number);
  47306. /**
  47307. * Gets wether the vignette effect is enabled.
  47308. */
  47309. get vignetteEnabled(): boolean;
  47310. /**
  47311. * Sets wether the vignette effect is enabled.
  47312. */
  47313. set vignetteEnabled(value: boolean);
  47314. private _fromLinearSpace;
  47315. /**
  47316. * Gets wether the input of the processing is in Gamma or Linear Space.
  47317. */
  47318. get fromLinearSpace(): boolean;
  47319. /**
  47320. * Sets wether the input of the processing is in Gamma or Linear Space.
  47321. */
  47322. set fromLinearSpace(value: boolean);
  47323. /**
  47324. * Defines cache preventing GC.
  47325. */
  47326. private _defines;
  47327. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47328. /**
  47329. * "ImageProcessingPostProcess"
  47330. * @returns "ImageProcessingPostProcess"
  47331. */
  47332. getClassName(): string;
  47333. protected _updateParameters(): void;
  47334. dispose(camera?: Camera): void;
  47335. }
  47336. }
  47337. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47338. import { Scene } from "babylonjs/scene";
  47339. import { Color3 } from "babylonjs/Maths/math.color";
  47340. import { Mesh } from "babylonjs/Meshes/mesh";
  47341. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47342. import { Nullable } from "babylonjs/types";
  47343. /**
  47344. * Class containing static functions to help procedurally build meshes
  47345. */
  47346. export class GroundBuilder {
  47347. /**
  47348. * Creates a ground mesh
  47349. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47350. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47352. * @param name defines the name of the mesh
  47353. * @param options defines the options used to create the mesh
  47354. * @param scene defines the hosting scene
  47355. * @returns the ground mesh
  47356. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47357. */
  47358. static CreateGround(name: string, options: {
  47359. width?: number;
  47360. height?: number;
  47361. subdivisions?: number;
  47362. subdivisionsX?: number;
  47363. subdivisionsY?: number;
  47364. updatable?: boolean;
  47365. }, scene: any): Mesh;
  47366. /**
  47367. * Creates a tiled ground mesh
  47368. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47369. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47370. * * 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
  47371. * * 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
  47372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47373. * @param name defines the name of the mesh
  47374. * @param options defines the options used to create the mesh
  47375. * @param scene defines the hosting scene
  47376. * @returns the tiled ground mesh
  47377. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47378. */
  47379. static CreateTiledGround(name: string, options: {
  47380. xmin: number;
  47381. zmin: number;
  47382. xmax: number;
  47383. zmax: number;
  47384. subdivisions?: {
  47385. w: number;
  47386. h: number;
  47387. };
  47388. precision?: {
  47389. w: number;
  47390. h: number;
  47391. };
  47392. updatable?: boolean;
  47393. }, scene?: Nullable<Scene>): Mesh;
  47394. /**
  47395. * Creates a ground mesh from a height map
  47396. * * The parameter `url` sets the URL of the height map image resource.
  47397. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47398. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47399. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47400. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47401. * * 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.
  47402. * * 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).
  47403. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47405. * @param name defines the name of the mesh
  47406. * @param url defines the url to the height map
  47407. * @param options defines the options used to create the mesh
  47408. * @param scene defines the hosting scene
  47409. * @returns the ground mesh
  47410. * @see https://doc.babylonjs.com/babylon101/height_map
  47411. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47412. */
  47413. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47414. width?: number;
  47415. height?: number;
  47416. subdivisions?: number;
  47417. minHeight?: number;
  47418. maxHeight?: number;
  47419. colorFilter?: Color3;
  47420. alphaFilter?: number;
  47421. updatable?: boolean;
  47422. onReady?: (mesh: GroundMesh) => void;
  47423. }, scene?: Nullable<Scene>): GroundMesh;
  47424. }
  47425. }
  47426. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47427. import { Vector4 } from "babylonjs/Maths/math.vector";
  47428. import { Mesh } from "babylonjs/Meshes/mesh";
  47429. /**
  47430. * Class containing static functions to help procedurally build meshes
  47431. */
  47432. export class TorusBuilder {
  47433. /**
  47434. * Creates a torus mesh
  47435. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47436. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47437. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47441. * @param name defines the name of the mesh
  47442. * @param options defines the options used to create the mesh
  47443. * @param scene defines the hosting scene
  47444. * @returns the torus mesh
  47445. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47446. */
  47447. static CreateTorus(name: string, options: {
  47448. diameter?: number;
  47449. thickness?: number;
  47450. tessellation?: number;
  47451. updatable?: boolean;
  47452. sideOrientation?: number;
  47453. frontUVs?: Vector4;
  47454. backUVs?: Vector4;
  47455. }, scene: any): Mesh;
  47456. }
  47457. }
  47458. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47459. import { Vector4 } from "babylonjs/Maths/math.vector";
  47460. import { Color4 } from "babylonjs/Maths/math.color";
  47461. import { Mesh } from "babylonjs/Meshes/mesh";
  47462. /**
  47463. * Class containing static functions to help procedurally build meshes
  47464. */
  47465. export class CylinderBuilder {
  47466. /**
  47467. * Creates a cylinder or a cone mesh
  47468. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47469. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47470. * * 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.
  47471. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47472. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47473. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47474. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47475. * * 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).
  47476. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47477. * * 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).
  47478. * * 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
  47479. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47480. * * 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
  47481. * * 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.
  47482. * * If `enclose` is false, a ring surface is one element.
  47483. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47484. * * 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
  47485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47488. * @param name defines the name of the mesh
  47489. * @param options defines the options used to create the mesh
  47490. * @param scene defines the hosting scene
  47491. * @returns the cylinder mesh
  47492. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47493. */
  47494. static CreateCylinder(name: string, options: {
  47495. height?: number;
  47496. diameterTop?: number;
  47497. diameterBottom?: number;
  47498. diameter?: number;
  47499. tessellation?: number;
  47500. subdivisions?: number;
  47501. arc?: number;
  47502. faceColors?: Color4[];
  47503. faceUV?: Vector4[];
  47504. updatable?: boolean;
  47505. hasRings?: boolean;
  47506. enclose?: boolean;
  47507. cap?: number;
  47508. sideOrientation?: number;
  47509. frontUVs?: Vector4;
  47510. backUVs?: Vector4;
  47511. }, scene: any): Mesh;
  47512. }
  47513. }
  47514. declare module "babylonjs/XR/webXRTypes" {
  47515. import { Nullable } from "babylonjs/types";
  47516. import { IDisposable } from "babylonjs/scene";
  47517. /**
  47518. * States of the webXR experience
  47519. */
  47520. export enum WebXRState {
  47521. /**
  47522. * Transitioning to being in XR mode
  47523. */
  47524. ENTERING_XR = 0,
  47525. /**
  47526. * Transitioning to non XR mode
  47527. */
  47528. EXITING_XR = 1,
  47529. /**
  47530. * In XR mode and presenting
  47531. */
  47532. IN_XR = 2,
  47533. /**
  47534. * Not entered XR mode
  47535. */
  47536. NOT_IN_XR = 3
  47537. }
  47538. /**
  47539. * Abstraction of the XR render target
  47540. */
  47541. export interface WebXRRenderTarget extends IDisposable {
  47542. /**
  47543. * xrpresent context of the canvas which can be used to display/mirror xr content
  47544. */
  47545. canvasContext: WebGLRenderingContext;
  47546. /**
  47547. * xr layer for the canvas
  47548. */
  47549. xrLayer: Nullable<XRWebGLLayer>;
  47550. /**
  47551. * Initializes the xr layer for the session
  47552. * @param xrSession xr session
  47553. * @returns a promise that will resolve once the XR Layer has been created
  47554. */
  47555. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47556. }
  47557. }
  47558. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47559. import { Nullable } from "babylonjs/types";
  47560. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47561. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47562. /**
  47563. * COnfiguration object for WebXR output canvas
  47564. */
  47565. export class WebXRManagedOutputCanvasOptions {
  47566. /**
  47567. * An optional canvas in case you wish to create it yourself and provide it here.
  47568. * If not provided, a new canvas will be created
  47569. */
  47570. canvasElement?: HTMLCanvasElement;
  47571. /**
  47572. * Options for this XR Layer output
  47573. */
  47574. canvasOptions?: XRWebGLLayerOptions;
  47575. /**
  47576. * CSS styling for a newly created canvas (if not provided)
  47577. */
  47578. newCanvasCssStyle?: string;
  47579. /**
  47580. * Get the default values of the configuration object
  47581. * @returns default values of this configuration object
  47582. */
  47583. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47584. }
  47585. /**
  47586. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47587. */
  47588. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47589. private _options;
  47590. private _canvas;
  47591. private _engine;
  47592. /**
  47593. * Rendering context of the canvas which can be used to display/mirror xr content
  47594. */
  47595. canvasContext: WebGLRenderingContext;
  47596. /**
  47597. * xr layer for the canvas
  47598. */
  47599. xrLayer: Nullable<XRWebGLLayer>;
  47600. /**
  47601. * Initializes the canvas to be added/removed upon entering/exiting xr
  47602. * @param _xrSessionManager The XR Session manager
  47603. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47604. */
  47605. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47606. /**
  47607. * Disposes of the object
  47608. */
  47609. dispose(): void;
  47610. /**
  47611. * Initializes the xr layer for the session
  47612. * @param xrSession xr session
  47613. * @returns a promise that will resolve once the XR Layer has been created
  47614. */
  47615. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47616. private _addCanvas;
  47617. private _removeCanvas;
  47618. private _setManagedOutputCanvas;
  47619. }
  47620. }
  47621. declare module "babylonjs/XR/webXRSessionManager" {
  47622. import { Observable } from "babylonjs/Misc/observable";
  47623. import { Nullable } from "babylonjs/types";
  47624. import { IDisposable, Scene } from "babylonjs/scene";
  47625. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47626. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47627. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47628. /**
  47629. * Manages an XRSession to work with Babylon's engine
  47630. * @see https://doc.babylonjs.com/how_to/webxr
  47631. */
  47632. export class WebXRSessionManager implements IDisposable {
  47633. /** The scene which the session should be created for */
  47634. scene: Scene;
  47635. private _referenceSpace;
  47636. private _rttProvider;
  47637. private _sessionEnded;
  47638. private _xrNavigator;
  47639. private baseLayer;
  47640. /**
  47641. * The base reference space from which the session started. good if you want to reset your
  47642. * reference space
  47643. */
  47644. baseReferenceSpace: XRReferenceSpace;
  47645. /**
  47646. * Current XR frame
  47647. */
  47648. currentFrame: Nullable<XRFrame>;
  47649. /** WebXR timestamp updated every frame */
  47650. currentTimestamp: number;
  47651. /**
  47652. * Used just in case of a failure to initialize an immersive session.
  47653. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47654. */
  47655. defaultHeightCompensation: number;
  47656. /**
  47657. * Fires every time a new xrFrame arrives which can be used to update the camera
  47658. */
  47659. onXRFrameObservable: Observable<XRFrame>;
  47660. /**
  47661. * Fires when the reference space changed
  47662. */
  47663. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47664. /**
  47665. * Fires when the xr session is ended either by the device or manually done
  47666. */
  47667. onXRSessionEnded: Observable<any>;
  47668. /**
  47669. * Fires when the xr session is ended either by the device or manually done
  47670. */
  47671. onXRSessionInit: Observable<XRSession>;
  47672. /**
  47673. * Underlying xr session
  47674. */
  47675. session: XRSession;
  47676. /**
  47677. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47678. * or get the offset the player is currently at.
  47679. */
  47680. viewerReferenceSpace: XRReferenceSpace;
  47681. /**
  47682. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47683. * @param scene The scene which the session should be created for
  47684. */
  47685. constructor(
  47686. /** The scene which the session should be created for */
  47687. scene: Scene);
  47688. /**
  47689. * The current reference space used in this session. This reference space can constantly change!
  47690. * It is mainly used to offset the camera's position.
  47691. */
  47692. get referenceSpace(): XRReferenceSpace;
  47693. /**
  47694. * Set a new reference space and triggers the observable
  47695. */
  47696. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47697. /**
  47698. * Disposes of the session manager
  47699. */
  47700. dispose(): void;
  47701. /**
  47702. * Stops the xrSession and restores the render loop
  47703. * @returns Promise which resolves after it exits XR
  47704. */
  47705. exitXRAsync(): Promise<void>;
  47706. /**
  47707. * Gets the correct render target texture to be rendered this frame for this eye
  47708. * @param eye the eye for which to get the render target
  47709. * @returns the render target for the specified eye
  47710. */
  47711. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47712. /**
  47713. * Creates a WebXRRenderTarget object for the XR session
  47714. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47715. * @param options optional options to provide when creating a new render target
  47716. * @returns a WebXR render target to which the session can render
  47717. */
  47718. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47719. /**
  47720. * Initializes the manager
  47721. * After initialization enterXR can be called to start an XR session
  47722. * @returns Promise which resolves after it is initialized
  47723. */
  47724. initializeAsync(): Promise<void>;
  47725. /**
  47726. * Initializes an xr session
  47727. * @param xrSessionMode mode to initialize
  47728. * @param xrSessionInit defines optional and required values to pass to the session builder
  47729. * @returns a promise which will resolve once the session has been initialized
  47730. */
  47731. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47732. /**
  47733. * Checks if a session would be supported for the creation options specified
  47734. * @param sessionMode session mode to check if supported eg. immersive-vr
  47735. * @returns A Promise that resolves to true if supported and false if not
  47736. */
  47737. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47738. /**
  47739. * Resets the reference space to the one started the session
  47740. */
  47741. resetReferenceSpace(): void;
  47742. /**
  47743. * Starts rendering to the xr layer
  47744. */
  47745. runXRRenderLoop(): void;
  47746. /**
  47747. * Sets the reference space on the xr session
  47748. * @param referenceSpaceType space to set
  47749. * @returns a promise that will resolve once the reference space has been set
  47750. */
  47751. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47752. /**
  47753. * Updates the render state of the session
  47754. * @param state state to set
  47755. * @returns a promise that resolves once the render state has been updated
  47756. */
  47757. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47758. /**
  47759. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47760. * @param sessionMode defines the session to test
  47761. * @returns a promise with boolean as final value
  47762. */
  47763. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47764. private _createRenderTargetTexture;
  47765. }
  47766. }
  47767. declare module "babylonjs/XR/webXRCamera" {
  47768. import { Matrix } from "babylonjs/Maths/math.vector";
  47769. import { Scene } from "babylonjs/scene";
  47770. import { Camera } from "babylonjs/Cameras/camera";
  47771. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47772. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47773. /**
  47774. * WebXR Camera which holds the views for the xrSession
  47775. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47776. */
  47777. export class WebXRCamera extends FreeCamera {
  47778. private _xrSessionManager;
  47779. private _firstFrame;
  47780. private _referenceQuaternion;
  47781. private _referencedPosition;
  47782. private _xrInvPositionCache;
  47783. private _xrInvQuaternionCache;
  47784. /**
  47785. * Should position compensation execute on first frame.
  47786. * This is used when copying the position from a native (non XR) camera
  47787. */
  47788. compensateOnFirstFrame: boolean;
  47789. /**
  47790. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47791. * @param name the name of the camera
  47792. * @param scene the scene to add the camera to
  47793. * @param _xrSessionManager a constructed xr session manager
  47794. */
  47795. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47796. /**
  47797. * Return the user's height, unrelated to the current ground.
  47798. * This will be the y position of this camera, when ground level is 0.
  47799. */
  47800. get realWorldHeight(): number;
  47801. /** @hidden */
  47802. _updateForDualEyeDebugging(): void;
  47803. /**
  47804. * Sets this camera's transformation based on a non-vr camera
  47805. * @param otherCamera the non-vr camera to copy the transformation from
  47806. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47807. */
  47808. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47809. /**
  47810. * Gets the current instance class name ("WebXRCamera").
  47811. * @returns the class name
  47812. */
  47813. getClassName(): string;
  47814. /**
  47815. * Overriding the _getViewMatrix function, as it is computed by WebXR
  47816. */
  47817. _getViewMatrix(): Matrix;
  47818. private _updateFromXRSession;
  47819. private _updateNumberOfRigCameras;
  47820. private _updateReferenceSpace;
  47821. private _updateReferenceSpaceOffset;
  47822. }
  47823. }
  47824. declare module "babylonjs/XR/webXRFeaturesManager" {
  47825. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47826. import { IDisposable } from "babylonjs/scene";
  47827. /**
  47828. * Defining the interface required for a (webxr) feature
  47829. */
  47830. export interface IWebXRFeature extends IDisposable {
  47831. /**
  47832. * Is this feature attached
  47833. */
  47834. attached: boolean;
  47835. /**
  47836. * Should auto-attach be disabled?
  47837. */
  47838. disableAutoAttach: boolean;
  47839. /**
  47840. * Attach the feature to the session
  47841. * Will usually be called by the features manager
  47842. *
  47843. * @param force should attachment be forced (even when already attached)
  47844. * @returns true if successful.
  47845. */
  47846. attach(force?: boolean): boolean;
  47847. /**
  47848. * Detach the feature from the session
  47849. * Will usually be called by the features manager
  47850. *
  47851. * @returns true if successful.
  47852. */
  47853. detach(): boolean;
  47854. }
  47855. /**
  47856. * A list of the currently available features without referencing them
  47857. */
  47858. export class WebXRFeatureName {
  47859. /**
  47860. * The name of the anchor system feature
  47861. */
  47862. static ANCHOR_SYSTEM: string;
  47863. /**
  47864. * The name of the background remover feature
  47865. */
  47866. static BACKGROUND_REMOVER: string;
  47867. /**
  47868. * The name of the hit test feature
  47869. */
  47870. static HIT_TEST: string;
  47871. /**
  47872. * physics impostors for xr controllers feature
  47873. */
  47874. static PHYSICS_CONTROLLERS: string;
  47875. /**
  47876. * The name of the plane detection feature
  47877. */
  47878. static PLANE_DETECTION: string;
  47879. /**
  47880. * The name of the pointer selection feature
  47881. */
  47882. static POINTER_SELECTION: string;
  47883. /**
  47884. * The name of the teleportation feature
  47885. */
  47886. static TELEPORTATION: string;
  47887. }
  47888. /**
  47889. * Defining the constructor of a feature. Used to register the modules.
  47890. */
  47891. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  47892. /**
  47893. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47894. * It is mainly used in AR sessions.
  47895. *
  47896. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47897. */
  47898. export class WebXRFeaturesManager implements IDisposable {
  47899. private _xrSessionManager;
  47900. private static readonly _AvailableFeatures;
  47901. private _features;
  47902. /**
  47903. * constructs a new features manages.
  47904. *
  47905. * @param _xrSessionManager an instance of WebXRSessionManager
  47906. */
  47907. constructor(_xrSessionManager: WebXRSessionManager);
  47908. /**
  47909. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47910. * Mainly used internally.
  47911. *
  47912. * @param featureName the name of the feature to register
  47913. * @param constructorFunction the function used to construct the module
  47914. * @param version the (babylon) version of the module
  47915. * @param stable is that a stable version of this module
  47916. */
  47917. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47918. /**
  47919. * Returns a constructor of a specific feature.
  47920. *
  47921. * @param featureName the name of the feature to construct
  47922. * @param version the version of the feature to load
  47923. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47924. * @param options optional options provided to the module.
  47925. * @returns a function that, when called, will return a new instance of this feature
  47926. */
  47927. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  47928. /**
  47929. * Can be used to return the list of features currently registered
  47930. *
  47931. * @returns an Array of available features
  47932. */
  47933. static GetAvailableFeatures(): string[];
  47934. /**
  47935. * Gets the versions available for a specific feature
  47936. * @param featureName the name of the feature
  47937. * @returns an array with the available versions
  47938. */
  47939. static GetAvailableVersions(featureName: string): string[];
  47940. /**
  47941. * Return the latest unstable version of this feature
  47942. * @param featureName the name of the feature to search
  47943. * @returns the version number. if not found will return -1
  47944. */
  47945. static GetLatestVersionOfFeature(featureName: string): number;
  47946. /**
  47947. * Return the latest stable version of this feature
  47948. * @param featureName the name of the feature to search
  47949. * @returns the version number. if not found will return -1
  47950. */
  47951. static GetStableVersionOfFeature(featureName: string): number;
  47952. /**
  47953. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47954. * Can be used during a session to start a feature
  47955. * @param featureName the name of feature to attach
  47956. */
  47957. attachFeature(featureName: string): void;
  47958. /**
  47959. * Can be used inside a session or when the session ends to detach a specific feature
  47960. * @param featureName the name of the feature to detach
  47961. */
  47962. detachFeature(featureName: string): void;
  47963. /**
  47964. * Used to disable an already-enabled feature
  47965. * The feature will be disposed and will be recreated once enabled.
  47966. * @param featureName the feature to disable
  47967. * @returns true if disable was successful
  47968. */
  47969. disableFeature(featureName: string | {
  47970. Name: string;
  47971. }): boolean;
  47972. /**
  47973. * dispose this features manager
  47974. */
  47975. dispose(): void;
  47976. /**
  47977. * 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.
  47978. * 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.
  47979. *
  47980. * @param featureName the name of the feature to load or the class of the feature
  47981. * @param version optional version to load. if not provided the latest version will be enabled
  47982. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47983. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47984. * @returns a new constructed feature or throws an error if feature not found.
  47985. */
  47986. enableFeature(featureName: string | {
  47987. Name: string;
  47988. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  47989. /**
  47990. * get the implementation of an enabled feature.
  47991. * @param featureName the name of the feature to load
  47992. * @returns the feature class, if found
  47993. */
  47994. getEnabledFeature(featureName: string): IWebXRFeature;
  47995. /**
  47996. * Get the list of enabled features
  47997. * @returns an array of enabled features
  47998. */
  47999. getEnabledFeatures(): string[];
  48000. }
  48001. }
  48002. declare module "babylonjs/XR/webXRExperienceHelper" {
  48003. import { Observable } from "babylonjs/Misc/observable";
  48004. import { IDisposable, Scene } from "babylonjs/scene";
  48005. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48006. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48007. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48008. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48009. /**
  48010. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48011. * @see https://doc.babylonjs.com/how_to/webxr
  48012. */
  48013. export class WebXRExperienceHelper implements IDisposable {
  48014. private scene;
  48015. private _nonVRCamera;
  48016. private _originalSceneAutoClear;
  48017. private _supported;
  48018. /**
  48019. * Camera used to render xr content
  48020. */
  48021. camera: WebXRCamera;
  48022. /** A features manager for this xr session */
  48023. featuresManager: WebXRFeaturesManager;
  48024. /**
  48025. * Observers registered here will be triggered after the camera's initial transformation is set
  48026. * This can be used to set a different ground level or an extra rotation.
  48027. *
  48028. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48029. * to the position set after this observable is done executing.
  48030. */
  48031. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48032. /**
  48033. * Fires when the state of the experience helper has changed
  48034. */
  48035. onStateChangedObservable: Observable<WebXRState>;
  48036. /** Session manager used to keep track of xr session */
  48037. sessionManager: WebXRSessionManager;
  48038. /**
  48039. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48040. */
  48041. state: WebXRState;
  48042. /**
  48043. * Creates a WebXRExperienceHelper
  48044. * @param scene The scene the helper should be created in
  48045. */
  48046. private constructor();
  48047. /**
  48048. * Creates the experience helper
  48049. * @param scene the scene to attach the experience helper to
  48050. * @returns a promise for the experience helper
  48051. */
  48052. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48053. /**
  48054. * Disposes of the experience helper
  48055. */
  48056. dispose(): void;
  48057. /**
  48058. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48059. * @param sessionMode options for the XR session
  48060. * @param referenceSpaceType frame of reference of the XR session
  48061. * @param renderTarget the output canvas that will be used to enter XR mode
  48062. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48063. * @returns promise that resolves after xr mode has entered
  48064. */
  48065. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48066. /**
  48067. * Exits XR mode and returns the scene to its original state
  48068. * @returns promise that resolves after xr mode has exited
  48069. */
  48070. exitXRAsync(): Promise<void>;
  48071. private _nonXRToXRCamera;
  48072. private _setState;
  48073. }
  48074. }
  48075. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48076. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48077. import { Observable } from "babylonjs/Misc/observable";
  48078. import { IDisposable } from "babylonjs/scene";
  48079. /**
  48080. * X-Y values for axes in WebXR
  48081. */
  48082. export interface IWebXRMotionControllerAxesValue {
  48083. /**
  48084. * The value of the x axis
  48085. */
  48086. x: number;
  48087. /**
  48088. * The value of the y-axis
  48089. */
  48090. y: number;
  48091. }
  48092. /**
  48093. * changed / previous values for the values of this component
  48094. */
  48095. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48096. /**
  48097. * current (this frame) value
  48098. */
  48099. current: T;
  48100. /**
  48101. * previous (last change) value
  48102. */
  48103. previous: T;
  48104. }
  48105. /**
  48106. * Represents changes in the component between current frame and last values recorded
  48107. */
  48108. export interface IWebXRMotionControllerComponentChanges {
  48109. /**
  48110. * will be populated with previous and current values if axes changed
  48111. */
  48112. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48113. /**
  48114. * will be populated with previous and current values if pressed changed
  48115. */
  48116. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48117. /**
  48118. * will be populated with previous and current values if touched changed
  48119. */
  48120. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48121. /**
  48122. * will be populated with previous and current values if value changed
  48123. */
  48124. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48125. }
  48126. /**
  48127. * This class represents a single component (for example button or thumbstick) of a motion controller
  48128. */
  48129. export class WebXRControllerComponent implements IDisposable {
  48130. /**
  48131. * the id of this component
  48132. */
  48133. id: string;
  48134. /**
  48135. * the type of the component
  48136. */
  48137. type: MotionControllerComponentType;
  48138. private _buttonIndex;
  48139. private _axesIndices;
  48140. private _axes;
  48141. private _changes;
  48142. private _currentValue;
  48143. private _hasChanges;
  48144. private _pressed;
  48145. private _touched;
  48146. /**
  48147. * button component type
  48148. */
  48149. static BUTTON_TYPE: MotionControllerComponentType;
  48150. /**
  48151. * squeeze component type
  48152. */
  48153. static SQUEEZE_TYPE: MotionControllerComponentType;
  48154. /**
  48155. * Thumbstick component type
  48156. */
  48157. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48158. /**
  48159. * Touchpad component type
  48160. */
  48161. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48162. /**
  48163. * trigger component type
  48164. */
  48165. static TRIGGER_TYPE: MotionControllerComponentType;
  48166. /**
  48167. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48168. * the axes data changes
  48169. */
  48170. onAxisValueChangedObservable: Observable<{
  48171. x: number;
  48172. y: number;
  48173. }>;
  48174. /**
  48175. * Observers registered here will be triggered when the state of a button changes
  48176. * State change is either pressed / touched / value
  48177. */
  48178. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48179. /**
  48180. * Creates a new component for a motion controller.
  48181. * It is created by the motion controller itself
  48182. *
  48183. * @param id the id of this component
  48184. * @param type the type of the component
  48185. * @param _buttonIndex index in the buttons array of the gamepad
  48186. * @param _axesIndices indices of the values in the axes array of the gamepad
  48187. */
  48188. constructor(
  48189. /**
  48190. * the id of this component
  48191. */
  48192. id: string,
  48193. /**
  48194. * the type of the component
  48195. */
  48196. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48197. /**
  48198. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48199. */
  48200. get axes(): IWebXRMotionControllerAxesValue;
  48201. /**
  48202. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48203. */
  48204. get changes(): IWebXRMotionControllerComponentChanges;
  48205. /**
  48206. * Return whether or not the component changed the last frame
  48207. */
  48208. get hasChanges(): boolean;
  48209. /**
  48210. * is the button currently pressed
  48211. */
  48212. get pressed(): boolean;
  48213. /**
  48214. * is the button currently touched
  48215. */
  48216. get touched(): boolean;
  48217. /**
  48218. * Get the current value of this component
  48219. */
  48220. get value(): number;
  48221. /**
  48222. * Dispose this component
  48223. */
  48224. dispose(): void;
  48225. /**
  48226. * Are there axes correlating to this component
  48227. * @return true is axes data is available
  48228. */
  48229. isAxes(): boolean;
  48230. /**
  48231. * Is this component a button (hence - pressable)
  48232. * @returns true if can be pressed
  48233. */
  48234. isButton(): boolean;
  48235. /**
  48236. * update this component using the gamepad object it is in. Called on every frame
  48237. * @param nativeController the native gamepad controller object
  48238. */
  48239. update(nativeController: IMinimalMotionControllerObject): void;
  48240. }
  48241. }
  48242. declare module "babylonjs/Loading/sceneLoader" {
  48243. import { Observable } from "babylonjs/Misc/observable";
  48244. import { Nullable } from "babylonjs/types";
  48245. import { Scene } from "babylonjs/scene";
  48246. import { Engine } from "babylonjs/Engines/engine";
  48247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48248. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48249. import { AssetContainer } from "babylonjs/assetContainer";
  48250. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48251. import { Skeleton } from "babylonjs/Bones/skeleton";
  48252. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48253. import { WebRequest } from "babylonjs/Misc/webRequest";
  48254. /**
  48255. * Interface used to represent data loading progression
  48256. */
  48257. export interface ISceneLoaderProgressEvent {
  48258. /**
  48259. * Defines if data length to load can be evaluated
  48260. */
  48261. readonly lengthComputable: boolean;
  48262. /**
  48263. * Defines the loaded data length
  48264. */
  48265. readonly loaded: number;
  48266. /**
  48267. * Defines the data length to load
  48268. */
  48269. readonly total: number;
  48270. }
  48271. /**
  48272. * Interface used by SceneLoader plugins to define supported file extensions
  48273. */
  48274. export interface ISceneLoaderPluginExtensions {
  48275. /**
  48276. * Defines the list of supported extensions
  48277. */
  48278. [extension: string]: {
  48279. isBinary: boolean;
  48280. };
  48281. }
  48282. /**
  48283. * Interface used by SceneLoader plugin factory
  48284. */
  48285. export interface ISceneLoaderPluginFactory {
  48286. /**
  48287. * Defines the name of the factory
  48288. */
  48289. name: string;
  48290. /**
  48291. * Function called to create a new plugin
  48292. * @return the new plugin
  48293. */
  48294. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48295. /**
  48296. * The callback that returns true if the data can be directly loaded.
  48297. * @param data string containing the file data
  48298. * @returns if the data can be loaded directly
  48299. */
  48300. canDirectLoad?(data: string): boolean;
  48301. }
  48302. /**
  48303. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48304. */
  48305. export interface ISceneLoaderPluginBase {
  48306. /**
  48307. * The friendly name of this plugin.
  48308. */
  48309. name: string;
  48310. /**
  48311. * The file extensions supported by this plugin.
  48312. */
  48313. extensions: string | ISceneLoaderPluginExtensions;
  48314. /**
  48315. * The callback called when loading from a url.
  48316. * @param scene scene loading this url
  48317. * @param url url to load
  48318. * @param onSuccess callback called when the file successfully loads
  48319. * @param onProgress callback called while file is loading (if the server supports this mode)
  48320. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48321. * @param onError callback called when the file fails to load
  48322. * @returns a file request object
  48323. */
  48324. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48325. /**
  48326. * The callback called when loading from a file object.
  48327. * @param scene scene loading this file
  48328. * @param file defines the file to load
  48329. * @param onSuccess defines the callback to call when data is loaded
  48330. * @param onProgress defines the callback to call during loading process
  48331. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48332. * @param onError defines the callback to call when an error occurs
  48333. * @returns a file request object
  48334. */
  48335. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48336. /**
  48337. * The callback that returns true if the data can be directly loaded.
  48338. * @param data string containing the file data
  48339. * @returns if the data can be loaded directly
  48340. */
  48341. canDirectLoad?(data: string): boolean;
  48342. /**
  48343. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48344. * @param scene scene loading this data
  48345. * @param data string containing the data
  48346. * @returns data to pass to the plugin
  48347. */
  48348. directLoad?(scene: Scene, data: string): any;
  48349. /**
  48350. * The callback that allows custom handling of the root url based on the response url.
  48351. * @param rootUrl the original root url
  48352. * @param responseURL the response url if available
  48353. * @returns the new root url
  48354. */
  48355. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48356. }
  48357. /**
  48358. * Interface used to define a SceneLoader plugin
  48359. */
  48360. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48361. /**
  48362. * Import meshes into a scene.
  48363. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48364. * @param scene The scene to import into
  48365. * @param data The data to import
  48366. * @param rootUrl The root url for scene and resources
  48367. * @param meshes The meshes array to import into
  48368. * @param particleSystems The particle systems array to import into
  48369. * @param skeletons The skeletons array to import into
  48370. * @param onError The callback when import fails
  48371. * @returns True if successful or false otherwise
  48372. */
  48373. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48374. /**
  48375. * Load into a scene.
  48376. * @param scene The scene to load into
  48377. * @param data The data to import
  48378. * @param rootUrl The root url for scene and resources
  48379. * @param onError The callback when import fails
  48380. * @returns True if successful or false otherwise
  48381. */
  48382. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48383. /**
  48384. * Load into an asset container.
  48385. * @param scene The scene to load into
  48386. * @param data The data to import
  48387. * @param rootUrl The root url for scene and resources
  48388. * @param onError The callback when import fails
  48389. * @returns The loaded asset container
  48390. */
  48391. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48392. }
  48393. /**
  48394. * Interface used to define an async SceneLoader plugin
  48395. */
  48396. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48397. /**
  48398. * Import meshes into a scene.
  48399. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48400. * @param scene The scene to import into
  48401. * @param data The data to import
  48402. * @param rootUrl The root url for scene and resources
  48403. * @param onProgress The callback when the load progresses
  48404. * @param fileName Defines the name of the file to load
  48405. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48406. */
  48407. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48408. meshes: AbstractMesh[];
  48409. particleSystems: IParticleSystem[];
  48410. skeletons: Skeleton[];
  48411. animationGroups: AnimationGroup[];
  48412. }>;
  48413. /**
  48414. * Load into a scene.
  48415. * @param scene The scene to load into
  48416. * @param data The data to import
  48417. * @param rootUrl The root url for scene and resources
  48418. * @param onProgress The callback when the load progresses
  48419. * @param fileName Defines the name of the file to load
  48420. * @returns Nothing
  48421. */
  48422. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48423. /**
  48424. * Load into an asset container.
  48425. * @param scene The scene to load into
  48426. * @param data The data to import
  48427. * @param rootUrl The root url for scene and resources
  48428. * @param onProgress The callback when the load progresses
  48429. * @param fileName Defines the name of the file to load
  48430. * @returns The loaded asset container
  48431. */
  48432. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48433. }
  48434. /**
  48435. * Mode that determines how to handle old animation groups before loading new ones.
  48436. */
  48437. export enum SceneLoaderAnimationGroupLoadingMode {
  48438. /**
  48439. * Reset all old animations to initial state then dispose them.
  48440. */
  48441. Clean = 0,
  48442. /**
  48443. * Stop all old animations.
  48444. */
  48445. Stop = 1,
  48446. /**
  48447. * Restart old animations from first frame.
  48448. */
  48449. Sync = 2,
  48450. /**
  48451. * Old animations remains untouched.
  48452. */
  48453. NoSync = 3
  48454. }
  48455. /**
  48456. * Class used to load scene from various file formats using registered plugins
  48457. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48458. */
  48459. export class SceneLoader {
  48460. /**
  48461. * No logging while loading
  48462. */
  48463. static readonly NO_LOGGING: number;
  48464. /**
  48465. * Minimal logging while loading
  48466. */
  48467. static readonly MINIMAL_LOGGING: number;
  48468. /**
  48469. * Summary logging while loading
  48470. */
  48471. static readonly SUMMARY_LOGGING: number;
  48472. /**
  48473. * Detailled logging while loading
  48474. */
  48475. static readonly DETAILED_LOGGING: number;
  48476. /**
  48477. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48478. */
  48479. static get ForceFullSceneLoadingForIncremental(): boolean;
  48480. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48481. /**
  48482. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48483. */
  48484. static get ShowLoadingScreen(): boolean;
  48485. static set ShowLoadingScreen(value: boolean);
  48486. /**
  48487. * Defines the current logging level (while loading the scene)
  48488. * @ignorenaming
  48489. */
  48490. static get loggingLevel(): number;
  48491. static set loggingLevel(value: number);
  48492. /**
  48493. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48494. */
  48495. static get CleanBoneMatrixWeights(): boolean;
  48496. static set CleanBoneMatrixWeights(value: boolean);
  48497. /**
  48498. * Event raised when a plugin is used to load a scene
  48499. */
  48500. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48501. private static _registeredPlugins;
  48502. private static _getDefaultPlugin;
  48503. private static _getPluginForExtension;
  48504. private static _getPluginForDirectLoad;
  48505. private static _getPluginForFilename;
  48506. private static _getDirectLoad;
  48507. private static _loadData;
  48508. private static _getFileInfo;
  48509. /**
  48510. * Gets a plugin that can load the given extension
  48511. * @param extension defines the extension to load
  48512. * @returns a plugin or null if none works
  48513. */
  48514. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48515. /**
  48516. * Gets a boolean indicating that the given extension can be loaded
  48517. * @param extension defines the extension to load
  48518. * @returns true if the extension is supported
  48519. */
  48520. static IsPluginForExtensionAvailable(extension: string): boolean;
  48521. /**
  48522. * Adds a new plugin to the list of registered plugins
  48523. * @param plugin defines the plugin to add
  48524. */
  48525. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48526. /**
  48527. * Import meshes into a scene
  48528. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48529. * @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)
  48530. * @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)
  48531. * @param scene the instance of BABYLON.Scene to append to
  48532. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48533. * @param onProgress a callback with a progress event for each file being loaded
  48534. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48535. * @param pluginExtension the extension used to determine the plugin
  48536. * @returns The loaded plugin
  48537. */
  48538. 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: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48539. /**
  48540. * Import meshes into a scene
  48541. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48542. * @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)
  48543. * @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)
  48544. * @param scene the instance of BABYLON.Scene to append to
  48545. * @param onProgress a callback with a progress event for each file being loaded
  48546. * @param pluginExtension the extension used to determine the plugin
  48547. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48548. */
  48549. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48550. meshes: AbstractMesh[];
  48551. particleSystems: IParticleSystem[];
  48552. skeletons: Skeleton[];
  48553. animationGroups: AnimationGroup[];
  48554. }>;
  48555. /**
  48556. * Load a scene
  48557. * @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)
  48558. * @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)
  48559. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48560. * @param onSuccess a callback with the scene when import succeeds
  48561. * @param onProgress a callback with a progress event for each file being loaded
  48562. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48563. * @param pluginExtension the extension used to determine the plugin
  48564. * @returns The loaded plugin
  48565. */
  48566. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48567. /**
  48568. * Load a scene
  48569. * @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)
  48570. * @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)
  48571. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48572. * @param onProgress a callback with a progress event for each file being loaded
  48573. * @param pluginExtension the extension used to determine the plugin
  48574. * @returns The loaded scene
  48575. */
  48576. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48577. /**
  48578. * Append a scene
  48579. * @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)
  48580. * @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)
  48581. * @param scene is the instance of BABYLON.Scene to append to
  48582. * @param onSuccess a callback with the scene when import succeeds
  48583. * @param onProgress a callback with a progress event for each file being loaded
  48584. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48585. * @param pluginExtension the extension used to determine the plugin
  48586. * @returns The loaded plugin
  48587. */
  48588. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48589. /**
  48590. * Append a scene
  48591. * @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)
  48592. * @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)
  48593. * @param scene is the instance of BABYLON.Scene to append to
  48594. * @param onProgress a callback with a progress event for each file being loaded
  48595. * @param pluginExtension the extension used to determine the plugin
  48596. * @returns The given scene
  48597. */
  48598. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48599. /**
  48600. * Load a scene into an asset container
  48601. * @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)
  48602. * @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)
  48603. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48604. * @param onSuccess a callback with the scene when import succeeds
  48605. * @param onProgress a callback with a progress event for each file being loaded
  48606. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48607. * @param pluginExtension the extension used to determine the plugin
  48608. * @returns The loaded plugin
  48609. */
  48610. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48611. /**
  48612. * Load a scene into an asset container
  48613. * @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)
  48614. * @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)
  48615. * @param scene is the instance of Scene to append to
  48616. * @param onProgress a callback with a progress event for each file being loaded
  48617. * @param pluginExtension the extension used to determine the plugin
  48618. * @returns The loaded asset container
  48619. */
  48620. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48621. /**
  48622. * Import animations from a file into a scene
  48623. * @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)
  48624. * @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)
  48625. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48626. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48627. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48628. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48629. * @param onSuccess a callback with the scene when import succeeds
  48630. * @param onProgress a callback with a progress event for each file being loaded
  48631. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48632. */
  48633. 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: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  48634. /**
  48635. * Import animations from a file into a scene
  48636. * @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)
  48637. * @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)
  48638. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48639. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48640. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48641. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48642. * @param onSuccess a callback with the scene when import succeeds
  48643. * @param onProgress a callback with a progress event for each file being loaded
  48644. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48645. * @returns the updated scene with imported animations
  48646. */
  48647. 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: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  48648. }
  48649. }
  48650. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48651. import { IDisposable, Scene } from "babylonjs/scene";
  48652. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48653. import { Observable } from "babylonjs/Misc/observable";
  48654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48655. import { Nullable } from "babylonjs/types";
  48656. /**
  48657. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48658. */
  48659. export type MotionControllerHandedness = "none" | "left" | "right";
  48660. /**
  48661. * The type of components available in motion controllers.
  48662. * This is not the name of the component.
  48663. */
  48664. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48665. /**
  48666. * The state of a controller component
  48667. */
  48668. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48669. /**
  48670. * The schema of motion controller layout.
  48671. * No object will be initialized using this interface
  48672. * This is used just to define the profile.
  48673. */
  48674. export interface IMotionControllerLayout {
  48675. /**
  48676. * Path to load the assets. Usually relative to the base path
  48677. */
  48678. assetPath: string;
  48679. /**
  48680. * Available components (unsorted)
  48681. */
  48682. components: {
  48683. /**
  48684. * A map of component Ids
  48685. */
  48686. [componentId: string]: {
  48687. /**
  48688. * The type of input the component outputs
  48689. */
  48690. type: MotionControllerComponentType;
  48691. /**
  48692. * The indices of this component in the gamepad object
  48693. */
  48694. gamepadIndices: {
  48695. /**
  48696. * Index of button
  48697. */
  48698. button?: number;
  48699. /**
  48700. * If available, index of x-axis
  48701. */
  48702. xAxis?: number;
  48703. /**
  48704. * If available, index of y-axis
  48705. */
  48706. yAxis?: number;
  48707. };
  48708. /**
  48709. * The mesh's root node name
  48710. */
  48711. rootNodeName: string;
  48712. /**
  48713. * Animation definitions for this model
  48714. */
  48715. visualResponses: {
  48716. [stateKey: string]: {
  48717. /**
  48718. * What property will be animated
  48719. */
  48720. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48721. /**
  48722. * What states influence this visual response
  48723. */
  48724. states: MotionControllerComponentStateType[];
  48725. /**
  48726. * Type of animation - movement or visibility
  48727. */
  48728. valueNodeProperty: "transform" | "visibility";
  48729. /**
  48730. * Base node name to move. Its position will be calculated according to the min and max nodes
  48731. */
  48732. valueNodeName?: string;
  48733. /**
  48734. * Minimum movement node
  48735. */
  48736. minNodeName?: string;
  48737. /**
  48738. * Max movement node
  48739. */
  48740. maxNodeName?: string;
  48741. };
  48742. };
  48743. /**
  48744. * If touch enabled, what is the name of node to display user feedback
  48745. */
  48746. touchPointNodeName?: string;
  48747. };
  48748. };
  48749. /**
  48750. * Is it xr standard mapping or not
  48751. */
  48752. gamepadMapping: "" | "xr-standard";
  48753. /**
  48754. * Base root node of this entire model
  48755. */
  48756. rootNodeName: string;
  48757. /**
  48758. * Defines the main button component id
  48759. */
  48760. selectComponentId: string;
  48761. }
  48762. /**
  48763. * A definition for the layout map in the input profile
  48764. */
  48765. export interface IMotionControllerLayoutMap {
  48766. /**
  48767. * Layouts with handedness type as a key
  48768. */
  48769. [handedness: string]: IMotionControllerLayout;
  48770. }
  48771. /**
  48772. * The XR Input profile schema
  48773. * Profiles can be found here:
  48774. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48775. */
  48776. export interface IMotionControllerProfile {
  48777. /**
  48778. * fallback profiles for this profileId
  48779. */
  48780. fallbackProfileIds: string[];
  48781. /**
  48782. * The layout map, with handedness as key
  48783. */
  48784. layouts: IMotionControllerLayoutMap;
  48785. /**
  48786. * The id of this profile
  48787. * correlates to the profile(s) in the xrInput.profiles array
  48788. */
  48789. profileId: string;
  48790. }
  48791. /**
  48792. * A helper-interface for the 3 meshes needed for controller button animation
  48793. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48794. */
  48795. export interface IMotionControllerButtonMeshMap {
  48796. /**
  48797. * the mesh that defines the pressed value mesh position.
  48798. * This is used to find the max-position of this button
  48799. */
  48800. pressedMesh: AbstractMesh;
  48801. /**
  48802. * the mesh that defines the unpressed value mesh position.
  48803. * This is used to find the min (or initial) position of this button
  48804. */
  48805. unpressedMesh: AbstractMesh;
  48806. /**
  48807. * The mesh that will be changed when value changes
  48808. */
  48809. valueMesh: AbstractMesh;
  48810. }
  48811. /**
  48812. * A helper-interface for the 3 meshes needed for controller axis animation.
  48813. * This will be expanded when touchpad animations are fully supported
  48814. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48815. */
  48816. export interface IMotionControllerMeshMap {
  48817. /**
  48818. * the mesh that defines the maximum value mesh position.
  48819. */
  48820. maxMesh?: AbstractMesh;
  48821. /**
  48822. * the mesh that defines the minimum value mesh position.
  48823. */
  48824. minMesh?: AbstractMesh;
  48825. /**
  48826. * The mesh that will be changed when axis value changes
  48827. */
  48828. valueMesh: AbstractMesh;
  48829. }
  48830. /**
  48831. * The elements needed for change-detection of the gamepad objects in motion controllers
  48832. */
  48833. export interface IMinimalMotionControllerObject {
  48834. /**
  48835. * Available axes of this controller
  48836. */
  48837. axes: number[];
  48838. /**
  48839. * An array of available buttons
  48840. */
  48841. buttons: Array<{
  48842. /**
  48843. * Value of the button/trigger
  48844. */
  48845. value: number;
  48846. /**
  48847. * If the button/trigger is currently touched
  48848. */
  48849. touched: boolean;
  48850. /**
  48851. * If the button/trigger is currently pressed
  48852. */
  48853. pressed: boolean;
  48854. }>;
  48855. /**
  48856. * EXPERIMENTAL haptic support.
  48857. */
  48858. hapticActuators?: Array<{
  48859. pulse: (value: number, duration: number) => Promise<boolean>;
  48860. }>;
  48861. }
  48862. /**
  48863. * An Abstract Motion controller
  48864. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48865. * Each component has an observable to check for changes in value and state
  48866. */
  48867. export abstract class WebXRAbstractMotionController implements IDisposable {
  48868. protected scene: Scene;
  48869. protected layout: IMotionControllerLayout;
  48870. /**
  48871. * The gamepad object correlating to this controller
  48872. */
  48873. gamepadObject: IMinimalMotionControllerObject;
  48874. /**
  48875. * handedness (left/right/none) of this controller
  48876. */
  48877. handedness: MotionControllerHandedness;
  48878. private _initComponent;
  48879. private _modelReady;
  48880. /**
  48881. * A map of components (WebXRControllerComponent) in this motion controller
  48882. * Components have a ComponentType and can also have both button and axis definitions
  48883. */
  48884. readonly components: {
  48885. [id: string]: WebXRControllerComponent;
  48886. };
  48887. /**
  48888. * Disable the model's animation. Can be set at any time.
  48889. */
  48890. disableAnimation: boolean;
  48891. /**
  48892. * Observers registered here will be triggered when the model of this controller is done loading
  48893. */
  48894. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48895. /**
  48896. * The profile id of this motion controller
  48897. */
  48898. abstract profileId: string;
  48899. /**
  48900. * The root mesh of the model. It is null if the model was not yet initialized
  48901. */
  48902. rootMesh: Nullable<AbstractMesh>;
  48903. /**
  48904. * constructs a new abstract motion controller
  48905. * @param scene the scene to which the model of the controller will be added
  48906. * @param layout The profile layout to load
  48907. * @param gamepadObject The gamepad object correlating to this controller
  48908. * @param handedness handedness (left/right/none) of this controller
  48909. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48910. */
  48911. constructor(scene: Scene, layout: IMotionControllerLayout,
  48912. /**
  48913. * The gamepad object correlating to this controller
  48914. */
  48915. gamepadObject: IMinimalMotionControllerObject,
  48916. /**
  48917. * handedness (left/right/none) of this controller
  48918. */
  48919. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48920. /**
  48921. * Dispose this controller, the model mesh and all its components
  48922. */
  48923. dispose(): void;
  48924. /**
  48925. * Returns all components of specific type
  48926. * @param type the type to search for
  48927. * @return an array of components with this type
  48928. */
  48929. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48930. /**
  48931. * get a component based an its component id as defined in layout.components
  48932. * @param id the id of the component
  48933. * @returns the component correlates to the id or undefined if not found
  48934. */
  48935. getComponent(id: string): WebXRControllerComponent;
  48936. /**
  48937. * Get the list of components available in this motion controller
  48938. * @returns an array of strings correlating to available components
  48939. */
  48940. getComponentIds(): string[];
  48941. /**
  48942. * Get the first component of specific type
  48943. * @param type type of component to find
  48944. * @return a controller component or null if not found
  48945. */
  48946. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48947. /**
  48948. * Get the main (Select) component of this controller as defined in the layout
  48949. * @returns the main component of this controller
  48950. */
  48951. getMainComponent(): WebXRControllerComponent;
  48952. /**
  48953. * Loads the model correlating to this controller
  48954. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48955. * @returns A promise fulfilled with the result of the model loading
  48956. */
  48957. loadModel(): Promise<boolean>;
  48958. /**
  48959. * Update this model using the current XRFrame
  48960. * @param xrFrame the current xr frame to use and update the model
  48961. */
  48962. updateFromXRFrame(xrFrame: XRFrame): void;
  48963. /**
  48964. * Backwards compatibility due to a deeply-integrated typo
  48965. */
  48966. get handness(): XREye;
  48967. /**
  48968. * Pulse (vibrate) this controller
  48969. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48970. * Consecutive calls to this function will cancel the last pulse call
  48971. *
  48972. * @param value the strength of the pulse in 0.0...1.0 range
  48973. * @param duration Duration of the pulse in milliseconds
  48974. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48975. * @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
  48976. */
  48977. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48978. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48979. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48980. /**
  48981. * Moves the axis on the controller mesh based on its current state
  48982. * @param axis the index of the axis
  48983. * @param axisValue the value of the axis which determines the meshes new position
  48984. * @hidden
  48985. */
  48986. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48987. /**
  48988. * Update the model itself with the current frame data
  48989. * @param xrFrame the frame to use for updating the model mesh
  48990. */
  48991. protected updateModel(xrFrame: XRFrame): void;
  48992. /**
  48993. * Get the filename and path for this controller's model
  48994. * @returns a map of filename and path
  48995. */
  48996. protected abstract _getFilenameAndPath(): {
  48997. filename: string;
  48998. path: string;
  48999. };
  49000. /**
  49001. * This function is called before the mesh is loaded. It checks for loading constraints.
  49002. * For example, this function can check if the GLB loader is available
  49003. * If this function returns false, the generic controller will be loaded instead
  49004. * @returns Is the client ready to load the mesh
  49005. */
  49006. protected abstract _getModelLoadingConstraints(): boolean;
  49007. /**
  49008. * This function will be called after the model was successfully loaded and can be used
  49009. * for mesh transformations before it is available for the user
  49010. * @param meshes the loaded meshes
  49011. */
  49012. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49013. /**
  49014. * Set the root mesh for this controller. Important for the WebXR controller class
  49015. * @param meshes the loaded meshes
  49016. */
  49017. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49018. /**
  49019. * A function executed each frame that updates the mesh (if needed)
  49020. * @param xrFrame the current xrFrame
  49021. */
  49022. protected abstract _updateModel(xrFrame: XRFrame): void;
  49023. private _getGenericFilenameAndPath;
  49024. private _getGenericParentMesh;
  49025. }
  49026. }
  49027. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49028. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49030. import { Scene } from "babylonjs/scene";
  49031. /**
  49032. * A generic trigger-only motion controller for WebXR
  49033. */
  49034. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49035. /**
  49036. * Static version of the profile id of this controller
  49037. */
  49038. static ProfileId: string;
  49039. profileId: string;
  49040. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49041. protected _getFilenameAndPath(): {
  49042. filename: string;
  49043. path: string;
  49044. };
  49045. protected _getModelLoadingConstraints(): boolean;
  49046. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49047. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49048. protected _updateModel(): void;
  49049. }
  49050. }
  49051. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49052. import { Vector4 } from "babylonjs/Maths/math.vector";
  49053. import { Mesh } from "babylonjs/Meshes/mesh";
  49054. import { Scene } from "babylonjs/scene";
  49055. import { Nullable } from "babylonjs/types";
  49056. /**
  49057. * Class containing static functions to help procedurally build meshes
  49058. */
  49059. export class SphereBuilder {
  49060. /**
  49061. * Creates a sphere mesh
  49062. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49063. * * 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`)
  49064. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49065. * * 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
  49066. * * 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)
  49067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49070. * @param name defines the name of the mesh
  49071. * @param options defines the options used to create the mesh
  49072. * @param scene defines the hosting scene
  49073. * @returns the sphere mesh
  49074. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49075. */
  49076. static CreateSphere(name: string, options: {
  49077. segments?: number;
  49078. diameter?: number;
  49079. diameterX?: number;
  49080. diameterY?: number;
  49081. diameterZ?: number;
  49082. arc?: number;
  49083. slice?: number;
  49084. sideOrientation?: number;
  49085. frontUVs?: Vector4;
  49086. backUVs?: Vector4;
  49087. updatable?: boolean;
  49088. }, scene?: Nullable<Scene>): Mesh;
  49089. }
  49090. }
  49091. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49093. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49094. import { Scene } from "babylonjs/scene";
  49095. /**
  49096. * A profiled motion controller has its profile loaded from an online repository.
  49097. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49098. */
  49099. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49100. private _repositoryUrl;
  49101. private _buttonMeshMapping;
  49102. private _touchDots;
  49103. /**
  49104. * The profile ID of this controller. Will be populated when the controller initializes.
  49105. */
  49106. profileId: string;
  49107. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49108. dispose(): void;
  49109. protected _getFilenameAndPath(): {
  49110. filename: string;
  49111. path: string;
  49112. };
  49113. protected _getModelLoadingConstraints(): boolean;
  49114. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49115. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49116. protected _updateModel(_xrFrame: XRFrame): void;
  49117. }
  49118. }
  49119. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49120. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49121. import { Scene } from "babylonjs/scene";
  49122. /**
  49123. * A construction function type to create a new controller based on an xrInput object
  49124. */
  49125. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49126. /**
  49127. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49128. *
  49129. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49130. * it should be replaced with auto-loaded controllers.
  49131. *
  49132. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49133. */
  49134. export class WebXRMotionControllerManager {
  49135. private static _AvailableControllers;
  49136. private static _Fallbacks;
  49137. private static _ProfileLoadingPromises;
  49138. private static _ProfilesList;
  49139. /**
  49140. * The base URL of the online controller repository. Can be changed at any time.
  49141. */
  49142. static BaseRepositoryUrl: string;
  49143. /**
  49144. * Which repository gets priority - local or online
  49145. */
  49146. static PrioritizeOnlineRepository: boolean;
  49147. /**
  49148. * Use the online repository, or use only locally-defined controllers
  49149. */
  49150. static UseOnlineRepository: boolean;
  49151. /**
  49152. * Clear the cache used for profile loading and reload when requested again
  49153. */
  49154. static ClearProfilesCache(): void;
  49155. /**
  49156. * Register the default fallbacks.
  49157. * This function is called automatically when this file is imported.
  49158. */
  49159. static DefaultFallbacks(): void;
  49160. /**
  49161. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49162. * @param profileId the profile to which a fallback needs to be found
  49163. * @return an array with corresponding fallback profiles
  49164. */
  49165. static FindFallbackWithProfileId(profileId: string): string[];
  49166. /**
  49167. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49168. * The order of search:
  49169. *
  49170. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49171. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49172. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49173. * 4) return the generic trigger controller if none were found
  49174. *
  49175. * @param xrInput the xrInput to which a new controller is initialized
  49176. * @param scene the scene to which the model will be added
  49177. * @param forceProfile force a certain profile for this controller
  49178. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49179. */
  49180. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49181. /**
  49182. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49183. *
  49184. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49185. *
  49186. * @param type the profile type to register
  49187. * @param constructFunction the function to be called when loading this profile
  49188. */
  49189. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49190. /**
  49191. * Register a fallback to a specific profile.
  49192. * @param profileId the profileId that will receive the fallbacks
  49193. * @param fallbacks A list of fallback profiles
  49194. */
  49195. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49196. /**
  49197. * Will update the list of profiles available in the repository
  49198. * @return a promise that resolves to a map of profiles available online
  49199. */
  49200. static UpdateProfilesList(): Promise<{
  49201. [profile: string]: string;
  49202. }>;
  49203. private static _LoadProfileFromRepository;
  49204. private static _LoadProfilesFromAvailableControllers;
  49205. }
  49206. }
  49207. declare module "babylonjs/XR/webXRInputSource" {
  49208. import { Observable } from "babylonjs/Misc/observable";
  49209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49210. import { Ray } from "babylonjs/Culling/ray";
  49211. import { Scene } from "babylonjs/scene";
  49212. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49213. /**
  49214. * Configuration options for the WebXR controller creation
  49215. */
  49216. export interface IWebXRControllerOptions {
  49217. /**
  49218. * Should the controller mesh be animated when a user interacts with it
  49219. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49220. */
  49221. disableMotionControllerAnimation?: boolean;
  49222. /**
  49223. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49224. */
  49225. doNotLoadControllerMesh?: boolean;
  49226. /**
  49227. * Force a specific controller type for this controller.
  49228. * This can be used when creating your own profile or when testing different controllers
  49229. */
  49230. forceControllerProfile?: string;
  49231. /**
  49232. * Defines a rendering group ID for meshes that will be loaded.
  49233. * This is for the default controllers only.
  49234. */
  49235. renderingGroupId?: number;
  49236. }
  49237. /**
  49238. * Represents an XR controller
  49239. */
  49240. export class WebXRInputSource {
  49241. private _scene;
  49242. /** The underlying input source for the controller */
  49243. inputSource: XRInputSource;
  49244. private _options;
  49245. private _tmpVector;
  49246. private _uniqueId;
  49247. /**
  49248. * 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
  49249. */
  49250. grip?: AbstractMesh;
  49251. /**
  49252. * If available, this is the gamepad object related to this controller.
  49253. * Using this object it is possible to get click events and trackpad changes of the
  49254. * webxr controller that is currently being used.
  49255. */
  49256. motionController?: WebXRAbstractMotionController;
  49257. /**
  49258. * Event that fires when the controller is removed/disposed.
  49259. * The object provided as event data is this controller, after associated assets were disposed.
  49260. * uniqueId is still available.
  49261. */
  49262. onDisposeObservable: Observable<WebXRInputSource>;
  49263. /**
  49264. * Will be triggered when the mesh associated with the motion controller is done loading.
  49265. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49266. * A shortened version of controller -> motion controller -> on mesh loaded.
  49267. */
  49268. onMeshLoadedObservable: Observable<AbstractMesh>;
  49269. /**
  49270. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49271. */
  49272. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49273. /**
  49274. * Pointer which can be used to select objects or attach a visible laser to
  49275. */
  49276. pointer: AbstractMesh;
  49277. /**
  49278. * Creates the controller
  49279. * @see https://doc.babylonjs.com/how_to/webxr
  49280. * @param _scene the scene which the controller should be associated to
  49281. * @param inputSource the underlying input source for the controller
  49282. * @param _options options for this controller creation
  49283. */
  49284. constructor(_scene: Scene,
  49285. /** The underlying input source for the controller */
  49286. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49287. /**
  49288. * Get this controllers unique id
  49289. */
  49290. get uniqueId(): string;
  49291. /**
  49292. * Disposes of the object
  49293. */
  49294. dispose(): void;
  49295. /**
  49296. * Gets a world space ray coming from the pointer or grip
  49297. * @param result the resulting ray
  49298. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49299. */
  49300. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49301. /**
  49302. * Updates the controller pose based on the given XRFrame
  49303. * @param xrFrame xr frame to update the pose with
  49304. * @param referenceSpace reference space to use
  49305. */
  49306. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49307. }
  49308. }
  49309. declare module "babylonjs/XR/webXRInput" {
  49310. import { Observable } from "babylonjs/Misc/observable";
  49311. import { IDisposable } from "babylonjs/scene";
  49312. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49313. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49314. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49315. /**
  49316. * The schema for initialization options of the XR Input class
  49317. */
  49318. export interface IWebXRInputOptions {
  49319. /**
  49320. * If set to true no model will be automatically loaded
  49321. */
  49322. doNotLoadControllerMeshes?: boolean;
  49323. /**
  49324. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49325. * If not found, the xr input profile data will be used.
  49326. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49327. */
  49328. forceInputProfile?: string;
  49329. /**
  49330. * Do not send a request to the controller repository to load the profile.
  49331. *
  49332. * Instead, use the controllers available in babylon itself.
  49333. */
  49334. disableOnlineControllerRepository?: boolean;
  49335. /**
  49336. * A custom URL for the controllers repository
  49337. */
  49338. customControllersRepositoryURL?: string;
  49339. /**
  49340. * Should the controller model's components not move according to the user input
  49341. */
  49342. disableControllerAnimation?: boolean;
  49343. /**
  49344. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49345. */
  49346. controllerOptions?: IWebXRControllerOptions;
  49347. }
  49348. /**
  49349. * XR input used to track XR inputs such as controllers/rays
  49350. */
  49351. export class WebXRInput implements IDisposable {
  49352. /**
  49353. * the xr session manager for this session
  49354. */
  49355. xrSessionManager: WebXRSessionManager;
  49356. /**
  49357. * the WebXR camera for this session. Mainly used for teleportation
  49358. */
  49359. xrCamera: WebXRCamera;
  49360. private readonly options;
  49361. /**
  49362. * XR controllers being tracked
  49363. */
  49364. controllers: Array<WebXRInputSource>;
  49365. private _frameObserver;
  49366. private _sessionEndedObserver;
  49367. private _sessionInitObserver;
  49368. /**
  49369. * Event when a controller has been connected/added
  49370. */
  49371. onControllerAddedObservable: Observable<WebXRInputSource>;
  49372. /**
  49373. * Event when a controller has been removed/disconnected
  49374. */
  49375. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49376. /**
  49377. * Initializes the WebXRInput
  49378. * @param xrSessionManager the xr session manager for this session
  49379. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49380. * @param options = initialization options for this xr input
  49381. */
  49382. constructor(
  49383. /**
  49384. * the xr session manager for this session
  49385. */
  49386. xrSessionManager: WebXRSessionManager,
  49387. /**
  49388. * the WebXR camera for this session. Mainly used for teleportation
  49389. */
  49390. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49391. private _onInputSourcesChange;
  49392. private _addAndRemoveControllers;
  49393. /**
  49394. * Disposes of the object
  49395. */
  49396. dispose(): void;
  49397. }
  49398. }
  49399. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49400. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49401. import { Observable, EventState } from "babylonjs/Misc/observable";
  49402. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49403. /**
  49404. * This is the base class for all WebXR features.
  49405. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49406. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49407. */
  49408. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49409. protected _xrSessionManager: WebXRSessionManager;
  49410. private _attached;
  49411. private _removeOnDetach;
  49412. /**
  49413. * Should auto-attach be disabled?
  49414. */
  49415. disableAutoAttach: boolean;
  49416. /**
  49417. * Construct a new (abstract) WebXR feature
  49418. * @param _xrSessionManager the xr session manager for this feature
  49419. */
  49420. constructor(_xrSessionManager: WebXRSessionManager);
  49421. /**
  49422. * Is this feature attached
  49423. */
  49424. get attached(): boolean;
  49425. /**
  49426. * attach this feature
  49427. *
  49428. * @param force should attachment be forced (even when already attached)
  49429. * @returns true if successful, false is failed or already attached
  49430. */
  49431. attach(force?: boolean): boolean;
  49432. /**
  49433. * detach this feature.
  49434. *
  49435. * @returns true if successful, false if failed or already detached
  49436. */
  49437. detach(): boolean;
  49438. /**
  49439. * Dispose this feature and all of the resources attached
  49440. */
  49441. dispose(): void;
  49442. /**
  49443. * This is used to register callbacks that will automatically be removed when detach is called.
  49444. * @param observable the observable to which the observer will be attached
  49445. * @param callback the callback to register
  49446. */
  49447. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49448. /**
  49449. * Code in this function will be executed on each xrFrame received from the browser.
  49450. * This function will not execute after the feature is detached.
  49451. * @param _xrFrame the current frame
  49452. */
  49453. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49454. }
  49455. }
  49456. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49457. import { IDisposable, Scene } from "babylonjs/scene";
  49458. import { Nullable } from "babylonjs/types";
  49459. import { Observable } from "babylonjs/Misc/observable";
  49460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49461. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49462. import { Camera } from "babylonjs/Cameras/camera";
  49463. /**
  49464. * Renders a layer on top of an existing scene
  49465. */
  49466. export class UtilityLayerRenderer implements IDisposable {
  49467. /** the original scene that will be rendered on top of */
  49468. originalScene: Scene;
  49469. private _pointerCaptures;
  49470. private _lastPointerEvents;
  49471. private static _DefaultUtilityLayer;
  49472. private static _DefaultKeepDepthUtilityLayer;
  49473. private _sharedGizmoLight;
  49474. private _renderCamera;
  49475. /**
  49476. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49477. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49478. * @returns the camera that is used when rendering the utility layer
  49479. */
  49480. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49481. /**
  49482. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49483. * @param cam the camera that should be used when rendering the utility layer
  49484. */
  49485. setRenderCamera(cam: Nullable<Camera>): void;
  49486. /**
  49487. * @hidden
  49488. * Light which used by gizmos to get light shading
  49489. */
  49490. _getSharedGizmoLight(): HemisphericLight;
  49491. /**
  49492. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49493. */
  49494. pickUtilitySceneFirst: boolean;
  49495. /**
  49496. * 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)
  49497. */
  49498. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49499. /**
  49500. * 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)
  49501. */
  49502. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49503. /**
  49504. * The scene that is rendered on top of the original scene
  49505. */
  49506. utilityLayerScene: Scene;
  49507. /**
  49508. * If the utility layer should automatically be rendered on top of existing scene
  49509. */
  49510. shouldRender: boolean;
  49511. /**
  49512. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49513. */
  49514. onlyCheckPointerDownEvents: boolean;
  49515. /**
  49516. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49517. */
  49518. processAllEvents: boolean;
  49519. /**
  49520. * Observable raised when the pointer move from the utility layer scene to the main scene
  49521. */
  49522. onPointerOutObservable: Observable<number>;
  49523. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49524. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49525. private _afterRenderObserver;
  49526. private _sceneDisposeObserver;
  49527. private _originalPointerObserver;
  49528. /**
  49529. * Instantiates a UtilityLayerRenderer
  49530. * @param originalScene the original scene that will be rendered on top of
  49531. * @param handleEvents boolean indicating if the utility layer should handle events
  49532. */
  49533. constructor(
  49534. /** the original scene that will be rendered on top of */
  49535. originalScene: Scene, handleEvents?: boolean);
  49536. private _notifyObservers;
  49537. /**
  49538. * Renders the utility layers scene on top of the original scene
  49539. */
  49540. render(): void;
  49541. /**
  49542. * Disposes of the renderer
  49543. */
  49544. dispose(): void;
  49545. private _updateCamera;
  49546. }
  49547. }
  49548. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49549. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49551. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49552. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49553. import { Scene } from "babylonjs/scene";
  49554. import { Nullable } from "babylonjs/types";
  49555. import { Color3 } from "babylonjs/Maths/math.color";
  49556. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49557. /**
  49558. * Options interface for the pointer selection module
  49559. */
  49560. export interface IWebXRControllerPointerSelectionOptions {
  49561. /**
  49562. * if provided, this scene will be used to render meshes.
  49563. */
  49564. customUtilityLayerScene?: Scene;
  49565. /**
  49566. * 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)
  49567. * If not disabled, the last picked point will be used to execute a pointer up event
  49568. * If disabled, pointer up event will be triggered right after the pointer down event.
  49569. * Used in screen and gaze target ray mode only
  49570. */
  49571. disablePointerUpOnTouchOut: boolean;
  49572. /**
  49573. * For gaze mode (time to select instead of press)
  49574. */
  49575. forceGazeMode: boolean;
  49576. /**
  49577. * 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
  49578. * to start a new countdown to the pointer down event.
  49579. * Defaults to 1.
  49580. */
  49581. gazeModePointerMovedFactor?: number;
  49582. /**
  49583. * Different button type to use instead of the main component
  49584. */
  49585. overrideButtonId?: string;
  49586. /**
  49587. * use this rendering group id for the meshes (optional)
  49588. */
  49589. renderingGroupId?: number;
  49590. /**
  49591. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49592. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49593. * 3000 means 3 seconds between pointing at something and selecting it
  49594. */
  49595. timeToSelect?: number;
  49596. /**
  49597. * Should meshes created here be added to a utility layer or the main scene
  49598. */
  49599. useUtilityLayer?: boolean;
  49600. /**
  49601. * the xr input to use with this pointer selection
  49602. */
  49603. xrInput: WebXRInput;
  49604. }
  49605. /**
  49606. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49607. */
  49608. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49609. private readonly _options;
  49610. private static _idCounter;
  49611. private _attachController;
  49612. private _controllers;
  49613. private _scene;
  49614. private _tmpVectorForPickCompare;
  49615. /**
  49616. * The module's name
  49617. */
  49618. static readonly Name: string;
  49619. /**
  49620. * The (Babylon) version of this module.
  49621. * This is an integer representing the implementation version.
  49622. * This number does not correspond to the WebXR specs version
  49623. */
  49624. static readonly Version: number;
  49625. /**
  49626. * Disable lighting on the laser pointer (so it will always be visible)
  49627. */
  49628. disablePointerLighting: boolean;
  49629. /**
  49630. * Disable lighting on the selection mesh (so it will always be visible)
  49631. */
  49632. disableSelectionMeshLighting: boolean;
  49633. /**
  49634. * Should the laser pointer be displayed
  49635. */
  49636. displayLaserPointer: boolean;
  49637. /**
  49638. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49639. */
  49640. displaySelectionMesh: boolean;
  49641. /**
  49642. * This color will be set to the laser pointer when selection is triggered
  49643. */
  49644. laserPointerPickedColor: Color3;
  49645. /**
  49646. * Default color of the laser pointer
  49647. */
  49648. laserPointerDefaultColor: Color3;
  49649. /**
  49650. * default color of the selection ring
  49651. */
  49652. selectionMeshDefaultColor: Color3;
  49653. /**
  49654. * This color will be applied to the selection ring when selection is triggered
  49655. */
  49656. selectionMeshPickedColor: Color3;
  49657. /**
  49658. * Optional filter to be used for ray selection. This predicate shares behavior with
  49659. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49660. */
  49661. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49662. /**
  49663. * constructs a new background remover module
  49664. * @param _xrSessionManager the session manager for this module
  49665. * @param _options read-only options to be used in this module
  49666. */
  49667. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49668. /**
  49669. * attach this feature
  49670. * Will usually be called by the features manager
  49671. *
  49672. * @returns true if successful.
  49673. */
  49674. attach(): boolean;
  49675. /**
  49676. * detach this feature.
  49677. * Will usually be called by the features manager
  49678. *
  49679. * @returns true if successful.
  49680. */
  49681. detach(): boolean;
  49682. /**
  49683. * Will get the mesh under a specific pointer.
  49684. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49685. * @param controllerId the controllerId to check
  49686. * @returns The mesh under pointer or null if no mesh is under the pointer
  49687. */
  49688. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49689. /**
  49690. * Get the xr controller that correlates to the pointer id in the pointer event
  49691. *
  49692. * @param id the pointer id to search for
  49693. * @returns the controller that correlates to this id or null if not found
  49694. */
  49695. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49696. protected _onXRFrame(_xrFrame: XRFrame): void;
  49697. private _attachGazeMode;
  49698. private _attachScreenRayMode;
  49699. private _attachTrackedPointerRayMode;
  49700. private _convertNormalToDirectionOfRay;
  49701. private _detachController;
  49702. private _generateNewMeshPair;
  49703. private _pickingMoved;
  49704. private _updatePointerDistance;
  49705. /** @hidden */
  49706. get lasterPointerDefaultColor(): Color3;
  49707. }
  49708. }
  49709. declare module "babylonjs/XR/webXREnterExitUI" {
  49710. import { Nullable } from "babylonjs/types";
  49711. import { Observable } from "babylonjs/Misc/observable";
  49712. import { IDisposable, Scene } from "babylonjs/scene";
  49713. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49714. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49715. /**
  49716. * Button which can be used to enter a different mode of XR
  49717. */
  49718. export class WebXREnterExitUIButton {
  49719. /** button element */
  49720. element: HTMLElement;
  49721. /** XR initialization options for the button */
  49722. sessionMode: XRSessionMode;
  49723. /** Reference space type */
  49724. referenceSpaceType: XRReferenceSpaceType;
  49725. /**
  49726. * Creates a WebXREnterExitUIButton
  49727. * @param element button element
  49728. * @param sessionMode XR initialization session mode
  49729. * @param referenceSpaceType the type of reference space to be used
  49730. */
  49731. constructor(
  49732. /** button element */
  49733. element: HTMLElement,
  49734. /** XR initialization options for the button */
  49735. sessionMode: XRSessionMode,
  49736. /** Reference space type */
  49737. referenceSpaceType: XRReferenceSpaceType);
  49738. /**
  49739. * Extendable function which can be used to update the button's visuals when the state changes
  49740. * @param activeButton the current active button in the UI
  49741. */
  49742. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49743. }
  49744. /**
  49745. * Options to create the webXR UI
  49746. */
  49747. export class WebXREnterExitUIOptions {
  49748. /**
  49749. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49750. */
  49751. customButtons?: Array<WebXREnterExitUIButton>;
  49752. /**
  49753. * A reference space type to use when creating the default button.
  49754. * Default is local-floor
  49755. */
  49756. referenceSpaceType?: XRReferenceSpaceType;
  49757. /**
  49758. * Context to enter xr with
  49759. */
  49760. renderTarget?: Nullable<WebXRRenderTarget>;
  49761. /**
  49762. * A session mode to use when creating the default button.
  49763. * Default is immersive-vr
  49764. */
  49765. sessionMode?: XRSessionMode;
  49766. /**
  49767. * A list of optional features to init the session with
  49768. */
  49769. optionalFeatures?: string[];
  49770. }
  49771. /**
  49772. * UI to allow the user to enter/exit XR mode
  49773. */
  49774. export class WebXREnterExitUI implements IDisposable {
  49775. private scene;
  49776. /** version of the options passed to this UI */
  49777. options: WebXREnterExitUIOptions;
  49778. private _activeButton;
  49779. private _buttons;
  49780. private _overlay;
  49781. /**
  49782. * Fired every time the active button is changed.
  49783. *
  49784. * When xr is entered via a button that launches xr that button will be the callback parameter
  49785. *
  49786. * When exiting xr the callback parameter will be null)
  49787. */
  49788. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49789. /**
  49790. *
  49791. * @param scene babylon scene object to use
  49792. * @param options (read-only) version of the options passed to this UI
  49793. */
  49794. private constructor();
  49795. /**
  49796. * Creates UI to allow the user to enter/exit XR mode
  49797. * @param scene the scene to add the ui to
  49798. * @param helper the xr experience helper to enter/exit xr with
  49799. * @param options options to configure the UI
  49800. * @returns the created ui
  49801. */
  49802. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49803. /**
  49804. * Disposes of the XR UI component
  49805. */
  49806. dispose(): void;
  49807. private _updateButtons;
  49808. }
  49809. }
  49810. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  49811. import { Vector3 } from "babylonjs/Maths/math.vector";
  49812. import { Color4 } from "babylonjs/Maths/math.color";
  49813. import { Nullable } from "babylonjs/types";
  49814. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49815. import { Scene } from "babylonjs/scene";
  49816. /**
  49817. * Class containing static functions to help procedurally build meshes
  49818. */
  49819. export class LinesBuilder {
  49820. /**
  49821. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49822. * * 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
  49823. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49824. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49825. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49826. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49827. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49828. * * 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
  49829. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49831. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49832. * @param name defines the name of the new line system
  49833. * @param options defines the options used to create the line system
  49834. * @param scene defines the hosting scene
  49835. * @returns a new line system mesh
  49836. */
  49837. static CreateLineSystem(name: string, options: {
  49838. lines: Vector3[][];
  49839. updatable?: boolean;
  49840. instance?: Nullable<LinesMesh>;
  49841. colors?: Nullable<Color4[][]>;
  49842. useVertexAlpha?: boolean;
  49843. }, scene: Nullable<Scene>): LinesMesh;
  49844. /**
  49845. * Creates a line mesh
  49846. * 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
  49847. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49848. * * The parameter `points` is an array successive Vector3
  49849. * * 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
  49850. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49851. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49852. * * When updating an instance, remember that only point positions can change, not the number of points
  49853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49855. * @param name defines the name of the new line system
  49856. * @param options defines the options used to create the line system
  49857. * @param scene defines the hosting scene
  49858. * @returns a new line mesh
  49859. */
  49860. static CreateLines(name: string, options: {
  49861. points: Vector3[];
  49862. updatable?: boolean;
  49863. instance?: Nullable<LinesMesh>;
  49864. colors?: Color4[];
  49865. useVertexAlpha?: boolean;
  49866. }, scene?: Nullable<Scene>): LinesMesh;
  49867. /**
  49868. * Creates a dashed line mesh
  49869. * * 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
  49870. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49871. * * The parameter `points` is an array successive Vector3
  49872. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49873. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49874. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49875. * * 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
  49876. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49877. * * When updating an instance, remember that only point positions can change, not the number of points
  49878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49879. * @param name defines the name of the mesh
  49880. * @param options defines the options used to create the mesh
  49881. * @param scene defines the hosting scene
  49882. * @returns the dashed line mesh
  49883. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49884. */
  49885. static CreateDashedLines(name: string, options: {
  49886. points: Vector3[];
  49887. dashSize?: number;
  49888. gapSize?: number;
  49889. dashNb?: number;
  49890. updatable?: boolean;
  49891. instance?: LinesMesh;
  49892. useVertexAlpha?: boolean;
  49893. }, scene?: Nullable<Scene>): LinesMesh;
  49894. }
  49895. }
  49896. declare module "babylonjs/Misc/timer" {
  49897. import { Observable, Observer } from "babylonjs/Misc/observable";
  49898. import { Nullable } from "babylonjs/types";
  49899. import { IDisposable } from "babylonjs/scene";
  49900. /**
  49901. * Construction options for a timer
  49902. */
  49903. export interface ITimerOptions<T> {
  49904. /**
  49905. * Time-to-end
  49906. */
  49907. timeout: number;
  49908. /**
  49909. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49910. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49911. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49912. */
  49913. contextObservable: Observable<T>;
  49914. /**
  49915. * Optional parameters when adding an observer to the observable
  49916. */
  49917. observableParameters?: {
  49918. mask?: number;
  49919. insertFirst?: boolean;
  49920. scope?: any;
  49921. };
  49922. /**
  49923. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49924. */
  49925. breakCondition?: (data?: ITimerData<T>) => boolean;
  49926. /**
  49927. * Will be triggered when the time condition has met
  49928. */
  49929. onEnded?: (data: ITimerData<any>) => void;
  49930. /**
  49931. * Will be triggered when the break condition has met (prematurely ended)
  49932. */
  49933. onAborted?: (data: ITimerData<any>) => void;
  49934. /**
  49935. * Optional function to execute on each tick (or count)
  49936. */
  49937. onTick?: (data: ITimerData<any>) => void;
  49938. }
  49939. /**
  49940. * An interface defining the data sent by the timer
  49941. */
  49942. export interface ITimerData<T> {
  49943. /**
  49944. * When did it start
  49945. */
  49946. startTime: number;
  49947. /**
  49948. * Time now
  49949. */
  49950. currentTime: number;
  49951. /**
  49952. * Time passed since started
  49953. */
  49954. deltaTime: number;
  49955. /**
  49956. * How much is completed, in [0.0...1.0].
  49957. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49958. */
  49959. completeRate: number;
  49960. /**
  49961. * What the registered observable sent in the last count
  49962. */
  49963. payload: T;
  49964. }
  49965. /**
  49966. * The current state of the timer
  49967. */
  49968. export enum TimerState {
  49969. /**
  49970. * Timer initialized, not yet started
  49971. */
  49972. INIT = 0,
  49973. /**
  49974. * Timer started and counting
  49975. */
  49976. STARTED = 1,
  49977. /**
  49978. * Timer ended (whether aborted or time reached)
  49979. */
  49980. ENDED = 2
  49981. }
  49982. /**
  49983. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49984. *
  49985. * @param options options with which to initialize this timer
  49986. */
  49987. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49988. /**
  49989. * An advanced implementation of a timer class
  49990. */
  49991. export class AdvancedTimer<T = any> implements IDisposable {
  49992. /**
  49993. * Will notify each time the timer calculates the remaining time
  49994. */
  49995. onEachCountObservable: Observable<ITimerData<T>>;
  49996. /**
  49997. * Will trigger when the timer was aborted due to the break condition
  49998. */
  49999. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50000. /**
  50001. * Will trigger when the timer ended successfully
  50002. */
  50003. onTimerEndedObservable: Observable<ITimerData<T>>;
  50004. /**
  50005. * Will trigger when the timer state has changed
  50006. */
  50007. onStateChangedObservable: Observable<TimerState>;
  50008. private _observer;
  50009. private _contextObservable;
  50010. private _observableParameters;
  50011. private _startTime;
  50012. private _timer;
  50013. private _state;
  50014. private _breakCondition;
  50015. private _timeToEnd;
  50016. private _breakOnNextTick;
  50017. /**
  50018. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50019. * @param options construction options for this advanced timer
  50020. */
  50021. constructor(options: ITimerOptions<T>);
  50022. /**
  50023. * set a breaking condition for this timer. Default is to never break during count
  50024. * @param predicate the new break condition. Returns true to break, false otherwise
  50025. */
  50026. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50027. /**
  50028. * Reset ALL associated observables in this advanced timer
  50029. */
  50030. clearObservables(): void;
  50031. /**
  50032. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50033. *
  50034. * @param timeToEnd how much time to measure until timer ended
  50035. */
  50036. start(timeToEnd?: number): void;
  50037. /**
  50038. * Will force a stop on the next tick.
  50039. */
  50040. stop(): void;
  50041. /**
  50042. * Dispose this timer, clearing all resources
  50043. */
  50044. dispose(): void;
  50045. private _setState;
  50046. private _tick;
  50047. private _stop;
  50048. }
  50049. }
  50050. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50051. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50052. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50053. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50055. import { Vector3 } from "babylonjs/Maths/math.vector";
  50056. import { Material } from "babylonjs/Materials/material";
  50057. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50058. import { Scene } from "babylonjs/scene";
  50059. /**
  50060. * The options container for the teleportation module
  50061. */
  50062. export interface IWebXRTeleportationOptions {
  50063. /**
  50064. * if provided, this scene will be used to render meshes.
  50065. */
  50066. customUtilityLayerScene?: Scene;
  50067. /**
  50068. * Values to configure the default target mesh
  50069. */
  50070. defaultTargetMeshOptions?: {
  50071. /**
  50072. * Fill color of the teleportation area
  50073. */
  50074. teleportationFillColor?: string;
  50075. /**
  50076. * Border color for the teleportation area
  50077. */
  50078. teleportationBorderColor?: string;
  50079. /**
  50080. * Disable the mesh's animation sequence
  50081. */
  50082. disableAnimation?: boolean;
  50083. /**
  50084. * Disable lighting on the material or the ring and arrow
  50085. */
  50086. disableLighting?: boolean;
  50087. /**
  50088. * Override the default material of the torus and arrow
  50089. */
  50090. torusArrowMaterial?: Material;
  50091. };
  50092. /**
  50093. * A list of meshes to use as floor meshes.
  50094. * Meshes can be added and removed after initializing the feature using the
  50095. * addFloorMesh and removeFloorMesh functions
  50096. * If empty, rotation will still work
  50097. */
  50098. floorMeshes?: AbstractMesh[];
  50099. /**
  50100. * use this rendering group id for the meshes (optional)
  50101. */
  50102. renderingGroupId?: number;
  50103. /**
  50104. * Should teleportation move only to snap points
  50105. */
  50106. snapPointsOnly?: boolean;
  50107. /**
  50108. * An array of points to which the teleportation will snap to.
  50109. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50110. */
  50111. snapPositions?: Vector3[];
  50112. /**
  50113. * How close should the teleportation ray be in order to snap to position.
  50114. * Default to 0.8 units (meters)
  50115. */
  50116. snapToPositionRadius?: number;
  50117. /**
  50118. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50119. * If you want to support rotation, make sure your mesh has a direction indicator.
  50120. *
  50121. * When left untouched, the default mesh will be initialized.
  50122. */
  50123. teleportationTargetMesh?: AbstractMesh;
  50124. /**
  50125. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50126. */
  50127. timeToTeleport?: number;
  50128. /**
  50129. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50130. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50131. */
  50132. useMainComponentOnly?: boolean;
  50133. /**
  50134. * Should meshes created here be added to a utility layer or the main scene
  50135. */
  50136. useUtilityLayer?: boolean;
  50137. /**
  50138. * Babylon XR Input class for controller
  50139. */
  50140. xrInput: WebXRInput;
  50141. }
  50142. /**
  50143. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50144. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50145. * the input of the attached controllers.
  50146. */
  50147. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50148. private _options;
  50149. private _controllers;
  50150. private _currentTeleportationControllerId;
  50151. private _floorMeshes;
  50152. private _quadraticBezierCurve;
  50153. private _selectionFeature;
  50154. private _snapToPositions;
  50155. private _snappedToPoint;
  50156. private _teleportationRingMaterial?;
  50157. private _tmpRay;
  50158. private _tmpVector;
  50159. /**
  50160. * The module's name
  50161. */
  50162. static readonly Name: string;
  50163. /**
  50164. * The (Babylon) version of this module.
  50165. * This is an integer representing the implementation version.
  50166. * This number does not correspond to the webxr specs version
  50167. */
  50168. static readonly Version: number;
  50169. /**
  50170. * Is movement backwards enabled
  50171. */
  50172. backwardsMovementEnabled: boolean;
  50173. /**
  50174. * Distance to travel when moving backwards
  50175. */
  50176. backwardsTeleportationDistance: number;
  50177. /**
  50178. * The distance from the user to the inspection point in the direction of the controller
  50179. * A higher number will allow the user to move further
  50180. * defaults to 5 (meters, in xr units)
  50181. */
  50182. parabolicCheckRadius: number;
  50183. /**
  50184. * Should the module support parabolic ray on top of direct ray
  50185. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50186. * Very helpful when moving between floors / different heights
  50187. */
  50188. parabolicRayEnabled: boolean;
  50189. /**
  50190. * How much rotation should be applied when rotating right and left
  50191. */
  50192. rotationAngle: number;
  50193. /**
  50194. * Is rotation enabled when moving forward?
  50195. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50196. */
  50197. rotationEnabled: boolean;
  50198. /**
  50199. * constructs a new anchor system
  50200. * @param _xrSessionManager an instance of WebXRSessionManager
  50201. * @param _options configuration object for this feature
  50202. */
  50203. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50204. /**
  50205. * Get the snapPointsOnly flag
  50206. */
  50207. get snapPointsOnly(): boolean;
  50208. /**
  50209. * Sets the snapPointsOnly flag
  50210. * @param snapToPoints should teleportation be exclusively to snap points
  50211. */
  50212. set snapPointsOnly(snapToPoints: boolean);
  50213. /**
  50214. * Add a new mesh to the floor meshes array
  50215. * @param mesh the mesh to use as floor mesh
  50216. */
  50217. addFloorMesh(mesh: AbstractMesh): void;
  50218. /**
  50219. * Add a new snap-to point to fix teleportation to this position
  50220. * @param newSnapPoint The new Snap-To point
  50221. */
  50222. addSnapPoint(newSnapPoint: Vector3): void;
  50223. attach(): boolean;
  50224. detach(): boolean;
  50225. dispose(): void;
  50226. /**
  50227. * Remove a mesh from the floor meshes array
  50228. * @param mesh the mesh to remove
  50229. */
  50230. removeFloorMesh(mesh: AbstractMesh): void;
  50231. /**
  50232. * Remove a mesh from the floor meshes array using its name
  50233. * @param name the mesh name to remove
  50234. */
  50235. removeFloorMeshByName(name: string): void;
  50236. /**
  50237. * 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
  50238. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50239. * @returns was the point found and removed or not
  50240. */
  50241. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50242. /**
  50243. * This function sets a selection feature that will be disabled when
  50244. * the forward ray is shown and will be reattached when hidden.
  50245. * This is used to remove the selection rays when moving.
  50246. * @param selectionFeature the feature to disable when forward movement is enabled
  50247. */
  50248. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50249. protected _onXRFrame(_xrFrame: XRFrame): void;
  50250. private _attachController;
  50251. private _createDefaultTargetMesh;
  50252. private _detachController;
  50253. private _findClosestSnapPointWithRadius;
  50254. private _setTargetMeshPosition;
  50255. private _setTargetMeshVisibility;
  50256. private _showParabolicPath;
  50257. private _teleportForward;
  50258. }
  50259. }
  50260. declare module "babylonjs/XR/webXRDefaultExperience" {
  50261. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50262. import { Scene } from "babylonjs/scene";
  50263. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50264. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50265. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50266. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50268. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50269. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50270. /**
  50271. * Options for the default xr helper
  50272. */
  50273. export class WebXRDefaultExperienceOptions {
  50274. /**
  50275. * Enable or disable default UI to enter XR
  50276. */
  50277. disableDefaultUI?: boolean;
  50278. /**
  50279. * Should teleportation not initialize. defaults to false.
  50280. */
  50281. disableTeleportation?: boolean;
  50282. /**
  50283. * Floor meshes that will be used for teleport
  50284. */
  50285. floorMeshes?: Array<AbstractMesh>;
  50286. /**
  50287. * If set to true, the first frame will not be used to reset position
  50288. * The first frame is mainly used when copying transformation from the old camera
  50289. * Mainly used in AR
  50290. */
  50291. ignoreNativeCameraTransformation?: boolean;
  50292. /**
  50293. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50294. */
  50295. inputOptions?: IWebXRInputOptions;
  50296. /**
  50297. * optional configuration for the output canvas
  50298. */
  50299. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50300. /**
  50301. * optional UI options. This can be used among other to change session mode and reference space type
  50302. */
  50303. uiOptions?: WebXREnterExitUIOptions;
  50304. /**
  50305. * When loading teleportation and pointer select, use stable versions instead of latest.
  50306. */
  50307. useStablePlugins?: boolean;
  50308. /**
  50309. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50310. */
  50311. renderingGroupId?: number;
  50312. /**
  50313. * A list of optional features to init the session with
  50314. * If set to true, all features we support will be added
  50315. */
  50316. optionalFeatures?: boolean | string[];
  50317. }
  50318. /**
  50319. * Default experience which provides a similar setup to the previous webVRExperience
  50320. */
  50321. export class WebXRDefaultExperience {
  50322. /**
  50323. * Base experience
  50324. */
  50325. baseExperience: WebXRExperienceHelper;
  50326. /**
  50327. * Enables ui for entering/exiting xr
  50328. */
  50329. enterExitUI: WebXREnterExitUI;
  50330. /**
  50331. * Input experience extension
  50332. */
  50333. input: WebXRInput;
  50334. /**
  50335. * Enables laser pointer and selection
  50336. */
  50337. pointerSelection: WebXRControllerPointerSelection;
  50338. /**
  50339. * Default target xr should render to
  50340. */
  50341. renderTarget: WebXRRenderTarget;
  50342. /**
  50343. * Enables teleportation
  50344. */
  50345. teleportation: WebXRMotionControllerTeleportation;
  50346. private constructor();
  50347. /**
  50348. * Creates the default xr experience
  50349. * @param scene scene
  50350. * @param options options for basic configuration
  50351. * @returns resulting WebXRDefaultExperience
  50352. */
  50353. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50354. /**
  50355. * DIsposes of the experience helper
  50356. */
  50357. dispose(): void;
  50358. }
  50359. }
  50360. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50361. import { Observable } from "babylonjs/Misc/observable";
  50362. import { Nullable } from "babylonjs/types";
  50363. import { Camera } from "babylonjs/Cameras/camera";
  50364. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50365. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50366. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50367. import { Scene } from "babylonjs/scene";
  50368. import { Vector3 } from "babylonjs/Maths/math.vector";
  50369. import { Color3 } from "babylonjs/Maths/math.color";
  50370. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50372. import { Mesh } from "babylonjs/Meshes/mesh";
  50373. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50374. import { EasingFunction } from "babylonjs/Animations/easing";
  50375. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50376. import "babylonjs/Meshes/Builders/groundBuilder";
  50377. import "babylonjs/Meshes/Builders/torusBuilder";
  50378. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50379. import "babylonjs/Gamepads/gamepadSceneComponent";
  50380. import "babylonjs/Animations/animatable";
  50381. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50382. /**
  50383. * Options to modify the vr teleportation behavior.
  50384. */
  50385. export interface VRTeleportationOptions {
  50386. /**
  50387. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50388. */
  50389. floorMeshName?: string;
  50390. /**
  50391. * A list of meshes to be used as the teleportation floor. (default: empty)
  50392. */
  50393. floorMeshes?: Mesh[];
  50394. /**
  50395. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50396. */
  50397. teleportationMode?: number;
  50398. /**
  50399. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50400. */
  50401. teleportationTime?: number;
  50402. /**
  50403. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50404. */
  50405. teleportationSpeed?: number;
  50406. /**
  50407. * The easing function used in the animation or null for Linear. (default CircleEase)
  50408. */
  50409. easingFunction?: EasingFunction;
  50410. }
  50411. /**
  50412. * Options to modify the vr experience helper's behavior.
  50413. */
  50414. export interface VRExperienceHelperOptions extends WebVROptions {
  50415. /**
  50416. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50417. */
  50418. createDeviceOrientationCamera?: boolean;
  50419. /**
  50420. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50421. */
  50422. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50423. /**
  50424. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50425. */
  50426. laserToggle?: boolean;
  50427. /**
  50428. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50429. */
  50430. floorMeshes?: Mesh[];
  50431. /**
  50432. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50433. */
  50434. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50435. /**
  50436. * Defines if WebXR should be used instead of WebVR (if available)
  50437. */
  50438. useXR?: boolean;
  50439. }
  50440. /**
  50441. * Event containing information after VR has been entered
  50442. */
  50443. export class OnAfterEnteringVRObservableEvent {
  50444. /**
  50445. * If entering vr was successful
  50446. */
  50447. success: boolean;
  50448. }
  50449. /**
  50450. * Helps to quickly add VR support to an existing scene.
  50451. * See http://doc.babylonjs.com/how_to/webvr_helper
  50452. */
  50453. export class VRExperienceHelper {
  50454. /** Options to modify the vr experience helper's behavior. */
  50455. webVROptions: VRExperienceHelperOptions;
  50456. private _scene;
  50457. private _position;
  50458. private _btnVR;
  50459. private _btnVRDisplayed;
  50460. private _webVRsupported;
  50461. private _webVRready;
  50462. private _webVRrequesting;
  50463. private _webVRpresenting;
  50464. private _hasEnteredVR;
  50465. private _fullscreenVRpresenting;
  50466. private _inputElement;
  50467. private _webVRCamera;
  50468. private _vrDeviceOrientationCamera;
  50469. private _deviceOrientationCamera;
  50470. private _existingCamera;
  50471. private _onKeyDown;
  50472. private _onVrDisplayPresentChange;
  50473. private _onVRDisplayChanged;
  50474. private _onVRRequestPresentStart;
  50475. private _onVRRequestPresentComplete;
  50476. /**
  50477. * 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)
  50478. */
  50479. enableGazeEvenWhenNoPointerLock: boolean;
  50480. /**
  50481. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50482. */
  50483. exitVROnDoubleTap: boolean;
  50484. /**
  50485. * Observable raised right before entering VR.
  50486. */
  50487. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50488. /**
  50489. * Observable raised when entering VR has completed.
  50490. */
  50491. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50492. /**
  50493. * Observable raised when exiting VR.
  50494. */
  50495. onExitingVRObservable: Observable<VRExperienceHelper>;
  50496. /**
  50497. * Observable raised when controller mesh is loaded.
  50498. */
  50499. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50500. /** Return this.onEnteringVRObservable
  50501. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50502. */
  50503. get onEnteringVR(): Observable<VRExperienceHelper>;
  50504. /** Return this.onExitingVRObservable
  50505. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50506. */
  50507. get onExitingVR(): Observable<VRExperienceHelper>;
  50508. /** Return this.onControllerMeshLoadedObservable
  50509. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50510. */
  50511. get onControllerMeshLoaded(): Observable<WebVRController>;
  50512. private _rayLength;
  50513. private _useCustomVRButton;
  50514. private _teleportationRequested;
  50515. private _teleportActive;
  50516. private _floorMeshName;
  50517. private _floorMeshesCollection;
  50518. private _teleportationMode;
  50519. private _teleportationTime;
  50520. private _teleportationSpeed;
  50521. private _teleportationEasing;
  50522. private _rotationAllowed;
  50523. private _teleportBackwardsVector;
  50524. private _teleportationTarget;
  50525. private _isDefaultTeleportationTarget;
  50526. private _postProcessMove;
  50527. private _teleportationFillColor;
  50528. private _teleportationBorderColor;
  50529. private _rotationAngle;
  50530. private _haloCenter;
  50531. private _cameraGazer;
  50532. private _padSensibilityUp;
  50533. private _padSensibilityDown;
  50534. private _leftController;
  50535. private _rightController;
  50536. private _gazeColor;
  50537. private _laserColor;
  50538. private _pickedLaserColor;
  50539. private _pickedGazeColor;
  50540. /**
  50541. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50542. */
  50543. onNewMeshSelected: Observable<AbstractMesh>;
  50544. /**
  50545. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50546. * This observable will provide the mesh and the controller used to select the mesh
  50547. */
  50548. onMeshSelectedWithController: Observable<{
  50549. mesh: AbstractMesh;
  50550. controller: WebVRController;
  50551. }>;
  50552. /**
  50553. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50554. */
  50555. onNewMeshPicked: Observable<PickingInfo>;
  50556. private _circleEase;
  50557. /**
  50558. * Observable raised before camera teleportation
  50559. */
  50560. onBeforeCameraTeleport: Observable<Vector3>;
  50561. /**
  50562. * Observable raised after camera teleportation
  50563. */
  50564. onAfterCameraTeleport: Observable<Vector3>;
  50565. /**
  50566. * Observable raised when current selected mesh gets unselected
  50567. */
  50568. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50569. private _raySelectionPredicate;
  50570. /**
  50571. * To be optionaly changed by user to define custom ray selection
  50572. */
  50573. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50574. /**
  50575. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50576. */
  50577. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50578. /**
  50579. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50580. */
  50581. teleportationEnabled: boolean;
  50582. private _defaultHeight;
  50583. private _teleportationInitialized;
  50584. private _interactionsEnabled;
  50585. private _interactionsRequested;
  50586. private _displayGaze;
  50587. private _displayLaserPointer;
  50588. /**
  50589. * The mesh used to display where the user is going to teleport.
  50590. */
  50591. get teleportationTarget(): Mesh;
  50592. /**
  50593. * Sets the mesh to be used to display where the user is going to teleport.
  50594. */
  50595. set teleportationTarget(value: Mesh);
  50596. /**
  50597. * 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
  50598. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50599. * See http://doc.babylonjs.com/resources/baking_transformations
  50600. */
  50601. get gazeTrackerMesh(): Mesh;
  50602. set gazeTrackerMesh(value: Mesh);
  50603. /**
  50604. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50605. */
  50606. updateGazeTrackerScale: boolean;
  50607. /**
  50608. * If the gaze trackers color should be updated when selecting meshes
  50609. */
  50610. updateGazeTrackerColor: boolean;
  50611. /**
  50612. * If the controller laser color should be updated when selecting meshes
  50613. */
  50614. updateControllerLaserColor: boolean;
  50615. /**
  50616. * The gaze tracking mesh corresponding to the left controller
  50617. */
  50618. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50619. /**
  50620. * The gaze tracking mesh corresponding to the right controller
  50621. */
  50622. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50623. /**
  50624. * If the ray of the gaze should be displayed.
  50625. */
  50626. get displayGaze(): boolean;
  50627. /**
  50628. * Sets if the ray of the gaze should be displayed.
  50629. */
  50630. set displayGaze(value: boolean);
  50631. /**
  50632. * If the ray of the LaserPointer should be displayed.
  50633. */
  50634. get displayLaserPointer(): boolean;
  50635. /**
  50636. * Sets if the ray of the LaserPointer should be displayed.
  50637. */
  50638. set displayLaserPointer(value: boolean);
  50639. /**
  50640. * The deviceOrientationCamera used as the camera when not in VR.
  50641. */
  50642. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50643. /**
  50644. * Based on the current WebVR support, returns the current VR camera used.
  50645. */
  50646. get currentVRCamera(): Nullable<Camera>;
  50647. /**
  50648. * The webVRCamera which is used when in VR.
  50649. */
  50650. get webVRCamera(): WebVRFreeCamera;
  50651. /**
  50652. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50653. */
  50654. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50655. /**
  50656. * The html button that is used to trigger entering into VR.
  50657. */
  50658. get vrButton(): Nullable<HTMLButtonElement>;
  50659. private get _teleportationRequestInitiated();
  50660. /**
  50661. * Defines whether or not Pointer lock should be requested when switching to
  50662. * full screen.
  50663. */
  50664. requestPointerLockOnFullScreen: boolean;
  50665. /**
  50666. * If asking to force XR, this will be populated with the default xr experience
  50667. */
  50668. xr: WebXRDefaultExperience;
  50669. /**
  50670. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50671. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50672. */
  50673. xrTestDone: boolean;
  50674. /**
  50675. * Instantiates a VRExperienceHelper.
  50676. * Helps to quickly add VR support to an existing scene.
  50677. * @param scene The scene the VRExperienceHelper belongs to.
  50678. * @param webVROptions Options to modify the vr experience helper's behavior.
  50679. */
  50680. constructor(scene: Scene,
  50681. /** Options to modify the vr experience helper's behavior. */
  50682. webVROptions?: VRExperienceHelperOptions);
  50683. private completeVRInit;
  50684. private _onDefaultMeshLoaded;
  50685. private _onResize;
  50686. private _onFullscreenChange;
  50687. /**
  50688. * Gets a value indicating if we are currently in VR mode.
  50689. */
  50690. get isInVRMode(): boolean;
  50691. private onVrDisplayPresentChange;
  50692. private onVRDisplayChanged;
  50693. private moveButtonToBottomRight;
  50694. private displayVRButton;
  50695. private updateButtonVisibility;
  50696. private _cachedAngularSensibility;
  50697. /**
  50698. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50699. * Otherwise, will use the fullscreen API.
  50700. */
  50701. enterVR(): void;
  50702. /**
  50703. * Attempt to exit VR, or fullscreen.
  50704. */
  50705. exitVR(): void;
  50706. /**
  50707. * The position of the vr experience helper.
  50708. */
  50709. get position(): Vector3;
  50710. /**
  50711. * Sets the position of the vr experience helper.
  50712. */
  50713. set position(value: Vector3);
  50714. /**
  50715. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50716. */
  50717. enableInteractions(): void;
  50718. private get _noControllerIsActive();
  50719. private beforeRender;
  50720. private _isTeleportationFloor;
  50721. /**
  50722. * Adds a floor mesh to be used for teleportation.
  50723. * @param floorMesh the mesh to be used for teleportation.
  50724. */
  50725. addFloorMesh(floorMesh: Mesh): void;
  50726. /**
  50727. * Removes a floor mesh from being used for teleportation.
  50728. * @param floorMesh the mesh to be removed.
  50729. */
  50730. removeFloorMesh(floorMesh: Mesh): void;
  50731. /**
  50732. * Enables interactions and teleportation using the VR controllers and gaze.
  50733. * @param vrTeleportationOptions options to modify teleportation behavior.
  50734. */
  50735. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50736. private _onNewGamepadConnected;
  50737. private _tryEnableInteractionOnController;
  50738. private _onNewGamepadDisconnected;
  50739. private _enableInteractionOnController;
  50740. private _checkTeleportWithRay;
  50741. private _checkRotate;
  50742. private _checkTeleportBackwards;
  50743. private _enableTeleportationOnController;
  50744. private _createTeleportationCircles;
  50745. private _displayTeleportationTarget;
  50746. private _hideTeleportationTarget;
  50747. private _rotateCamera;
  50748. private _moveTeleportationSelectorTo;
  50749. private _workingVector;
  50750. private _workingQuaternion;
  50751. private _workingMatrix;
  50752. /**
  50753. * Time Constant Teleportation Mode
  50754. */
  50755. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50756. /**
  50757. * Speed Constant Teleportation Mode
  50758. */
  50759. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50760. /**
  50761. * Teleports the users feet to the desired location
  50762. * @param location The location where the user's feet should be placed
  50763. */
  50764. teleportCamera(location: Vector3): void;
  50765. private _convertNormalToDirectionOfRay;
  50766. private _castRayAndSelectObject;
  50767. private _notifySelectedMeshUnselected;
  50768. /**
  50769. * Permanently set new colors for the laser pointer
  50770. * @param color the new laser color
  50771. * @param pickedColor the new laser color when picked mesh detected
  50772. */
  50773. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50774. /**
  50775. * Set lighting enabled / disabled on the laser pointer of both controllers
  50776. * @param enabled should the lighting be enabled on the laser pointer
  50777. */
  50778. setLaserLightingState(enabled?: boolean): void;
  50779. /**
  50780. * Permanently set new colors for the gaze pointer
  50781. * @param color the new gaze color
  50782. * @param pickedColor the new gaze color when picked mesh detected
  50783. */
  50784. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50785. /**
  50786. * Sets the color of the laser ray from the vr controllers.
  50787. * @param color new color for the ray.
  50788. */
  50789. changeLaserColor(color: Color3): void;
  50790. /**
  50791. * Sets the color of the ray from the vr headsets gaze.
  50792. * @param color new color for the ray.
  50793. */
  50794. changeGazeColor(color: Color3): void;
  50795. /**
  50796. * Exits VR and disposes of the vr experience helper
  50797. */
  50798. dispose(): void;
  50799. /**
  50800. * Gets the name of the VRExperienceHelper class
  50801. * @returns "VRExperienceHelper"
  50802. */
  50803. getClassName(): string;
  50804. }
  50805. }
  50806. declare module "babylonjs/Cameras/VR/index" {
  50807. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  50808. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  50809. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50810. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  50811. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  50812. export * from "babylonjs/Cameras/VR/webVRCamera";
  50813. }
  50814. declare module "babylonjs/Cameras/RigModes/index" {
  50815. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  50816. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  50817. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  50818. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  50819. }
  50820. declare module "babylonjs/Cameras/index" {
  50821. export * from "babylonjs/Cameras/Inputs/index";
  50822. export * from "babylonjs/Cameras/cameraInputsManager";
  50823. export * from "babylonjs/Cameras/camera";
  50824. export * from "babylonjs/Cameras/targetCamera";
  50825. export * from "babylonjs/Cameras/freeCamera";
  50826. export * from "babylonjs/Cameras/freeCameraInputsManager";
  50827. export * from "babylonjs/Cameras/touchCamera";
  50828. export * from "babylonjs/Cameras/arcRotateCamera";
  50829. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  50830. export * from "babylonjs/Cameras/deviceOrientationCamera";
  50831. export * from "babylonjs/Cameras/flyCamera";
  50832. export * from "babylonjs/Cameras/flyCameraInputsManager";
  50833. export * from "babylonjs/Cameras/followCamera";
  50834. export * from "babylonjs/Cameras/followCameraInputsManager";
  50835. export * from "babylonjs/Cameras/gamepadCamera";
  50836. export * from "babylonjs/Cameras/Stereoscopic/index";
  50837. export * from "babylonjs/Cameras/universalCamera";
  50838. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  50839. export * from "babylonjs/Cameras/VR/index";
  50840. export * from "babylonjs/Cameras/RigModes/index";
  50841. }
  50842. declare module "babylonjs/Collisions/index" {
  50843. export * from "babylonjs/Collisions/collider";
  50844. export * from "babylonjs/Collisions/collisionCoordinator";
  50845. export * from "babylonjs/Collisions/pickingInfo";
  50846. export * from "babylonjs/Collisions/intersectionInfo";
  50847. export * from "babylonjs/Collisions/meshCollisionData";
  50848. }
  50849. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  50850. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  50851. import { Vector3 } from "babylonjs/Maths/math.vector";
  50852. import { Ray } from "babylonjs/Culling/ray";
  50853. import { Plane } from "babylonjs/Maths/math.plane";
  50854. /**
  50855. * Contains an array of blocks representing the octree
  50856. */
  50857. export interface IOctreeContainer<T> {
  50858. /**
  50859. * Blocks within the octree
  50860. */
  50861. blocks: Array<OctreeBlock<T>>;
  50862. }
  50863. /**
  50864. * Class used to store a cell in an octree
  50865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50866. */
  50867. export class OctreeBlock<T> {
  50868. /**
  50869. * Gets the content of the current block
  50870. */
  50871. entries: T[];
  50872. /**
  50873. * Gets the list of block children
  50874. */
  50875. blocks: Array<OctreeBlock<T>>;
  50876. private _depth;
  50877. private _maxDepth;
  50878. private _capacity;
  50879. private _minPoint;
  50880. private _maxPoint;
  50881. private _boundingVectors;
  50882. private _creationFunc;
  50883. /**
  50884. * Creates a new block
  50885. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50886. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50887. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50888. * @param depth defines the current depth of this block in the octree
  50889. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50890. * @param creationFunc defines a callback to call when an element is added to the block
  50891. */
  50892. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50893. /**
  50894. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50895. */
  50896. get capacity(): number;
  50897. /**
  50898. * Gets the minimum vector (in world space) of the block's bounding box
  50899. */
  50900. get minPoint(): Vector3;
  50901. /**
  50902. * Gets the maximum vector (in world space) of the block's bounding box
  50903. */
  50904. get maxPoint(): Vector3;
  50905. /**
  50906. * Add a new element to this block
  50907. * @param entry defines the element to add
  50908. */
  50909. addEntry(entry: T): void;
  50910. /**
  50911. * Remove an element from this block
  50912. * @param entry defines the element to remove
  50913. */
  50914. removeEntry(entry: T): void;
  50915. /**
  50916. * Add an array of elements to this block
  50917. * @param entries defines the array of elements to add
  50918. */
  50919. addEntries(entries: T[]): void;
  50920. /**
  50921. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50922. * @param frustumPlanes defines the frustum planes to test
  50923. * @param selection defines the array to store current content if selection is positive
  50924. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50925. */
  50926. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50927. /**
  50928. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50929. * @param sphereCenter defines the bounding sphere center
  50930. * @param sphereRadius defines the bounding sphere radius
  50931. * @param selection defines the array to store current content if selection is positive
  50932. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50933. */
  50934. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50935. /**
  50936. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50937. * @param ray defines the ray to test with
  50938. * @param selection defines the array to store current content if selection is positive
  50939. */
  50940. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50941. /**
  50942. * Subdivide the content into child blocks (this block will then be empty)
  50943. */
  50944. createInnerBlocks(): void;
  50945. /**
  50946. * @hidden
  50947. */
  50948. 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;
  50949. }
  50950. }
  50951. declare module "babylonjs/Culling/Octrees/octree" {
  50952. import { SmartArray } from "babylonjs/Misc/smartArray";
  50953. import { Vector3 } from "babylonjs/Maths/math.vector";
  50954. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50955. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50956. import { Ray } from "babylonjs/Culling/ray";
  50957. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  50958. import { Plane } from "babylonjs/Maths/math.plane";
  50959. /**
  50960. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50961. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50962. */
  50963. export class Octree<T> {
  50964. /** 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.) */
  50965. maxDepth: number;
  50966. /**
  50967. * Blocks within the octree containing objects
  50968. */
  50969. blocks: Array<OctreeBlock<T>>;
  50970. /**
  50971. * Content stored in the octree
  50972. */
  50973. dynamicContent: T[];
  50974. private _maxBlockCapacity;
  50975. private _selectionContent;
  50976. private _creationFunc;
  50977. /**
  50978. * Creates a octree
  50979. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50980. * @param creationFunc function to be used to instatiate the octree
  50981. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50982. * @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.)
  50983. */
  50984. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50985. /** 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.) */
  50986. maxDepth?: number);
  50987. /**
  50988. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50989. * @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);
  50990. * @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);
  50991. * @param entries meshes to be added to the octree blocks
  50992. */
  50993. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50994. /**
  50995. * Adds a mesh to the octree
  50996. * @param entry Mesh to add to the octree
  50997. */
  50998. addMesh(entry: T): void;
  50999. /**
  51000. * Remove an element from the octree
  51001. * @param entry defines the element to remove
  51002. */
  51003. removeMesh(entry: T): void;
  51004. /**
  51005. * Selects an array of meshes within the frustum
  51006. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51007. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51008. * @returns array of meshes within the frustum
  51009. */
  51010. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51011. /**
  51012. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51013. * @param sphereCenter defines the bounding sphere center
  51014. * @param sphereRadius defines the bounding sphere radius
  51015. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51016. * @returns an array of objects that intersect the sphere
  51017. */
  51018. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51019. /**
  51020. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51021. * @param ray defines the ray to test with
  51022. * @returns array of intersected objects
  51023. */
  51024. intersectsRay(ray: Ray): SmartArray<T>;
  51025. /**
  51026. * Adds a mesh into the octree block if it intersects the block
  51027. */
  51028. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51029. /**
  51030. * Adds a submesh into the octree block if it intersects the block
  51031. */
  51032. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51033. }
  51034. }
  51035. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51036. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51037. import { Scene } from "babylonjs/scene";
  51038. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51040. import { Ray } from "babylonjs/Culling/ray";
  51041. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51042. import { Collider } from "babylonjs/Collisions/collider";
  51043. module "babylonjs/scene" {
  51044. interface Scene {
  51045. /**
  51046. * @hidden
  51047. * Backing Filed
  51048. */
  51049. _selectionOctree: Octree<AbstractMesh>;
  51050. /**
  51051. * Gets the octree used to boost mesh selection (picking)
  51052. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51053. */
  51054. selectionOctree: Octree<AbstractMesh>;
  51055. /**
  51056. * Creates or updates the octree used to boost selection (picking)
  51057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51058. * @param maxCapacity defines the maximum capacity per leaf
  51059. * @param maxDepth defines the maximum depth of the octree
  51060. * @returns an octree of AbstractMesh
  51061. */
  51062. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51063. }
  51064. }
  51065. module "babylonjs/Meshes/abstractMesh" {
  51066. interface AbstractMesh {
  51067. /**
  51068. * @hidden
  51069. * Backing Field
  51070. */
  51071. _submeshesOctree: Octree<SubMesh>;
  51072. /**
  51073. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51074. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51075. * @param maxCapacity defines the maximum size of each block (64 by default)
  51076. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51077. * @returns the new octree
  51078. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51080. */
  51081. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51082. }
  51083. }
  51084. /**
  51085. * Defines the octree scene component responsible to manage any octrees
  51086. * in a given scene.
  51087. */
  51088. export class OctreeSceneComponent {
  51089. /**
  51090. * The component name help to identify the component in the list of scene components.
  51091. */
  51092. readonly name: string;
  51093. /**
  51094. * The scene the component belongs to.
  51095. */
  51096. scene: Scene;
  51097. /**
  51098. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51099. */
  51100. readonly checksIsEnabled: boolean;
  51101. /**
  51102. * Creates a new instance of the component for the given scene
  51103. * @param scene Defines the scene to register the component in
  51104. */
  51105. constructor(scene: Scene);
  51106. /**
  51107. * Registers the component in a given scene
  51108. */
  51109. register(): void;
  51110. /**
  51111. * Return the list of active meshes
  51112. * @returns the list of active meshes
  51113. */
  51114. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51115. /**
  51116. * Return the list of active sub meshes
  51117. * @param mesh The mesh to get the candidates sub meshes from
  51118. * @returns the list of active sub meshes
  51119. */
  51120. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51121. private _tempRay;
  51122. /**
  51123. * Return the list of sub meshes intersecting with a given local ray
  51124. * @param mesh defines the mesh to find the submesh for
  51125. * @param localRay defines the ray in local space
  51126. * @returns the list of intersecting sub meshes
  51127. */
  51128. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51129. /**
  51130. * Return the list of sub meshes colliding with a collider
  51131. * @param mesh defines the mesh to find the submesh for
  51132. * @param collider defines the collider to evaluate the collision against
  51133. * @returns the list of colliding sub meshes
  51134. */
  51135. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51136. /**
  51137. * Rebuilds the elements related to this component in case of
  51138. * context lost for instance.
  51139. */
  51140. rebuild(): void;
  51141. /**
  51142. * Disposes the component and the associated ressources.
  51143. */
  51144. dispose(): void;
  51145. }
  51146. }
  51147. declare module "babylonjs/Culling/Octrees/index" {
  51148. export * from "babylonjs/Culling/Octrees/octree";
  51149. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51150. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51151. }
  51152. declare module "babylonjs/Culling/index" {
  51153. export * from "babylonjs/Culling/boundingBox";
  51154. export * from "babylonjs/Culling/boundingInfo";
  51155. export * from "babylonjs/Culling/boundingSphere";
  51156. export * from "babylonjs/Culling/Octrees/index";
  51157. export * from "babylonjs/Culling/ray";
  51158. }
  51159. declare module "babylonjs/Gizmos/gizmo" {
  51160. import { Nullable } from "babylonjs/types";
  51161. import { IDisposable } from "babylonjs/scene";
  51162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51163. import { Mesh } from "babylonjs/Meshes/mesh";
  51164. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51165. /**
  51166. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51167. */
  51168. export class Gizmo implements IDisposable {
  51169. /** The utility layer the gizmo will be added to */
  51170. gizmoLayer: UtilityLayerRenderer;
  51171. /**
  51172. * The root mesh of the gizmo
  51173. */
  51174. _rootMesh: Mesh;
  51175. private _attachedMesh;
  51176. /**
  51177. * Ratio for the scale of the gizmo (Default: 1)
  51178. */
  51179. scaleRatio: number;
  51180. /**
  51181. * If a custom mesh has been set (Default: false)
  51182. */
  51183. protected _customMeshSet: boolean;
  51184. /**
  51185. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51186. * * When set, interactions will be enabled
  51187. */
  51188. get attachedMesh(): Nullable<AbstractMesh>;
  51189. set attachedMesh(value: Nullable<AbstractMesh>);
  51190. /**
  51191. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51192. * @param mesh The mesh to replace the default mesh of the gizmo
  51193. */
  51194. setCustomMesh(mesh: Mesh): void;
  51195. /**
  51196. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51197. */
  51198. updateGizmoRotationToMatchAttachedMesh: boolean;
  51199. /**
  51200. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51201. */
  51202. updateGizmoPositionToMatchAttachedMesh: boolean;
  51203. /**
  51204. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51205. */
  51206. updateScale: boolean;
  51207. protected _interactionsEnabled: boolean;
  51208. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51209. private _beforeRenderObserver;
  51210. private _tempVector;
  51211. /**
  51212. * Creates a gizmo
  51213. * @param gizmoLayer The utility layer the gizmo will be added to
  51214. */
  51215. constructor(
  51216. /** The utility layer the gizmo will be added to */
  51217. gizmoLayer?: UtilityLayerRenderer);
  51218. /**
  51219. * Updates the gizmo to match the attached mesh's position/rotation
  51220. */
  51221. protected _update(): void;
  51222. /**
  51223. * Disposes of the gizmo
  51224. */
  51225. dispose(): void;
  51226. }
  51227. }
  51228. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51229. import { Observable } from "babylonjs/Misc/observable";
  51230. import { Nullable } from "babylonjs/types";
  51231. import { Vector3 } from "babylonjs/Maths/math.vector";
  51232. import { Color3 } from "babylonjs/Maths/math.color";
  51233. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51235. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51236. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51237. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51238. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51239. import { Scene } from "babylonjs/scene";
  51240. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51241. /**
  51242. * Single plane drag gizmo
  51243. */
  51244. export class PlaneDragGizmo extends Gizmo {
  51245. /**
  51246. * Drag behavior responsible for the gizmos dragging interactions
  51247. */
  51248. dragBehavior: PointerDragBehavior;
  51249. private _pointerObserver;
  51250. /**
  51251. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51252. */
  51253. snapDistance: number;
  51254. /**
  51255. * Event that fires each time the gizmo snaps to a new location.
  51256. * * snapDistance is the the change in distance
  51257. */
  51258. onSnapObservable: Observable<{
  51259. snapDistance: number;
  51260. }>;
  51261. private _plane;
  51262. private _coloredMaterial;
  51263. private _hoverMaterial;
  51264. private _isEnabled;
  51265. private _parent;
  51266. /** @hidden */
  51267. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51268. /** @hidden */
  51269. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51270. /**
  51271. * Creates a PlaneDragGizmo
  51272. * @param gizmoLayer The utility layer the gizmo will be added to
  51273. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51274. * @param color The color of the gizmo
  51275. */
  51276. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51277. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51278. /**
  51279. * If the gizmo is enabled
  51280. */
  51281. set isEnabled(value: boolean);
  51282. get isEnabled(): boolean;
  51283. /**
  51284. * Disposes of the gizmo
  51285. */
  51286. dispose(): void;
  51287. }
  51288. }
  51289. declare module "babylonjs/Gizmos/positionGizmo" {
  51290. import { Observable } from "babylonjs/Misc/observable";
  51291. import { Nullable } from "babylonjs/types";
  51292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51293. import { Mesh } from "babylonjs/Meshes/mesh";
  51294. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51295. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51296. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51297. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51298. /**
  51299. * Gizmo that enables dragging a mesh along 3 axis
  51300. */
  51301. export class PositionGizmo extends Gizmo {
  51302. /**
  51303. * Internal gizmo used for interactions on the x axis
  51304. */
  51305. xGizmo: AxisDragGizmo;
  51306. /**
  51307. * Internal gizmo used for interactions on the y axis
  51308. */
  51309. yGizmo: AxisDragGizmo;
  51310. /**
  51311. * Internal gizmo used for interactions on the z axis
  51312. */
  51313. zGizmo: AxisDragGizmo;
  51314. /**
  51315. * Internal gizmo used for interactions on the yz plane
  51316. */
  51317. xPlaneGizmo: PlaneDragGizmo;
  51318. /**
  51319. * Internal gizmo used for interactions on the xz plane
  51320. */
  51321. yPlaneGizmo: PlaneDragGizmo;
  51322. /**
  51323. * Internal gizmo used for interactions on the xy plane
  51324. */
  51325. zPlaneGizmo: PlaneDragGizmo;
  51326. /**
  51327. * private variables
  51328. */
  51329. private _meshAttached;
  51330. private _updateGizmoRotationToMatchAttachedMesh;
  51331. private _snapDistance;
  51332. private _scaleRatio;
  51333. /** Fires an event when any of it's sub gizmos are dragged */
  51334. onDragStartObservable: Observable<unknown>;
  51335. /** Fires an event when any of it's sub gizmos are released from dragging */
  51336. onDragEndObservable: Observable<unknown>;
  51337. /**
  51338. * If set to true, planar drag is enabled
  51339. */
  51340. private _planarGizmoEnabled;
  51341. get attachedMesh(): Nullable<AbstractMesh>;
  51342. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51343. /**
  51344. * Creates a PositionGizmo
  51345. * @param gizmoLayer The utility layer the gizmo will be added to
  51346. */
  51347. constructor(gizmoLayer?: UtilityLayerRenderer);
  51348. /**
  51349. * If the planar drag gizmo is enabled
  51350. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51351. */
  51352. set planarGizmoEnabled(value: boolean);
  51353. get planarGizmoEnabled(): boolean;
  51354. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51355. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51356. /**
  51357. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51358. */
  51359. set snapDistance(value: number);
  51360. get snapDistance(): number;
  51361. /**
  51362. * Ratio for the scale of the gizmo (Default: 1)
  51363. */
  51364. set scaleRatio(value: number);
  51365. get scaleRatio(): number;
  51366. /**
  51367. * Disposes of the gizmo
  51368. */
  51369. dispose(): void;
  51370. /**
  51371. * CustomMeshes are not supported by this gizmo
  51372. * @param mesh The mesh to replace the default mesh of the gizmo
  51373. */
  51374. setCustomMesh(mesh: Mesh): void;
  51375. }
  51376. }
  51377. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51378. import { Observable } from "babylonjs/Misc/observable";
  51379. import { Nullable } from "babylonjs/types";
  51380. import { Vector3 } from "babylonjs/Maths/math.vector";
  51381. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51383. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51384. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51385. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51386. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51387. import { Scene } from "babylonjs/scene";
  51388. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51389. import { Color3 } from "babylonjs/Maths/math.color";
  51390. /**
  51391. * Single axis drag gizmo
  51392. */
  51393. export class AxisDragGizmo extends Gizmo {
  51394. /**
  51395. * Drag behavior responsible for the gizmos dragging interactions
  51396. */
  51397. dragBehavior: PointerDragBehavior;
  51398. private _pointerObserver;
  51399. /**
  51400. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51401. */
  51402. snapDistance: number;
  51403. /**
  51404. * Event that fires each time the gizmo snaps to a new location.
  51405. * * snapDistance is the the change in distance
  51406. */
  51407. onSnapObservable: Observable<{
  51408. snapDistance: number;
  51409. }>;
  51410. private _isEnabled;
  51411. private _parent;
  51412. private _arrow;
  51413. private _coloredMaterial;
  51414. private _hoverMaterial;
  51415. /** @hidden */
  51416. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51417. /** @hidden */
  51418. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51419. /**
  51420. * Creates an AxisDragGizmo
  51421. * @param gizmoLayer The utility layer the gizmo will be added to
  51422. * @param dragAxis The axis which the gizmo will be able to drag on
  51423. * @param color The color of the gizmo
  51424. */
  51425. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51426. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51427. /**
  51428. * If the gizmo is enabled
  51429. */
  51430. set isEnabled(value: boolean);
  51431. get isEnabled(): boolean;
  51432. /**
  51433. * Disposes of the gizmo
  51434. */
  51435. dispose(): void;
  51436. }
  51437. }
  51438. declare module "babylonjs/Debug/axesViewer" {
  51439. import { Vector3 } from "babylonjs/Maths/math.vector";
  51440. import { Nullable } from "babylonjs/types";
  51441. import { Scene } from "babylonjs/scene";
  51442. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51443. /**
  51444. * The Axes viewer will show 3 axes in a specific point in space
  51445. */
  51446. export class AxesViewer {
  51447. private _xAxis;
  51448. private _yAxis;
  51449. private _zAxis;
  51450. private _scaleLinesFactor;
  51451. private _instanced;
  51452. /**
  51453. * Gets the hosting scene
  51454. */
  51455. scene: Scene;
  51456. /**
  51457. * Gets or sets a number used to scale line length
  51458. */
  51459. scaleLines: number;
  51460. /** Gets the node hierarchy used to render x-axis */
  51461. get xAxis(): TransformNode;
  51462. /** Gets the node hierarchy used to render y-axis */
  51463. get yAxis(): TransformNode;
  51464. /** Gets the node hierarchy used to render z-axis */
  51465. get zAxis(): TransformNode;
  51466. /**
  51467. * Creates a new AxesViewer
  51468. * @param scene defines the hosting scene
  51469. * @param scaleLines defines a number used to scale line length (1 by default)
  51470. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51471. * @param xAxis defines the node hierarchy used to render the x-axis
  51472. * @param yAxis defines the node hierarchy used to render the y-axis
  51473. * @param zAxis defines the node hierarchy used to render the z-axis
  51474. */
  51475. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51476. /**
  51477. * Force the viewer to update
  51478. * @param position defines the position of the viewer
  51479. * @param xaxis defines the x axis of the viewer
  51480. * @param yaxis defines the y axis of the viewer
  51481. * @param zaxis defines the z axis of the viewer
  51482. */
  51483. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51484. /**
  51485. * Creates an instance of this axes viewer.
  51486. * @returns a new axes viewer with instanced meshes
  51487. */
  51488. createInstance(): AxesViewer;
  51489. /** Releases resources */
  51490. dispose(): void;
  51491. private static _SetRenderingGroupId;
  51492. }
  51493. }
  51494. declare module "babylonjs/Debug/boneAxesViewer" {
  51495. import { Nullable } from "babylonjs/types";
  51496. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51497. import { Vector3 } from "babylonjs/Maths/math.vector";
  51498. import { Mesh } from "babylonjs/Meshes/mesh";
  51499. import { Bone } from "babylonjs/Bones/bone";
  51500. import { Scene } from "babylonjs/scene";
  51501. /**
  51502. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51503. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51504. */
  51505. export class BoneAxesViewer extends AxesViewer {
  51506. /**
  51507. * Gets or sets the target mesh where to display the axes viewer
  51508. */
  51509. mesh: Nullable<Mesh>;
  51510. /**
  51511. * Gets or sets the target bone where to display the axes viewer
  51512. */
  51513. bone: Nullable<Bone>;
  51514. /** Gets current position */
  51515. pos: Vector3;
  51516. /** Gets direction of X axis */
  51517. xaxis: Vector3;
  51518. /** Gets direction of Y axis */
  51519. yaxis: Vector3;
  51520. /** Gets direction of Z axis */
  51521. zaxis: Vector3;
  51522. /**
  51523. * Creates a new BoneAxesViewer
  51524. * @param scene defines the hosting scene
  51525. * @param bone defines the target bone
  51526. * @param mesh defines the target mesh
  51527. * @param scaleLines defines a scaling factor for line length (1 by default)
  51528. */
  51529. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51530. /**
  51531. * Force the viewer to update
  51532. */
  51533. update(): void;
  51534. /** Releases resources */
  51535. dispose(): void;
  51536. }
  51537. }
  51538. declare module "babylonjs/Debug/debugLayer" {
  51539. import { Scene } from "babylonjs/scene";
  51540. /**
  51541. * Interface used to define scene explorer extensibility option
  51542. */
  51543. export interface IExplorerExtensibilityOption {
  51544. /**
  51545. * Define the option label
  51546. */
  51547. label: string;
  51548. /**
  51549. * Defines the action to execute on click
  51550. */
  51551. action: (entity: any) => void;
  51552. }
  51553. /**
  51554. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51555. */
  51556. export interface IExplorerExtensibilityGroup {
  51557. /**
  51558. * Defines a predicate to test if a given type mut be extended
  51559. */
  51560. predicate: (entity: any) => boolean;
  51561. /**
  51562. * Gets the list of options added to a type
  51563. */
  51564. entries: IExplorerExtensibilityOption[];
  51565. }
  51566. /**
  51567. * Interface used to define the options to use to create the Inspector
  51568. */
  51569. export interface IInspectorOptions {
  51570. /**
  51571. * Display in overlay mode (default: false)
  51572. */
  51573. overlay?: boolean;
  51574. /**
  51575. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51576. */
  51577. globalRoot?: HTMLElement;
  51578. /**
  51579. * Display the Scene explorer
  51580. */
  51581. showExplorer?: boolean;
  51582. /**
  51583. * Display the property inspector
  51584. */
  51585. showInspector?: boolean;
  51586. /**
  51587. * Display in embed mode (both panes on the right)
  51588. */
  51589. embedMode?: boolean;
  51590. /**
  51591. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51592. */
  51593. handleResize?: boolean;
  51594. /**
  51595. * Allow the panes to popup (default: true)
  51596. */
  51597. enablePopup?: boolean;
  51598. /**
  51599. * Allow the panes to be closed by users (default: true)
  51600. */
  51601. enableClose?: boolean;
  51602. /**
  51603. * Optional list of extensibility entries
  51604. */
  51605. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51606. /**
  51607. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51608. */
  51609. inspectorURL?: string;
  51610. /**
  51611. * Optional initial tab (default to DebugLayerTab.Properties)
  51612. */
  51613. initialTab?: DebugLayerTab;
  51614. }
  51615. module "babylonjs/scene" {
  51616. interface Scene {
  51617. /**
  51618. * @hidden
  51619. * Backing field
  51620. */
  51621. _debugLayer: DebugLayer;
  51622. /**
  51623. * Gets the debug layer (aka Inspector) associated with the scene
  51624. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51625. */
  51626. debugLayer: DebugLayer;
  51627. }
  51628. }
  51629. /**
  51630. * Enum of inspector action tab
  51631. */
  51632. export enum DebugLayerTab {
  51633. /**
  51634. * Properties tag (default)
  51635. */
  51636. Properties = 0,
  51637. /**
  51638. * Debug tab
  51639. */
  51640. Debug = 1,
  51641. /**
  51642. * Statistics tab
  51643. */
  51644. Statistics = 2,
  51645. /**
  51646. * Tools tab
  51647. */
  51648. Tools = 3,
  51649. /**
  51650. * Settings tab
  51651. */
  51652. Settings = 4
  51653. }
  51654. /**
  51655. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51656. * what is happening in your scene
  51657. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51658. */
  51659. export class DebugLayer {
  51660. /**
  51661. * Define the url to get the inspector script from.
  51662. * By default it uses the babylonjs CDN.
  51663. * @ignoreNaming
  51664. */
  51665. static InspectorURL: string;
  51666. private _scene;
  51667. private BJSINSPECTOR;
  51668. private _onPropertyChangedObservable?;
  51669. /**
  51670. * Observable triggered when a property is changed through the inspector.
  51671. */
  51672. get onPropertyChangedObservable(): any;
  51673. /**
  51674. * Instantiates a new debug layer.
  51675. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51676. * what is happening in your scene
  51677. * @see http://doc.babylonjs.com/features/playground_debuglayer
  51678. * @param scene Defines the scene to inspect
  51679. */
  51680. constructor(scene: Scene);
  51681. /** Creates the inspector window. */
  51682. private _createInspector;
  51683. /**
  51684. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51685. * @param entity defines the entity to select
  51686. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51687. */
  51688. select(entity: any, lineContainerTitles?: string | string[]): void;
  51689. /** Get the inspector from bundle or global */
  51690. private _getGlobalInspector;
  51691. /**
  51692. * Get if the inspector is visible or not.
  51693. * @returns true if visible otherwise, false
  51694. */
  51695. isVisible(): boolean;
  51696. /**
  51697. * Hide the inspector and close its window.
  51698. */
  51699. hide(): void;
  51700. /**
  51701. * Update the scene in the inspector
  51702. */
  51703. setAsActiveScene(): void;
  51704. /**
  51705. * Launch the debugLayer.
  51706. * @param config Define the configuration of the inspector
  51707. * @return a promise fulfilled when the debug layer is visible
  51708. */
  51709. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51710. }
  51711. }
  51712. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51713. import { Nullable } from "babylonjs/types";
  51714. import { Scene } from "babylonjs/scene";
  51715. import { Vector4 } from "babylonjs/Maths/math.vector";
  51716. import { Color4 } from "babylonjs/Maths/math.color";
  51717. import { Mesh } from "babylonjs/Meshes/mesh";
  51718. /**
  51719. * Class containing static functions to help procedurally build meshes
  51720. */
  51721. export class BoxBuilder {
  51722. /**
  51723. * Creates a box mesh
  51724. * * The parameter `size` sets the size (float) of each box side (default 1)
  51725. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51726. * * 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)
  51727. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51731. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51732. * @param name defines the name of the mesh
  51733. * @param options defines the options used to create the mesh
  51734. * @param scene defines the hosting scene
  51735. * @returns the box mesh
  51736. */
  51737. static CreateBox(name: string, options: {
  51738. size?: number;
  51739. width?: number;
  51740. height?: number;
  51741. depth?: number;
  51742. faceUV?: Vector4[];
  51743. faceColors?: Color4[];
  51744. sideOrientation?: number;
  51745. frontUVs?: Vector4;
  51746. backUVs?: Vector4;
  51747. wrap?: boolean;
  51748. topBaseAt?: number;
  51749. bottomBaseAt?: number;
  51750. updatable?: boolean;
  51751. }, scene?: Nullable<Scene>): Mesh;
  51752. }
  51753. }
  51754. declare module "babylonjs/Debug/physicsViewer" {
  51755. import { Nullable } from "babylonjs/types";
  51756. import { Scene } from "babylonjs/scene";
  51757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51758. import { Mesh } from "babylonjs/Meshes/mesh";
  51759. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51760. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51761. /**
  51762. * Used to show the physics impostor around the specific mesh
  51763. */
  51764. export class PhysicsViewer {
  51765. /** @hidden */
  51766. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51767. /** @hidden */
  51768. protected _meshes: Array<Nullable<AbstractMesh>>;
  51769. /** @hidden */
  51770. protected _scene: Nullable<Scene>;
  51771. /** @hidden */
  51772. protected _numMeshes: number;
  51773. /** @hidden */
  51774. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51775. private _renderFunction;
  51776. private _utilityLayer;
  51777. private _debugBoxMesh;
  51778. private _debugSphereMesh;
  51779. private _debugCylinderMesh;
  51780. private _debugMaterial;
  51781. private _debugMeshMeshes;
  51782. /**
  51783. * Creates a new PhysicsViewer
  51784. * @param scene defines the hosting scene
  51785. */
  51786. constructor(scene: Scene);
  51787. /** @hidden */
  51788. protected _updateDebugMeshes(): void;
  51789. /**
  51790. * Renders a specified physic impostor
  51791. * @param impostor defines the impostor to render
  51792. * @param targetMesh defines the mesh represented by the impostor
  51793. * @returns the new debug mesh used to render the impostor
  51794. */
  51795. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51796. /**
  51797. * Hides a specified physic impostor
  51798. * @param impostor defines the impostor to hide
  51799. */
  51800. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51801. private _getDebugMaterial;
  51802. private _getDebugBoxMesh;
  51803. private _getDebugSphereMesh;
  51804. private _getDebugCylinderMesh;
  51805. private _getDebugMeshMesh;
  51806. private _getDebugMesh;
  51807. /** Releases all resources */
  51808. dispose(): void;
  51809. }
  51810. }
  51811. declare module "babylonjs/Debug/rayHelper" {
  51812. import { Nullable } from "babylonjs/types";
  51813. import { Ray } from "babylonjs/Culling/ray";
  51814. import { Vector3 } from "babylonjs/Maths/math.vector";
  51815. import { Color3 } from "babylonjs/Maths/math.color";
  51816. import { Scene } from "babylonjs/scene";
  51817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51818. import "babylonjs/Meshes/Builders/linesBuilder";
  51819. /**
  51820. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51821. * in order to better appreciate the issue one might have.
  51822. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51823. */
  51824. export class RayHelper {
  51825. /**
  51826. * Defines the ray we are currently tryin to visualize.
  51827. */
  51828. ray: Nullable<Ray>;
  51829. private _renderPoints;
  51830. private _renderLine;
  51831. private _renderFunction;
  51832. private _scene;
  51833. private _updateToMeshFunction;
  51834. private _attachedToMesh;
  51835. private _meshSpaceDirection;
  51836. private _meshSpaceOrigin;
  51837. /**
  51838. * Helper function to create a colored helper in a scene in one line.
  51839. * @param ray Defines the ray we are currently tryin to visualize
  51840. * @param scene Defines the scene the ray is used in
  51841. * @param color Defines the color we want to see the ray in
  51842. * @returns The newly created ray helper.
  51843. */
  51844. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51845. /**
  51846. * Instantiate a new ray helper.
  51847. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51848. * in order to better appreciate the issue one might have.
  51849. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  51850. * @param ray Defines the ray we are currently tryin to visualize
  51851. */
  51852. constructor(ray: Ray);
  51853. /**
  51854. * Shows the ray we are willing to debug.
  51855. * @param scene Defines the scene the ray needs to be rendered in
  51856. * @param color Defines the color the ray needs to be rendered in
  51857. */
  51858. show(scene: Scene, color?: Color3): void;
  51859. /**
  51860. * Hides the ray we are debugging.
  51861. */
  51862. hide(): void;
  51863. private _render;
  51864. /**
  51865. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51866. * @param mesh Defines the mesh we want the helper attached to
  51867. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51868. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51869. * @param length Defines the length of the ray
  51870. */
  51871. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51872. /**
  51873. * Detach the ray helper from the mesh it has previously been attached to.
  51874. */
  51875. detachFromMesh(): void;
  51876. private _updateToMesh;
  51877. /**
  51878. * Dispose the helper and release its associated resources.
  51879. */
  51880. dispose(): void;
  51881. }
  51882. }
  51883. declare module "babylonjs/Debug/skeletonViewer" {
  51884. import { Color3 } from "babylonjs/Maths/math.color";
  51885. import { Scene } from "babylonjs/scene";
  51886. import { Nullable } from "babylonjs/types";
  51887. import { Skeleton } from "babylonjs/Bones/skeleton";
  51888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51889. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51890. /**
  51891. * Class used to render a debug view of a given skeleton
  51892. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51893. */
  51894. export class SkeletonViewer {
  51895. /** defines the skeleton to render */
  51896. skeleton: Skeleton;
  51897. /** defines the mesh attached to the skeleton */
  51898. mesh: AbstractMesh;
  51899. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51900. autoUpdateBonesMatrices: boolean;
  51901. /** defines the rendering group id to use with the viewer */
  51902. renderingGroupId: number;
  51903. /** Gets or sets the color used to render the skeleton */
  51904. color: Color3;
  51905. private _scene;
  51906. private _debugLines;
  51907. private _debugMesh;
  51908. private _isEnabled;
  51909. private _renderFunction;
  51910. private _utilityLayer;
  51911. /**
  51912. * Returns the mesh used to render the bones
  51913. */
  51914. get debugMesh(): Nullable<LinesMesh>;
  51915. /**
  51916. * Creates a new SkeletonViewer
  51917. * @param skeleton defines the skeleton to render
  51918. * @param mesh defines the mesh attached to the skeleton
  51919. * @param scene defines the hosting scene
  51920. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51921. * @param renderingGroupId defines the rendering group id to use with the viewer
  51922. */
  51923. constructor(
  51924. /** defines the skeleton to render */
  51925. skeleton: Skeleton,
  51926. /** defines the mesh attached to the skeleton */
  51927. mesh: AbstractMesh, scene: Scene,
  51928. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51929. autoUpdateBonesMatrices?: boolean,
  51930. /** defines the rendering group id to use with the viewer */
  51931. renderingGroupId?: number);
  51932. /** Gets or sets a boolean indicating if the viewer is enabled */
  51933. set isEnabled(value: boolean);
  51934. get isEnabled(): boolean;
  51935. private _getBonePosition;
  51936. private _getLinesForBonesWithLength;
  51937. private _getLinesForBonesNoLength;
  51938. /** Update the viewer to sync with current skeleton state */
  51939. update(): void;
  51940. /** Release associated resources */
  51941. dispose(): void;
  51942. }
  51943. }
  51944. declare module "babylonjs/Debug/index" {
  51945. export * from "babylonjs/Debug/axesViewer";
  51946. export * from "babylonjs/Debug/boneAxesViewer";
  51947. export * from "babylonjs/Debug/debugLayer";
  51948. export * from "babylonjs/Debug/physicsViewer";
  51949. export * from "babylonjs/Debug/rayHelper";
  51950. export * from "babylonjs/Debug/skeletonViewer";
  51951. }
  51952. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  51953. /**
  51954. * Enum for Device Types
  51955. */
  51956. export enum DeviceType {
  51957. /** Generic */
  51958. Generic = 0,
  51959. /** Keyboard */
  51960. Keyboard = 1,
  51961. /** Mouse */
  51962. Mouse = 2,
  51963. /** Touch Pointers */
  51964. Touch = 3,
  51965. /** PS4 Dual Shock */
  51966. DualShock = 4,
  51967. /** Xbox */
  51968. Xbox = 5,
  51969. /** Switch Controller */
  51970. Switch = 6
  51971. }
  51972. /**
  51973. * Enum for All Pointers (Touch/Mouse)
  51974. */
  51975. export enum PointerInput {
  51976. /** Horizontal Axis */
  51977. Horizontal = 0,
  51978. /** Vertical Axis */
  51979. Vertical = 1,
  51980. /** Left Click or Touch */
  51981. LeftClick = 2,
  51982. /** Middle Click */
  51983. MiddleClick = 3,
  51984. /** Right Click */
  51985. RightClick = 4,
  51986. /** Browser Back */
  51987. BrowserBack = 5,
  51988. /** Browser Forward */
  51989. BrowserForward = 6
  51990. }
  51991. /**
  51992. * Enum for Dual Shock Gamepad
  51993. */
  51994. export enum DualShockInput {
  51995. /** Cross */
  51996. Cross = 0,
  51997. /** Circle */
  51998. Circle = 1,
  51999. /** Square */
  52000. Square = 2,
  52001. /** Triangle */
  52002. Triangle = 3,
  52003. /** L1 */
  52004. L1 = 4,
  52005. /** R1 */
  52006. R1 = 5,
  52007. /** L2 */
  52008. L2 = 6,
  52009. /** R2 */
  52010. R2 = 7,
  52011. /** Share */
  52012. Share = 8,
  52013. /** Options */
  52014. Options = 9,
  52015. /** L3 */
  52016. L3 = 10,
  52017. /** R3 */
  52018. R3 = 11,
  52019. /** DPadUp */
  52020. DPadUp = 12,
  52021. /** DPadDown */
  52022. DPadDown = 13,
  52023. /** DPadLeft */
  52024. DPadLeft = 14,
  52025. /** DRight */
  52026. DPadRight = 15,
  52027. /** Home */
  52028. Home = 16,
  52029. /** TouchPad */
  52030. TouchPad = 17,
  52031. /** LStickXAxis */
  52032. LStickXAxis = 18,
  52033. /** LStickYAxis */
  52034. LStickYAxis = 19,
  52035. /** RStickXAxis */
  52036. RStickXAxis = 20,
  52037. /** RStickYAxis */
  52038. RStickYAxis = 21
  52039. }
  52040. /**
  52041. * Enum for Xbox Gamepad
  52042. */
  52043. export enum XboxInput {
  52044. /** A */
  52045. A = 0,
  52046. /** B */
  52047. B = 1,
  52048. /** X */
  52049. X = 2,
  52050. /** Y */
  52051. Y = 3,
  52052. /** LB */
  52053. LB = 4,
  52054. /** RB */
  52055. RB = 5,
  52056. /** LT */
  52057. LT = 6,
  52058. /** RT */
  52059. RT = 7,
  52060. /** Back */
  52061. Back = 8,
  52062. /** Start */
  52063. Start = 9,
  52064. /** LS */
  52065. LS = 10,
  52066. /** RS */
  52067. RS = 11,
  52068. /** DPadUp */
  52069. DPadUp = 12,
  52070. /** DPadDown */
  52071. DPadDown = 13,
  52072. /** DPadLeft */
  52073. DPadLeft = 14,
  52074. /** DRight */
  52075. DPadRight = 15,
  52076. /** Home */
  52077. Home = 16,
  52078. /** LStickXAxis */
  52079. LStickXAxis = 17,
  52080. /** LStickYAxis */
  52081. LStickYAxis = 18,
  52082. /** RStickXAxis */
  52083. RStickXAxis = 19,
  52084. /** RStickYAxis */
  52085. RStickYAxis = 20
  52086. }
  52087. /**
  52088. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52089. */
  52090. export enum SwitchInput {
  52091. /** B */
  52092. B = 0,
  52093. /** A */
  52094. A = 1,
  52095. /** Y */
  52096. Y = 2,
  52097. /** X */
  52098. X = 3,
  52099. /** L */
  52100. L = 4,
  52101. /** R */
  52102. R = 5,
  52103. /** ZL */
  52104. ZL = 6,
  52105. /** ZR */
  52106. ZR = 7,
  52107. /** Minus */
  52108. Minus = 8,
  52109. /** Plus */
  52110. Plus = 9,
  52111. /** LS */
  52112. LS = 10,
  52113. /** RS */
  52114. RS = 11,
  52115. /** DPadUp */
  52116. DPadUp = 12,
  52117. /** DPadDown */
  52118. DPadDown = 13,
  52119. /** DPadLeft */
  52120. DPadLeft = 14,
  52121. /** DRight */
  52122. DPadRight = 15,
  52123. /** Home */
  52124. Home = 16,
  52125. /** Capture */
  52126. Capture = 17,
  52127. /** LStickXAxis */
  52128. LStickXAxis = 18,
  52129. /** LStickYAxis */
  52130. LStickYAxis = 19,
  52131. /** RStickXAxis */
  52132. RStickXAxis = 20,
  52133. /** RStickYAxis */
  52134. RStickYAxis = 21
  52135. }
  52136. }
  52137. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52138. import { Engine } from "babylonjs/Engines/engine";
  52139. import { IDisposable } from "babylonjs/scene";
  52140. import { Nullable } from "babylonjs/types";
  52141. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52142. /**
  52143. * This class will take all inputs from Keyboard, Pointer, and
  52144. * any Gamepads and provide a polling system that all devices
  52145. * will use. This class assumes that there will only be one
  52146. * pointer device and one keyboard.
  52147. */
  52148. export class DeviceInputSystem implements IDisposable {
  52149. /**
  52150. * Callback to be triggered when a device is connected
  52151. */
  52152. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52153. /**
  52154. * Callback to be triggered when a device is disconnected
  52155. */
  52156. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52157. /**
  52158. * Callback to be triggered when event driven input is updated
  52159. */
  52160. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52161. private _inputs;
  52162. private _gamepads;
  52163. private _keyboardActive;
  52164. private _pointerActive;
  52165. private _elementToAttachTo;
  52166. private _keyboardDownEvent;
  52167. private _keyboardUpEvent;
  52168. private _pointerMoveEvent;
  52169. private _pointerDownEvent;
  52170. private _pointerUpEvent;
  52171. private _gamepadConnectedEvent;
  52172. private _gamepadDisconnectedEvent;
  52173. private static _MAX_KEYCODES;
  52174. private static _MAX_POINTER_INPUTS;
  52175. private constructor();
  52176. /**
  52177. * Creates a new DeviceInputSystem instance
  52178. * @param engine Engine to pull input element from
  52179. * @returns The new instance
  52180. */
  52181. static Create(engine: Engine): DeviceInputSystem;
  52182. /**
  52183. * Checks for current device input value, given an id and input index
  52184. * @param deviceName Id of connected device
  52185. * @param inputIndex Index of device input
  52186. * @returns Current value of input
  52187. */
  52188. /**
  52189. * Checks for current device input value, given an id and input index
  52190. * @param deviceType Enum specifiying device type
  52191. * @param deviceSlot "Slot" or index that device is referenced in
  52192. * @param inputIndex Id of input to be checked
  52193. * @returns Current value of input
  52194. */
  52195. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52196. /**
  52197. * Dispose of all the eventlisteners
  52198. */
  52199. dispose(): void;
  52200. /**
  52201. * Add device and inputs to device array
  52202. * @param deviceType Enum specifiying device type
  52203. * @param deviceSlot "Slot" or index that device is referenced in
  52204. * @param numberOfInputs Number of input entries to create for given device
  52205. */
  52206. private _registerDevice;
  52207. /**
  52208. * Given a specific device name, remove that device from the device map
  52209. * @param deviceType Enum specifiying device type
  52210. * @param deviceSlot "Slot" or index that device is referenced in
  52211. */
  52212. private _unregisterDevice;
  52213. /**
  52214. * Handle all actions that come from keyboard interaction
  52215. */
  52216. private _handleKeyActions;
  52217. /**
  52218. * Handle all actions that come from pointer interaction
  52219. */
  52220. private _handlePointerActions;
  52221. /**
  52222. * Handle all actions that come from gamepad interaction
  52223. */
  52224. private _handleGamepadActions;
  52225. /**
  52226. * Update all non-event based devices with each frame
  52227. * @param deviceType Enum specifiying device type
  52228. * @param deviceSlot "Slot" or index that device is referenced in
  52229. * @param inputIndex Id of input to be checked
  52230. */
  52231. private _updateDevice;
  52232. /**
  52233. * Gets DeviceType from the device name
  52234. * @param deviceName Name of Device from DeviceInputSystem
  52235. * @returns DeviceType enum value
  52236. */
  52237. private _getGamepadDeviceType;
  52238. }
  52239. }
  52240. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52241. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52242. /**
  52243. * Type to handle enforcement of inputs
  52244. */
  52245. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  52246. }
  52247. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52248. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52249. import { Engine } from "babylonjs/Engines/engine";
  52250. import { IDisposable } from "babylonjs/scene";
  52251. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52252. import { Nullable } from "babylonjs/types";
  52253. import { Observable } from "babylonjs/Misc/observable";
  52254. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52255. /**
  52256. * Class that handles all input for a specific device
  52257. */
  52258. export class DeviceSource<T extends DeviceType> {
  52259. /** Type of device */
  52260. readonly deviceType: DeviceType;
  52261. /** "Slot" or index that device is referenced in */
  52262. readonly deviceSlot: number;
  52263. /**
  52264. * Observable to handle device input changes per device
  52265. */
  52266. readonly onInputChangedObservable: Observable<{
  52267. inputIndex: DeviceInput<T>;
  52268. previousState: Nullable<number>;
  52269. currentState: Nullable<number>;
  52270. }>;
  52271. private readonly _deviceInputSystem;
  52272. /**
  52273. * Default Constructor
  52274. * @param deviceInputSystem Reference to DeviceInputSystem
  52275. * @param deviceType Type of device
  52276. * @param deviceSlot "Slot" or index that device is referenced in
  52277. */
  52278. constructor(deviceInputSystem: DeviceInputSystem,
  52279. /** Type of device */
  52280. deviceType: DeviceType,
  52281. /** "Slot" or index that device is referenced in */
  52282. deviceSlot?: number);
  52283. /**
  52284. * Get input for specific input
  52285. * @param inputIndex index of specific input on device
  52286. * @returns Input value from DeviceInputSystem
  52287. */
  52288. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52289. }
  52290. /**
  52291. * Class to keep track of devices
  52292. */
  52293. export class DeviceSourceManager implements IDisposable {
  52294. /**
  52295. * Observable to be triggered when before a device is connected
  52296. */
  52297. readonly onBeforeDeviceConnectedObservable: Observable<{
  52298. deviceType: DeviceType;
  52299. deviceSlot: number;
  52300. }>;
  52301. /**
  52302. * Observable to be triggered when before a device is disconnected
  52303. */
  52304. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52305. deviceType: DeviceType;
  52306. deviceSlot: number;
  52307. }>;
  52308. /**
  52309. * Observable to be triggered when after a device is connected
  52310. */
  52311. readonly onAfterDeviceConnectedObservable: Observable<{
  52312. deviceType: DeviceType;
  52313. deviceSlot: number;
  52314. }>;
  52315. /**
  52316. * Observable to be triggered when after a device is disconnected
  52317. */
  52318. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52319. deviceType: DeviceType;
  52320. deviceSlot: number;
  52321. }>;
  52322. private readonly _devices;
  52323. private readonly _firstDevice;
  52324. private readonly _deviceInputSystem;
  52325. /**
  52326. * Default Constructor
  52327. * @param engine engine to pull input element from
  52328. */
  52329. constructor(engine: Engine);
  52330. /**
  52331. * Gets a DeviceSource, given a type and slot
  52332. * @param deviceType Enum specifying device type
  52333. * @param deviceSlot "Slot" or index that device is referenced in
  52334. * @returns DeviceSource object
  52335. */
  52336. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52337. /**
  52338. * Gets an array of DeviceSource objects for a given device type
  52339. * @param deviceType Enum specifying device type
  52340. * @returns Array of DeviceSource objects
  52341. */
  52342. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52343. /**
  52344. * Dispose of DeviceInputSystem and other parts
  52345. */
  52346. dispose(): void;
  52347. /**
  52348. * Function to add device name to device list
  52349. * @param deviceType Enum specifying device type
  52350. * @param deviceSlot "Slot" or index that device is referenced in
  52351. */
  52352. private _addDevice;
  52353. /**
  52354. * Function to remove device name to device list
  52355. * @param deviceType Enum specifying device type
  52356. * @param deviceSlot "Slot" or index that device is referenced in
  52357. */
  52358. private _removeDevice;
  52359. /**
  52360. * Updates array storing first connected device of each type
  52361. * @param type Type of Device
  52362. */
  52363. private _updateFirstDevices;
  52364. }
  52365. }
  52366. declare module "babylonjs/DeviceInput/index" {
  52367. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52368. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52369. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52370. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52371. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52372. }
  52373. declare module "babylonjs/Engines/nullEngine" {
  52374. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52375. import { Engine } from "babylonjs/Engines/engine";
  52376. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52377. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52378. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52379. import { Effect } from "babylonjs/Materials/effect";
  52380. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52381. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52382. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52383. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52384. /**
  52385. * Options to create the null engine
  52386. */
  52387. export class NullEngineOptions {
  52388. /**
  52389. * Render width (Default: 512)
  52390. */
  52391. renderWidth: number;
  52392. /**
  52393. * Render height (Default: 256)
  52394. */
  52395. renderHeight: number;
  52396. /**
  52397. * Texture size (Default: 512)
  52398. */
  52399. textureSize: number;
  52400. /**
  52401. * If delta time between frames should be constant
  52402. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52403. */
  52404. deterministicLockstep: boolean;
  52405. /**
  52406. * Maximum about of steps between frames (Default: 4)
  52407. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52408. */
  52409. lockstepMaxSteps: number;
  52410. }
  52411. /**
  52412. * The null engine class provides support for headless version of babylon.js.
  52413. * This can be used in server side scenario or for testing purposes
  52414. */
  52415. export class NullEngine extends Engine {
  52416. private _options;
  52417. /**
  52418. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52419. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52420. * @returns true if engine is in deterministic lock step mode
  52421. */
  52422. isDeterministicLockStep(): boolean;
  52423. /**
  52424. * Gets the max steps when engine is running in deterministic lock step
  52425. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52426. * @returns the max steps
  52427. */
  52428. getLockstepMaxSteps(): number;
  52429. /**
  52430. * Gets the current hardware scaling level.
  52431. * By default the hardware scaling level is computed from the window device ratio.
  52432. * 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.
  52433. * @returns a number indicating the current hardware scaling level
  52434. */
  52435. getHardwareScalingLevel(): number;
  52436. constructor(options?: NullEngineOptions);
  52437. /**
  52438. * Creates a vertex buffer
  52439. * @param vertices the data for the vertex buffer
  52440. * @returns the new WebGL static buffer
  52441. */
  52442. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52443. /**
  52444. * Creates a new index buffer
  52445. * @param indices defines the content of the index buffer
  52446. * @param updatable defines if the index buffer must be updatable
  52447. * @returns a new webGL buffer
  52448. */
  52449. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52450. /**
  52451. * Clear the current render buffer or the current render target (if any is set up)
  52452. * @param color defines the color to use
  52453. * @param backBuffer defines if the back buffer must be cleared
  52454. * @param depth defines if the depth buffer must be cleared
  52455. * @param stencil defines if the stencil buffer must be cleared
  52456. */
  52457. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52458. /**
  52459. * Gets the current render width
  52460. * @param useScreen defines if screen size must be used (or the current render target if any)
  52461. * @returns a number defining the current render width
  52462. */
  52463. getRenderWidth(useScreen?: boolean): number;
  52464. /**
  52465. * Gets the current render height
  52466. * @param useScreen defines if screen size must be used (or the current render target if any)
  52467. * @returns a number defining the current render height
  52468. */
  52469. getRenderHeight(useScreen?: boolean): number;
  52470. /**
  52471. * Set the WebGL's viewport
  52472. * @param viewport defines the viewport element to be used
  52473. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52474. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52475. */
  52476. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52477. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52478. /**
  52479. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52480. * @param pipelineContext defines the pipeline context to use
  52481. * @param uniformsNames defines the list of uniform names
  52482. * @returns an array of webGL uniform locations
  52483. */
  52484. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52485. /**
  52486. * Gets the lsit of active attributes for a given webGL program
  52487. * @param pipelineContext defines the pipeline context to use
  52488. * @param attributesNames defines the list of attribute names to get
  52489. * @returns an array of indices indicating the offset of each attribute
  52490. */
  52491. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52492. /**
  52493. * Binds an effect to the webGL context
  52494. * @param effect defines the effect to bind
  52495. */
  52496. bindSamplers(effect: Effect): void;
  52497. /**
  52498. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52499. * @param effect defines the effect to activate
  52500. */
  52501. enableEffect(effect: Effect): void;
  52502. /**
  52503. * Set various states to the webGL context
  52504. * @param culling defines backface culling state
  52505. * @param zOffset defines the value to apply to zOffset (0 by default)
  52506. * @param force defines if states must be applied even if cache is up to date
  52507. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52508. */
  52509. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52510. /**
  52511. * Set the value of an uniform to an array of int32
  52512. * @param uniform defines the webGL uniform location where to store the value
  52513. * @param array defines the array of int32 to store
  52514. */
  52515. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52516. /**
  52517. * Set the value of an uniform to an array of int32 (stored as vec2)
  52518. * @param uniform defines the webGL uniform location where to store the value
  52519. * @param array defines the array of int32 to store
  52520. */
  52521. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52522. /**
  52523. * Set the value of an uniform to an array of int32 (stored as vec3)
  52524. * @param uniform defines the webGL uniform location where to store the value
  52525. * @param array defines the array of int32 to store
  52526. */
  52527. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52528. /**
  52529. * Set the value of an uniform to an array of int32 (stored as vec4)
  52530. * @param uniform defines the webGL uniform location where to store the value
  52531. * @param array defines the array of int32 to store
  52532. */
  52533. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52534. /**
  52535. * Set the value of an uniform to an array of float32
  52536. * @param uniform defines the webGL uniform location where to store the value
  52537. * @param array defines the array of float32 to store
  52538. */
  52539. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52540. /**
  52541. * Set the value of an uniform to an array of float32 (stored as vec2)
  52542. * @param uniform defines the webGL uniform location where to store the value
  52543. * @param array defines the array of float32 to store
  52544. */
  52545. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52546. /**
  52547. * Set the value of an uniform to an array of float32 (stored as vec3)
  52548. * @param uniform defines the webGL uniform location where to store the value
  52549. * @param array defines the array of float32 to store
  52550. */
  52551. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52552. /**
  52553. * Set the value of an uniform to an array of float32 (stored as vec4)
  52554. * @param uniform defines the webGL uniform location where to store the value
  52555. * @param array defines the array of float32 to store
  52556. */
  52557. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52558. /**
  52559. * Set the value of an uniform to an array of number
  52560. * @param uniform defines the webGL uniform location where to store the value
  52561. * @param array defines the array of number to store
  52562. */
  52563. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52564. /**
  52565. * Set the value of an uniform to an array of number (stored as vec2)
  52566. * @param uniform defines the webGL uniform location where to store the value
  52567. * @param array defines the array of number to store
  52568. */
  52569. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52570. /**
  52571. * Set the value of an uniform to an array of number (stored as vec3)
  52572. * @param uniform defines the webGL uniform location where to store the value
  52573. * @param array defines the array of number to store
  52574. */
  52575. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52576. /**
  52577. * Set the value of an uniform to an array of number (stored as vec4)
  52578. * @param uniform defines the webGL uniform location where to store the value
  52579. * @param array defines the array of number to store
  52580. */
  52581. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52582. /**
  52583. * Set the value of an uniform to an array of float32 (stored as matrices)
  52584. * @param uniform defines the webGL uniform location where to store the value
  52585. * @param matrices defines the array of float32 to store
  52586. */
  52587. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52588. /**
  52589. * Set the value of an uniform to a matrix (3x3)
  52590. * @param uniform defines the webGL uniform location where to store the value
  52591. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52592. */
  52593. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52594. /**
  52595. * Set the value of an uniform to a matrix (2x2)
  52596. * @param uniform defines the webGL uniform location where to store the value
  52597. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52598. */
  52599. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52600. /**
  52601. * Set the value of an uniform to a number (float)
  52602. * @param uniform defines the webGL uniform location where to store the value
  52603. * @param value defines the float number to store
  52604. */
  52605. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52606. /**
  52607. * Set the value of an uniform to a vec2
  52608. * @param uniform defines the webGL uniform location where to store the value
  52609. * @param x defines the 1st component of the value
  52610. * @param y defines the 2nd component of the value
  52611. */
  52612. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52613. /**
  52614. * Set the value of an uniform to a vec3
  52615. * @param uniform defines the webGL uniform location where to store the value
  52616. * @param x defines the 1st component of the value
  52617. * @param y defines the 2nd component of the value
  52618. * @param z defines the 3rd component of the value
  52619. */
  52620. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52621. /**
  52622. * Set the value of an uniform to a boolean
  52623. * @param uniform defines the webGL uniform location where to store the value
  52624. * @param bool defines the boolean to store
  52625. */
  52626. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52627. /**
  52628. * Set the value of an uniform to a vec4
  52629. * @param uniform defines the webGL uniform location where to store the value
  52630. * @param x defines the 1st component of the value
  52631. * @param y defines the 2nd component of the value
  52632. * @param z defines the 3rd component of the value
  52633. * @param w defines the 4th component of the value
  52634. */
  52635. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52636. /**
  52637. * Sets the current alpha mode
  52638. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52639. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52640. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52641. */
  52642. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52643. /**
  52644. * Bind webGl buffers directly to the webGL context
  52645. * @param vertexBuffers defines the vertex buffer to bind
  52646. * @param indexBuffer defines the index buffer to bind
  52647. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52648. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52649. * @param effect defines the effect associated with the vertex buffer
  52650. */
  52651. bindBuffers(vertexBuffers: {
  52652. [key: string]: VertexBuffer;
  52653. }, indexBuffer: DataBuffer, effect: Effect): void;
  52654. /**
  52655. * Force the entire cache to be cleared
  52656. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52657. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52658. */
  52659. wipeCaches(bruteForce?: boolean): void;
  52660. /**
  52661. * Send a draw order
  52662. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52663. * @param indexStart defines the starting index
  52664. * @param indexCount defines the number of index to draw
  52665. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52666. */
  52667. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52668. /**
  52669. * Draw a list of indexed primitives
  52670. * @param fillMode defines the primitive to use
  52671. * @param indexStart defines the starting index
  52672. * @param indexCount defines the number of index to draw
  52673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52674. */
  52675. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52676. /**
  52677. * Draw a list of unindexed primitives
  52678. * @param fillMode defines the primitive to use
  52679. * @param verticesStart defines the index of first vertex to draw
  52680. * @param verticesCount defines the count of vertices to draw
  52681. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52682. */
  52683. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52684. /** @hidden */
  52685. _createTexture(): WebGLTexture;
  52686. /** @hidden */
  52687. _releaseTexture(texture: InternalTexture): void;
  52688. /**
  52689. * Usually called from Texture.ts.
  52690. * Passed information to create a WebGLTexture
  52691. * @param urlArg defines a value which contains one of the following:
  52692. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52693. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52694. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52695. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52696. * @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)
  52697. * @param scene needed for loading to the correct scene
  52698. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52699. * @param onLoad optional callback to be called upon successful completion
  52700. * @param onError optional callback to be called upon failure
  52701. * @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
  52702. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52703. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52704. * @param forcedExtension defines the extension to use to pick the right loader
  52705. * @param mimeType defines an optional mime type
  52706. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52707. */
  52708. 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;
  52709. /**
  52710. * Creates a new render target texture
  52711. * @param size defines the size of the texture
  52712. * @param options defines the options used to create the texture
  52713. * @returns a new render target texture stored in an InternalTexture
  52714. */
  52715. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52716. /**
  52717. * Update the sampling mode of a given texture
  52718. * @param samplingMode defines the required sampling mode
  52719. * @param texture defines the texture to update
  52720. */
  52721. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52722. /**
  52723. * Binds the frame buffer to the specified texture.
  52724. * @param texture The texture to render to or null for the default canvas
  52725. * @param faceIndex The face of the texture to render to in case of cube texture
  52726. * @param requiredWidth The width of the target to render to
  52727. * @param requiredHeight The height of the target to render to
  52728. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52729. * @param lodLevel defines le lod level to bind to the frame buffer
  52730. */
  52731. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52732. /**
  52733. * Unbind the current render target texture from the webGL context
  52734. * @param texture defines the render target texture to unbind
  52735. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52736. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52737. */
  52738. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52739. /**
  52740. * Creates a dynamic vertex buffer
  52741. * @param vertices the data for the dynamic vertex buffer
  52742. * @returns the new WebGL dynamic buffer
  52743. */
  52744. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52745. /**
  52746. * Update the content of a dynamic texture
  52747. * @param texture defines the texture to update
  52748. * @param canvas defines the canvas containing the source
  52749. * @param invertY defines if data must be stored with Y axis inverted
  52750. * @param premulAlpha defines if alpha is stored as premultiplied
  52751. * @param format defines the format of the data
  52752. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52753. */
  52754. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52755. /**
  52756. * Gets a boolean indicating if all created effects are ready
  52757. * @returns true if all effects are ready
  52758. */
  52759. areAllEffectsReady(): boolean;
  52760. /**
  52761. * @hidden
  52762. * Get the current error code of the webGL context
  52763. * @returns the error code
  52764. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52765. */
  52766. getError(): number;
  52767. /** @hidden */
  52768. _getUnpackAlignement(): number;
  52769. /** @hidden */
  52770. _unpackFlipY(value: boolean): void;
  52771. /**
  52772. * Update a dynamic index buffer
  52773. * @param indexBuffer defines the target index buffer
  52774. * @param indices defines the data to update
  52775. * @param offset defines the offset in the target index buffer where update should start
  52776. */
  52777. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52778. /**
  52779. * Updates a dynamic vertex buffer.
  52780. * @param vertexBuffer the vertex buffer to update
  52781. * @param vertices the data used to update the vertex buffer
  52782. * @param byteOffset the byte offset of the data (optional)
  52783. * @param byteLength the byte length of the data (optional)
  52784. */
  52785. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52786. /** @hidden */
  52787. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52788. /** @hidden */
  52789. _bindTexture(channel: number, texture: InternalTexture): void;
  52790. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52791. /**
  52792. * 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
  52793. */
  52794. releaseEffects(): void;
  52795. displayLoadingUI(): void;
  52796. hideLoadingUI(): void;
  52797. /** @hidden */
  52798. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52799. /** @hidden */
  52800. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52801. /** @hidden */
  52802. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52803. /** @hidden */
  52804. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52805. }
  52806. }
  52807. declare module "babylonjs/Instrumentation/timeToken" {
  52808. import { Nullable } from "babylonjs/types";
  52809. /**
  52810. * @hidden
  52811. **/
  52812. export class _TimeToken {
  52813. _startTimeQuery: Nullable<WebGLQuery>;
  52814. _endTimeQuery: Nullable<WebGLQuery>;
  52815. _timeElapsedQuery: Nullable<WebGLQuery>;
  52816. _timeElapsedQueryEnded: boolean;
  52817. }
  52818. }
  52819. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  52820. import { Nullable, int } from "babylonjs/types";
  52821. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  52822. /** @hidden */
  52823. export class _OcclusionDataStorage {
  52824. /** @hidden */
  52825. occlusionInternalRetryCounter: number;
  52826. /** @hidden */
  52827. isOcclusionQueryInProgress: boolean;
  52828. /** @hidden */
  52829. isOccluded: boolean;
  52830. /** @hidden */
  52831. occlusionRetryCount: number;
  52832. /** @hidden */
  52833. occlusionType: number;
  52834. /** @hidden */
  52835. occlusionQueryAlgorithmType: number;
  52836. }
  52837. module "babylonjs/Engines/engine" {
  52838. interface Engine {
  52839. /**
  52840. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52841. * @return the new query
  52842. */
  52843. createQuery(): WebGLQuery;
  52844. /**
  52845. * Delete and release a webGL query
  52846. * @param query defines the query to delete
  52847. * @return the current engine
  52848. */
  52849. deleteQuery(query: WebGLQuery): Engine;
  52850. /**
  52851. * Check if a given query has resolved and got its value
  52852. * @param query defines the query to check
  52853. * @returns true if the query got its value
  52854. */
  52855. isQueryResultAvailable(query: WebGLQuery): boolean;
  52856. /**
  52857. * Gets the value of a given query
  52858. * @param query defines the query to check
  52859. * @returns the value of the query
  52860. */
  52861. getQueryResult(query: WebGLQuery): number;
  52862. /**
  52863. * Initiates an occlusion query
  52864. * @param algorithmType defines the algorithm to use
  52865. * @param query defines the query to use
  52866. * @returns the current engine
  52867. * @see http://doc.babylonjs.com/features/occlusionquery
  52868. */
  52869. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52870. /**
  52871. * Ends an occlusion query
  52872. * @see http://doc.babylonjs.com/features/occlusionquery
  52873. * @param algorithmType defines the algorithm to use
  52874. * @returns the current engine
  52875. */
  52876. endOcclusionQuery(algorithmType: number): Engine;
  52877. /**
  52878. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52879. * Please note that only one query can be issued at a time
  52880. * @returns a time token used to track the time span
  52881. */
  52882. startTimeQuery(): Nullable<_TimeToken>;
  52883. /**
  52884. * Ends a time query
  52885. * @param token defines the token used to measure the time span
  52886. * @returns the time spent (in ns)
  52887. */
  52888. endTimeQuery(token: _TimeToken): int;
  52889. /** @hidden */
  52890. _currentNonTimestampToken: Nullable<_TimeToken>;
  52891. /** @hidden */
  52892. _createTimeQuery(): WebGLQuery;
  52893. /** @hidden */
  52894. _deleteTimeQuery(query: WebGLQuery): void;
  52895. /** @hidden */
  52896. _getGlAlgorithmType(algorithmType: number): number;
  52897. /** @hidden */
  52898. _getTimeQueryResult(query: WebGLQuery): any;
  52899. /** @hidden */
  52900. _getTimeQueryAvailability(query: WebGLQuery): any;
  52901. }
  52902. }
  52903. module "babylonjs/Meshes/abstractMesh" {
  52904. interface AbstractMesh {
  52905. /**
  52906. * Backing filed
  52907. * @hidden
  52908. */
  52909. __occlusionDataStorage: _OcclusionDataStorage;
  52910. /**
  52911. * Access property
  52912. * @hidden
  52913. */
  52914. _occlusionDataStorage: _OcclusionDataStorage;
  52915. /**
  52916. * 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.
  52917. * The default value is -1 which means don't break the query and wait till the result
  52918. * @see http://doc.babylonjs.com/features/occlusionquery
  52919. */
  52920. occlusionRetryCount: number;
  52921. /**
  52922. * 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:
  52923. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52924. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52925. * * 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.
  52926. * @see http://doc.babylonjs.com/features/occlusionquery
  52927. */
  52928. occlusionType: number;
  52929. /**
  52930. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52931. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52932. * * 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.
  52933. * @see http://doc.babylonjs.com/features/occlusionquery
  52934. */
  52935. occlusionQueryAlgorithmType: number;
  52936. /**
  52937. * 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
  52938. * @see http://doc.babylonjs.com/features/occlusionquery
  52939. */
  52940. isOccluded: boolean;
  52941. /**
  52942. * Flag to check the progress status of the query
  52943. * @see http://doc.babylonjs.com/features/occlusionquery
  52944. */
  52945. isOcclusionQueryInProgress: boolean;
  52946. }
  52947. }
  52948. }
  52949. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  52950. import { Nullable } from "babylonjs/types";
  52951. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52952. /** @hidden */
  52953. export var _forceTransformFeedbackToBundle: boolean;
  52954. module "babylonjs/Engines/engine" {
  52955. interface Engine {
  52956. /**
  52957. * Creates a webGL transform feedback object
  52958. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52959. * @returns the webGL transform feedback object
  52960. */
  52961. createTransformFeedback(): WebGLTransformFeedback;
  52962. /**
  52963. * Delete a webGL transform feedback object
  52964. * @param value defines the webGL transform feedback object to delete
  52965. */
  52966. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52967. /**
  52968. * Bind a webGL transform feedback object to the webgl context
  52969. * @param value defines the webGL transform feedback object to bind
  52970. */
  52971. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52972. /**
  52973. * Begins a transform feedback operation
  52974. * @param usePoints defines if points or triangles must be used
  52975. */
  52976. beginTransformFeedback(usePoints: boolean): void;
  52977. /**
  52978. * Ends a transform feedback operation
  52979. */
  52980. endTransformFeedback(): void;
  52981. /**
  52982. * Specify the varyings to use with transform feedback
  52983. * @param program defines the associated webGL program
  52984. * @param value defines the list of strings representing the varying names
  52985. */
  52986. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52987. /**
  52988. * Bind a webGL buffer for a transform feedback operation
  52989. * @param value defines the webGL buffer to bind
  52990. */
  52991. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52992. }
  52993. }
  52994. }
  52995. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  52996. import { Scene } from "babylonjs/scene";
  52997. import { Engine } from "babylonjs/Engines/engine";
  52998. import { Texture } from "babylonjs/Materials/Textures/texture";
  52999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53000. import "babylonjs/Engines/Extensions/engine.multiRender";
  53001. /**
  53002. * Creation options of the multi render target texture.
  53003. */
  53004. export interface IMultiRenderTargetOptions {
  53005. /**
  53006. * Define if the texture needs to create mip maps after render.
  53007. */
  53008. generateMipMaps?: boolean;
  53009. /**
  53010. * Define the types of all the draw buffers we want to create
  53011. */
  53012. types?: number[];
  53013. /**
  53014. * Define the sampling modes of all the draw buffers we want to create
  53015. */
  53016. samplingModes?: number[];
  53017. /**
  53018. * Define if a depth buffer is required
  53019. */
  53020. generateDepthBuffer?: boolean;
  53021. /**
  53022. * Define if a stencil buffer is required
  53023. */
  53024. generateStencilBuffer?: boolean;
  53025. /**
  53026. * Define if a depth texture is required instead of a depth buffer
  53027. */
  53028. generateDepthTexture?: boolean;
  53029. /**
  53030. * Define the number of desired draw buffers
  53031. */
  53032. textureCount?: number;
  53033. /**
  53034. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53035. */
  53036. doNotChangeAspectRatio?: boolean;
  53037. /**
  53038. * Define the default type of the buffers we are creating
  53039. */
  53040. defaultType?: number;
  53041. }
  53042. /**
  53043. * A multi render target, like a render target provides the ability to render to a texture.
  53044. * Unlike the render target, it can render to several draw buffers in one draw.
  53045. * This is specially interesting in deferred rendering or for any effects requiring more than
  53046. * just one color from a single pass.
  53047. */
  53048. export class MultiRenderTarget extends RenderTargetTexture {
  53049. private _internalTextures;
  53050. private _textures;
  53051. private _multiRenderTargetOptions;
  53052. /**
  53053. * Get if draw buffers are currently supported by the used hardware and browser.
  53054. */
  53055. get isSupported(): boolean;
  53056. /**
  53057. * Get the list of textures generated by the multi render target.
  53058. */
  53059. get textures(): Texture[];
  53060. /**
  53061. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53062. */
  53063. get depthTexture(): Texture;
  53064. /**
  53065. * Set the wrapping mode on U of all the textures we are rendering to.
  53066. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53067. */
  53068. set wrapU(wrap: number);
  53069. /**
  53070. * Set the wrapping mode on V of all the textures we are rendering to.
  53071. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53072. */
  53073. set wrapV(wrap: number);
  53074. /**
  53075. * Instantiate a new multi render target texture.
  53076. * A multi render target, like a render target provides the ability to render to a texture.
  53077. * Unlike the render target, it can render to several draw buffers in one draw.
  53078. * This is specially interesting in deferred rendering or for any effects requiring more than
  53079. * just one color from a single pass.
  53080. * @param name Define the name of the texture
  53081. * @param size Define the size of the buffers to render to
  53082. * @param count Define the number of target we are rendering into
  53083. * @param scene Define the scene the texture belongs to
  53084. * @param options Define the options used to create the multi render target
  53085. */
  53086. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53087. /** @hidden */
  53088. _rebuild(): void;
  53089. private _createInternalTextures;
  53090. private _createTextures;
  53091. /**
  53092. * Define the number of samples used if MSAA is enabled.
  53093. */
  53094. get samples(): number;
  53095. set samples(value: number);
  53096. /**
  53097. * Resize all the textures in the multi render target.
  53098. * Be carrefull as it will recreate all the data in the new texture.
  53099. * @param size Define the new size
  53100. */
  53101. resize(size: any): void;
  53102. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53103. /**
  53104. * Dispose the render targets and their associated resources
  53105. */
  53106. dispose(): void;
  53107. /**
  53108. * Release all the underlying texture used as draw buffers.
  53109. */
  53110. releaseInternalTextures(): void;
  53111. }
  53112. }
  53113. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53114. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53115. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53116. import { Nullable } from "babylonjs/types";
  53117. module "babylonjs/Engines/thinEngine" {
  53118. interface ThinEngine {
  53119. /**
  53120. * Unbind a list of render target textures from the webGL context
  53121. * This is used only when drawBuffer extension or webGL2 are active
  53122. * @param textures defines the render target textures to unbind
  53123. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53124. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53125. */
  53126. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53127. /**
  53128. * Create a multi render target texture
  53129. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  53130. * @param size defines the size of the texture
  53131. * @param options defines the creation options
  53132. * @returns the cube texture as an InternalTexture
  53133. */
  53134. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53135. /**
  53136. * Update the sample count for a given multiple render target texture
  53137. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53138. * @param textures defines the textures to update
  53139. * @param samples defines the sample count to set
  53140. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53141. */
  53142. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53143. }
  53144. }
  53145. }
  53146. declare module "babylonjs/Engines/Extensions/engine.views" {
  53147. import { Camera } from "babylonjs/Cameras/camera";
  53148. import { Nullable } from "babylonjs/types";
  53149. /**
  53150. * Class used to define an additional view for the engine
  53151. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53152. */
  53153. export class EngineView {
  53154. /** Defines the canvas where to render the view */
  53155. target: HTMLCanvasElement;
  53156. /** Defines an optional camera used to render the view (will use active camera else) */
  53157. camera?: Camera;
  53158. }
  53159. module "babylonjs/Engines/engine" {
  53160. interface Engine {
  53161. /**
  53162. * Gets or sets the HTML element to use for attaching events
  53163. */
  53164. inputElement: Nullable<HTMLElement>;
  53165. /**
  53166. * Gets the current engine view
  53167. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53168. */
  53169. activeView: Nullable<EngineView>;
  53170. /** Gets or sets the list of views */
  53171. views: EngineView[];
  53172. /**
  53173. * Register a new child canvas
  53174. * @param canvas defines the canvas to register
  53175. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53176. * @returns the associated view
  53177. */
  53178. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53179. /**
  53180. * Remove a registered child canvas
  53181. * @param canvas defines the canvas to remove
  53182. * @returns the current engine
  53183. */
  53184. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53185. }
  53186. }
  53187. }
  53188. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53189. import { Nullable } from "babylonjs/types";
  53190. module "babylonjs/Engines/engine" {
  53191. interface Engine {
  53192. /** @hidden */
  53193. _excludedCompressedTextures: string[];
  53194. /** @hidden */
  53195. _textureFormatInUse: string;
  53196. /**
  53197. * Gets the list of texture formats supported
  53198. */
  53199. readonly texturesSupported: Array<string>;
  53200. /**
  53201. * Gets the texture format in use
  53202. */
  53203. readonly textureFormatInUse: Nullable<string>;
  53204. /**
  53205. * Set the compressed texture extensions or file names to skip.
  53206. *
  53207. * @param skippedFiles defines the list of those texture files you want to skip
  53208. * Example: [".dds", ".env", "myfile.png"]
  53209. */
  53210. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53211. /**
  53212. * Set the compressed texture format to use, based on the formats you have, and the formats
  53213. * supported by the hardware / browser.
  53214. *
  53215. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53216. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53217. * to API arguments needed to compressed textures. This puts the burden on the container
  53218. * generator to house the arcane code for determining these for current & future formats.
  53219. *
  53220. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53221. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53222. *
  53223. * Note: The result of this call is not taken into account when a texture is base64.
  53224. *
  53225. * @param formatsAvailable defines the list of those format families you have created
  53226. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53227. *
  53228. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53229. * @returns The extension selected.
  53230. */
  53231. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53232. }
  53233. }
  53234. }
  53235. declare module "babylonjs/Engines/Extensions/index" {
  53236. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53237. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53238. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53239. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53240. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53241. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53242. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53243. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53244. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53245. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53246. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53247. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53248. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53249. export * from "babylonjs/Engines/Extensions/engine.views";
  53250. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53251. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53252. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53253. }
  53254. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53255. import { Nullable } from "babylonjs/types";
  53256. /**
  53257. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53258. */
  53259. export interface CubeMapInfo {
  53260. /**
  53261. * The pixel array for the front face.
  53262. * This is stored in format, left to right, up to down format.
  53263. */
  53264. front: Nullable<ArrayBufferView>;
  53265. /**
  53266. * The pixel array for the back face.
  53267. * This is stored in format, left to right, up to down format.
  53268. */
  53269. back: Nullable<ArrayBufferView>;
  53270. /**
  53271. * The pixel array for the left face.
  53272. * This is stored in format, left to right, up to down format.
  53273. */
  53274. left: Nullable<ArrayBufferView>;
  53275. /**
  53276. * The pixel array for the right face.
  53277. * This is stored in format, left to right, up to down format.
  53278. */
  53279. right: Nullable<ArrayBufferView>;
  53280. /**
  53281. * The pixel array for the up face.
  53282. * This is stored in format, left to right, up to down format.
  53283. */
  53284. up: Nullable<ArrayBufferView>;
  53285. /**
  53286. * The pixel array for the down face.
  53287. * This is stored in format, left to right, up to down format.
  53288. */
  53289. down: Nullable<ArrayBufferView>;
  53290. /**
  53291. * The size of the cubemap stored.
  53292. *
  53293. * Each faces will be size * size pixels.
  53294. */
  53295. size: number;
  53296. /**
  53297. * The format of the texture.
  53298. *
  53299. * RGBA, RGB.
  53300. */
  53301. format: number;
  53302. /**
  53303. * The type of the texture data.
  53304. *
  53305. * UNSIGNED_INT, FLOAT.
  53306. */
  53307. type: number;
  53308. /**
  53309. * Specifies whether the texture is in gamma space.
  53310. */
  53311. gammaSpace: boolean;
  53312. }
  53313. /**
  53314. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53315. */
  53316. export class PanoramaToCubeMapTools {
  53317. private static FACE_LEFT;
  53318. private static FACE_RIGHT;
  53319. private static FACE_FRONT;
  53320. private static FACE_BACK;
  53321. private static FACE_DOWN;
  53322. private static FACE_UP;
  53323. /**
  53324. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53325. *
  53326. * @param float32Array The source data.
  53327. * @param inputWidth The width of the input panorama.
  53328. * @param inputHeight The height of the input panorama.
  53329. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53330. * @return The cubemap data
  53331. */
  53332. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53333. private static CreateCubemapTexture;
  53334. private static CalcProjectionSpherical;
  53335. }
  53336. }
  53337. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53338. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53340. import { Nullable } from "babylonjs/types";
  53341. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53342. /**
  53343. * Helper class dealing with the extraction of spherical polynomial dataArray
  53344. * from a cube map.
  53345. */
  53346. export class CubeMapToSphericalPolynomialTools {
  53347. private static FileFaces;
  53348. /**
  53349. * Converts a texture to the according Spherical Polynomial data.
  53350. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53351. *
  53352. * @param texture The texture to extract the information from.
  53353. * @return The Spherical Polynomial data.
  53354. */
  53355. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53356. /**
  53357. * Converts a cubemap to the according Spherical Polynomial data.
  53358. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53359. *
  53360. * @param cubeInfo The Cube map to extract the information from.
  53361. * @return The Spherical Polynomial data.
  53362. */
  53363. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53364. }
  53365. }
  53366. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53367. import { Nullable } from "babylonjs/types";
  53368. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53369. module "babylonjs/Materials/Textures/baseTexture" {
  53370. interface BaseTexture {
  53371. /**
  53372. * Get the polynomial representation of the texture data.
  53373. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53374. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53375. */
  53376. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53377. }
  53378. }
  53379. }
  53380. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53381. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53382. /** @hidden */
  53383. export var rgbdEncodePixelShader: {
  53384. name: string;
  53385. shader: string;
  53386. };
  53387. }
  53388. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53389. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53390. /** @hidden */
  53391. export var rgbdDecodePixelShader: {
  53392. name: string;
  53393. shader: string;
  53394. };
  53395. }
  53396. declare module "babylonjs/Misc/environmentTextureTools" {
  53397. import { Nullable } from "babylonjs/types";
  53398. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53401. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53402. import "babylonjs/Engines/Extensions/engine.readTexture";
  53403. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53404. import "babylonjs/Shaders/rgbdEncode.fragment";
  53405. import "babylonjs/Shaders/rgbdDecode.fragment";
  53406. /**
  53407. * Raw texture data and descriptor sufficient for WebGL texture upload
  53408. */
  53409. export interface EnvironmentTextureInfo {
  53410. /**
  53411. * Version of the environment map
  53412. */
  53413. version: number;
  53414. /**
  53415. * Width of image
  53416. */
  53417. width: number;
  53418. /**
  53419. * Irradiance information stored in the file.
  53420. */
  53421. irradiance: any;
  53422. /**
  53423. * Specular information stored in the file.
  53424. */
  53425. specular: any;
  53426. }
  53427. /**
  53428. * Defines One Image in the file. It requires only the position in the file
  53429. * as well as the length.
  53430. */
  53431. interface BufferImageData {
  53432. /**
  53433. * Length of the image data.
  53434. */
  53435. length: number;
  53436. /**
  53437. * Position of the data from the null terminator delimiting the end of the JSON.
  53438. */
  53439. position: number;
  53440. }
  53441. /**
  53442. * Defines the specular data enclosed in the file.
  53443. * This corresponds to the version 1 of the data.
  53444. */
  53445. export interface EnvironmentTextureSpecularInfoV1 {
  53446. /**
  53447. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53448. */
  53449. specularDataPosition?: number;
  53450. /**
  53451. * This contains all the images data needed to reconstruct the cubemap.
  53452. */
  53453. mipmaps: Array<BufferImageData>;
  53454. /**
  53455. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53456. */
  53457. lodGenerationScale: number;
  53458. }
  53459. /**
  53460. * Sets of helpers addressing the serialization and deserialization of environment texture
  53461. * stored in a BabylonJS env file.
  53462. * Those files are usually stored as .env files.
  53463. */
  53464. export class EnvironmentTextureTools {
  53465. /**
  53466. * Magic number identifying the env file.
  53467. */
  53468. private static _MagicBytes;
  53469. /**
  53470. * Gets the environment info from an env file.
  53471. * @param data The array buffer containing the .env bytes.
  53472. * @returns the environment file info (the json header) if successfully parsed.
  53473. */
  53474. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53475. /**
  53476. * Creates an environment texture from a loaded cube texture.
  53477. * @param texture defines the cube texture to convert in env file
  53478. * @return a promise containing the environment data if succesfull.
  53479. */
  53480. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53481. /**
  53482. * Creates a JSON representation of the spherical data.
  53483. * @param texture defines the texture containing the polynomials
  53484. * @return the JSON representation of the spherical info
  53485. */
  53486. private static _CreateEnvTextureIrradiance;
  53487. /**
  53488. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53489. * @param data the image data
  53490. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53491. * @return the views described by info providing access to the underlying buffer
  53492. */
  53493. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53494. /**
  53495. * Uploads the texture info contained in the env file to the GPU.
  53496. * @param texture defines the internal texture to upload to
  53497. * @param data defines the data to load
  53498. * @param info defines the texture info retrieved through the GetEnvInfo method
  53499. * @returns a promise
  53500. */
  53501. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53502. private static _OnImageReadyAsync;
  53503. /**
  53504. * Uploads the levels of image data to the GPU.
  53505. * @param texture defines the internal texture to upload to
  53506. * @param imageData defines the array buffer views of image data [mipmap][face]
  53507. * @returns a promise
  53508. */
  53509. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53510. /**
  53511. * Uploads spherical polynomials information to the texture.
  53512. * @param texture defines the texture we are trying to upload the information to
  53513. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53514. */
  53515. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53516. /** @hidden */
  53517. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53518. }
  53519. }
  53520. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  53521. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53522. /** @hidden */
  53523. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  53524. private _genericAttributeLocation;
  53525. private _varyingLocationCount;
  53526. private _varyingLocationMap;
  53527. private _replacements;
  53528. private _textureCount;
  53529. private _uniforms;
  53530. lineProcessor(line: string): string;
  53531. attributeProcessor(attribute: string): string;
  53532. varyingProcessor(varying: string, isFragment: boolean): string;
  53533. uniformProcessor(uniform: string): string;
  53534. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  53535. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  53536. }
  53537. }
  53538. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53539. /**
  53540. * Class used to inline functions in shader code
  53541. */
  53542. export class ShaderCodeInliner {
  53543. private static readonly _RegexpFindFunctionNameAndType;
  53544. private _sourceCode;
  53545. private _functionDescr;
  53546. private _numMaxIterations;
  53547. /** Gets or sets the token used to mark the functions to inline */
  53548. inlineToken: string;
  53549. /** Gets or sets the debug mode */
  53550. debug: boolean;
  53551. /** Gets the code after the inlining process */
  53552. get code(): string;
  53553. /**
  53554. * Initializes the inliner
  53555. * @param sourceCode shader code source to inline
  53556. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53557. */
  53558. constructor(sourceCode: string, numMaxIterations?: number);
  53559. /**
  53560. * Start the processing of the shader code
  53561. */
  53562. processCode(): void;
  53563. private _collectFunctions;
  53564. private _processInlining;
  53565. private _extractBetweenMarkers;
  53566. private _skipWhitespaces;
  53567. private _removeComments;
  53568. private _replaceFunctionCallsByCode;
  53569. private _findBackward;
  53570. private _escapeRegExp;
  53571. private _replaceNames;
  53572. }
  53573. }
  53574. declare module "babylonjs/Engines/nativeEngine" {
  53575. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53576. import { Engine } from "babylonjs/Engines/engine";
  53577. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53578. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53580. import { Effect } from "babylonjs/Materials/effect";
  53581. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53582. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53583. import { IColor4Like } from "babylonjs/Maths/math.like";
  53584. import { Scene } from "babylonjs/scene";
  53585. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53586. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53587. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53588. /**
  53589. * Container for accessors for natively-stored mesh data buffers.
  53590. */
  53591. class NativeDataBuffer extends DataBuffer {
  53592. /**
  53593. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53594. */
  53595. nativeIndexBuffer?: any;
  53596. /**
  53597. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53598. */
  53599. nativeVertexBuffer?: any;
  53600. }
  53601. /** @hidden */
  53602. class NativeTexture extends InternalTexture {
  53603. getInternalTexture(): InternalTexture;
  53604. getViewCount(): number;
  53605. }
  53606. /** @hidden */
  53607. export class NativeEngine extends Engine {
  53608. private readonly _native;
  53609. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53610. private readonly INVALID_HANDLE;
  53611. getHardwareScalingLevel(): number;
  53612. constructor();
  53613. dispose(): void;
  53614. /**
  53615. * Can be used to override the current requestAnimationFrame requester.
  53616. * @hidden
  53617. */
  53618. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53619. /**
  53620. * Override default engine behavior.
  53621. * @param color
  53622. * @param backBuffer
  53623. * @param depth
  53624. * @param stencil
  53625. */
  53626. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53627. /**
  53628. * Gets host document
  53629. * @returns the host document object
  53630. */
  53631. getHostDocument(): Nullable<Document>;
  53632. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53633. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53634. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53635. recordVertexArrayObject(vertexBuffers: {
  53636. [key: string]: VertexBuffer;
  53637. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53638. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53639. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53640. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53641. /**
  53642. * Draw a list of indexed primitives
  53643. * @param fillMode defines the primitive to use
  53644. * @param indexStart defines the starting index
  53645. * @param indexCount defines the number of index to draw
  53646. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53647. */
  53648. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53649. /**
  53650. * Draw a list of unindexed primitives
  53651. * @param fillMode defines the primitive to use
  53652. * @param verticesStart defines the index of first vertex to draw
  53653. * @param verticesCount defines the count of vertices to draw
  53654. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53655. */
  53656. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53657. createPipelineContext(): IPipelineContext;
  53658. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53659. /** @hidden */
  53660. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53661. /** @hidden */
  53662. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53663. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53664. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53665. protected _setProgram(program: WebGLProgram): void;
  53666. _releaseEffect(effect: Effect): void;
  53667. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53668. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53669. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53670. bindSamplers(effect: Effect): void;
  53671. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53672. getRenderWidth(useScreen?: boolean): number;
  53673. getRenderHeight(useScreen?: boolean): number;
  53674. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53675. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53676. /**
  53677. * Set the z offset to apply to current rendering
  53678. * @param value defines the offset to apply
  53679. */
  53680. setZOffset(value: number): void;
  53681. /**
  53682. * Gets the current value of the zOffset
  53683. * @returns the current zOffset state
  53684. */
  53685. getZOffset(): number;
  53686. /**
  53687. * Enable or disable depth buffering
  53688. * @param enable defines the state to set
  53689. */
  53690. setDepthBuffer(enable: boolean): void;
  53691. /**
  53692. * Gets a boolean indicating if depth writing is enabled
  53693. * @returns the current depth writing state
  53694. */
  53695. getDepthWrite(): boolean;
  53696. /**
  53697. * Enable or disable depth writing
  53698. * @param enable defines the state to set
  53699. */
  53700. setDepthWrite(enable: boolean): void;
  53701. /**
  53702. * Enable or disable color writing
  53703. * @param enable defines the state to set
  53704. */
  53705. setColorWrite(enable: boolean): void;
  53706. /**
  53707. * Gets a boolean indicating if color writing is enabled
  53708. * @returns the current color writing state
  53709. */
  53710. getColorWrite(): boolean;
  53711. /**
  53712. * Sets alpha constants used by some alpha blending modes
  53713. * @param r defines the red component
  53714. * @param g defines the green component
  53715. * @param b defines the blue component
  53716. * @param a defines the alpha component
  53717. */
  53718. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53719. /**
  53720. * Sets the current alpha mode
  53721. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53722. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53723. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53724. */
  53725. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53726. /**
  53727. * Gets the current alpha mode
  53728. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53729. * @returns the current alpha mode
  53730. */
  53731. getAlphaMode(): number;
  53732. setInt(uniform: WebGLUniformLocation, int: number): void;
  53733. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53734. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53735. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53736. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53737. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53738. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53739. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53740. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53741. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53742. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53743. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53744. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53745. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53746. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53747. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53748. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53749. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53750. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53751. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53752. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53753. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53754. wipeCaches(bruteForce?: boolean): void;
  53755. _createTexture(): WebGLTexture;
  53756. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53757. /**
  53758. * Usually called from Texture.ts.
  53759. * Passed information to create a WebGLTexture
  53760. * @param url defines a value which contains one of the following:
  53761. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53762. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53763. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53764. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53765. * @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)
  53766. * @param scene needed for loading to the correct scene
  53767. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53768. * @param onLoad optional callback to be called upon successful completion
  53769. * @param onError optional callback to be called upon failure
  53770. * @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
  53771. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53772. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53773. * @param forcedExtension defines the extension to use to pick the right loader
  53774. * @param mimeType defines an optional mime type
  53775. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53776. */
  53777. 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;
  53778. /**
  53779. * Creates a cube texture
  53780. * @param rootUrl defines the url where the files to load is located
  53781. * @param scene defines the current scene
  53782. * @param files defines the list of files to load (1 per face)
  53783. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53784. * @param onLoad defines an optional callback raised when the texture is loaded
  53785. * @param onError defines an optional callback raised if there is an issue to load the texture
  53786. * @param format defines the format of the data
  53787. * @param forcedExtension defines the extension to use to pick the right loader
  53788. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53789. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53790. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53791. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53792. * @returns the cube texture as an InternalTexture
  53793. */
  53794. 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;
  53795. private _getSamplingFilter;
  53796. private static _GetNativeTextureFormat;
  53797. createRenderTargetTexture(size: number | {
  53798. width: number;
  53799. height: number;
  53800. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53801. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53802. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53803. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53804. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53805. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53806. /**
  53807. * Updates a dynamic vertex buffer.
  53808. * @param vertexBuffer the vertex buffer to update
  53809. * @param data the data used to update the vertex buffer
  53810. * @param byteOffset the byte offset of the data (optional)
  53811. * @param byteLength the byte length of the data (optional)
  53812. */
  53813. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53814. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53815. private _updateAnisotropicLevel;
  53816. private _getAddressMode;
  53817. /** @hidden */
  53818. _bindTexture(channel: number, texture: InternalTexture): void;
  53819. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53820. releaseEffects(): void;
  53821. /** @hidden */
  53822. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53823. /** @hidden */
  53824. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53825. /** @hidden */
  53826. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53827. /** @hidden */
  53828. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53829. }
  53830. }
  53831. declare module "babylonjs/Engines/index" {
  53832. export * from "babylonjs/Engines/constants";
  53833. export * from "babylonjs/Engines/engineCapabilities";
  53834. export * from "babylonjs/Engines/instancingAttributeInfo";
  53835. export * from "babylonjs/Engines/thinEngine";
  53836. export * from "babylonjs/Engines/engine";
  53837. export * from "babylonjs/Engines/engineStore";
  53838. export * from "babylonjs/Engines/nullEngine";
  53839. export * from "babylonjs/Engines/Extensions/index";
  53840. export * from "babylonjs/Engines/IPipelineContext";
  53841. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  53842. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  53843. export * from "babylonjs/Engines/nativeEngine";
  53844. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  53845. }
  53846. declare module "babylonjs/Events/clipboardEvents" {
  53847. /**
  53848. * Gather the list of clipboard event types as constants.
  53849. */
  53850. export class ClipboardEventTypes {
  53851. /**
  53852. * The clipboard event is fired when a copy command is active (pressed).
  53853. */
  53854. static readonly COPY: number;
  53855. /**
  53856. * The clipboard event is fired when a cut command is active (pressed).
  53857. */
  53858. static readonly CUT: number;
  53859. /**
  53860. * The clipboard event is fired when a paste command is active (pressed).
  53861. */
  53862. static readonly PASTE: number;
  53863. }
  53864. /**
  53865. * This class is used to store clipboard related info for the onClipboardObservable event.
  53866. */
  53867. export class ClipboardInfo {
  53868. /**
  53869. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53870. */
  53871. type: number;
  53872. /**
  53873. * Defines the related dom event
  53874. */
  53875. event: ClipboardEvent;
  53876. /**
  53877. *Creates an instance of ClipboardInfo.
  53878. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53879. * @param event Defines the related dom event
  53880. */
  53881. constructor(
  53882. /**
  53883. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53884. */
  53885. type: number,
  53886. /**
  53887. * Defines the related dom event
  53888. */
  53889. event: ClipboardEvent);
  53890. /**
  53891. * Get the clipboard event's type from the keycode.
  53892. * @param keyCode Defines the keyCode for the current keyboard event.
  53893. * @return {number}
  53894. */
  53895. static GetTypeFromCharacter(keyCode: number): number;
  53896. }
  53897. }
  53898. declare module "babylonjs/Events/index" {
  53899. export * from "babylonjs/Events/keyboardEvents";
  53900. export * from "babylonjs/Events/pointerEvents";
  53901. export * from "babylonjs/Events/clipboardEvents";
  53902. }
  53903. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  53904. import { Scene } from "babylonjs/scene";
  53905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53906. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53907. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53908. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53909. /**
  53910. * Google Daydream controller
  53911. */
  53912. export class DaydreamController extends WebVRController {
  53913. /**
  53914. * Base Url for the controller model.
  53915. */
  53916. static MODEL_BASE_URL: string;
  53917. /**
  53918. * File name for the controller model.
  53919. */
  53920. static MODEL_FILENAME: string;
  53921. /**
  53922. * Gamepad Id prefix used to identify Daydream Controller.
  53923. */
  53924. static readonly GAMEPAD_ID_PREFIX: string;
  53925. /**
  53926. * Creates a new DaydreamController from a gamepad
  53927. * @param vrGamepad the gamepad that the controller should be created from
  53928. */
  53929. constructor(vrGamepad: any);
  53930. /**
  53931. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53932. * @param scene scene in which to add meshes
  53933. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53934. */
  53935. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53936. /**
  53937. * Called once for each button that changed state since the last frame
  53938. * @param buttonIdx Which button index changed
  53939. * @param state New state of the button
  53940. * @param changes Which properties on the state changed since last frame
  53941. */
  53942. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53943. }
  53944. }
  53945. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  53946. import { Scene } from "babylonjs/scene";
  53947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53948. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53949. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53950. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53951. /**
  53952. * Gear VR Controller
  53953. */
  53954. export class GearVRController extends WebVRController {
  53955. /**
  53956. * Base Url for the controller model.
  53957. */
  53958. static MODEL_BASE_URL: string;
  53959. /**
  53960. * File name for the controller model.
  53961. */
  53962. static MODEL_FILENAME: string;
  53963. /**
  53964. * Gamepad Id prefix used to identify this controller.
  53965. */
  53966. static readonly GAMEPAD_ID_PREFIX: string;
  53967. private readonly _buttonIndexToObservableNameMap;
  53968. /**
  53969. * Creates a new GearVRController from a gamepad
  53970. * @param vrGamepad the gamepad that the controller should be created from
  53971. */
  53972. constructor(vrGamepad: any);
  53973. /**
  53974. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53975. * @param scene scene in which to add meshes
  53976. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53977. */
  53978. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53979. /**
  53980. * Called once for each button that changed state since the last frame
  53981. * @param buttonIdx Which button index changed
  53982. * @param state New state of the button
  53983. * @param changes Which properties on the state changed since last frame
  53984. */
  53985. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53986. }
  53987. }
  53988. declare module "babylonjs/Gamepads/Controllers/genericController" {
  53989. import { Scene } from "babylonjs/scene";
  53990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53991. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  53992. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  53993. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  53994. /**
  53995. * Generic Controller
  53996. */
  53997. export class GenericController extends WebVRController {
  53998. /**
  53999. * Base Url for the controller model.
  54000. */
  54001. static readonly MODEL_BASE_URL: string;
  54002. /**
  54003. * File name for the controller model.
  54004. */
  54005. static readonly MODEL_FILENAME: string;
  54006. /**
  54007. * Creates a new GenericController from a gamepad
  54008. * @param vrGamepad the gamepad that the controller should be created from
  54009. */
  54010. constructor(vrGamepad: any);
  54011. /**
  54012. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54013. * @param scene scene in which to add meshes
  54014. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54015. */
  54016. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54017. /**
  54018. * Called once for each button that changed state since the last frame
  54019. * @param buttonIdx Which button index changed
  54020. * @param state New state of the button
  54021. * @param changes Which properties on the state changed since last frame
  54022. */
  54023. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54024. }
  54025. }
  54026. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54027. import { Observable } from "babylonjs/Misc/observable";
  54028. import { Scene } from "babylonjs/scene";
  54029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54030. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54031. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54032. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54033. /**
  54034. * Oculus Touch Controller
  54035. */
  54036. export class OculusTouchController extends WebVRController {
  54037. /**
  54038. * Base Url for the controller model.
  54039. */
  54040. static MODEL_BASE_URL: string;
  54041. /**
  54042. * File name for the left controller model.
  54043. */
  54044. static MODEL_LEFT_FILENAME: string;
  54045. /**
  54046. * File name for the right controller model.
  54047. */
  54048. static MODEL_RIGHT_FILENAME: string;
  54049. /**
  54050. * Base Url for the Quest controller model.
  54051. */
  54052. static QUEST_MODEL_BASE_URL: string;
  54053. /**
  54054. * @hidden
  54055. * If the controllers are running on a device that needs the updated Quest controller models
  54056. */
  54057. static _IsQuest: boolean;
  54058. /**
  54059. * Fired when the secondary trigger on this controller is modified
  54060. */
  54061. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54062. /**
  54063. * Fired when the thumb rest on this controller is modified
  54064. */
  54065. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54066. /**
  54067. * Creates a new OculusTouchController from a gamepad
  54068. * @param vrGamepad the gamepad that the controller should be created from
  54069. */
  54070. constructor(vrGamepad: any);
  54071. /**
  54072. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54073. * @param scene scene in which to add meshes
  54074. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54075. */
  54076. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54077. /**
  54078. * Fired when the A button on this controller is modified
  54079. */
  54080. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54081. /**
  54082. * Fired when the B button on this controller is modified
  54083. */
  54084. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54085. /**
  54086. * Fired when the X button on this controller is modified
  54087. */
  54088. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54089. /**
  54090. * Fired when the Y button on this controller is modified
  54091. */
  54092. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54093. /**
  54094. * Called once for each button that changed state since the last frame
  54095. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54096. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54097. * 2) secondary trigger (same)
  54098. * 3) A (right) X (left), touch, pressed = value
  54099. * 4) B / Y
  54100. * 5) thumb rest
  54101. * @param buttonIdx Which button index changed
  54102. * @param state New state of the button
  54103. * @param changes Which properties on the state changed since last frame
  54104. */
  54105. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54106. }
  54107. }
  54108. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54109. import { Scene } from "babylonjs/scene";
  54110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54111. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54112. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54113. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54114. import { Observable } from "babylonjs/Misc/observable";
  54115. /**
  54116. * Vive Controller
  54117. */
  54118. export class ViveController extends WebVRController {
  54119. /**
  54120. * Base Url for the controller model.
  54121. */
  54122. static MODEL_BASE_URL: string;
  54123. /**
  54124. * File name for the controller model.
  54125. */
  54126. static MODEL_FILENAME: string;
  54127. /**
  54128. * Creates a new ViveController from a gamepad
  54129. * @param vrGamepad the gamepad that the controller should be created from
  54130. */
  54131. constructor(vrGamepad: any);
  54132. /**
  54133. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54134. * @param scene scene in which to add meshes
  54135. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54136. */
  54137. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54138. /**
  54139. * Fired when the left button on this controller is modified
  54140. */
  54141. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54142. /**
  54143. * Fired when the right button on this controller is modified
  54144. */
  54145. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54146. /**
  54147. * Fired when the menu button on this controller is modified
  54148. */
  54149. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54150. /**
  54151. * Called once for each button that changed state since the last frame
  54152. * Vive mapping:
  54153. * 0: touchpad
  54154. * 1: trigger
  54155. * 2: left AND right buttons
  54156. * 3: menu button
  54157. * @param buttonIdx Which button index changed
  54158. * @param state New state of the button
  54159. * @param changes Which properties on the state changed since last frame
  54160. */
  54161. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54162. }
  54163. }
  54164. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54165. import { Observable } from "babylonjs/Misc/observable";
  54166. import { Scene } from "babylonjs/scene";
  54167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54168. import { Ray } from "babylonjs/Culling/ray";
  54169. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54170. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54171. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54172. /**
  54173. * Defines the WindowsMotionController object that the state of the windows motion controller
  54174. */
  54175. export class WindowsMotionController extends WebVRController {
  54176. /**
  54177. * The base url used to load the left and right controller models
  54178. */
  54179. static MODEL_BASE_URL: string;
  54180. /**
  54181. * The name of the left controller model file
  54182. */
  54183. static MODEL_LEFT_FILENAME: string;
  54184. /**
  54185. * The name of the right controller model file
  54186. */
  54187. static MODEL_RIGHT_FILENAME: string;
  54188. /**
  54189. * The controller name prefix for this controller type
  54190. */
  54191. static readonly GAMEPAD_ID_PREFIX: string;
  54192. /**
  54193. * The controller id pattern for this controller type
  54194. */
  54195. private static readonly GAMEPAD_ID_PATTERN;
  54196. private _loadedMeshInfo;
  54197. protected readonly _mapping: {
  54198. buttons: string[];
  54199. buttonMeshNames: {
  54200. trigger: string;
  54201. menu: string;
  54202. grip: string;
  54203. thumbstick: string;
  54204. trackpad: string;
  54205. };
  54206. buttonObservableNames: {
  54207. trigger: string;
  54208. menu: string;
  54209. grip: string;
  54210. thumbstick: string;
  54211. trackpad: string;
  54212. };
  54213. axisMeshNames: string[];
  54214. pointingPoseMeshName: string;
  54215. };
  54216. /**
  54217. * Fired when the trackpad on this controller is clicked
  54218. */
  54219. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54220. /**
  54221. * Fired when the trackpad on this controller is modified
  54222. */
  54223. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54224. /**
  54225. * The current x and y values of this controller's trackpad
  54226. */
  54227. trackpad: StickValues;
  54228. /**
  54229. * Creates a new WindowsMotionController from a gamepad
  54230. * @param vrGamepad the gamepad that the controller should be created from
  54231. */
  54232. constructor(vrGamepad: any);
  54233. /**
  54234. * Fired when the trigger on this controller is modified
  54235. */
  54236. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54237. /**
  54238. * Fired when the menu button on this controller is modified
  54239. */
  54240. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54241. /**
  54242. * Fired when the grip button on this controller is modified
  54243. */
  54244. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54245. /**
  54246. * Fired when the thumbstick button on this controller is modified
  54247. */
  54248. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54249. /**
  54250. * Fired when the touchpad button on this controller is modified
  54251. */
  54252. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54253. /**
  54254. * Fired when the touchpad values on this controller are modified
  54255. */
  54256. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54257. protected _updateTrackpad(): void;
  54258. /**
  54259. * Called once per frame by the engine.
  54260. */
  54261. update(): void;
  54262. /**
  54263. * Called once for each button that changed state since the last frame
  54264. * @param buttonIdx Which button index changed
  54265. * @param state New state of the button
  54266. * @param changes Which properties on the state changed since last frame
  54267. */
  54268. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54269. /**
  54270. * Moves the buttons on the controller mesh based on their current state
  54271. * @param buttonName the name of the button to move
  54272. * @param buttonValue the value of the button which determines the buttons new position
  54273. */
  54274. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54275. /**
  54276. * Moves the axis on the controller mesh based on its current state
  54277. * @param axis the index of the axis
  54278. * @param axisValue the value of the axis which determines the meshes new position
  54279. * @hidden
  54280. */
  54281. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54282. /**
  54283. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54284. * @param scene scene in which to add meshes
  54285. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54286. */
  54287. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54288. /**
  54289. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54290. * can be transformed by button presses and axes values, based on this._mapping.
  54291. *
  54292. * @param scene scene in which the meshes exist
  54293. * @param meshes list of meshes that make up the controller model to process
  54294. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54295. */
  54296. private processModel;
  54297. private createMeshInfo;
  54298. /**
  54299. * Gets the ray of the controller in the direction the controller is pointing
  54300. * @param length the length the resulting ray should be
  54301. * @returns a ray in the direction the controller is pointing
  54302. */
  54303. getForwardRay(length?: number): Ray;
  54304. /**
  54305. * Disposes of the controller
  54306. */
  54307. dispose(): void;
  54308. }
  54309. /**
  54310. * This class represents a new windows motion controller in XR.
  54311. */
  54312. export class XRWindowsMotionController extends WindowsMotionController {
  54313. /**
  54314. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54315. */
  54316. protected readonly _mapping: {
  54317. buttons: string[];
  54318. buttonMeshNames: {
  54319. trigger: string;
  54320. menu: string;
  54321. grip: string;
  54322. thumbstick: string;
  54323. trackpad: string;
  54324. };
  54325. buttonObservableNames: {
  54326. trigger: string;
  54327. menu: string;
  54328. grip: string;
  54329. thumbstick: string;
  54330. trackpad: string;
  54331. };
  54332. axisMeshNames: string[];
  54333. pointingPoseMeshName: string;
  54334. };
  54335. /**
  54336. * Construct a new XR-Based windows motion controller
  54337. *
  54338. * @param gamepadInfo the gamepad object from the browser
  54339. */
  54340. constructor(gamepadInfo: any);
  54341. /**
  54342. * holds the thumbstick values (X,Y)
  54343. */
  54344. thumbstickValues: StickValues;
  54345. /**
  54346. * Fired when the thumbstick on this controller is clicked
  54347. */
  54348. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54349. /**
  54350. * Fired when the thumbstick on this controller is modified
  54351. */
  54352. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54353. /**
  54354. * Fired when the touchpad button on this controller is modified
  54355. */
  54356. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54357. /**
  54358. * Fired when the touchpad values on this controller are modified
  54359. */
  54360. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54361. /**
  54362. * Fired when the thumbstick button on this controller is modified
  54363. * here to prevent breaking changes
  54364. */
  54365. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54366. /**
  54367. * updating the thumbstick(!) and not the trackpad.
  54368. * This is named this way due to the difference between WebVR and XR and to avoid
  54369. * changing the parent class.
  54370. */
  54371. protected _updateTrackpad(): void;
  54372. /**
  54373. * Disposes the class with joy
  54374. */
  54375. dispose(): void;
  54376. }
  54377. }
  54378. declare module "babylonjs/Gamepads/Controllers/index" {
  54379. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54380. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54381. export * from "babylonjs/Gamepads/Controllers/genericController";
  54382. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54383. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54384. export * from "babylonjs/Gamepads/Controllers/viveController";
  54385. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54386. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54387. }
  54388. declare module "babylonjs/Gamepads/index" {
  54389. export * from "babylonjs/Gamepads/Controllers/index";
  54390. export * from "babylonjs/Gamepads/gamepad";
  54391. export * from "babylonjs/Gamepads/gamepadManager";
  54392. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54393. export * from "babylonjs/Gamepads/xboxGamepad";
  54394. export * from "babylonjs/Gamepads/dualShockGamepad";
  54395. }
  54396. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54397. import { Scene } from "babylonjs/scene";
  54398. import { Vector4 } from "babylonjs/Maths/math.vector";
  54399. import { Color4 } from "babylonjs/Maths/math.color";
  54400. import { Mesh } from "babylonjs/Meshes/mesh";
  54401. import { Nullable } from "babylonjs/types";
  54402. /**
  54403. * Class containing static functions to help procedurally build meshes
  54404. */
  54405. export class PolyhedronBuilder {
  54406. /**
  54407. * Creates a polyhedron mesh
  54408. * * 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
  54409. * * The parameter `size` (positive float, default 1) sets the polygon size
  54410. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54411. * * 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`
  54412. * * 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
  54413. * * 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)`)
  54414. * * 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
  54415. * * 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
  54416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54419. * @param name defines the name of the mesh
  54420. * @param options defines the options used to create the mesh
  54421. * @param scene defines the hosting scene
  54422. * @returns the polyhedron mesh
  54423. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54424. */
  54425. static CreatePolyhedron(name: string, options: {
  54426. type?: number;
  54427. size?: number;
  54428. sizeX?: number;
  54429. sizeY?: number;
  54430. sizeZ?: number;
  54431. custom?: any;
  54432. faceUV?: Vector4[];
  54433. faceColors?: Color4[];
  54434. flat?: boolean;
  54435. updatable?: boolean;
  54436. sideOrientation?: number;
  54437. frontUVs?: Vector4;
  54438. backUVs?: Vector4;
  54439. }, scene?: Nullable<Scene>): Mesh;
  54440. }
  54441. }
  54442. declare module "babylonjs/Gizmos/scaleGizmo" {
  54443. import { Observable } from "babylonjs/Misc/observable";
  54444. import { Nullable } from "babylonjs/types";
  54445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54446. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54447. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54448. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54449. /**
  54450. * Gizmo that enables scaling a mesh along 3 axis
  54451. */
  54452. export class ScaleGizmo extends Gizmo {
  54453. /**
  54454. * Internal gizmo used for interactions on the x axis
  54455. */
  54456. xGizmo: AxisScaleGizmo;
  54457. /**
  54458. * Internal gizmo used for interactions on the y axis
  54459. */
  54460. yGizmo: AxisScaleGizmo;
  54461. /**
  54462. * Internal gizmo used for interactions on the z axis
  54463. */
  54464. zGizmo: AxisScaleGizmo;
  54465. /**
  54466. * Internal gizmo used to scale all axis equally
  54467. */
  54468. uniformScaleGizmo: AxisScaleGizmo;
  54469. private _meshAttached;
  54470. private _updateGizmoRotationToMatchAttachedMesh;
  54471. private _snapDistance;
  54472. private _scaleRatio;
  54473. private _uniformScalingMesh;
  54474. private _octahedron;
  54475. private _sensitivity;
  54476. /** Fires an event when any of it's sub gizmos are dragged */
  54477. onDragStartObservable: Observable<unknown>;
  54478. /** Fires an event when any of it's sub gizmos are released from dragging */
  54479. onDragEndObservable: Observable<unknown>;
  54480. get attachedMesh(): Nullable<AbstractMesh>;
  54481. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54482. /**
  54483. * Creates a ScaleGizmo
  54484. * @param gizmoLayer The utility layer the gizmo will be added to
  54485. */
  54486. constructor(gizmoLayer?: UtilityLayerRenderer);
  54487. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54488. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54489. /**
  54490. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54491. */
  54492. set snapDistance(value: number);
  54493. get snapDistance(): number;
  54494. /**
  54495. * Ratio for the scale of the gizmo (Default: 1)
  54496. */
  54497. set scaleRatio(value: number);
  54498. get scaleRatio(): number;
  54499. /**
  54500. * Sensitivity factor for dragging (Default: 1)
  54501. */
  54502. set sensitivity(value: number);
  54503. get sensitivity(): number;
  54504. /**
  54505. * Disposes of the gizmo
  54506. */
  54507. dispose(): void;
  54508. }
  54509. }
  54510. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54511. import { Observable } from "babylonjs/Misc/observable";
  54512. import { Nullable } from "babylonjs/types";
  54513. import { Vector3 } from "babylonjs/Maths/math.vector";
  54514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54515. import { Mesh } from "babylonjs/Meshes/mesh";
  54516. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54517. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54518. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54519. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54520. import { Color3 } from "babylonjs/Maths/math.color";
  54521. /**
  54522. * Single axis scale gizmo
  54523. */
  54524. export class AxisScaleGizmo extends Gizmo {
  54525. /**
  54526. * Drag behavior responsible for the gizmos dragging interactions
  54527. */
  54528. dragBehavior: PointerDragBehavior;
  54529. private _pointerObserver;
  54530. /**
  54531. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54532. */
  54533. snapDistance: number;
  54534. /**
  54535. * Event that fires each time the gizmo snaps to a new location.
  54536. * * snapDistance is the the change in distance
  54537. */
  54538. onSnapObservable: Observable<{
  54539. snapDistance: number;
  54540. }>;
  54541. /**
  54542. * If the scaling operation should be done on all axis (default: false)
  54543. */
  54544. uniformScaling: boolean;
  54545. /**
  54546. * Custom sensitivity value for the drag strength
  54547. */
  54548. sensitivity: number;
  54549. private _isEnabled;
  54550. private _parent;
  54551. private _arrow;
  54552. private _coloredMaterial;
  54553. private _hoverMaterial;
  54554. /**
  54555. * Creates an AxisScaleGizmo
  54556. * @param gizmoLayer The utility layer the gizmo will be added to
  54557. * @param dragAxis The axis which the gizmo will be able to scale on
  54558. * @param color The color of the gizmo
  54559. */
  54560. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54561. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54562. /**
  54563. * If the gizmo is enabled
  54564. */
  54565. set isEnabled(value: boolean);
  54566. get isEnabled(): boolean;
  54567. /**
  54568. * Disposes of the gizmo
  54569. */
  54570. dispose(): void;
  54571. /**
  54572. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54573. * @param mesh The mesh to replace the default mesh of the gizmo
  54574. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54575. */
  54576. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54577. }
  54578. }
  54579. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54580. import { Observable } from "babylonjs/Misc/observable";
  54581. import { Nullable } from "babylonjs/types";
  54582. import { Vector3 } from "babylonjs/Maths/math.vector";
  54583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54584. import { Mesh } from "babylonjs/Meshes/mesh";
  54585. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54586. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54587. import { Color3 } from "babylonjs/Maths/math.color";
  54588. import "babylonjs/Meshes/Builders/boxBuilder";
  54589. /**
  54590. * Bounding box gizmo
  54591. */
  54592. export class BoundingBoxGizmo extends Gizmo {
  54593. private _lineBoundingBox;
  54594. private _rotateSpheresParent;
  54595. private _scaleBoxesParent;
  54596. private _boundingDimensions;
  54597. private _renderObserver;
  54598. private _pointerObserver;
  54599. private _scaleDragSpeed;
  54600. private _tmpQuaternion;
  54601. private _tmpVector;
  54602. private _tmpRotationMatrix;
  54603. /**
  54604. * 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)
  54605. */
  54606. ignoreChildren: boolean;
  54607. /**
  54608. * 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)
  54609. */
  54610. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54611. /**
  54612. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54613. */
  54614. rotationSphereSize: number;
  54615. /**
  54616. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54617. */
  54618. scaleBoxSize: number;
  54619. /**
  54620. * 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)
  54621. */
  54622. fixedDragMeshScreenSize: boolean;
  54623. /**
  54624. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54625. */
  54626. fixedDragMeshScreenSizeDistanceFactor: number;
  54627. /**
  54628. * Fired when a rotation sphere or scale box is dragged
  54629. */
  54630. onDragStartObservable: Observable<{}>;
  54631. /**
  54632. * Fired when a scale box is dragged
  54633. */
  54634. onScaleBoxDragObservable: Observable<{}>;
  54635. /**
  54636. * Fired when a scale box drag is ended
  54637. */
  54638. onScaleBoxDragEndObservable: Observable<{}>;
  54639. /**
  54640. * Fired when a rotation sphere is dragged
  54641. */
  54642. onRotationSphereDragObservable: Observable<{}>;
  54643. /**
  54644. * Fired when a rotation sphere drag is ended
  54645. */
  54646. onRotationSphereDragEndObservable: Observable<{}>;
  54647. /**
  54648. * 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)
  54649. */
  54650. scalePivot: Nullable<Vector3>;
  54651. /**
  54652. * Mesh used as a pivot to rotate the attached mesh
  54653. */
  54654. private _anchorMesh;
  54655. private _existingMeshScale;
  54656. private _dragMesh;
  54657. private pointerDragBehavior;
  54658. private coloredMaterial;
  54659. private hoverColoredMaterial;
  54660. /**
  54661. * Sets the color of the bounding box gizmo
  54662. * @param color the color to set
  54663. */
  54664. setColor(color: Color3): void;
  54665. /**
  54666. * Creates an BoundingBoxGizmo
  54667. * @param gizmoLayer The utility layer the gizmo will be added to
  54668. * @param color The color of the gizmo
  54669. */
  54670. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54671. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54672. private _selectNode;
  54673. /**
  54674. * Updates the bounding box information for the Gizmo
  54675. */
  54676. updateBoundingBox(): void;
  54677. private _updateRotationSpheres;
  54678. private _updateScaleBoxes;
  54679. /**
  54680. * Enables rotation on the specified axis and disables rotation on the others
  54681. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54682. */
  54683. setEnabledRotationAxis(axis: string): void;
  54684. /**
  54685. * Enables/disables scaling
  54686. * @param enable if scaling should be enabled
  54687. * @param homogeneousScaling defines if scaling should only be homogeneous
  54688. */
  54689. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54690. private _updateDummy;
  54691. /**
  54692. * Enables a pointer drag behavior on the bounding box of the gizmo
  54693. */
  54694. enableDragBehavior(): void;
  54695. /**
  54696. * Disposes of the gizmo
  54697. */
  54698. dispose(): void;
  54699. /**
  54700. * 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)
  54701. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54702. * @returns the bounding box mesh with the passed in mesh as a child
  54703. */
  54704. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54705. /**
  54706. * CustomMeshes are not supported by this gizmo
  54707. * @param mesh The mesh to replace the default mesh of the gizmo
  54708. */
  54709. setCustomMesh(mesh: Mesh): void;
  54710. }
  54711. }
  54712. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54713. import { Observable } from "babylonjs/Misc/observable";
  54714. import { Nullable } from "babylonjs/types";
  54715. import { Vector3 } from "babylonjs/Maths/math.vector";
  54716. import { Color3 } from "babylonjs/Maths/math.color";
  54717. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54718. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54719. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54720. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54721. import "babylonjs/Meshes/Builders/linesBuilder";
  54722. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54723. /**
  54724. * Single plane rotation gizmo
  54725. */
  54726. export class PlaneRotationGizmo extends Gizmo {
  54727. /**
  54728. * Drag behavior responsible for the gizmos dragging interactions
  54729. */
  54730. dragBehavior: PointerDragBehavior;
  54731. private _pointerObserver;
  54732. /**
  54733. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54734. */
  54735. snapDistance: number;
  54736. /**
  54737. * Event that fires each time the gizmo snaps to a new location.
  54738. * * snapDistance is the the change in distance
  54739. */
  54740. onSnapObservable: Observable<{
  54741. snapDistance: number;
  54742. }>;
  54743. private _isEnabled;
  54744. private _parent;
  54745. /**
  54746. * Creates a PlaneRotationGizmo
  54747. * @param gizmoLayer The utility layer the gizmo will be added to
  54748. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54749. * @param color The color of the gizmo
  54750. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54751. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54752. */
  54753. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  54754. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54755. /**
  54756. * If the gizmo is enabled
  54757. */
  54758. set isEnabled(value: boolean);
  54759. get isEnabled(): boolean;
  54760. /**
  54761. * Disposes of the gizmo
  54762. */
  54763. dispose(): void;
  54764. }
  54765. }
  54766. declare module "babylonjs/Gizmos/rotationGizmo" {
  54767. import { Observable } from "babylonjs/Misc/observable";
  54768. import { Nullable } from "babylonjs/types";
  54769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54770. import { Mesh } from "babylonjs/Meshes/mesh";
  54771. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54772. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  54773. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54774. /**
  54775. * Gizmo that enables rotating a mesh along 3 axis
  54776. */
  54777. export class RotationGizmo extends Gizmo {
  54778. /**
  54779. * Internal gizmo used for interactions on the x axis
  54780. */
  54781. xGizmo: PlaneRotationGizmo;
  54782. /**
  54783. * Internal gizmo used for interactions on the y axis
  54784. */
  54785. yGizmo: PlaneRotationGizmo;
  54786. /**
  54787. * Internal gizmo used for interactions on the z axis
  54788. */
  54789. zGizmo: PlaneRotationGizmo;
  54790. /** Fires an event when any of it's sub gizmos are dragged */
  54791. onDragStartObservable: Observable<unknown>;
  54792. /** Fires an event when any of it's sub gizmos are released from dragging */
  54793. onDragEndObservable: Observable<unknown>;
  54794. private _meshAttached;
  54795. get attachedMesh(): Nullable<AbstractMesh>;
  54796. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54797. /**
  54798. * Creates a RotationGizmo
  54799. * @param gizmoLayer The utility layer the gizmo will be added to
  54800. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54801. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54802. */
  54803. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  54804. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54805. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54806. /**
  54807. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54808. */
  54809. set snapDistance(value: number);
  54810. get snapDistance(): number;
  54811. /**
  54812. * Ratio for the scale of the gizmo (Default: 1)
  54813. */
  54814. set scaleRatio(value: number);
  54815. get scaleRatio(): number;
  54816. /**
  54817. * Disposes of the gizmo
  54818. */
  54819. dispose(): void;
  54820. /**
  54821. * CustomMeshes are not supported by this gizmo
  54822. * @param mesh The mesh to replace the default mesh of the gizmo
  54823. */
  54824. setCustomMesh(mesh: Mesh): void;
  54825. }
  54826. }
  54827. declare module "babylonjs/Gizmos/gizmoManager" {
  54828. import { Observable } from "babylonjs/Misc/observable";
  54829. import { Nullable } from "babylonjs/types";
  54830. import { Scene, IDisposable } from "babylonjs/scene";
  54831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54832. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54833. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  54834. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54835. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  54836. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54837. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  54838. /**
  54839. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  54840. */
  54841. export class GizmoManager implements IDisposable {
  54842. private scene;
  54843. /**
  54844. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54845. */
  54846. gizmos: {
  54847. positionGizmo: Nullable<PositionGizmo>;
  54848. rotationGizmo: Nullable<RotationGizmo>;
  54849. scaleGizmo: Nullable<ScaleGizmo>;
  54850. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54851. };
  54852. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54853. clearGizmoOnEmptyPointerEvent: boolean;
  54854. /** Fires an event when the manager is attached to a mesh */
  54855. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54856. private _gizmosEnabled;
  54857. private _pointerObserver;
  54858. private _attachedMesh;
  54859. private _boundingBoxColor;
  54860. private _defaultUtilityLayer;
  54861. private _defaultKeepDepthUtilityLayer;
  54862. /**
  54863. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54864. */
  54865. boundingBoxDragBehavior: SixDofDragBehavior;
  54866. /**
  54867. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54868. */
  54869. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54870. /**
  54871. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  54872. */
  54873. usePointerToAttachGizmos: boolean;
  54874. /**
  54875. * Utility layer that the bounding box gizmo belongs to
  54876. */
  54877. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54878. /**
  54879. * Utility layer that all gizmos besides bounding box belong to
  54880. */
  54881. get utilityLayer(): UtilityLayerRenderer;
  54882. /**
  54883. * Instatiates a gizmo manager
  54884. * @param scene the scene to overlay the gizmos on top of
  54885. */
  54886. constructor(scene: Scene);
  54887. /**
  54888. * Attaches a set of gizmos to the specified mesh
  54889. * @param mesh The mesh the gizmo's should be attached to
  54890. */
  54891. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54892. /**
  54893. * If the position gizmo is enabled
  54894. */
  54895. set positionGizmoEnabled(value: boolean);
  54896. get positionGizmoEnabled(): boolean;
  54897. /**
  54898. * If the rotation gizmo is enabled
  54899. */
  54900. set rotationGizmoEnabled(value: boolean);
  54901. get rotationGizmoEnabled(): boolean;
  54902. /**
  54903. * If the scale gizmo is enabled
  54904. */
  54905. set scaleGizmoEnabled(value: boolean);
  54906. get scaleGizmoEnabled(): boolean;
  54907. /**
  54908. * If the boundingBox gizmo is enabled
  54909. */
  54910. set boundingBoxGizmoEnabled(value: boolean);
  54911. get boundingBoxGizmoEnabled(): boolean;
  54912. /**
  54913. * Disposes of the gizmo manager
  54914. */
  54915. dispose(): void;
  54916. }
  54917. }
  54918. declare module "babylonjs/Lights/directionalLight" {
  54919. import { Camera } from "babylonjs/Cameras/camera";
  54920. import { Scene } from "babylonjs/scene";
  54921. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  54922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54923. import { Light } from "babylonjs/Lights/light";
  54924. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  54925. import { Effect } from "babylonjs/Materials/effect";
  54926. /**
  54927. * A directional light is defined by a direction (what a surprise!).
  54928. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54929. * 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.
  54930. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54931. */
  54932. export class DirectionalLight extends ShadowLight {
  54933. private _shadowFrustumSize;
  54934. /**
  54935. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54936. */
  54937. get shadowFrustumSize(): number;
  54938. /**
  54939. * Specifies a fix frustum size for the shadow generation.
  54940. */
  54941. set shadowFrustumSize(value: number);
  54942. private _shadowOrthoScale;
  54943. /**
  54944. * Gets the shadow projection scale against the optimal computed one.
  54945. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54946. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54947. */
  54948. get shadowOrthoScale(): number;
  54949. /**
  54950. * Sets the shadow projection scale against the optimal computed one.
  54951. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54952. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54953. */
  54954. set shadowOrthoScale(value: number);
  54955. /**
  54956. * Automatically compute the projection matrix to best fit (including all the casters)
  54957. * on each frame.
  54958. */
  54959. autoUpdateExtends: boolean;
  54960. /**
  54961. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54962. * on each frame. autoUpdateExtends must be set to true for this to work
  54963. */
  54964. autoCalcShadowZBounds: boolean;
  54965. private _orthoLeft;
  54966. private _orthoRight;
  54967. private _orthoTop;
  54968. private _orthoBottom;
  54969. /**
  54970. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54971. * The directional light is emitted from everywhere in the given direction.
  54972. * It can cast shadows.
  54973. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54974. * @param name The friendly name of the light
  54975. * @param direction The direction of the light
  54976. * @param scene The scene the light belongs to
  54977. */
  54978. constructor(name: string, direction: Vector3, scene: Scene);
  54979. /**
  54980. * Returns the string "DirectionalLight".
  54981. * @return The class name
  54982. */
  54983. getClassName(): string;
  54984. /**
  54985. * Returns the integer 1.
  54986. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54987. */
  54988. getTypeID(): number;
  54989. /**
  54990. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54991. * Returns the DirectionalLight Shadow projection matrix.
  54992. */
  54993. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54994. /**
  54995. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54996. * Returns the DirectionalLight Shadow projection matrix.
  54997. */
  54998. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54999. /**
  55000. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55001. * Returns the DirectionalLight Shadow projection matrix.
  55002. */
  55003. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55004. protected _buildUniformLayout(): void;
  55005. /**
  55006. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55007. * @param effect The effect to update
  55008. * @param lightIndex The index of the light in the effect to update
  55009. * @returns The directional light
  55010. */
  55011. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55012. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55013. /**
  55014. * Gets the minZ used for shadow according to both the scene and the light.
  55015. *
  55016. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55017. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55018. * @param activeCamera The camera we are returning the min for
  55019. * @returns the depth min z
  55020. */
  55021. getDepthMinZ(activeCamera: Camera): number;
  55022. /**
  55023. * Gets the maxZ used for shadow according to both the scene and the light.
  55024. *
  55025. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55026. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55027. * @param activeCamera The camera we are returning the max for
  55028. * @returns the depth max z
  55029. */
  55030. getDepthMaxZ(activeCamera: Camera): number;
  55031. /**
  55032. * Prepares the list of defines specific to the light type.
  55033. * @param defines the list of defines
  55034. * @param lightIndex defines the index of the light for the effect
  55035. */
  55036. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55037. }
  55038. }
  55039. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55040. import { Mesh } from "babylonjs/Meshes/mesh";
  55041. /**
  55042. * Class containing static functions to help procedurally build meshes
  55043. */
  55044. export class HemisphereBuilder {
  55045. /**
  55046. * Creates a hemisphere mesh
  55047. * @param name defines the name of the mesh
  55048. * @param options defines the options used to create the mesh
  55049. * @param scene defines the hosting scene
  55050. * @returns the hemisphere mesh
  55051. */
  55052. static CreateHemisphere(name: string, options: {
  55053. segments?: number;
  55054. diameter?: number;
  55055. sideOrientation?: number;
  55056. }, scene: any): Mesh;
  55057. }
  55058. }
  55059. declare module "babylonjs/Lights/spotLight" {
  55060. import { Nullable } from "babylonjs/types";
  55061. import { Scene } from "babylonjs/scene";
  55062. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55064. import { Effect } from "babylonjs/Materials/effect";
  55065. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55066. import { Light } from "babylonjs/Lights/light";
  55067. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55068. /**
  55069. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55070. * These values define a cone of light starting from the position, emitting toward the direction.
  55071. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55072. * and the exponent defines the speed of the decay of the light with distance (reach).
  55073. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55074. */
  55075. export class SpotLight extends ShadowLight {
  55076. private _angle;
  55077. private _innerAngle;
  55078. private _cosHalfAngle;
  55079. private _lightAngleScale;
  55080. private _lightAngleOffset;
  55081. /**
  55082. * Gets the cone angle of the spot light in Radians.
  55083. */
  55084. get angle(): number;
  55085. /**
  55086. * Sets the cone angle of the spot light in Radians.
  55087. */
  55088. set angle(value: number);
  55089. /**
  55090. * Only used in gltf falloff mode, this defines the angle where
  55091. * the directional falloff will start before cutting at angle which could be seen
  55092. * as outer angle.
  55093. */
  55094. get innerAngle(): number;
  55095. /**
  55096. * Only used in gltf falloff mode, this defines the angle where
  55097. * the directional falloff will start before cutting at angle which could be seen
  55098. * as outer angle.
  55099. */
  55100. set innerAngle(value: number);
  55101. private _shadowAngleScale;
  55102. /**
  55103. * Allows scaling the angle of the light for shadow generation only.
  55104. */
  55105. get shadowAngleScale(): number;
  55106. /**
  55107. * Allows scaling the angle of the light for shadow generation only.
  55108. */
  55109. set shadowAngleScale(value: number);
  55110. /**
  55111. * The light decay speed with the distance from the emission spot.
  55112. */
  55113. exponent: number;
  55114. private _projectionTextureMatrix;
  55115. /**
  55116. * Allows reading the projecton texture
  55117. */
  55118. get projectionTextureMatrix(): Matrix;
  55119. protected _projectionTextureLightNear: number;
  55120. /**
  55121. * Gets the near clip of the Spotlight for texture projection.
  55122. */
  55123. get projectionTextureLightNear(): number;
  55124. /**
  55125. * Sets the near clip of the Spotlight for texture projection.
  55126. */
  55127. set projectionTextureLightNear(value: number);
  55128. protected _projectionTextureLightFar: number;
  55129. /**
  55130. * Gets the far clip of the Spotlight for texture projection.
  55131. */
  55132. get projectionTextureLightFar(): number;
  55133. /**
  55134. * Sets the far clip of the Spotlight for texture projection.
  55135. */
  55136. set projectionTextureLightFar(value: number);
  55137. protected _projectionTextureUpDirection: Vector3;
  55138. /**
  55139. * Gets the Up vector of the Spotlight for texture projection.
  55140. */
  55141. get projectionTextureUpDirection(): Vector3;
  55142. /**
  55143. * Sets the Up vector of the Spotlight for texture projection.
  55144. */
  55145. set projectionTextureUpDirection(value: Vector3);
  55146. private _projectionTexture;
  55147. /**
  55148. * Gets the projection texture of the light.
  55149. */
  55150. get projectionTexture(): Nullable<BaseTexture>;
  55151. /**
  55152. * Sets the projection texture of the light.
  55153. */
  55154. set projectionTexture(value: Nullable<BaseTexture>);
  55155. private _projectionTextureViewLightDirty;
  55156. private _projectionTextureProjectionLightDirty;
  55157. private _projectionTextureDirty;
  55158. private _projectionTextureViewTargetVector;
  55159. private _projectionTextureViewLightMatrix;
  55160. private _projectionTextureProjectionLightMatrix;
  55161. private _projectionTextureScalingMatrix;
  55162. /**
  55163. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55164. * It can cast shadows.
  55165. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55166. * @param name The light friendly name
  55167. * @param position The position of the spot light in the scene
  55168. * @param direction The direction of the light in the scene
  55169. * @param angle The cone angle of the light in Radians
  55170. * @param exponent The light decay speed with the distance from the emission spot
  55171. * @param scene The scene the lights belongs to
  55172. */
  55173. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55174. /**
  55175. * Returns the string "SpotLight".
  55176. * @returns the class name
  55177. */
  55178. getClassName(): string;
  55179. /**
  55180. * Returns the integer 2.
  55181. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55182. */
  55183. getTypeID(): number;
  55184. /**
  55185. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55186. */
  55187. protected _setDirection(value: Vector3): void;
  55188. /**
  55189. * Overrides the position setter to recompute the projection texture view light Matrix.
  55190. */
  55191. protected _setPosition(value: Vector3): void;
  55192. /**
  55193. * 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.
  55194. * Returns the SpotLight.
  55195. */
  55196. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55197. protected _computeProjectionTextureViewLightMatrix(): void;
  55198. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55199. /**
  55200. * Main function for light texture projection matrix computing.
  55201. */
  55202. protected _computeProjectionTextureMatrix(): void;
  55203. protected _buildUniformLayout(): void;
  55204. private _computeAngleValues;
  55205. /**
  55206. * Sets the passed Effect "effect" with the Light textures.
  55207. * @param effect The effect to update
  55208. * @param lightIndex The index of the light in the effect to update
  55209. * @returns The light
  55210. */
  55211. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55212. /**
  55213. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55214. * @param effect The effect to update
  55215. * @param lightIndex The index of the light in the effect to update
  55216. * @returns The spot light
  55217. */
  55218. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55219. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55220. /**
  55221. * Disposes the light and the associated resources.
  55222. */
  55223. dispose(): void;
  55224. /**
  55225. * Prepares the list of defines specific to the light type.
  55226. * @param defines the list of defines
  55227. * @param lightIndex defines the index of the light for the effect
  55228. */
  55229. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55230. }
  55231. }
  55232. declare module "babylonjs/Gizmos/lightGizmo" {
  55233. import { Nullable } from "babylonjs/types";
  55234. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55235. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55236. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55237. import { Light } from "babylonjs/Lights/light";
  55238. /**
  55239. * Gizmo that enables viewing a light
  55240. */
  55241. export class LightGizmo extends Gizmo {
  55242. private _lightMesh;
  55243. private _material;
  55244. private _cachedPosition;
  55245. private _cachedForward;
  55246. private _attachedMeshParent;
  55247. /**
  55248. * Creates a LightGizmo
  55249. * @param gizmoLayer The utility layer the gizmo will be added to
  55250. */
  55251. constructor(gizmoLayer?: UtilityLayerRenderer);
  55252. private _light;
  55253. /**
  55254. * The light that the gizmo is attached to
  55255. */
  55256. set light(light: Nullable<Light>);
  55257. get light(): Nullable<Light>;
  55258. /**
  55259. * Gets the material used to render the light gizmo
  55260. */
  55261. get material(): StandardMaterial;
  55262. /**
  55263. * @hidden
  55264. * Updates the gizmo to match the attached mesh's position/rotation
  55265. */
  55266. protected _update(): void;
  55267. private static _Scale;
  55268. /**
  55269. * Creates the lines for a light mesh
  55270. */
  55271. private static _CreateLightLines;
  55272. /**
  55273. * Disposes of the light gizmo
  55274. */
  55275. dispose(): void;
  55276. private static _CreateHemisphericLightMesh;
  55277. private static _CreatePointLightMesh;
  55278. private static _CreateSpotLightMesh;
  55279. private static _CreateDirectionalLightMesh;
  55280. }
  55281. }
  55282. declare module "babylonjs/Gizmos/index" {
  55283. export * from "babylonjs/Gizmos/axisDragGizmo";
  55284. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55285. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55286. export * from "babylonjs/Gizmos/gizmo";
  55287. export * from "babylonjs/Gizmos/gizmoManager";
  55288. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55289. export * from "babylonjs/Gizmos/positionGizmo";
  55290. export * from "babylonjs/Gizmos/rotationGizmo";
  55291. export * from "babylonjs/Gizmos/scaleGizmo";
  55292. export * from "babylonjs/Gizmos/lightGizmo";
  55293. export * from "babylonjs/Gizmos/planeDragGizmo";
  55294. }
  55295. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55296. /** @hidden */
  55297. export var backgroundFragmentDeclaration: {
  55298. name: string;
  55299. shader: string;
  55300. };
  55301. }
  55302. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55303. /** @hidden */
  55304. export var backgroundUboDeclaration: {
  55305. name: string;
  55306. shader: string;
  55307. };
  55308. }
  55309. declare module "babylonjs/Shaders/background.fragment" {
  55310. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55311. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55312. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55313. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55314. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55315. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55316. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55317. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55318. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55319. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55320. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55321. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55322. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55323. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55324. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55325. /** @hidden */
  55326. export var backgroundPixelShader: {
  55327. name: string;
  55328. shader: string;
  55329. };
  55330. }
  55331. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55332. /** @hidden */
  55333. export var backgroundVertexDeclaration: {
  55334. name: string;
  55335. shader: string;
  55336. };
  55337. }
  55338. declare module "babylonjs/Shaders/background.vertex" {
  55339. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55340. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55341. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55342. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55343. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55344. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55345. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55346. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55347. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55348. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55349. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55350. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55351. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55352. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55353. /** @hidden */
  55354. export var backgroundVertexShader: {
  55355. name: string;
  55356. shader: string;
  55357. };
  55358. }
  55359. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55360. import { Nullable, int, float } from "babylonjs/types";
  55361. import { Scene } from "babylonjs/scene";
  55362. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55363. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55365. import { Mesh } from "babylonjs/Meshes/mesh";
  55366. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55367. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55368. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55369. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55370. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55371. import { Color3 } from "babylonjs/Maths/math.color";
  55372. import "babylonjs/Shaders/background.fragment";
  55373. import "babylonjs/Shaders/background.vertex";
  55374. /**
  55375. * Background material used to create an efficient environement around your scene.
  55376. */
  55377. export class BackgroundMaterial extends PushMaterial {
  55378. /**
  55379. * Standard reflectance value at parallel view angle.
  55380. */
  55381. static StandardReflectance0: number;
  55382. /**
  55383. * Standard reflectance value at grazing angle.
  55384. */
  55385. static StandardReflectance90: number;
  55386. protected _primaryColor: Color3;
  55387. /**
  55388. * Key light Color (multiply against the environement texture)
  55389. */
  55390. primaryColor: Color3;
  55391. protected __perceptualColor: Nullable<Color3>;
  55392. /**
  55393. * Experimental Internal Use Only.
  55394. *
  55395. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55396. * This acts as a helper to set the primary color to a more "human friendly" value.
  55397. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55398. * output color as close as possible from the chosen value.
  55399. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55400. * part of lighting setup.)
  55401. */
  55402. get _perceptualColor(): Nullable<Color3>;
  55403. set _perceptualColor(value: Nullable<Color3>);
  55404. protected _primaryColorShadowLevel: float;
  55405. /**
  55406. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55407. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55408. */
  55409. get primaryColorShadowLevel(): float;
  55410. set primaryColorShadowLevel(value: float);
  55411. protected _primaryColorHighlightLevel: float;
  55412. /**
  55413. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55414. * The primary color is used at the level chosen to define what the white area would look.
  55415. */
  55416. get primaryColorHighlightLevel(): float;
  55417. set primaryColorHighlightLevel(value: float);
  55418. protected _reflectionTexture: Nullable<BaseTexture>;
  55419. /**
  55420. * Reflection Texture used in the material.
  55421. * Should be author in a specific way for the best result (refer to the documentation).
  55422. */
  55423. reflectionTexture: Nullable<BaseTexture>;
  55424. protected _reflectionBlur: float;
  55425. /**
  55426. * Reflection Texture level of blur.
  55427. *
  55428. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55429. * texture twice.
  55430. */
  55431. reflectionBlur: float;
  55432. protected _diffuseTexture: Nullable<BaseTexture>;
  55433. /**
  55434. * Diffuse Texture used in the material.
  55435. * Should be author in a specific way for the best result (refer to the documentation).
  55436. */
  55437. diffuseTexture: Nullable<BaseTexture>;
  55438. protected _shadowLights: Nullable<IShadowLight[]>;
  55439. /**
  55440. * Specify the list of lights casting shadow on the material.
  55441. * All scene shadow lights will be included if null.
  55442. */
  55443. shadowLights: Nullable<IShadowLight[]>;
  55444. protected _shadowLevel: float;
  55445. /**
  55446. * Helps adjusting the shadow to a softer level if required.
  55447. * 0 means black shadows and 1 means no shadows.
  55448. */
  55449. shadowLevel: float;
  55450. protected _sceneCenter: Vector3;
  55451. /**
  55452. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55453. * It is usually zero but might be interesting to modify according to your setup.
  55454. */
  55455. sceneCenter: Vector3;
  55456. protected _opacityFresnel: boolean;
  55457. /**
  55458. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55459. * This helps ensuring a nice transition when the camera goes under the ground.
  55460. */
  55461. opacityFresnel: boolean;
  55462. protected _reflectionFresnel: boolean;
  55463. /**
  55464. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55465. * This helps adding a mirror texture on the ground.
  55466. */
  55467. reflectionFresnel: boolean;
  55468. protected _reflectionFalloffDistance: number;
  55469. /**
  55470. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55471. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55472. */
  55473. reflectionFalloffDistance: number;
  55474. protected _reflectionAmount: number;
  55475. /**
  55476. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55477. */
  55478. reflectionAmount: number;
  55479. protected _reflectionReflectance0: number;
  55480. /**
  55481. * This specifies the weight of the reflection at grazing angle.
  55482. */
  55483. reflectionReflectance0: number;
  55484. protected _reflectionReflectance90: number;
  55485. /**
  55486. * This specifies the weight of the reflection at a perpendicular point of view.
  55487. */
  55488. reflectionReflectance90: number;
  55489. /**
  55490. * Sets the reflection reflectance fresnel values according to the default standard
  55491. * empirically know to work well :-)
  55492. */
  55493. set reflectionStandardFresnelWeight(value: number);
  55494. protected _useRGBColor: boolean;
  55495. /**
  55496. * Helps to directly use the maps channels instead of their level.
  55497. */
  55498. useRGBColor: boolean;
  55499. protected _enableNoise: boolean;
  55500. /**
  55501. * This helps reducing the banding effect that could occur on the background.
  55502. */
  55503. enableNoise: boolean;
  55504. /**
  55505. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55506. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55507. * Recommended to be keep at 1.0 except for special cases.
  55508. */
  55509. get fovMultiplier(): number;
  55510. set fovMultiplier(value: number);
  55511. private _fovMultiplier;
  55512. /**
  55513. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55514. */
  55515. useEquirectangularFOV: boolean;
  55516. private _maxSimultaneousLights;
  55517. /**
  55518. * Number of Simultaneous lights allowed on the material.
  55519. */
  55520. maxSimultaneousLights: int;
  55521. /**
  55522. * Default configuration related to image processing available in the Background Material.
  55523. */
  55524. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55525. /**
  55526. * Keep track of the image processing observer to allow dispose and replace.
  55527. */
  55528. private _imageProcessingObserver;
  55529. /**
  55530. * Attaches a new image processing configuration to the PBR Material.
  55531. * @param configuration (if null the scene configuration will be use)
  55532. */
  55533. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55534. /**
  55535. * Gets the image processing configuration used either in this material.
  55536. */
  55537. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55538. /**
  55539. * Sets the Default image processing configuration used either in the this material.
  55540. *
  55541. * If sets to null, the scene one is in use.
  55542. */
  55543. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55544. /**
  55545. * Gets wether the color curves effect is enabled.
  55546. */
  55547. get cameraColorCurvesEnabled(): boolean;
  55548. /**
  55549. * Sets wether the color curves effect is enabled.
  55550. */
  55551. set cameraColorCurvesEnabled(value: boolean);
  55552. /**
  55553. * Gets wether the color grading effect is enabled.
  55554. */
  55555. get cameraColorGradingEnabled(): boolean;
  55556. /**
  55557. * Gets wether the color grading effect is enabled.
  55558. */
  55559. set cameraColorGradingEnabled(value: boolean);
  55560. /**
  55561. * Gets wether tonemapping is enabled or not.
  55562. */
  55563. get cameraToneMappingEnabled(): boolean;
  55564. /**
  55565. * Sets wether tonemapping is enabled or not
  55566. */
  55567. set cameraToneMappingEnabled(value: boolean);
  55568. /**
  55569. * The camera exposure used on this material.
  55570. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55571. * This corresponds to a photographic exposure.
  55572. */
  55573. get cameraExposure(): float;
  55574. /**
  55575. * The camera exposure used on this material.
  55576. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55577. * This corresponds to a photographic exposure.
  55578. */
  55579. set cameraExposure(value: float);
  55580. /**
  55581. * Gets The camera contrast used on this material.
  55582. */
  55583. get cameraContrast(): float;
  55584. /**
  55585. * Sets The camera contrast used on this material.
  55586. */
  55587. set cameraContrast(value: float);
  55588. /**
  55589. * Gets the Color Grading 2D Lookup Texture.
  55590. */
  55591. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55592. /**
  55593. * Sets the Color Grading 2D Lookup Texture.
  55594. */
  55595. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55596. /**
  55597. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55598. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55599. * 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;
  55600. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55601. */
  55602. get cameraColorCurves(): Nullable<ColorCurves>;
  55603. /**
  55604. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55605. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55606. * 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;
  55607. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55608. */
  55609. set cameraColorCurves(value: Nullable<ColorCurves>);
  55610. /**
  55611. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55612. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55613. */
  55614. switchToBGR: boolean;
  55615. private _renderTargets;
  55616. private _reflectionControls;
  55617. private _white;
  55618. private _primaryShadowColor;
  55619. private _primaryHighlightColor;
  55620. /**
  55621. * Instantiates a Background Material in the given scene
  55622. * @param name The friendly name of the material
  55623. * @param scene The scene to add the material to
  55624. */
  55625. constructor(name: string, scene: Scene);
  55626. /**
  55627. * Gets a boolean indicating that current material needs to register RTT
  55628. */
  55629. get hasRenderTargetTextures(): boolean;
  55630. /**
  55631. * The entire material has been created in order to prevent overdraw.
  55632. * @returns false
  55633. */
  55634. needAlphaTesting(): boolean;
  55635. /**
  55636. * The entire material has been created in order to prevent overdraw.
  55637. * @returns true if blending is enable
  55638. */
  55639. needAlphaBlending(): boolean;
  55640. /**
  55641. * Checks wether the material is ready to be rendered for a given mesh.
  55642. * @param mesh The mesh to render
  55643. * @param subMesh The submesh to check against
  55644. * @param useInstances Specify wether or not the material is used with instances
  55645. * @returns true if all the dependencies are ready (Textures, Effects...)
  55646. */
  55647. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55648. /**
  55649. * Compute the primary color according to the chosen perceptual color.
  55650. */
  55651. private _computePrimaryColorFromPerceptualColor;
  55652. /**
  55653. * Compute the highlights and shadow colors according to their chosen levels.
  55654. */
  55655. private _computePrimaryColors;
  55656. /**
  55657. * Build the uniform buffer used in the material.
  55658. */
  55659. buildUniformLayout(): void;
  55660. /**
  55661. * Unbind the material.
  55662. */
  55663. unbind(): void;
  55664. /**
  55665. * Bind only the world matrix to the material.
  55666. * @param world The world matrix to bind.
  55667. */
  55668. bindOnlyWorldMatrix(world: Matrix): void;
  55669. /**
  55670. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55671. * @param world The world matrix to bind.
  55672. * @param subMesh The submesh to bind for.
  55673. */
  55674. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55675. /**
  55676. * Checks to see if a texture is used in the material.
  55677. * @param texture - Base texture to use.
  55678. * @returns - Boolean specifying if a texture is used in the material.
  55679. */
  55680. hasTexture(texture: BaseTexture): boolean;
  55681. /**
  55682. * Dispose the material.
  55683. * @param forceDisposeEffect Force disposal of the associated effect.
  55684. * @param forceDisposeTextures Force disposal of the associated textures.
  55685. */
  55686. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55687. /**
  55688. * Clones the material.
  55689. * @param name The cloned name.
  55690. * @returns The cloned material.
  55691. */
  55692. clone(name: string): BackgroundMaterial;
  55693. /**
  55694. * Serializes the current material to its JSON representation.
  55695. * @returns The JSON representation.
  55696. */
  55697. serialize(): any;
  55698. /**
  55699. * Gets the class name of the material
  55700. * @returns "BackgroundMaterial"
  55701. */
  55702. getClassName(): string;
  55703. /**
  55704. * Parse a JSON input to create back a background material.
  55705. * @param source The JSON data to parse
  55706. * @param scene The scene to create the parsed material in
  55707. * @param rootUrl The root url of the assets the material depends upon
  55708. * @returns the instantiated BackgroundMaterial.
  55709. */
  55710. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55711. }
  55712. }
  55713. declare module "babylonjs/Helpers/environmentHelper" {
  55714. import { Observable } from "babylonjs/Misc/observable";
  55715. import { Nullable } from "babylonjs/types";
  55716. import { Scene } from "babylonjs/scene";
  55717. import { Vector3 } from "babylonjs/Maths/math.vector";
  55718. import { Color3 } from "babylonjs/Maths/math.color";
  55719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55720. import { Mesh } from "babylonjs/Meshes/mesh";
  55721. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55722. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55723. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55724. import "babylonjs/Meshes/Builders/planeBuilder";
  55725. import "babylonjs/Meshes/Builders/boxBuilder";
  55726. /**
  55727. * Represents the different options available during the creation of
  55728. * a Environment helper.
  55729. *
  55730. * This can control the default ground, skybox and image processing setup of your scene.
  55731. */
  55732. export interface IEnvironmentHelperOptions {
  55733. /**
  55734. * Specifies whether or not to create a ground.
  55735. * True by default.
  55736. */
  55737. createGround: boolean;
  55738. /**
  55739. * Specifies the ground size.
  55740. * 15 by default.
  55741. */
  55742. groundSize: number;
  55743. /**
  55744. * The texture used on the ground for the main color.
  55745. * Comes from the BabylonJS CDN by default.
  55746. *
  55747. * Remarks: Can be either a texture or a url.
  55748. */
  55749. groundTexture: string | BaseTexture;
  55750. /**
  55751. * The color mixed in the ground texture by default.
  55752. * BabylonJS clearColor by default.
  55753. */
  55754. groundColor: Color3;
  55755. /**
  55756. * Specifies the ground opacity.
  55757. * 1 by default.
  55758. */
  55759. groundOpacity: number;
  55760. /**
  55761. * Enables the ground to receive shadows.
  55762. * True by default.
  55763. */
  55764. enableGroundShadow: boolean;
  55765. /**
  55766. * Helps preventing the shadow to be fully black on the ground.
  55767. * 0.5 by default.
  55768. */
  55769. groundShadowLevel: number;
  55770. /**
  55771. * Creates a mirror texture attach to the ground.
  55772. * false by default.
  55773. */
  55774. enableGroundMirror: boolean;
  55775. /**
  55776. * Specifies the ground mirror size ratio.
  55777. * 0.3 by default as the default kernel is 64.
  55778. */
  55779. groundMirrorSizeRatio: number;
  55780. /**
  55781. * Specifies the ground mirror blur kernel size.
  55782. * 64 by default.
  55783. */
  55784. groundMirrorBlurKernel: number;
  55785. /**
  55786. * Specifies the ground mirror visibility amount.
  55787. * 1 by default
  55788. */
  55789. groundMirrorAmount: number;
  55790. /**
  55791. * Specifies the ground mirror reflectance weight.
  55792. * This uses the standard weight of the background material to setup the fresnel effect
  55793. * of the mirror.
  55794. * 1 by default.
  55795. */
  55796. groundMirrorFresnelWeight: number;
  55797. /**
  55798. * Specifies the ground mirror Falloff distance.
  55799. * This can helps reducing the size of the reflection.
  55800. * 0 by Default.
  55801. */
  55802. groundMirrorFallOffDistance: number;
  55803. /**
  55804. * Specifies the ground mirror texture type.
  55805. * Unsigned Int by Default.
  55806. */
  55807. groundMirrorTextureType: number;
  55808. /**
  55809. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55810. * the shown objects.
  55811. */
  55812. groundYBias: number;
  55813. /**
  55814. * Specifies whether or not to create a skybox.
  55815. * True by default.
  55816. */
  55817. createSkybox: boolean;
  55818. /**
  55819. * Specifies the skybox size.
  55820. * 20 by default.
  55821. */
  55822. skyboxSize: number;
  55823. /**
  55824. * The texture used on the skybox for the main color.
  55825. * Comes from the BabylonJS CDN by default.
  55826. *
  55827. * Remarks: Can be either a texture or a url.
  55828. */
  55829. skyboxTexture: string | BaseTexture;
  55830. /**
  55831. * The color mixed in the skybox texture by default.
  55832. * BabylonJS clearColor by default.
  55833. */
  55834. skyboxColor: Color3;
  55835. /**
  55836. * The background rotation around the Y axis of the scene.
  55837. * This helps aligning the key lights of your scene with the background.
  55838. * 0 by default.
  55839. */
  55840. backgroundYRotation: number;
  55841. /**
  55842. * Compute automatically the size of the elements to best fit with the scene.
  55843. */
  55844. sizeAuto: boolean;
  55845. /**
  55846. * Default position of the rootMesh if autoSize is not true.
  55847. */
  55848. rootPosition: Vector3;
  55849. /**
  55850. * Sets up the image processing in the scene.
  55851. * true by default.
  55852. */
  55853. setupImageProcessing: boolean;
  55854. /**
  55855. * The texture used as your environment texture in the scene.
  55856. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55857. *
  55858. * Remarks: Can be either a texture or a url.
  55859. */
  55860. environmentTexture: string | BaseTexture;
  55861. /**
  55862. * The value of the exposure to apply to the scene.
  55863. * 0.6 by default if setupImageProcessing is true.
  55864. */
  55865. cameraExposure: number;
  55866. /**
  55867. * The value of the contrast to apply to the scene.
  55868. * 1.6 by default if setupImageProcessing is true.
  55869. */
  55870. cameraContrast: number;
  55871. /**
  55872. * Specifies whether or not tonemapping should be enabled in the scene.
  55873. * true by default if setupImageProcessing is true.
  55874. */
  55875. toneMappingEnabled: boolean;
  55876. }
  55877. /**
  55878. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55879. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55880. * It also helps with the default setup of your imageProcessing configuration.
  55881. */
  55882. export class EnvironmentHelper {
  55883. /**
  55884. * Default ground texture URL.
  55885. */
  55886. private static _groundTextureCDNUrl;
  55887. /**
  55888. * Default skybox texture URL.
  55889. */
  55890. private static _skyboxTextureCDNUrl;
  55891. /**
  55892. * Default environment texture URL.
  55893. */
  55894. private static _environmentTextureCDNUrl;
  55895. /**
  55896. * Creates the default options for the helper.
  55897. */
  55898. private static _getDefaultOptions;
  55899. private _rootMesh;
  55900. /**
  55901. * Gets the root mesh created by the helper.
  55902. */
  55903. get rootMesh(): Mesh;
  55904. private _skybox;
  55905. /**
  55906. * Gets the skybox created by the helper.
  55907. */
  55908. get skybox(): Nullable<Mesh>;
  55909. private _skyboxTexture;
  55910. /**
  55911. * Gets the skybox texture created by the helper.
  55912. */
  55913. get skyboxTexture(): Nullable<BaseTexture>;
  55914. private _skyboxMaterial;
  55915. /**
  55916. * Gets the skybox material created by the helper.
  55917. */
  55918. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55919. private _ground;
  55920. /**
  55921. * Gets the ground mesh created by the helper.
  55922. */
  55923. get ground(): Nullable<Mesh>;
  55924. private _groundTexture;
  55925. /**
  55926. * Gets the ground texture created by the helper.
  55927. */
  55928. get groundTexture(): Nullable<BaseTexture>;
  55929. private _groundMirror;
  55930. /**
  55931. * Gets the ground mirror created by the helper.
  55932. */
  55933. get groundMirror(): Nullable<MirrorTexture>;
  55934. /**
  55935. * Gets the ground mirror render list to helps pushing the meshes
  55936. * you wish in the ground reflection.
  55937. */
  55938. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55939. private _groundMaterial;
  55940. /**
  55941. * Gets the ground material created by the helper.
  55942. */
  55943. get groundMaterial(): Nullable<BackgroundMaterial>;
  55944. /**
  55945. * Stores the creation options.
  55946. */
  55947. private readonly _scene;
  55948. private _options;
  55949. /**
  55950. * This observable will be notified with any error during the creation of the environment,
  55951. * mainly texture creation errors.
  55952. */
  55953. onErrorObservable: Observable<{
  55954. message?: string;
  55955. exception?: any;
  55956. }>;
  55957. /**
  55958. * constructor
  55959. * @param options Defines the options we want to customize the helper
  55960. * @param scene The scene to add the material to
  55961. */
  55962. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55963. /**
  55964. * Updates the background according to the new options
  55965. * @param options
  55966. */
  55967. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55968. /**
  55969. * Sets the primary color of all the available elements.
  55970. * @param color the main color to affect to the ground and the background
  55971. */
  55972. setMainColor(color: Color3): void;
  55973. /**
  55974. * Setup the image processing according to the specified options.
  55975. */
  55976. private _setupImageProcessing;
  55977. /**
  55978. * Setup the environment texture according to the specified options.
  55979. */
  55980. private _setupEnvironmentTexture;
  55981. /**
  55982. * Setup the background according to the specified options.
  55983. */
  55984. private _setupBackground;
  55985. /**
  55986. * Get the scene sizes according to the setup.
  55987. */
  55988. private _getSceneSize;
  55989. /**
  55990. * Setup the ground according to the specified options.
  55991. */
  55992. private _setupGround;
  55993. /**
  55994. * Setup the ground material according to the specified options.
  55995. */
  55996. private _setupGroundMaterial;
  55997. /**
  55998. * Setup the ground diffuse texture according to the specified options.
  55999. */
  56000. private _setupGroundDiffuseTexture;
  56001. /**
  56002. * Setup the ground mirror texture according to the specified options.
  56003. */
  56004. private _setupGroundMirrorTexture;
  56005. /**
  56006. * Setup the ground to receive the mirror texture.
  56007. */
  56008. private _setupMirrorInGroundMaterial;
  56009. /**
  56010. * Setup the skybox according to the specified options.
  56011. */
  56012. private _setupSkybox;
  56013. /**
  56014. * Setup the skybox material according to the specified options.
  56015. */
  56016. private _setupSkyboxMaterial;
  56017. /**
  56018. * Setup the skybox reflection texture according to the specified options.
  56019. */
  56020. private _setupSkyboxReflectionTexture;
  56021. private _errorHandler;
  56022. /**
  56023. * Dispose all the elements created by the Helper.
  56024. */
  56025. dispose(): void;
  56026. }
  56027. }
  56028. declare module "babylonjs/Helpers/photoDome" {
  56029. import { Observable } from "babylonjs/Misc/observable";
  56030. import { Nullable } from "babylonjs/types";
  56031. import { Scene } from "babylonjs/scene";
  56032. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56033. import { Mesh } from "babylonjs/Meshes/mesh";
  56034. import { Texture } from "babylonjs/Materials/Textures/texture";
  56035. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56036. import "babylonjs/Meshes/Builders/sphereBuilder";
  56037. /**
  56038. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56039. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56040. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56041. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56042. */
  56043. export class PhotoDome extends TransformNode {
  56044. /**
  56045. * Define the image as a Monoscopic panoramic 360 image.
  56046. */
  56047. static readonly MODE_MONOSCOPIC: number;
  56048. /**
  56049. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56050. */
  56051. static readonly MODE_TOPBOTTOM: number;
  56052. /**
  56053. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56054. */
  56055. static readonly MODE_SIDEBYSIDE: number;
  56056. private _useDirectMapping;
  56057. /**
  56058. * The texture being displayed on the sphere
  56059. */
  56060. protected _photoTexture: Texture;
  56061. /**
  56062. * Gets or sets the texture being displayed on the sphere
  56063. */
  56064. get photoTexture(): Texture;
  56065. set photoTexture(value: Texture);
  56066. /**
  56067. * Observable raised when an error occured while loading the 360 image
  56068. */
  56069. onLoadErrorObservable: Observable<string>;
  56070. /**
  56071. * The skybox material
  56072. */
  56073. protected _material: BackgroundMaterial;
  56074. /**
  56075. * The surface used for the skybox
  56076. */
  56077. protected _mesh: Mesh;
  56078. /**
  56079. * Gets the mesh used for the skybox.
  56080. */
  56081. get mesh(): Mesh;
  56082. /**
  56083. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56084. * Also see the options.resolution property.
  56085. */
  56086. get fovMultiplier(): number;
  56087. set fovMultiplier(value: number);
  56088. private _imageMode;
  56089. /**
  56090. * Gets or set the current video mode for the video. It can be:
  56091. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56092. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56093. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56094. */
  56095. get imageMode(): number;
  56096. set imageMode(value: number);
  56097. /**
  56098. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56099. * @param name Element's name, child elements will append suffixes for their own names.
  56100. * @param urlsOfPhoto defines the url of the photo to display
  56101. * @param options defines an object containing optional or exposed sub element properties
  56102. * @param onError defines a callback called when an error occured while loading the texture
  56103. */
  56104. constructor(name: string, urlOfPhoto: string, options: {
  56105. resolution?: number;
  56106. size?: number;
  56107. useDirectMapping?: boolean;
  56108. faceForward?: boolean;
  56109. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56110. private _onBeforeCameraRenderObserver;
  56111. private _changeImageMode;
  56112. /**
  56113. * Releases resources associated with this node.
  56114. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56115. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56116. */
  56117. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56118. }
  56119. }
  56120. declare module "babylonjs/Misc/rgbdTextureTools" {
  56121. import "babylonjs/Shaders/rgbdDecode.fragment";
  56122. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56123. import { Texture } from "babylonjs/Materials/Textures/texture";
  56124. /**
  56125. * Class used to host RGBD texture specific utilities
  56126. */
  56127. export class RGBDTextureTools {
  56128. /**
  56129. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56130. * @param texture the texture to expand.
  56131. */
  56132. static ExpandRGBDTexture(texture: Texture): void;
  56133. }
  56134. }
  56135. declare module "babylonjs/Misc/brdfTextureTools" {
  56136. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56137. import { Scene } from "babylonjs/scene";
  56138. /**
  56139. * Class used to host texture specific utilities
  56140. */
  56141. export class BRDFTextureTools {
  56142. /**
  56143. * Prevents texture cache collision
  56144. */
  56145. private static _instanceNumber;
  56146. /**
  56147. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56148. * @param scene defines the hosting scene
  56149. * @returns the environment BRDF texture
  56150. */
  56151. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56152. private static _environmentBRDFBase64Texture;
  56153. }
  56154. }
  56155. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56156. import { Nullable } from "babylonjs/types";
  56157. import { Color3 } from "babylonjs/Maths/math.color";
  56158. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56159. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56160. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56161. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56162. import { Engine } from "babylonjs/Engines/engine";
  56163. import { Scene } from "babylonjs/scene";
  56164. /**
  56165. * @hidden
  56166. */
  56167. export interface IMaterialClearCoatDefines {
  56168. CLEARCOAT: boolean;
  56169. CLEARCOAT_DEFAULTIOR: boolean;
  56170. CLEARCOAT_TEXTURE: boolean;
  56171. CLEARCOAT_TEXTUREDIRECTUV: number;
  56172. CLEARCOAT_BUMP: boolean;
  56173. CLEARCOAT_BUMPDIRECTUV: number;
  56174. CLEARCOAT_TINT: boolean;
  56175. CLEARCOAT_TINT_TEXTURE: boolean;
  56176. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56177. /** @hidden */
  56178. _areTexturesDirty: boolean;
  56179. }
  56180. /**
  56181. * Define the code related to the clear coat parameters of the pbr material.
  56182. */
  56183. export class PBRClearCoatConfiguration {
  56184. /**
  56185. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56186. * The default fits with a polyurethane material.
  56187. */
  56188. private static readonly _DefaultIndexOfRefraction;
  56189. private _isEnabled;
  56190. /**
  56191. * Defines if the clear coat is enabled in the material.
  56192. */
  56193. isEnabled: boolean;
  56194. /**
  56195. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56196. */
  56197. intensity: number;
  56198. /**
  56199. * Defines the clear coat layer roughness.
  56200. */
  56201. roughness: number;
  56202. private _indexOfRefraction;
  56203. /**
  56204. * Defines the index of refraction of the clear coat.
  56205. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56206. * The default fits with a polyurethane material.
  56207. * Changing the default value is more performance intensive.
  56208. */
  56209. indexOfRefraction: number;
  56210. private _texture;
  56211. /**
  56212. * Stores the clear coat values in a texture.
  56213. */
  56214. texture: Nullable<BaseTexture>;
  56215. private _bumpTexture;
  56216. /**
  56217. * Define the clear coat specific bump texture.
  56218. */
  56219. bumpTexture: Nullable<BaseTexture>;
  56220. private _isTintEnabled;
  56221. /**
  56222. * Defines if the clear coat tint is enabled in the material.
  56223. */
  56224. isTintEnabled: boolean;
  56225. /**
  56226. * Defines the clear coat tint of the material.
  56227. * This is only use if tint is enabled
  56228. */
  56229. tintColor: Color3;
  56230. /**
  56231. * Defines the distance at which the tint color should be found in the
  56232. * clear coat media.
  56233. * This is only use if tint is enabled
  56234. */
  56235. tintColorAtDistance: number;
  56236. /**
  56237. * Defines the clear coat layer thickness.
  56238. * This is only use if tint is enabled
  56239. */
  56240. tintThickness: number;
  56241. private _tintTexture;
  56242. /**
  56243. * Stores the clear tint values in a texture.
  56244. * rgb is tint
  56245. * a is a thickness factor
  56246. */
  56247. tintTexture: Nullable<BaseTexture>;
  56248. /** @hidden */
  56249. private _internalMarkAllSubMeshesAsTexturesDirty;
  56250. /** @hidden */
  56251. _markAllSubMeshesAsTexturesDirty(): void;
  56252. /**
  56253. * Instantiate a new istance of clear coat configuration.
  56254. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56255. */
  56256. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56257. /**
  56258. * Gets wehter the submesh is ready to be used or not.
  56259. * @param defines the list of "defines" to update.
  56260. * @param scene defines the scene the material belongs to.
  56261. * @param engine defines the engine the material belongs to.
  56262. * @param disableBumpMap defines wether the material disables bump or not.
  56263. * @returns - boolean indicating that the submesh is ready or not.
  56264. */
  56265. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56266. /**
  56267. * Checks to see if a texture is used in the material.
  56268. * @param defines the list of "defines" to update.
  56269. * @param scene defines the scene to the material belongs to.
  56270. */
  56271. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56272. /**
  56273. * Binds the material data.
  56274. * @param uniformBuffer defines the Uniform buffer to fill in.
  56275. * @param scene defines the scene the material belongs to.
  56276. * @param engine defines the engine the material belongs to.
  56277. * @param disableBumpMap defines wether the material disables bump or not.
  56278. * @param isFrozen defines wether the material is frozen or not.
  56279. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56280. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56281. */
  56282. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56283. /**
  56284. * Checks to see if a texture is used in the material.
  56285. * @param texture - Base texture to use.
  56286. * @returns - Boolean specifying if a texture is used in the material.
  56287. */
  56288. hasTexture(texture: BaseTexture): boolean;
  56289. /**
  56290. * Returns an array of the actively used textures.
  56291. * @param activeTextures Array of BaseTextures
  56292. */
  56293. getActiveTextures(activeTextures: BaseTexture[]): void;
  56294. /**
  56295. * Returns the animatable textures.
  56296. * @param animatables Array of animatable textures.
  56297. */
  56298. getAnimatables(animatables: IAnimatable[]): void;
  56299. /**
  56300. * Disposes the resources of the material.
  56301. * @param forceDisposeTextures - Forces the disposal of all textures.
  56302. */
  56303. dispose(forceDisposeTextures?: boolean): void;
  56304. /**
  56305. * Get the current class name of the texture useful for serialization or dynamic coding.
  56306. * @returns "PBRClearCoatConfiguration"
  56307. */
  56308. getClassName(): string;
  56309. /**
  56310. * Add fallbacks to the effect fallbacks list.
  56311. * @param defines defines the Base texture to use.
  56312. * @param fallbacks defines the current fallback list.
  56313. * @param currentRank defines the current fallback rank.
  56314. * @returns the new fallback rank.
  56315. */
  56316. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56317. /**
  56318. * Add the required uniforms to the current list.
  56319. * @param uniforms defines the current uniform list.
  56320. */
  56321. static AddUniforms(uniforms: string[]): void;
  56322. /**
  56323. * Add the required samplers to the current list.
  56324. * @param samplers defines the current sampler list.
  56325. */
  56326. static AddSamplers(samplers: string[]): void;
  56327. /**
  56328. * Add the required uniforms to the current buffer.
  56329. * @param uniformBuffer defines the current uniform buffer.
  56330. */
  56331. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56332. /**
  56333. * Makes a duplicate of the current configuration into another one.
  56334. * @param clearCoatConfiguration define the config where to copy the info
  56335. */
  56336. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56337. /**
  56338. * Serializes this clear coat configuration.
  56339. * @returns - An object with the serialized config.
  56340. */
  56341. serialize(): any;
  56342. /**
  56343. * Parses a anisotropy Configuration from a serialized object.
  56344. * @param source - Serialized object.
  56345. * @param scene Defines the scene we are parsing for
  56346. * @param rootUrl Defines the rootUrl to load from
  56347. */
  56348. parse(source: any, scene: Scene, rootUrl: string): void;
  56349. }
  56350. }
  56351. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56352. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56354. import { Vector2 } from "babylonjs/Maths/math.vector";
  56355. import { Scene } from "babylonjs/scene";
  56356. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56357. import { Nullable } from "babylonjs/types";
  56358. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56359. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56360. /**
  56361. * @hidden
  56362. */
  56363. export interface IMaterialAnisotropicDefines {
  56364. ANISOTROPIC: boolean;
  56365. ANISOTROPIC_TEXTURE: boolean;
  56366. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56367. MAINUV1: boolean;
  56368. _areTexturesDirty: boolean;
  56369. _needUVs: boolean;
  56370. }
  56371. /**
  56372. * Define the code related to the anisotropic parameters of the pbr material.
  56373. */
  56374. export class PBRAnisotropicConfiguration {
  56375. private _isEnabled;
  56376. /**
  56377. * Defines if the anisotropy is enabled in the material.
  56378. */
  56379. isEnabled: boolean;
  56380. /**
  56381. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56382. */
  56383. intensity: number;
  56384. /**
  56385. * Defines if the effect is along the tangents, bitangents or in between.
  56386. * By default, the effect is "strectching" the highlights along the tangents.
  56387. */
  56388. direction: Vector2;
  56389. private _texture;
  56390. /**
  56391. * Stores the anisotropy values in a texture.
  56392. * rg is direction (like normal from -1 to 1)
  56393. * b is a intensity
  56394. */
  56395. texture: Nullable<BaseTexture>;
  56396. /** @hidden */
  56397. private _internalMarkAllSubMeshesAsTexturesDirty;
  56398. /** @hidden */
  56399. _markAllSubMeshesAsTexturesDirty(): void;
  56400. /**
  56401. * Instantiate a new istance of anisotropy configuration.
  56402. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56403. */
  56404. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56405. /**
  56406. * Specifies that the submesh is ready to be used.
  56407. * @param defines the list of "defines" to update.
  56408. * @param scene defines the scene the material belongs to.
  56409. * @returns - boolean indicating that the submesh is ready or not.
  56410. */
  56411. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56412. /**
  56413. * Checks to see if a texture is used in the material.
  56414. * @param defines the list of "defines" to update.
  56415. * @param mesh the mesh we are preparing the defines for.
  56416. * @param scene defines the scene the material belongs to.
  56417. */
  56418. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56419. /**
  56420. * Binds the material data.
  56421. * @param uniformBuffer defines the Uniform buffer to fill in.
  56422. * @param scene defines the scene the material belongs to.
  56423. * @param isFrozen defines wether the material is frozen or not.
  56424. */
  56425. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56426. /**
  56427. * Checks to see if a texture is used in the material.
  56428. * @param texture - Base texture to use.
  56429. * @returns - Boolean specifying if a texture is used in the material.
  56430. */
  56431. hasTexture(texture: BaseTexture): boolean;
  56432. /**
  56433. * Returns an array of the actively used textures.
  56434. * @param activeTextures Array of BaseTextures
  56435. */
  56436. getActiveTextures(activeTextures: BaseTexture[]): void;
  56437. /**
  56438. * Returns the animatable textures.
  56439. * @param animatables Array of animatable textures.
  56440. */
  56441. getAnimatables(animatables: IAnimatable[]): void;
  56442. /**
  56443. * Disposes the resources of the material.
  56444. * @param forceDisposeTextures - Forces the disposal of all textures.
  56445. */
  56446. dispose(forceDisposeTextures?: boolean): void;
  56447. /**
  56448. * Get the current class name of the texture useful for serialization or dynamic coding.
  56449. * @returns "PBRAnisotropicConfiguration"
  56450. */
  56451. getClassName(): string;
  56452. /**
  56453. * Add fallbacks to the effect fallbacks list.
  56454. * @param defines defines the Base texture to use.
  56455. * @param fallbacks defines the current fallback list.
  56456. * @param currentRank defines the current fallback rank.
  56457. * @returns the new fallback rank.
  56458. */
  56459. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56460. /**
  56461. * Add the required uniforms to the current list.
  56462. * @param uniforms defines the current uniform list.
  56463. */
  56464. static AddUniforms(uniforms: string[]): void;
  56465. /**
  56466. * Add the required uniforms to the current buffer.
  56467. * @param uniformBuffer defines the current uniform buffer.
  56468. */
  56469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56470. /**
  56471. * Add the required samplers to the current list.
  56472. * @param samplers defines the current sampler list.
  56473. */
  56474. static AddSamplers(samplers: string[]): void;
  56475. /**
  56476. * Makes a duplicate of the current configuration into another one.
  56477. * @param anisotropicConfiguration define the config where to copy the info
  56478. */
  56479. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56480. /**
  56481. * Serializes this anisotropy configuration.
  56482. * @returns - An object with the serialized config.
  56483. */
  56484. serialize(): any;
  56485. /**
  56486. * Parses a anisotropy Configuration from a serialized object.
  56487. * @param source - Serialized object.
  56488. * @param scene Defines the scene we are parsing for
  56489. * @param rootUrl Defines the rootUrl to load from
  56490. */
  56491. parse(source: any, scene: Scene, rootUrl: string): void;
  56492. }
  56493. }
  56494. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56495. import { Scene } from "babylonjs/scene";
  56496. /**
  56497. * @hidden
  56498. */
  56499. export interface IMaterialBRDFDefines {
  56500. BRDF_V_HEIGHT_CORRELATED: boolean;
  56501. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56502. SPHERICAL_HARMONICS: boolean;
  56503. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56504. /** @hidden */
  56505. _areMiscDirty: boolean;
  56506. }
  56507. /**
  56508. * Define the code related to the BRDF parameters of the pbr material.
  56509. */
  56510. export class PBRBRDFConfiguration {
  56511. /**
  56512. * Default value used for the energy conservation.
  56513. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56514. */
  56515. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56516. /**
  56517. * Default value used for the Smith Visibility Height Correlated mode.
  56518. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56519. */
  56520. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56521. /**
  56522. * Default value used for the IBL diffuse part.
  56523. * This can help switching back to the polynomials mode globally which is a tiny bit
  56524. * less GPU intensive at the drawback of a lower quality.
  56525. */
  56526. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56527. /**
  56528. * Default value used for activating energy conservation for the specular workflow.
  56529. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56530. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56531. */
  56532. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56533. private _useEnergyConservation;
  56534. /**
  56535. * Defines if the material uses energy conservation.
  56536. */
  56537. useEnergyConservation: boolean;
  56538. private _useSmithVisibilityHeightCorrelated;
  56539. /**
  56540. * LEGACY Mode set to false
  56541. * Defines if the material uses height smith correlated visibility term.
  56542. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56543. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56544. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56545. * Not relying on height correlated will also disable energy conservation.
  56546. */
  56547. useSmithVisibilityHeightCorrelated: boolean;
  56548. private _useSphericalHarmonics;
  56549. /**
  56550. * LEGACY Mode set to false
  56551. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56552. * diffuse part of the IBL.
  56553. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56554. * to the ground truth.
  56555. */
  56556. useSphericalHarmonics: boolean;
  56557. private _useSpecularGlossinessInputEnergyConservation;
  56558. /**
  56559. * Defines if the material uses energy conservation, when the specular workflow is active.
  56560. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56561. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56562. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56563. */
  56564. useSpecularGlossinessInputEnergyConservation: boolean;
  56565. /** @hidden */
  56566. private _internalMarkAllSubMeshesAsMiscDirty;
  56567. /** @hidden */
  56568. _markAllSubMeshesAsMiscDirty(): void;
  56569. /**
  56570. * Instantiate a new istance of clear coat configuration.
  56571. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56572. */
  56573. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56574. /**
  56575. * Checks to see if a texture is used in the material.
  56576. * @param defines the list of "defines" to update.
  56577. */
  56578. prepareDefines(defines: IMaterialBRDFDefines): void;
  56579. /**
  56580. * Get the current class name of the texture useful for serialization or dynamic coding.
  56581. * @returns "PBRClearCoatConfiguration"
  56582. */
  56583. getClassName(): string;
  56584. /**
  56585. * Makes a duplicate of the current configuration into another one.
  56586. * @param brdfConfiguration define the config where to copy the info
  56587. */
  56588. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56589. /**
  56590. * Serializes this BRDF configuration.
  56591. * @returns - An object with the serialized config.
  56592. */
  56593. serialize(): any;
  56594. /**
  56595. * Parses a anisotropy Configuration from a serialized object.
  56596. * @param source - Serialized object.
  56597. * @param scene Defines the scene we are parsing for
  56598. * @param rootUrl Defines the rootUrl to load from
  56599. */
  56600. parse(source: any, scene: Scene, rootUrl: string): void;
  56601. }
  56602. }
  56603. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56604. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56605. import { Color3 } from "babylonjs/Maths/math.color";
  56606. import { Scene } from "babylonjs/scene";
  56607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56608. import { Nullable } from "babylonjs/types";
  56609. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56610. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56611. /**
  56612. * @hidden
  56613. */
  56614. export interface IMaterialSheenDefines {
  56615. SHEEN: boolean;
  56616. SHEEN_TEXTURE: boolean;
  56617. SHEEN_TEXTUREDIRECTUV: number;
  56618. SHEEN_LINKWITHALBEDO: boolean;
  56619. SHEEN_ROUGHNESS: boolean;
  56620. SHEEN_ALBEDOSCALING: boolean;
  56621. /** @hidden */
  56622. _areTexturesDirty: boolean;
  56623. }
  56624. /**
  56625. * Define the code related to the Sheen parameters of the pbr material.
  56626. */
  56627. export class PBRSheenConfiguration {
  56628. private _isEnabled;
  56629. /**
  56630. * Defines if the material uses sheen.
  56631. */
  56632. isEnabled: boolean;
  56633. private _linkSheenWithAlbedo;
  56634. /**
  56635. * Defines if the sheen is linked to the sheen color.
  56636. */
  56637. linkSheenWithAlbedo: boolean;
  56638. /**
  56639. * Defines the sheen intensity.
  56640. */
  56641. intensity: number;
  56642. /**
  56643. * Defines the sheen color.
  56644. */
  56645. color: Color3;
  56646. private _texture;
  56647. /**
  56648. * Stores the sheen tint values in a texture.
  56649. * rgb is tint
  56650. * a is a intensity
  56651. */
  56652. texture: Nullable<BaseTexture>;
  56653. private _roughness;
  56654. /**
  56655. * Defines the sheen roughness.
  56656. * It is not taken into account if linkSheenWithAlbedo is true.
  56657. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56658. */
  56659. roughness: Nullable<number>;
  56660. private _albedoScaling;
  56661. /**
  56662. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56663. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56664. * making it easier to setup and tweak the effect
  56665. */
  56666. albedoScaling: boolean;
  56667. /** @hidden */
  56668. private _internalMarkAllSubMeshesAsTexturesDirty;
  56669. /** @hidden */
  56670. _markAllSubMeshesAsTexturesDirty(): void;
  56671. /**
  56672. * Instantiate a new istance of clear coat configuration.
  56673. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56674. */
  56675. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56676. /**
  56677. * Specifies that the submesh is ready to be used.
  56678. * @param defines the list of "defines" to update.
  56679. * @param scene defines the scene the material belongs to.
  56680. * @returns - boolean indicating that the submesh is ready or not.
  56681. */
  56682. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56683. /**
  56684. * Checks to see if a texture is used in the material.
  56685. * @param defines the list of "defines" to update.
  56686. * @param scene defines the scene the material belongs to.
  56687. */
  56688. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56689. /**
  56690. * Binds the material data.
  56691. * @param uniformBuffer defines the Uniform buffer to fill in.
  56692. * @param scene defines the scene the material belongs to.
  56693. * @param isFrozen defines wether the material is frozen or not.
  56694. */
  56695. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56696. /**
  56697. * Checks to see if a texture is used in the material.
  56698. * @param texture - Base texture to use.
  56699. * @returns - Boolean specifying if a texture is used in the material.
  56700. */
  56701. hasTexture(texture: BaseTexture): boolean;
  56702. /**
  56703. * Returns an array of the actively used textures.
  56704. * @param activeTextures Array of BaseTextures
  56705. */
  56706. getActiveTextures(activeTextures: BaseTexture[]): void;
  56707. /**
  56708. * Returns the animatable textures.
  56709. * @param animatables Array of animatable textures.
  56710. */
  56711. getAnimatables(animatables: IAnimatable[]): void;
  56712. /**
  56713. * Disposes the resources of the material.
  56714. * @param forceDisposeTextures - Forces the disposal of all textures.
  56715. */
  56716. dispose(forceDisposeTextures?: boolean): void;
  56717. /**
  56718. * Get the current class name of the texture useful for serialization or dynamic coding.
  56719. * @returns "PBRSheenConfiguration"
  56720. */
  56721. getClassName(): string;
  56722. /**
  56723. * Add fallbacks to the effect fallbacks list.
  56724. * @param defines defines the Base texture to use.
  56725. * @param fallbacks defines the current fallback list.
  56726. * @param currentRank defines the current fallback rank.
  56727. * @returns the new fallback rank.
  56728. */
  56729. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56730. /**
  56731. * Add the required uniforms to the current list.
  56732. * @param uniforms defines the current uniform list.
  56733. */
  56734. static AddUniforms(uniforms: string[]): void;
  56735. /**
  56736. * Add the required uniforms to the current buffer.
  56737. * @param uniformBuffer defines the current uniform buffer.
  56738. */
  56739. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56740. /**
  56741. * Add the required samplers to the current list.
  56742. * @param samplers defines the current sampler list.
  56743. */
  56744. static AddSamplers(samplers: string[]): void;
  56745. /**
  56746. * Makes a duplicate of the current configuration into another one.
  56747. * @param sheenConfiguration define the config where to copy the info
  56748. */
  56749. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56750. /**
  56751. * Serializes this BRDF configuration.
  56752. * @returns - An object with the serialized config.
  56753. */
  56754. serialize(): any;
  56755. /**
  56756. * Parses a anisotropy Configuration from a serialized object.
  56757. * @param source - Serialized object.
  56758. * @param scene Defines the scene we are parsing for
  56759. * @param rootUrl Defines the rootUrl to load from
  56760. */
  56761. parse(source: any, scene: Scene, rootUrl: string): void;
  56762. }
  56763. }
  56764. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  56765. import { Nullable } from "babylonjs/types";
  56766. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56767. import { Color3 } from "babylonjs/Maths/math.color";
  56768. import { SmartArray } from "babylonjs/Misc/smartArray";
  56769. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56770. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56771. import { Effect } from "babylonjs/Materials/effect";
  56772. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56773. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56774. import { Engine } from "babylonjs/Engines/engine";
  56775. import { Scene } from "babylonjs/scene";
  56776. /**
  56777. * @hidden
  56778. */
  56779. export interface IMaterialSubSurfaceDefines {
  56780. SUBSURFACE: boolean;
  56781. SS_REFRACTION: boolean;
  56782. SS_TRANSLUCENCY: boolean;
  56783. SS_SCATTERING: boolean;
  56784. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56785. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56786. SS_REFRACTIONMAP_3D: boolean;
  56787. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56788. SS_LODINREFRACTIONALPHA: boolean;
  56789. SS_GAMMAREFRACTION: boolean;
  56790. SS_RGBDREFRACTION: boolean;
  56791. SS_LINEARSPECULARREFRACTION: boolean;
  56792. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56793. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56794. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56795. /** @hidden */
  56796. _areTexturesDirty: boolean;
  56797. }
  56798. /**
  56799. * Define the code related to the sub surface parameters of the pbr material.
  56800. */
  56801. export class PBRSubSurfaceConfiguration {
  56802. private _isRefractionEnabled;
  56803. /**
  56804. * Defines if the refraction is enabled in the material.
  56805. */
  56806. isRefractionEnabled: boolean;
  56807. private _isTranslucencyEnabled;
  56808. /**
  56809. * Defines if the translucency is enabled in the material.
  56810. */
  56811. isTranslucencyEnabled: boolean;
  56812. private _isScatteringEnabled;
  56813. /**
  56814. * Defines the refraction intensity of the material.
  56815. * The refraction when enabled replaces the Diffuse part of the material.
  56816. * The intensity helps transitionning between diffuse and refraction.
  56817. */
  56818. refractionIntensity: number;
  56819. /**
  56820. * Defines the translucency intensity of the material.
  56821. * When translucency has been enabled, this defines how much of the "translucency"
  56822. * is addded to the diffuse part of the material.
  56823. */
  56824. translucencyIntensity: number;
  56825. /**
  56826. * Defines the scattering intensity of the material.
  56827. * When scattering has been enabled, this defines how much of the "scattered light"
  56828. * is addded to the diffuse part of the material.
  56829. */
  56830. scatteringIntensity: number;
  56831. /**
  56832. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56833. */
  56834. useAlbedoToTintRefraction: boolean;
  56835. private _thicknessTexture;
  56836. /**
  56837. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56838. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56839. * 0 would mean minimumThickness
  56840. * 1 would mean maximumThickness
  56841. * The other channels might be use as a mask to vary the different effects intensity.
  56842. */
  56843. thicknessTexture: Nullable<BaseTexture>;
  56844. private _refractionTexture;
  56845. /**
  56846. * Defines the texture to use for refraction.
  56847. */
  56848. refractionTexture: Nullable<BaseTexture>;
  56849. private _indexOfRefraction;
  56850. /**
  56851. * Index of refraction of the material base layer.
  56852. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56853. *
  56854. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56855. *
  56856. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56857. */
  56858. indexOfRefraction: number;
  56859. private _volumeIndexOfRefraction;
  56860. /**
  56861. * Index of refraction of the material's volume.
  56862. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56863. *
  56864. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56865. * the volume will use the same IOR as the surface.
  56866. */
  56867. get volumeIndexOfRefraction(): number;
  56868. set volumeIndexOfRefraction(value: number);
  56869. private _invertRefractionY;
  56870. /**
  56871. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56872. */
  56873. invertRefractionY: boolean;
  56874. private _linkRefractionWithTransparency;
  56875. /**
  56876. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56877. * Materials half opaque for instance using refraction could benefit from this control.
  56878. */
  56879. linkRefractionWithTransparency: boolean;
  56880. /**
  56881. * Defines the minimum thickness stored in the thickness map.
  56882. * If no thickness map is defined, this value will be used to simulate thickness.
  56883. */
  56884. minimumThickness: number;
  56885. /**
  56886. * Defines the maximum thickness stored in the thickness map.
  56887. */
  56888. maximumThickness: number;
  56889. /**
  56890. * Defines the volume tint of the material.
  56891. * This is used for both translucency and scattering.
  56892. */
  56893. tintColor: Color3;
  56894. /**
  56895. * Defines the distance at which the tint color should be found in the media.
  56896. * This is used for refraction only.
  56897. */
  56898. tintColorAtDistance: number;
  56899. /**
  56900. * Defines how far each channel transmit through the media.
  56901. * It is defined as a color to simplify it selection.
  56902. */
  56903. diffusionDistance: Color3;
  56904. private _useMaskFromThicknessTexture;
  56905. /**
  56906. * Stores the intensity of the different subsurface effects in the thickness texture.
  56907. * * the green channel is the translucency intensity.
  56908. * * the blue channel is the scattering intensity.
  56909. * * the alpha channel is the refraction intensity.
  56910. */
  56911. useMaskFromThicknessTexture: boolean;
  56912. /** @hidden */
  56913. private _internalMarkAllSubMeshesAsTexturesDirty;
  56914. /** @hidden */
  56915. _markAllSubMeshesAsTexturesDirty(): void;
  56916. /**
  56917. * Instantiate a new istance of sub surface configuration.
  56918. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56919. */
  56920. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56921. /**
  56922. * Gets wehter the submesh is ready to be used or not.
  56923. * @param defines the list of "defines" to update.
  56924. * @param scene defines the scene the material belongs to.
  56925. * @returns - boolean indicating that the submesh is ready or not.
  56926. */
  56927. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56928. /**
  56929. * Checks to see if a texture is used in the material.
  56930. * @param defines the list of "defines" to update.
  56931. * @param scene defines the scene to the material belongs to.
  56932. */
  56933. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56934. /**
  56935. * Binds the material data.
  56936. * @param uniformBuffer defines the Uniform buffer to fill in.
  56937. * @param scene defines the scene the material belongs to.
  56938. * @param engine defines the engine the material belongs to.
  56939. * @param isFrozen defines whether the material is frozen or not.
  56940. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56941. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56942. */
  56943. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56944. /**
  56945. * Unbinds the material from the mesh.
  56946. * @param activeEffect defines the effect that should be unbound from.
  56947. * @returns true if unbound, otherwise false
  56948. */
  56949. unbind(activeEffect: Effect): boolean;
  56950. /**
  56951. * Returns the texture used for refraction or null if none is used.
  56952. * @param scene defines the scene the material belongs to.
  56953. * @returns - Refraction texture if present. If no refraction texture and refraction
  56954. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56955. */
  56956. private _getRefractionTexture;
  56957. /**
  56958. * Returns true if alpha blending should be disabled.
  56959. */
  56960. get disableAlphaBlending(): boolean;
  56961. /**
  56962. * Fills the list of render target textures.
  56963. * @param renderTargets the list of render targets to update
  56964. */
  56965. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56966. /**
  56967. * Checks to see if a texture is used in the material.
  56968. * @param texture - Base texture to use.
  56969. * @returns - Boolean specifying if a texture is used in the material.
  56970. */
  56971. hasTexture(texture: BaseTexture): boolean;
  56972. /**
  56973. * Gets a boolean indicating that current material needs to register RTT
  56974. * @returns true if this uses a render target otherwise false.
  56975. */
  56976. hasRenderTargetTextures(): boolean;
  56977. /**
  56978. * Returns an array of the actively used textures.
  56979. * @param activeTextures Array of BaseTextures
  56980. */
  56981. getActiveTextures(activeTextures: BaseTexture[]): void;
  56982. /**
  56983. * Returns the animatable textures.
  56984. * @param animatables Array of animatable textures.
  56985. */
  56986. getAnimatables(animatables: IAnimatable[]): void;
  56987. /**
  56988. * Disposes the resources of the material.
  56989. * @param forceDisposeTextures - Forces the disposal of all textures.
  56990. */
  56991. dispose(forceDisposeTextures?: boolean): void;
  56992. /**
  56993. * Get the current class name of the texture useful for serialization or dynamic coding.
  56994. * @returns "PBRSubSurfaceConfiguration"
  56995. */
  56996. getClassName(): string;
  56997. /**
  56998. * Add fallbacks to the effect fallbacks list.
  56999. * @param defines defines the Base texture to use.
  57000. * @param fallbacks defines the current fallback list.
  57001. * @param currentRank defines the current fallback rank.
  57002. * @returns the new fallback rank.
  57003. */
  57004. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57005. /**
  57006. * Add the required uniforms to the current list.
  57007. * @param uniforms defines the current uniform list.
  57008. */
  57009. static AddUniforms(uniforms: string[]): void;
  57010. /**
  57011. * Add the required samplers to the current list.
  57012. * @param samplers defines the current sampler list.
  57013. */
  57014. static AddSamplers(samplers: string[]): void;
  57015. /**
  57016. * Add the required uniforms to the current buffer.
  57017. * @param uniformBuffer defines the current uniform buffer.
  57018. */
  57019. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57020. /**
  57021. * Makes a duplicate of the current configuration into another one.
  57022. * @param configuration define the config where to copy the info
  57023. */
  57024. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57025. /**
  57026. * Serializes this Sub Surface configuration.
  57027. * @returns - An object with the serialized config.
  57028. */
  57029. serialize(): any;
  57030. /**
  57031. * Parses a anisotropy Configuration from a serialized object.
  57032. * @param source - Serialized object.
  57033. * @param scene Defines the scene we are parsing for
  57034. * @param rootUrl Defines the rootUrl to load from
  57035. */
  57036. parse(source: any, scene: Scene, rootUrl: string): void;
  57037. }
  57038. }
  57039. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57040. /** @hidden */
  57041. export var pbrFragmentDeclaration: {
  57042. name: string;
  57043. shader: string;
  57044. };
  57045. }
  57046. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57047. /** @hidden */
  57048. export var pbrUboDeclaration: {
  57049. name: string;
  57050. shader: string;
  57051. };
  57052. }
  57053. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57054. /** @hidden */
  57055. export var pbrFragmentExtraDeclaration: {
  57056. name: string;
  57057. shader: string;
  57058. };
  57059. }
  57060. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57061. /** @hidden */
  57062. export var pbrFragmentSamplersDeclaration: {
  57063. name: string;
  57064. shader: string;
  57065. };
  57066. }
  57067. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57068. /** @hidden */
  57069. export var importanceSampling: {
  57070. name: string;
  57071. shader: string;
  57072. };
  57073. }
  57074. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57075. /** @hidden */
  57076. export var pbrHelperFunctions: {
  57077. name: string;
  57078. shader: string;
  57079. };
  57080. }
  57081. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57082. /** @hidden */
  57083. export var harmonicsFunctions: {
  57084. name: string;
  57085. shader: string;
  57086. };
  57087. }
  57088. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57089. /** @hidden */
  57090. export var pbrDirectLightingSetupFunctions: {
  57091. name: string;
  57092. shader: string;
  57093. };
  57094. }
  57095. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57096. /** @hidden */
  57097. export var pbrDirectLightingFalloffFunctions: {
  57098. name: string;
  57099. shader: string;
  57100. };
  57101. }
  57102. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57103. /** @hidden */
  57104. export var pbrBRDFFunctions: {
  57105. name: string;
  57106. shader: string;
  57107. };
  57108. }
  57109. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57110. /** @hidden */
  57111. export var hdrFilteringFunctions: {
  57112. name: string;
  57113. shader: string;
  57114. };
  57115. }
  57116. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57117. /** @hidden */
  57118. export var pbrDirectLightingFunctions: {
  57119. name: string;
  57120. shader: string;
  57121. };
  57122. }
  57123. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57124. /** @hidden */
  57125. export var pbrIBLFunctions: {
  57126. name: string;
  57127. shader: string;
  57128. };
  57129. }
  57130. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57131. /** @hidden */
  57132. export var pbrBlockAlbedoOpacity: {
  57133. name: string;
  57134. shader: string;
  57135. };
  57136. }
  57137. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57138. /** @hidden */
  57139. export var pbrBlockReflectivity: {
  57140. name: string;
  57141. shader: string;
  57142. };
  57143. }
  57144. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57145. /** @hidden */
  57146. export var pbrBlockAmbientOcclusion: {
  57147. name: string;
  57148. shader: string;
  57149. };
  57150. }
  57151. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57152. /** @hidden */
  57153. export var pbrBlockAlphaFresnel: {
  57154. name: string;
  57155. shader: string;
  57156. };
  57157. }
  57158. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57159. /** @hidden */
  57160. export var pbrBlockAnisotropic: {
  57161. name: string;
  57162. shader: string;
  57163. };
  57164. }
  57165. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57166. /** @hidden */
  57167. export var pbrBlockReflection: {
  57168. name: string;
  57169. shader: string;
  57170. };
  57171. }
  57172. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57173. /** @hidden */
  57174. export var pbrBlockSheen: {
  57175. name: string;
  57176. shader: string;
  57177. };
  57178. }
  57179. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57180. /** @hidden */
  57181. export var pbrBlockClearcoat: {
  57182. name: string;
  57183. shader: string;
  57184. };
  57185. }
  57186. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57187. /** @hidden */
  57188. export var pbrBlockSubSurface: {
  57189. name: string;
  57190. shader: string;
  57191. };
  57192. }
  57193. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57194. /** @hidden */
  57195. export var pbrBlockNormalGeometric: {
  57196. name: string;
  57197. shader: string;
  57198. };
  57199. }
  57200. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57201. /** @hidden */
  57202. export var pbrBlockNormalFinal: {
  57203. name: string;
  57204. shader: string;
  57205. };
  57206. }
  57207. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57208. /** @hidden */
  57209. export var pbrBlockGeometryInfo: {
  57210. name: string;
  57211. shader: string;
  57212. };
  57213. }
  57214. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57215. /** @hidden */
  57216. export var pbrBlockReflectance0: {
  57217. name: string;
  57218. shader: string;
  57219. };
  57220. }
  57221. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57222. /** @hidden */
  57223. export var pbrBlockReflectance: {
  57224. name: string;
  57225. shader: string;
  57226. };
  57227. }
  57228. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57229. /** @hidden */
  57230. export var pbrBlockDirectLighting: {
  57231. name: string;
  57232. shader: string;
  57233. };
  57234. }
  57235. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57236. /** @hidden */
  57237. export var pbrBlockFinalLitComponents: {
  57238. name: string;
  57239. shader: string;
  57240. };
  57241. }
  57242. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57243. /** @hidden */
  57244. export var pbrBlockFinalUnlitComponents: {
  57245. name: string;
  57246. shader: string;
  57247. };
  57248. }
  57249. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57250. /** @hidden */
  57251. export var pbrBlockFinalColorComposition: {
  57252. name: string;
  57253. shader: string;
  57254. };
  57255. }
  57256. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57257. /** @hidden */
  57258. export var pbrBlockImageProcessing: {
  57259. name: string;
  57260. shader: string;
  57261. };
  57262. }
  57263. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57264. /** @hidden */
  57265. export var pbrDebug: {
  57266. name: string;
  57267. shader: string;
  57268. };
  57269. }
  57270. declare module "babylonjs/Shaders/pbr.fragment" {
  57271. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57272. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57273. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57274. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57275. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57276. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57277. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57278. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57279. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57280. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57281. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57282. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57283. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57284. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57285. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57286. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57287. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57288. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57289. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57290. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57291. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57292. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57293. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57294. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57295. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57296. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57297. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57298. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57299. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57300. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57301. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57302. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57303. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57304. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57305. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57306. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57307. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57308. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57309. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57310. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57311. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57312. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57313. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57314. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57315. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57316. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57317. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57318. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57319. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57320. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57321. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57322. /** @hidden */
  57323. export var pbrPixelShader: {
  57324. name: string;
  57325. shader: string;
  57326. };
  57327. }
  57328. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57329. /** @hidden */
  57330. export var pbrVertexDeclaration: {
  57331. name: string;
  57332. shader: string;
  57333. };
  57334. }
  57335. declare module "babylonjs/Shaders/pbr.vertex" {
  57336. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57337. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57338. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57339. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57340. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57341. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57342. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57343. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57344. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57345. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57346. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57347. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57348. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57349. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57350. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57351. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57352. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57353. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57354. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57355. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57356. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57357. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57358. /** @hidden */
  57359. export var pbrVertexShader: {
  57360. name: string;
  57361. shader: string;
  57362. };
  57363. }
  57364. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57365. import { Nullable } from "babylonjs/types";
  57366. import { Scene } from "babylonjs/scene";
  57367. import { Matrix } from "babylonjs/Maths/math.vector";
  57368. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57370. import { Mesh } from "babylonjs/Meshes/mesh";
  57371. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57372. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57373. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57374. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57375. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57376. import { Color3 } from "babylonjs/Maths/math.color";
  57377. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57378. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57379. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57380. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57382. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57383. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57384. import "babylonjs/Shaders/pbr.fragment";
  57385. import "babylonjs/Shaders/pbr.vertex";
  57386. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57387. /**
  57388. * Manages the defines for the PBR Material.
  57389. * @hidden
  57390. */
  57391. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57392. PBR: boolean;
  57393. NUM_SAMPLES: string;
  57394. REALTIME_FILTERING: boolean;
  57395. MAINUV1: boolean;
  57396. MAINUV2: boolean;
  57397. UV1: boolean;
  57398. UV2: boolean;
  57399. ALBEDO: boolean;
  57400. GAMMAALBEDO: boolean;
  57401. ALBEDODIRECTUV: number;
  57402. VERTEXCOLOR: boolean;
  57403. DETAIL: boolean;
  57404. DETAILDIRECTUV: number;
  57405. DETAIL_NORMALBLENDMETHOD: number;
  57406. AMBIENT: boolean;
  57407. AMBIENTDIRECTUV: number;
  57408. AMBIENTINGRAYSCALE: boolean;
  57409. OPACITY: boolean;
  57410. VERTEXALPHA: boolean;
  57411. OPACITYDIRECTUV: number;
  57412. OPACITYRGB: boolean;
  57413. ALPHATEST: boolean;
  57414. DEPTHPREPASS: boolean;
  57415. ALPHABLEND: boolean;
  57416. ALPHAFROMALBEDO: boolean;
  57417. ALPHATESTVALUE: string;
  57418. SPECULAROVERALPHA: boolean;
  57419. RADIANCEOVERALPHA: boolean;
  57420. ALPHAFRESNEL: boolean;
  57421. LINEARALPHAFRESNEL: boolean;
  57422. PREMULTIPLYALPHA: boolean;
  57423. EMISSIVE: boolean;
  57424. EMISSIVEDIRECTUV: number;
  57425. REFLECTIVITY: boolean;
  57426. REFLECTIVITYDIRECTUV: number;
  57427. SPECULARTERM: boolean;
  57428. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57429. MICROSURFACEAUTOMATIC: boolean;
  57430. LODBASEDMICROSFURACE: boolean;
  57431. MICROSURFACEMAP: boolean;
  57432. MICROSURFACEMAPDIRECTUV: number;
  57433. METALLICWORKFLOW: boolean;
  57434. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57435. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57436. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57437. AOSTOREINMETALMAPRED: boolean;
  57438. METALLIC_REFLECTANCE: boolean;
  57439. METALLIC_REFLECTANCEDIRECTUV: number;
  57440. ENVIRONMENTBRDF: boolean;
  57441. ENVIRONMENTBRDF_RGBD: boolean;
  57442. NORMAL: boolean;
  57443. TANGENT: boolean;
  57444. BUMP: boolean;
  57445. BUMPDIRECTUV: number;
  57446. OBJECTSPACE_NORMALMAP: boolean;
  57447. PARALLAX: boolean;
  57448. PARALLAXOCCLUSION: boolean;
  57449. NORMALXYSCALE: boolean;
  57450. LIGHTMAP: boolean;
  57451. LIGHTMAPDIRECTUV: number;
  57452. USELIGHTMAPASSHADOWMAP: boolean;
  57453. GAMMALIGHTMAP: boolean;
  57454. RGBDLIGHTMAP: boolean;
  57455. REFLECTION: boolean;
  57456. REFLECTIONMAP_3D: boolean;
  57457. REFLECTIONMAP_SPHERICAL: boolean;
  57458. REFLECTIONMAP_PLANAR: boolean;
  57459. REFLECTIONMAP_CUBIC: boolean;
  57460. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57461. REFLECTIONMAP_PROJECTION: boolean;
  57462. REFLECTIONMAP_SKYBOX: boolean;
  57463. REFLECTIONMAP_EXPLICIT: boolean;
  57464. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57465. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57466. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57467. INVERTCUBICMAP: boolean;
  57468. USESPHERICALFROMREFLECTIONMAP: boolean;
  57469. USEIRRADIANCEMAP: boolean;
  57470. SPHERICAL_HARMONICS: boolean;
  57471. USESPHERICALINVERTEX: boolean;
  57472. REFLECTIONMAP_OPPOSITEZ: boolean;
  57473. LODINREFLECTIONALPHA: boolean;
  57474. GAMMAREFLECTION: boolean;
  57475. RGBDREFLECTION: boolean;
  57476. LINEARSPECULARREFLECTION: boolean;
  57477. RADIANCEOCCLUSION: boolean;
  57478. HORIZONOCCLUSION: boolean;
  57479. INSTANCES: boolean;
  57480. THIN_INSTANCES: boolean;
  57481. NUM_BONE_INFLUENCERS: number;
  57482. BonesPerMesh: number;
  57483. BONETEXTURE: boolean;
  57484. NONUNIFORMSCALING: boolean;
  57485. MORPHTARGETS: boolean;
  57486. MORPHTARGETS_NORMAL: boolean;
  57487. MORPHTARGETS_TANGENT: boolean;
  57488. MORPHTARGETS_UV: boolean;
  57489. NUM_MORPH_INFLUENCERS: number;
  57490. IMAGEPROCESSING: boolean;
  57491. VIGNETTE: boolean;
  57492. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57493. VIGNETTEBLENDMODEOPAQUE: boolean;
  57494. TONEMAPPING: boolean;
  57495. TONEMAPPING_ACES: boolean;
  57496. CONTRAST: boolean;
  57497. COLORCURVES: boolean;
  57498. COLORGRADING: boolean;
  57499. COLORGRADING3D: boolean;
  57500. SAMPLER3DGREENDEPTH: boolean;
  57501. SAMPLER3DBGRMAP: boolean;
  57502. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57503. EXPOSURE: boolean;
  57504. MULTIVIEW: boolean;
  57505. USEPHYSICALLIGHTFALLOFF: boolean;
  57506. USEGLTFLIGHTFALLOFF: boolean;
  57507. TWOSIDEDLIGHTING: boolean;
  57508. SHADOWFLOAT: boolean;
  57509. CLIPPLANE: boolean;
  57510. CLIPPLANE2: boolean;
  57511. CLIPPLANE3: boolean;
  57512. CLIPPLANE4: boolean;
  57513. CLIPPLANE5: boolean;
  57514. CLIPPLANE6: boolean;
  57515. POINTSIZE: boolean;
  57516. FOG: boolean;
  57517. LOGARITHMICDEPTH: boolean;
  57518. FORCENORMALFORWARD: boolean;
  57519. SPECULARAA: boolean;
  57520. CLEARCOAT: boolean;
  57521. CLEARCOAT_DEFAULTIOR: boolean;
  57522. CLEARCOAT_TEXTURE: boolean;
  57523. CLEARCOAT_TEXTUREDIRECTUV: number;
  57524. CLEARCOAT_BUMP: boolean;
  57525. CLEARCOAT_BUMPDIRECTUV: number;
  57526. CLEARCOAT_TINT: boolean;
  57527. CLEARCOAT_TINT_TEXTURE: boolean;
  57528. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57529. ANISOTROPIC: boolean;
  57530. ANISOTROPIC_TEXTURE: boolean;
  57531. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57532. BRDF_V_HEIGHT_CORRELATED: boolean;
  57533. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57534. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57535. SHEEN: boolean;
  57536. SHEEN_TEXTURE: boolean;
  57537. SHEEN_TEXTUREDIRECTUV: number;
  57538. SHEEN_LINKWITHALBEDO: boolean;
  57539. SHEEN_ROUGHNESS: boolean;
  57540. SHEEN_ALBEDOSCALING: boolean;
  57541. SUBSURFACE: boolean;
  57542. SS_REFRACTION: boolean;
  57543. SS_TRANSLUCENCY: boolean;
  57544. SS_SCATTERING: boolean;
  57545. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57546. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57547. SS_REFRACTIONMAP_3D: boolean;
  57548. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57549. SS_LODINREFRACTIONALPHA: boolean;
  57550. SS_GAMMAREFRACTION: boolean;
  57551. SS_RGBDREFRACTION: boolean;
  57552. SS_LINEARSPECULARREFRACTION: boolean;
  57553. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57554. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57555. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57556. UNLIT: boolean;
  57557. DEBUGMODE: number;
  57558. /**
  57559. * Initializes the PBR Material defines.
  57560. */
  57561. constructor();
  57562. /**
  57563. * Resets the PBR Material defines.
  57564. */
  57565. reset(): void;
  57566. }
  57567. /**
  57568. * The Physically based material base class of BJS.
  57569. *
  57570. * This offers the main features of a standard PBR material.
  57571. * For more information, please refer to the documentation :
  57572. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57573. */
  57574. export abstract class PBRBaseMaterial extends PushMaterial {
  57575. /**
  57576. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57577. */
  57578. static readonly PBRMATERIAL_OPAQUE: number;
  57579. /**
  57580. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57581. */
  57582. static readonly PBRMATERIAL_ALPHATEST: number;
  57583. /**
  57584. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57585. */
  57586. static readonly PBRMATERIAL_ALPHABLEND: number;
  57587. /**
  57588. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57589. * They are also discarded below the alpha cutoff threshold to improve performances.
  57590. */
  57591. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57592. /**
  57593. * Defines the default value of how much AO map is occluding the analytical lights
  57594. * (point spot...).
  57595. */
  57596. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57597. /**
  57598. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57599. */
  57600. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57601. /**
  57602. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57603. * to enhance interoperability with other engines.
  57604. */
  57605. static readonly LIGHTFALLOFF_GLTF: number;
  57606. /**
  57607. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57608. * to enhance interoperability with other materials.
  57609. */
  57610. static readonly LIGHTFALLOFF_STANDARD: number;
  57611. /**
  57612. * Intensity of the direct lights e.g. the four lights available in your scene.
  57613. * This impacts both the direct diffuse and specular highlights.
  57614. */
  57615. protected _directIntensity: number;
  57616. /**
  57617. * Intensity of the emissive part of the material.
  57618. * This helps controlling the emissive effect without modifying the emissive color.
  57619. */
  57620. protected _emissiveIntensity: number;
  57621. /**
  57622. * Intensity of the environment e.g. how much the environment will light the object
  57623. * either through harmonics for rough material or through the refelction for shiny ones.
  57624. */
  57625. protected _environmentIntensity: number;
  57626. /**
  57627. * This is a special control allowing the reduction of the specular highlights coming from the
  57628. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57629. */
  57630. protected _specularIntensity: number;
  57631. /**
  57632. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57633. */
  57634. private _lightingInfos;
  57635. /**
  57636. * Debug Control allowing disabling the bump map on this material.
  57637. */
  57638. protected _disableBumpMap: boolean;
  57639. /**
  57640. * AKA Diffuse Texture in standard nomenclature.
  57641. */
  57642. protected _albedoTexture: Nullable<BaseTexture>;
  57643. /**
  57644. * AKA Occlusion Texture in other nomenclature.
  57645. */
  57646. protected _ambientTexture: Nullable<BaseTexture>;
  57647. /**
  57648. * AKA Occlusion Texture Intensity in other nomenclature.
  57649. */
  57650. protected _ambientTextureStrength: number;
  57651. /**
  57652. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57653. * 1 means it completely occludes it
  57654. * 0 mean it has no impact
  57655. */
  57656. protected _ambientTextureImpactOnAnalyticalLights: number;
  57657. /**
  57658. * Stores the alpha values in a texture.
  57659. */
  57660. protected _opacityTexture: Nullable<BaseTexture>;
  57661. /**
  57662. * Stores the reflection values in a texture.
  57663. */
  57664. protected _reflectionTexture: Nullable<BaseTexture>;
  57665. /**
  57666. * Stores the emissive values in a texture.
  57667. */
  57668. protected _emissiveTexture: Nullable<BaseTexture>;
  57669. /**
  57670. * AKA Specular texture in other nomenclature.
  57671. */
  57672. protected _reflectivityTexture: Nullable<BaseTexture>;
  57673. /**
  57674. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57675. */
  57676. protected _metallicTexture: Nullable<BaseTexture>;
  57677. /**
  57678. * Specifies the metallic scalar of the metallic/roughness workflow.
  57679. * Can also be used to scale the metalness values of the metallic texture.
  57680. */
  57681. protected _metallic: Nullable<number>;
  57682. /**
  57683. * Specifies the roughness scalar of the metallic/roughness workflow.
  57684. * Can also be used to scale the roughness values of the metallic texture.
  57685. */
  57686. protected _roughness: Nullable<number>;
  57687. /**
  57688. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57689. * By default the indexOfrefraction is used to compute F0;
  57690. *
  57691. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57692. *
  57693. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57694. * F90 = metallicReflectanceColor;
  57695. */
  57696. protected _metallicF0Factor: number;
  57697. /**
  57698. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57699. * By default the F90 is always 1;
  57700. *
  57701. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57702. *
  57703. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57704. * F90 = metallicReflectanceColor;
  57705. */
  57706. protected _metallicReflectanceColor: Color3;
  57707. /**
  57708. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57709. * This is multiply against the scalar values defined in the material.
  57710. */
  57711. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57712. /**
  57713. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57714. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57715. */
  57716. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57717. /**
  57718. * Stores surface normal data used to displace a mesh in a texture.
  57719. */
  57720. protected _bumpTexture: Nullable<BaseTexture>;
  57721. /**
  57722. * Stores the pre-calculated light information of a mesh in a texture.
  57723. */
  57724. protected _lightmapTexture: Nullable<BaseTexture>;
  57725. /**
  57726. * The color of a material in ambient lighting.
  57727. */
  57728. protected _ambientColor: Color3;
  57729. /**
  57730. * AKA Diffuse Color in other nomenclature.
  57731. */
  57732. protected _albedoColor: Color3;
  57733. /**
  57734. * AKA Specular Color in other nomenclature.
  57735. */
  57736. protected _reflectivityColor: Color3;
  57737. /**
  57738. * The color applied when light is reflected from a material.
  57739. */
  57740. protected _reflectionColor: Color3;
  57741. /**
  57742. * The color applied when light is emitted from a material.
  57743. */
  57744. protected _emissiveColor: Color3;
  57745. /**
  57746. * AKA Glossiness in other nomenclature.
  57747. */
  57748. protected _microSurface: number;
  57749. /**
  57750. * Specifies that the material will use the light map as a show map.
  57751. */
  57752. protected _useLightmapAsShadowmap: boolean;
  57753. /**
  57754. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57755. * makes the reflect vector face the model (under horizon).
  57756. */
  57757. protected _useHorizonOcclusion: boolean;
  57758. /**
  57759. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57760. * too much the area relying on ambient texture to define their ambient occlusion.
  57761. */
  57762. protected _useRadianceOcclusion: boolean;
  57763. /**
  57764. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57765. */
  57766. protected _useAlphaFromAlbedoTexture: boolean;
  57767. /**
  57768. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57769. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57770. */
  57771. protected _useSpecularOverAlpha: boolean;
  57772. /**
  57773. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57774. */
  57775. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57776. /**
  57777. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57778. */
  57779. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57780. /**
  57781. * Specifies if the metallic texture contains the roughness information in its green channel.
  57782. */
  57783. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57784. /**
  57785. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57786. */
  57787. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57788. /**
  57789. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57790. */
  57791. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57792. /**
  57793. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57794. */
  57795. protected _useAmbientInGrayScale: boolean;
  57796. /**
  57797. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57798. * The material will try to infer what glossiness each pixel should be.
  57799. */
  57800. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57801. /**
  57802. * Defines the falloff type used in this material.
  57803. * It by default is Physical.
  57804. */
  57805. protected _lightFalloff: number;
  57806. /**
  57807. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57808. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57809. */
  57810. protected _useRadianceOverAlpha: boolean;
  57811. /**
  57812. * Allows using an object space normal map (instead of tangent space).
  57813. */
  57814. protected _useObjectSpaceNormalMap: boolean;
  57815. /**
  57816. * Allows using the bump map in parallax mode.
  57817. */
  57818. protected _useParallax: boolean;
  57819. /**
  57820. * Allows using the bump map in parallax occlusion mode.
  57821. */
  57822. protected _useParallaxOcclusion: boolean;
  57823. /**
  57824. * Controls the scale bias of the parallax mode.
  57825. */
  57826. protected _parallaxScaleBias: number;
  57827. /**
  57828. * If sets to true, disables all the lights affecting the material.
  57829. */
  57830. protected _disableLighting: boolean;
  57831. /**
  57832. * Number of Simultaneous lights allowed on the material.
  57833. */
  57834. protected _maxSimultaneousLights: number;
  57835. /**
  57836. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57837. */
  57838. protected _invertNormalMapX: boolean;
  57839. /**
  57840. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57841. */
  57842. protected _invertNormalMapY: boolean;
  57843. /**
  57844. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57845. */
  57846. protected _twoSidedLighting: boolean;
  57847. /**
  57848. * Defines the alpha limits in alpha test mode.
  57849. */
  57850. protected _alphaCutOff: number;
  57851. /**
  57852. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57853. */
  57854. protected _forceAlphaTest: boolean;
  57855. /**
  57856. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57857. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57858. */
  57859. protected _useAlphaFresnel: boolean;
  57860. /**
  57861. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57862. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57863. */
  57864. protected _useLinearAlphaFresnel: boolean;
  57865. /**
  57866. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57867. * from cos thetav and roughness:
  57868. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57869. */
  57870. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57871. /**
  57872. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57873. */
  57874. protected _forceIrradianceInFragment: boolean;
  57875. private _realTimeFiltering;
  57876. /**
  57877. * Enables realtime filtering on the texture.
  57878. */
  57879. get realTimeFiltering(): boolean;
  57880. set realTimeFiltering(b: boolean);
  57881. private _realTimeFilteringQuality;
  57882. /**
  57883. * Quality switch for realtime filtering
  57884. */
  57885. get realTimeFilteringQuality(): number;
  57886. set realTimeFilteringQuality(n: number);
  57887. /**
  57888. * Force normal to face away from face.
  57889. */
  57890. protected _forceNormalForward: boolean;
  57891. /**
  57892. * Enables specular anti aliasing in the PBR shader.
  57893. * It will both interacts on the Geometry for analytical and IBL lighting.
  57894. * It also prefilter the roughness map based on the bump values.
  57895. */
  57896. protected _enableSpecularAntiAliasing: boolean;
  57897. /**
  57898. * Default configuration related to image processing available in the PBR Material.
  57899. */
  57900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57901. /**
  57902. * Keep track of the image processing observer to allow dispose and replace.
  57903. */
  57904. private _imageProcessingObserver;
  57905. /**
  57906. * Attaches a new image processing configuration to the PBR Material.
  57907. * @param configuration
  57908. */
  57909. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57910. /**
  57911. * Stores the available render targets.
  57912. */
  57913. private _renderTargets;
  57914. /**
  57915. * Sets the global ambient color for the material used in lighting calculations.
  57916. */
  57917. private _globalAmbientColor;
  57918. /**
  57919. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57920. */
  57921. private _useLogarithmicDepth;
  57922. /**
  57923. * If set to true, no lighting calculations will be applied.
  57924. */
  57925. private _unlit;
  57926. private _debugMode;
  57927. /**
  57928. * @hidden
  57929. * This is reserved for the inspector.
  57930. * Defines the material debug mode.
  57931. * It helps seeing only some components of the material while troubleshooting.
  57932. */
  57933. debugMode: number;
  57934. /**
  57935. * @hidden
  57936. * This is reserved for the inspector.
  57937. * Specify from where on screen the debug mode should start.
  57938. * The value goes from -1 (full screen) to 1 (not visible)
  57939. * It helps with side by side comparison against the final render
  57940. * This defaults to -1
  57941. */
  57942. private debugLimit;
  57943. /**
  57944. * @hidden
  57945. * This is reserved for the inspector.
  57946. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57947. * You can use the factor to better multiply the final value.
  57948. */
  57949. private debugFactor;
  57950. /**
  57951. * Defines the clear coat layer parameters for the material.
  57952. */
  57953. readonly clearCoat: PBRClearCoatConfiguration;
  57954. /**
  57955. * Defines the anisotropic parameters for the material.
  57956. */
  57957. readonly anisotropy: PBRAnisotropicConfiguration;
  57958. /**
  57959. * Defines the BRDF parameters for the material.
  57960. */
  57961. readonly brdf: PBRBRDFConfiguration;
  57962. /**
  57963. * Defines the Sheen parameters for the material.
  57964. */
  57965. readonly sheen: PBRSheenConfiguration;
  57966. /**
  57967. * Defines the SubSurface parameters for the material.
  57968. */
  57969. readonly subSurface: PBRSubSurfaceConfiguration;
  57970. /**
  57971. * Defines the detail map parameters for the material.
  57972. */
  57973. readonly detailMap: DetailMapConfiguration;
  57974. protected _rebuildInParallel: boolean;
  57975. /**
  57976. * Instantiates a new PBRMaterial instance.
  57977. *
  57978. * @param name The material name
  57979. * @param scene The scene the material will be use in.
  57980. */
  57981. constructor(name: string, scene: Scene);
  57982. /**
  57983. * Gets a boolean indicating that current material needs to register RTT
  57984. */
  57985. get hasRenderTargetTextures(): boolean;
  57986. /**
  57987. * Gets the name of the material class.
  57988. */
  57989. getClassName(): string;
  57990. /**
  57991. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57992. */
  57993. get useLogarithmicDepth(): boolean;
  57994. /**
  57995. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57996. */
  57997. set useLogarithmicDepth(value: boolean);
  57998. /**
  57999. * Returns true if alpha blending should be disabled.
  58000. */
  58001. protected get _disableAlphaBlending(): boolean;
  58002. /**
  58003. * Specifies whether or not this material should be rendered in alpha blend mode.
  58004. */
  58005. needAlphaBlending(): boolean;
  58006. /**
  58007. * Specifies whether or not this material should be rendered in alpha test mode.
  58008. */
  58009. needAlphaTesting(): boolean;
  58010. /**
  58011. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58012. */
  58013. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58014. /**
  58015. * Gets the texture used for the alpha test.
  58016. */
  58017. getAlphaTestTexture(): Nullable<BaseTexture>;
  58018. /**
  58019. * Specifies that the submesh is ready to be used.
  58020. * @param mesh - BJS mesh.
  58021. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58022. * @param useInstances - Specifies that instances should be used.
  58023. * @returns - boolean indicating that the submesh is ready or not.
  58024. */
  58025. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58026. /**
  58027. * Specifies if the material uses metallic roughness workflow.
  58028. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58029. */
  58030. isMetallicWorkflow(): boolean;
  58031. private _prepareEffect;
  58032. private _prepareDefines;
  58033. /**
  58034. * Force shader compilation
  58035. */
  58036. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58037. /**
  58038. * Initializes the uniform buffer layout for the shader.
  58039. */
  58040. buildUniformLayout(): void;
  58041. /**
  58042. * Unbinds the material from the mesh
  58043. */
  58044. unbind(): void;
  58045. /**
  58046. * Binds the submesh data.
  58047. * @param world - The world matrix.
  58048. * @param mesh - The BJS mesh.
  58049. * @param subMesh - A submesh of the BJS mesh.
  58050. */
  58051. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58052. /**
  58053. * Returns the animatable textures.
  58054. * @returns - Array of animatable textures.
  58055. */
  58056. getAnimatables(): IAnimatable[];
  58057. /**
  58058. * Returns the texture used for reflections.
  58059. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58060. */
  58061. private _getReflectionTexture;
  58062. /**
  58063. * Returns an array of the actively used textures.
  58064. * @returns - Array of BaseTextures
  58065. */
  58066. getActiveTextures(): BaseTexture[];
  58067. /**
  58068. * Checks to see if a texture is used in the material.
  58069. * @param texture - Base texture to use.
  58070. * @returns - Boolean specifying if a texture is used in the material.
  58071. */
  58072. hasTexture(texture: BaseTexture): boolean;
  58073. /**
  58074. * Disposes the resources of the material.
  58075. * @param forceDisposeEffect - Forces the disposal of effects.
  58076. * @param forceDisposeTextures - Forces the disposal of all textures.
  58077. */
  58078. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58079. }
  58080. }
  58081. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58082. import { Nullable } from "babylonjs/types";
  58083. import { Scene } from "babylonjs/scene";
  58084. import { Color3 } from "babylonjs/Maths/math.color";
  58085. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58086. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58087. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58088. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58089. /**
  58090. * The Physically based material of BJS.
  58091. *
  58092. * This offers the main features of a standard PBR material.
  58093. * For more information, please refer to the documentation :
  58094. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58095. */
  58096. export class PBRMaterial extends PBRBaseMaterial {
  58097. /**
  58098. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58099. */
  58100. static readonly PBRMATERIAL_OPAQUE: number;
  58101. /**
  58102. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58103. */
  58104. static readonly PBRMATERIAL_ALPHATEST: number;
  58105. /**
  58106. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58107. */
  58108. static readonly PBRMATERIAL_ALPHABLEND: number;
  58109. /**
  58110. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58111. * They are also discarded below the alpha cutoff threshold to improve performances.
  58112. */
  58113. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58114. /**
  58115. * Defines the default value of how much AO map is occluding the analytical lights
  58116. * (point spot...).
  58117. */
  58118. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58119. /**
  58120. * Intensity of the direct lights e.g. the four lights available in your scene.
  58121. * This impacts both the direct diffuse and specular highlights.
  58122. */
  58123. directIntensity: number;
  58124. /**
  58125. * Intensity of the emissive part of the material.
  58126. * This helps controlling the emissive effect without modifying the emissive color.
  58127. */
  58128. emissiveIntensity: number;
  58129. /**
  58130. * Intensity of the environment e.g. how much the environment will light the object
  58131. * either through harmonics for rough material or through the refelction for shiny ones.
  58132. */
  58133. environmentIntensity: number;
  58134. /**
  58135. * This is a special control allowing the reduction of the specular highlights coming from the
  58136. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58137. */
  58138. specularIntensity: number;
  58139. /**
  58140. * Debug Control allowing disabling the bump map on this material.
  58141. */
  58142. disableBumpMap: boolean;
  58143. /**
  58144. * AKA Diffuse Texture in standard nomenclature.
  58145. */
  58146. albedoTexture: BaseTexture;
  58147. /**
  58148. * AKA Occlusion Texture in other nomenclature.
  58149. */
  58150. ambientTexture: BaseTexture;
  58151. /**
  58152. * AKA Occlusion Texture Intensity in other nomenclature.
  58153. */
  58154. ambientTextureStrength: number;
  58155. /**
  58156. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58157. * 1 means it completely occludes it
  58158. * 0 mean it has no impact
  58159. */
  58160. ambientTextureImpactOnAnalyticalLights: number;
  58161. /**
  58162. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58163. */
  58164. opacityTexture: BaseTexture;
  58165. /**
  58166. * Stores the reflection values in a texture.
  58167. */
  58168. reflectionTexture: Nullable<BaseTexture>;
  58169. /**
  58170. * Stores the emissive values in a texture.
  58171. */
  58172. emissiveTexture: BaseTexture;
  58173. /**
  58174. * AKA Specular texture in other nomenclature.
  58175. */
  58176. reflectivityTexture: BaseTexture;
  58177. /**
  58178. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58179. */
  58180. metallicTexture: BaseTexture;
  58181. /**
  58182. * Specifies the metallic scalar of the metallic/roughness workflow.
  58183. * Can also be used to scale the metalness values of the metallic texture.
  58184. */
  58185. metallic: Nullable<number>;
  58186. /**
  58187. * Specifies the roughness scalar of the metallic/roughness workflow.
  58188. * Can also be used to scale the roughness values of the metallic texture.
  58189. */
  58190. roughness: Nullable<number>;
  58191. /**
  58192. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58193. * By default the indexOfrefraction is used to compute F0;
  58194. *
  58195. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58196. *
  58197. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58198. * F90 = metallicReflectanceColor;
  58199. */
  58200. metallicF0Factor: number;
  58201. /**
  58202. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58203. * By default the F90 is always 1;
  58204. *
  58205. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58206. *
  58207. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58208. * F90 = metallicReflectanceColor;
  58209. */
  58210. metallicReflectanceColor: Color3;
  58211. /**
  58212. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58213. * This is multiply against the scalar values defined in the material.
  58214. */
  58215. metallicReflectanceTexture: Nullable<BaseTexture>;
  58216. /**
  58217. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58218. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58219. */
  58220. microSurfaceTexture: BaseTexture;
  58221. /**
  58222. * Stores surface normal data used to displace a mesh in a texture.
  58223. */
  58224. bumpTexture: BaseTexture;
  58225. /**
  58226. * Stores the pre-calculated light information of a mesh in a texture.
  58227. */
  58228. lightmapTexture: BaseTexture;
  58229. /**
  58230. * Stores the refracted light information in a texture.
  58231. */
  58232. get refractionTexture(): Nullable<BaseTexture>;
  58233. set refractionTexture(value: Nullable<BaseTexture>);
  58234. /**
  58235. * The color of a material in ambient lighting.
  58236. */
  58237. ambientColor: Color3;
  58238. /**
  58239. * AKA Diffuse Color in other nomenclature.
  58240. */
  58241. albedoColor: Color3;
  58242. /**
  58243. * AKA Specular Color in other nomenclature.
  58244. */
  58245. reflectivityColor: Color3;
  58246. /**
  58247. * The color reflected from the material.
  58248. */
  58249. reflectionColor: Color3;
  58250. /**
  58251. * The color emitted from the material.
  58252. */
  58253. emissiveColor: Color3;
  58254. /**
  58255. * AKA Glossiness in other nomenclature.
  58256. */
  58257. microSurface: number;
  58258. /**
  58259. * Index of refraction of the material base layer.
  58260. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58261. *
  58262. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58263. *
  58264. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58265. */
  58266. get indexOfRefraction(): number;
  58267. set indexOfRefraction(value: number);
  58268. /**
  58269. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58270. */
  58271. get invertRefractionY(): boolean;
  58272. set invertRefractionY(value: boolean);
  58273. /**
  58274. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58275. * Materials half opaque for instance using refraction could benefit from this control.
  58276. */
  58277. get linkRefractionWithTransparency(): boolean;
  58278. set linkRefractionWithTransparency(value: boolean);
  58279. /**
  58280. * If true, the light map contains occlusion information instead of lighting info.
  58281. */
  58282. useLightmapAsShadowmap: boolean;
  58283. /**
  58284. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58285. */
  58286. useAlphaFromAlbedoTexture: boolean;
  58287. /**
  58288. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58289. */
  58290. forceAlphaTest: boolean;
  58291. /**
  58292. * Defines the alpha limits in alpha test mode.
  58293. */
  58294. alphaCutOff: number;
  58295. /**
  58296. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58297. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58298. */
  58299. useSpecularOverAlpha: boolean;
  58300. /**
  58301. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58302. */
  58303. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58304. /**
  58305. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58306. */
  58307. useRoughnessFromMetallicTextureAlpha: boolean;
  58308. /**
  58309. * Specifies if the metallic texture contains the roughness information in its green channel.
  58310. */
  58311. useRoughnessFromMetallicTextureGreen: boolean;
  58312. /**
  58313. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58314. */
  58315. useMetallnessFromMetallicTextureBlue: boolean;
  58316. /**
  58317. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58318. */
  58319. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58320. /**
  58321. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58322. */
  58323. useAmbientInGrayScale: boolean;
  58324. /**
  58325. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58326. * The material will try to infer what glossiness each pixel should be.
  58327. */
  58328. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58329. /**
  58330. * BJS is using an harcoded light falloff based on a manually sets up range.
  58331. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58332. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58333. */
  58334. get usePhysicalLightFalloff(): boolean;
  58335. /**
  58336. * BJS is using an harcoded light falloff based on a manually sets up range.
  58337. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58338. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58339. */
  58340. set usePhysicalLightFalloff(value: boolean);
  58341. /**
  58342. * In order to support the falloff compatibility with gltf, a special mode has been added
  58343. * to reproduce the gltf light falloff.
  58344. */
  58345. get useGLTFLightFalloff(): boolean;
  58346. /**
  58347. * In order to support the falloff compatibility with gltf, a special mode has been added
  58348. * to reproduce the gltf light falloff.
  58349. */
  58350. set useGLTFLightFalloff(value: boolean);
  58351. /**
  58352. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58353. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58354. */
  58355. useRadianceOverAlpha: boolean;
  58356. /**
  58357. * Allows using an object space normal map (instead of tangent space).
  58358. */
  58359. useObjectSpaceNormalMap: boolean;
  58360. /**
  58361. * Allows using the bump map in parallax mode.
  58362. */
  58363. useParallax: boolean;
  58364. /**
  58365. * Allows using the bump map in parallax occlusion mode.
  58366. */
  58367. useParallaxOcclusion: boolean;
  58368. /**
  58369. * Controls the scale bias of the parallax mode.
  58370. */
  58371. parallaxScaleBias: number;
  58372. /**
  58373. * If sets to true, disables all the lights affecting the material.
  58374. */
  58375. disableLighting: boolean;
  58376. /**
  58377. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58378. */
  58379. forceIrradianceInFragment: boolean;
  58380. /**
  58381. * Number of Simultaneous lights allowed on the material.
  58382. */
  58383. maxSimultaneousLights: number;
  58384. /**
  58385. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58386. */
  58387. invertNormalMapX: boolean;
  58388. /**
  58389. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58390. */
  58391. invertNormalMapY: boolean;
  58392. /**
  58393. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58394. */
  58395. twoSidedLighting: boolean;
  58396. /**
  58397. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58398. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58399. */
  58400. useAlphaFresnel: boolean;
  58401. /**
  58402. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58403. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58404. */
  58405. useLinearAlphaFresnel: boolean;
  58406. /**
  58407. * Let user defines the brdf lookup texture used for IBL.
  58408. * A default 8bit version is embedded but you could point at :
  58409. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58410. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58411. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58412. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58413. */
  58414. environmentBRDFTexture: Nullable<BaseTexture>;
  58415. /**
  58416. * Force normal to face away from face.
  58417. */
  58418. forceNormalForward: boolean;
  58419. /**
  58420. * Enables specular anti aliasing in the PBR shader.
  58421. * It will both interacts on the Geometry for analytical and IBL lighting.
  58422. * It also prefilter the roughness map based on the bump values.
  58423. */
  58424. enableSpecularAntiAliasing: boolean;
  58425. /**
  58426. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58427. * makes the reflect vector face the model (under horizon).
  58428. */
  58429. useHorizonOcclusion: boolean;
  58430. /**
  58431. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58432. * too much the area relying on ambient texture to define their ambient occlusion.
  58433. */
  58434. useRadianceOcclusion: boolean;
  58435. /**
  58436. * If set to true, no lighting calculations will be applied.
  58437. */
  58438. unlit: boolean;
  58439. /**
  58440. * Gets the image processing configuration used either in this material.
  58441. */
  58442. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58443. /**
  58444. * Sets the Default image processing configuration used either in the this material.
  58445. *
  58446. * If sets to null, the scene one is in use.
  58447. */
  58448. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58449. /**
  58450. * Gets wether the color curves effect is enabled.
  58451. */
  58452. get cameraColorCurvesEnabled(): boolean;
  58453. /**
  58454. * Sets wether the color curves effect is enabled.
  58455. */
  58456. set cameraColorCurvesEnabled(value: boolean);
  58457. /**
  58458. * Gets wether the color grading effect is enabled.
  58459. */
  58460. get cameraColorGradingEnabled(): boolean;
  58461. /**
  58462. * Gets wether the color grading effect is enabled.
  58463. */
  58464. set cameraColorGradingEnabled(value: boolean);
  58465. /**
  58466. * Gets wether tonemapping is enabled or not.
  58467. */
  58468. get cameraToneMappingEnabled(): boolean;
  58469. /**
  58470. * Sets wether tonemapping is enabled or not
  58471. */
  58472. set cameraToneMappingEnabled(value: boolean);
  58473. /**
  58474. * The camera exposure used on this material.
  58475. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58476. * This corresponds to a photographic exposure.
  58477. */
  58478. get cameraExposure(): number;
  58479. /**
  58480. * The camera exposure used on this material.
  58481. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58482. * This corresponds to a photographic exposure.
  58483. */
  58484. set cameraExposure(value: number);
  58485. /**
  58486. * Gets The camera contrast used on this material.
  58487. */
  58488. get cameraContrast(): number;
  58489. /**
  58490. * Sets The camera contrast used on this material.
  58491. */
  58492. set cameraContrast(value: number);
  58493. /**
  58494. * Gets the Color Grading 2D Lookup Texture.
  58495. */
  58496. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58497. /**
  58498. * Sets the Color Grading 2D Lookup Texture.
  58499. */
  58500. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58501. /**
  58502. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58503. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58504. * 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;
  58505. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58506. */
  58507. get cameraColorCurves(): Nullable<ColorCurves>;
  58508. /**
  58509. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58510. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58511. * 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;
  58512. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58513. */
  58514. set cameraColorCurves(value: Nullable<ColorCurves>);
  58515. /**
  58516. * Instantiates a new PBRMaterial instance.
  58517. *
  58518. * @param name The material name
  58519. * @param scene The scene the material will be use in.
  58520. */
  58521. constructor(name: string, scene: Scene);
  58522. /**
  58523. * Returns the name of this material class.
  58524. */
  58525. getClassName(): string;
  58526. /**
  58527. * Makes a duplicate of the current material.
  58528. * @param name - name to use for the new material.
  58529. */
  58530. clone(name: string): PBRMaterial;
  58531. /**
  58532. * Serializes this PBR Material.
  58533. * @returns - An object with the serialized material.
  58534. */
  58535. serialize(): any;
  58536. /**
  58537. * Parses a PBR Material from a serialized object.
  58538. * @param source - Serialized object.
  58539. * @param scene - BJS scene instance.
  58540. * @param rootUrl - url for the scene object
  58541. * @returns - PBRMaterial
  58542. */
  58543. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58544. }
  58545. }
  58546. declare module "babylonjs/Misc/dds" {
  58547. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58548. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58549. import { Nullable } from "babylonjs/types";
  58550. import { Scene } from "babylonjs/scene";
  58551. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58552. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58553. /**
  58554. * Direct draw surface info
  58555. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58556. */
  58557. export interface DDSInfo {
  58558. /**
  58559. * Width of the texture
  58560. */
  58561. width: number;
  58562. /**
  58563. * Width of the texture
  58564. */
  58565. height: number;
  58566. /**
  58567. * Number of Mipmaps for the texture
  58568. * @see https://en.wikipedia.org/wiki/Mipmap
  58569. */
  58570. mipmapCount: number;
  58571. /**
  58572. * If the textures format is a known fourCC format
  58573. * @see https://www.fourcc.org/
  58574. */
  58575. isFourCC: boolean;
  58576. /**
  58577. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58578. */
  58579. isRGB: boolean;
  58580. /**
  58581. * If the texture is a lumincance format
  58582. */
  58583. isLuminance: boolean;
  58584. /**
  58585. * If this is a cube texture
  58586. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58587. */
  58588. isCube: boolean;
  58589. /**
  58590. * If the texture is a compressed format eg. FOURCC_DXT1
  58591. */
  58592. isCompressed: boolean;
  58593. /**
  58594. * The dxgiFormat of the texture
  58595. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58596. */
  58597. dxgiFormat: number;
  58598. /**
  58599. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58600. */
  58601. textureType: number;
  58602. /**
  58603. * Sphericle polynomial created for the dds texture
  58604. */
  58605. sphericalPolynomial?: SphericalPolynomial;
  58606. }
  58607. /**
  58608. * Class used to provide DDS decompression tools
  58609. */
  58610. export class DDSTools {
  58611. /**
  58612. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58613. */
  58614. static StoreLODInAlphaChannel: boolean;
  58615. /**
  58616. * Gets DDS information from an array buffer
  58617. * @param data defines the array buffer view to read data from
  58618. * @returns the DDS information
  58619. */
  58620. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58621. private static _FloatView;
  58622. private static _Int32View;
  58623. private static _ToHalfFloat;
  58624. private static _FromHalfFloat;
  58625. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58626. private static _GetHalfFloatRGBAArrayBuffer;
  58627. private static _GetFloatRGBAArrayBuffer;
  58628. private static _GetFloatAsUIntRGBAArrayBuffer;
  58629. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58630. private static _GetRGBAArrayBuffer;
  58631. private static _ExtractLongWordOrder;
  58632. private static _GetRGBArrayBuffer;
  58633. private static _GetLuminanceArrayBuffer;
  58634. /**
  58635. * Uploads DDS Levels to a Babylon Texture
  58636. * @hidden
  58637. */
  58638. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58639. }
  58640. module "babylonjs/Engines/thinEngine" {
  58641. interface ThinEngine {
  58642. /**
  58643. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58644. * @param rootUrl defines the url where the file to load is located
  58645. * @param scene defines the current scene
  58646. * @param lodScale defines scale to apply to the mip map selection
  58647. * @param lodOffset defines offset to apply to the mip map selection
  58648. * @param onLoad defines an optional callback raised when the texture is loaded
  58649. * @param onError defines an optional callback raised if there is an issue to load the texture
  58650. * @param format defines the format of the data
  58651. * @param forcedExtension defines the extension to use to pick the right loader
  58652. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58653. * @returns the cube texture as an InternalTexture
  58654. */
  58655. 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;
  58656. }
  58657. }
  58658. }
  58659. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58660. import { Nullable } from "babylonjs/types";
  58661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58662. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58663. /**
  58664. * Implementation of the DDS Texture Loader.
  58665. * @hidden
  58666. */
  58667. export class _DDSTextureLoader implements IInternalTextureLoader {
  58668. /**
  58669. * Defines wether the loader supports cascade loading the different faces.
  58670. */
  58671. readonly supportCascades: boolean;
  58672. /**
  58673. * This returns if the loader support the current file information.
  58674. * @param extension defines the file extension of the file being loaded
  58675. * @returns true if the loader can load the specified file
  58676. */
  58677. canLoad(extension: string): boolean;
  58678. /**
  58679. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58680. * @param data contains the texture data
  58681. * @param texture defines the BabylonJS internal texture
  58682. * @param createPolynomials will be true if polynomials have been requested
  58683. * @param onLoad defines the callback to trigger once the texture is ready
  58684. * @param onError defines the callback to trigger in case of error
  58685. */
  58686. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58687. /**
  58688. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58689. * @param data contains the texture data
  58690. * @param texture defines the BabylonJS internal texture
  58691. * @param callback defines the method to call once ready to upload
  58692. */
  58693. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58694. }
  58695. }
  58696. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58697. import { Nullable } from "babylonjs/types";
  58698. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58699. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58700. /**
  58701. * Implementation of the ENV Texture Loader.
  58702. * @hidden
  58703. */
  58704. export class _ENVTextureLoader implements IInternalTextureLoader {
  58705. /**
  58706. * Defines wether the loader supports cascade loading the different faces.
  58707. */
  58708. readonly supportCascades: boolean;
  58709. /**
  58710. * This returns if the loader support the current file information.
  58711. * @param extension defines the file extension of the file being loaded
  58712. * @returns true if the loader can load the specified file
  58713. */
  58714. canLoad(extension: string): boolean;
  58715. /**
  58716. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58717. * @param data contains the texture data
  58718. * @param texture defines the BabylonJS internal texture
  58719. * @param createPolynomials will be true if polynomials have been requested
  58720. * @param onLoad defines the callback to trigger once the texture is ready
  58721. * @param onError defines the callback to trigger in case of error
  58722. */
  58723. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58724. /**
  58725. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58726. * @param data contains the texture data
  58727. * @param texture defines the BabylonJS internal texture
  58728. * @param callback defines the method to call once ready to upload
  58729. */
  58730. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58731. }
  58732. }
  58733. declare module "babylonjs/Misc/khronosTextureContainer" {
  58734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58735. /**
  58736. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58737. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58738. */
  58739. export class KhronosTextureContainer {
  58740. /** contents of the KTX container file */
  58741. data: ArrayBufferView;
  58742. private static HEADER_LEN;
  58743. private static COMPRESSED_2D;
  58744. private static COMPRESSED_3D;
  58745. private static TEX_2D;
  58746. private static TEX_3D;
  58747. /**
  58748. * Gets the openGL type
  58749. */
  58750. glType: number;
  58751. /**
  58752. * Gets the openGL type size
  58753. */
  58754. glTypeSize: number;
  58755. /**
  58756. * Gets the openGL format
  58757. */
  58758. glFormat: number;
  58759. /**
  58760. * Gets the openGL internal format
  58761. */
  58762. glInternalFormat: number;
  58763. /**
  58764. * Gets the base internal format
  58765. */
  58766. glBaseInternalFormat: number;
  58767. /**
  58768. * Gets image width in pixel
  58769. */
  58770. pixelWidth: number;
  58771. /**
  58772. * Gets image height in pixel
  58773. */
  58774. pixelHeight: number;
  58775. /**
  58776. * Gets image depth in pixels
  58777. */
  58778. pixelDepth: number;
  58779. /**
  58780. * Gets the number of array elements
  58781. */
  58782. numberOfArrayElements: number;
  58783. /**
  58784. * Gets the number of faces
  58785. */
  58786. numberOfFaces: number;
  58787. /**
  58788. * Gets the number of mipmap levels
  58789. */
  58790. numberOfMipmapLevels: number;
  58791. /**
  58792. * Gets the bytes of key value data
  58793. */
  58794. bytesOfKeyValueData: number;
  58795. /**
  58796. * Gets the load type
  58797. */
  58798. loadType: number;
  58799. /**
  58800. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58801. */
  58802. isInvalid: boolean;
  58803. /**
  58804. * Creates a new KhronosTextureContainer
  58805. * @param data contents of the KTX container file
  58806. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58807. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58808. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58809. */
  58810. constructor(
  58811. /** contents of the KTX container file */
  58812. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58813. /**
  58814. * Uploads KTX content to a Babylon Texture.
  58815. * It is assumed that the texture has already been created & is currently bound
  58816. * @hidden
  58817. */
  58818. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58819. private _upload2DCompressedLevels;
  58820. /**
  58821. * Checks if the given data starts with a KTX file identifier.
  58822. * @param data the data to check
  58823. * @returns true if the data is a KTX file or false otherwise
  58824. */
  58825. static IsValid(data: ArrayBufferView): boolean;
  58826. }
  58827. }
  58828. declare module "babylonjs/Misc/khronosTextureContainer2" {
  58829. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58830. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58831. /**
  58832. * Class for loading KTX2 files
  58833. * !!! Experimental Extension Subject to Changes !!!
  58834. * @hidden
  58835. */
  58836. export class KhronosTextureContainer2 {
  58837. private static _ModulePromise;
  58838. private static _TranscodeFormat;
  58839. constructor(engine: ThinEngine);
  58840. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58841. private _determineTranscodeFormat;
  58842. /**
  58843. * Checks if the given data starts with a KTX2 file identifier.
  58844. * @param data the data to check
  58845. * @returns true if the data is a KTX2 file or false otherwise
  58846. */
  58847. static IsValid(data: ArrayBufferView): boolean;
  58848. }
  58849. }
  58850. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  58851. import { Nullable } from "babylonjs/types";
  58852. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58853. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58854. /**
  58855. * Implementation of the KTX Texture Loader.
  58856. * @hidden
  58857. */
  58858. export class _KTXTextureLoader implements IInternalTextureLoader {
  58859. /**
  58860. * Defines wether the loader supports cascade loading the different faces.
  58861. */
  58862. readonly supportCascades: boolean;
  58863. /**
  58864. * This returns if the loader support the current file information.
  58865. * @param extension defines the file extension of the file being loaded
  58866. * @returns true if the loader can load the specified file
  58867. */
  58868. canLoad(extension: string): boolean;
  58869. /**
  58870. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58871. * @param data contains the texture data
  58872. * @param texture defines the BabylonJS internal texture
  58873. * @param createPolynomials will be true if polynomials have been requested
  58874. * @param onLoad defines the callback to trigger once the texture is ready
  58875. * @param onError defines the callback to trigger in case of error
  58876. */
  58877. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58878. /**
  58879. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58880. * @param data contains the texture data
  58881. * @param texture defines the BabylonJS internal texture
  58882. * @param callback defines the method to call once ready to upload
  58883. */
  58884. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58885. }
  58886. }
  58887. declare module "babylonjs/Helpers/sceneHelpers" {
  58888. import { Nullable } from "babylonjs/types";
  58889. import { Mesh } from "babylonjs/Meshes/mesh";
  58890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58891. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  58892. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  58893. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58894. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58895. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58896. import "babylonjs/Meshes/Builders/boxBuilder";
  58897. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  58898. /** @hidden */
  58899. export var _forceSceneHelpersToBundle: boolean;
  58900. module "babylonjs/scene" {
  58901. interface Scene {
  58902. /**
  58903. * Creates a default light for the scene.
  58904. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58905. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58906. */
  58907. createDefaultLight(replace?: boolean): void;
  58908. /**
  58909. * Creates a default camera for the scene.
  58910. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58911. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58912. * @param replace has default false, when true replaces the active camera in the scene
  58913. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58914. */
  58915. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58916. /**
  58917. * Creates a default camera and a default light.
  58918. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58919. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58920. * @param replace has the default false, when true replaces the active camera/light in the scene
  58921. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58922. */
  58923. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58924. /**
  58925. * Creates a new sky box
  58926. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58927. * @param environmentTexture defines the texture to use as environment texture
  58928. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58929. * @param scale defines the overall scale of the skybox
  58930. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58931. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58932. * @returns a new mesh holding the sky box
  58933. */
  58934. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58935. /**
  58936. * Creates a new environment
  58937. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58938. * @param options defines the options you can use to configure the environment
  58939. * @returns the new EnvironmentHelper
  58940. */
  58941. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58942. /**
  58943. * Creates a new VREXperienceHelper
  58944. * @see http://doc.babylonjs.com/how_to/webvr_helper
  58945. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58946. * @returns a new VREXperienceHelper
  58947. */
  58948. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58949. /**
  58950. * Creates a new WebXRDefaultExperience
  58951. * @see http://doc.babylonjs.com/how_to/webxr
  58952. * @param options experience options
  58953. * @returns a promise for a new WebXRDefaultExperience
  58954. */
  58955. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58956. }
  58957. }
  58958. }
  58959. declare module "babylonjs/Helpers/videoDome" {
  58960. import { Scene } from "babylonjs/scene";
  58961. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58962. import { Mesh } from "babylonjs/Meshes/mesh";
  58963. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  58964. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  58965. import "babylonjs/Meshes/Builders/sphereBuilder";
  58966. /**
  58967. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58968. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58969. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58970. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58971. */
  58972. export class VideoDome extends TransformNode {
  58973. /**
  58974. * Define the video source as a Monoscopic panoramic 360 video.
  58975. */
  58976. static readonly MODE_MONOSCOPIC: number;
  58977. /**
  58978. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58979. */
  58980. static readonly MODE_TOPBOTTOM: number;
  58981. /**
  58982. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58983. */
  58984. static readonly MODE_SIDEBYSIDE: number;
  58985. private _halfDome;
  58986. private _useDirectMapping;
  58987. /**
  58988. * The video texture being displayed on the sphere
  58989. */
  58990. protected _videoTexture: VideoTexture;
  58991. /**
  58992. * Gets the video texture being displayed on the sphere
  58993. */
  58994. get videoTexture(): VideoTexture;
  58995. /**
  58996. * The skybox material
  58997. */
  58998. protected _material: BackgroundMaterial;
  58999. /**
  59000. * The surface used for the skybox
  59001. */
  59002. protected _mesh: Mesh;
  59003. /**
  59004. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59005. */
  59006. private _halfDomeMask;
  59007. /**
  59008. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59009. * Also see the options.resolution property.
  59010. */
  59011. get fovMultiplier(): number;
  59012. set fovMultiplier(value: number);
  59013. private _videoMode;
  59014. /**
  59015. * Gets or set the current video mode for the video. It can be:
  59016. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59017. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59018. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59019. */
  59020. get videoMode(): number;
  59021. set videoMode(value: number);
  59022. /**
  59023. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59024. *
  59025. */
  59026. get halfDome(): boolean;
  59027. /**
  59028. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59029. */
  59030. set halfDome(enabled: boolean);
  59031. /**
  59032. * Oberserver used in Stereoscopic VR Mode.
  59033. */
  59034. private _onBeforeCameraRenderObserver;
  59035. /**
  59036. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59037. * @param name Element's name, child elements will append suffixes for their own names.
  59038. * @param urlsOrVideo defines the url(s) or the video element to use
  59039. * @param options An object containing optional or exposed sub element properties
  59040. */
  59041. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59042. resolution?: number;
  59043. clickToPlay?: boolean;
  59044. autoPlay?: boolean;
  59045. loop?: boolean;
  59046. size?: number;
  59047. poster?: string;
  59048. faceForward?: boolean;
  59049. useDirectMapping?: boolean;
  59050. halfDomeMode?: boolean;
  59051. }, scene: Scene);
  59052. private _changeVideoMode;
  59053. /**
  59054. * Releases resources associated with this node.
  59055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59057. */
  59058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59059. }
  59060. }
  59061. declare module "babylonjs/Helpers/index" {
  59062. export * from "babylonjs/Helpers/environmentHelper";
  59063. export * from "babylonjs/Helpers/photoDome";
  59064. export * from "babylonjs/Helpers/sceneHelpers";
  59065. export * from "babylonjs/Helpers/videoDome";
  59066. }
  59067. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59068. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59069. import { IDisposable } from "babylonjs/scene";
  59070. import { Engine } from "babylonjs/Engines/engine";
  59071. /**
  59072. * This class can be used to get instrumentation data from a Babylon engine
  59073. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59074. */
  59075. export class EngineInstrumentation implements IDisposable {
  59076. /**
  59077. * Define the instrumented engine.
  59078. */
  59079. engine: Engine;
  59080. private _captureGPUFrameTime;
  59081. private _gpuFrameTimeToken;
  59082. private _gpuFrameTime;
  59083. private _captureShaderCompilationTime;
  59084. private _shaderCompilationTime;
  59085. private _onBeginFrameObserver;
  59086. private _onEndFrameObserver;
  59087. private _onBeforeShaderCompilationObserver;
  59088. private _onAfterShaderCompilationObserver;
  59089. /**
  59090. * Gets the perf counter used for GPU frame time
  59091. */
  59092. get gpuFrameTimeCounter(): PerfCounter;
  59093. /**
  59094. * Gets the GPU frame time capture status
  59095. */
  59096. get captureGPUFrameTime(): boolean;
  59097. /**
  59098. * Enable or disable the GPU frame time capture
  59099. */
  59100. set captureGPUFrameTime(value: boolean);
  59101. /**
  59102. * Gets the perf counter used for shader compilation time
  59103. */
  59104. get shaderCompilationTimeCounter(): PerfCounter;
  59105. /**
  59106. * Gets the shader compilation time capture status
  59107. */
  59108. get captureShaderCompilationTime(): boolean;
  59109. /**
  59110. * Enable or disable the shader compilation time capture
  59111. */
  59112. set captureShaderCompilationTime(value: boolean);
  59113. /**
  59114. * Instantiates a new engine instrumentation.
  59115. * This class can be used to get instrumentation data from a Babylon engine
  59116. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59117. * @param engine Defines the engine to instrument
  59118. */
  59119. constructor(
  59120. /**
  59121. * Define the instrumented engine.
  59122. */
  59123. engine: Engine);
  59124. /**
  59125. * Dispose and release associated resources.
  59126. */
  59127. dispose(): void;
  59128. }
  59129. }
  59130. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59131. import { Scene, IDisposable } from "babylonjs/scene";
  59132. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59133. /**
  59134. * This class can be used to get instrumentation data from a Babylon engine
  59135. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59136. */
  59137. export class SceneInstrumentation implements IDisposable {
  59138. /**
  59139. * Defines the scene to instrument
  59140. */
  59141. scene: Scene;
  59142. private _captureActiveMeshesEvaluationTime;
  59143. private _activeMeshesEvaluationTime;
  59144. private _captureRenderTargetsRenderTime;
  59145. private _renderTargetsRenderTime;
  59146. private _captureFrameTime;
  59147. private _frameTime;
  59148. private _captureRenderTime;
  59149. private _renderTime;
  59150. private _captureInterFrameTime;
  59151. private _interFrameTime;
  59152. private _captureParticlesRenderTime;
  59153. private _particlesRenderTime;
  59154. private _captureSpritesRenderTime;
  59155. private _spritesRenderTime;
  59156. private _capturePhysicsTime;
  59157. private _physicsTime;
  59158. private _captureAnimationsTime;
  59159. private _animationsTime;
  59160. private _captureCameraRenderTime;
  59161. private _cameraRenderTime;
  59162. private _onBeforeActiveMeshesEvaluationObserver;
  59163. private _onAfterActiveMeshesEvaluationObserver;
  59164. private _onBeforeRenderTargetsRenderObserver;
  59165. private _onAfterRenderTargetsRenderObserver;
  59166. private _onAfterRenderObserver;
  59167. private _onBeforeDrawPhaseObserver;
  59168. private _onAfterDrawPhaseObserver;
  59169. private _onBeforeAnimationsObserver;
  59170. private _onBeforeParticlesRenderingObserver;
  59171. private _onAfterParticlesRenderingObserver;
  59172. private _onBeforeSpritesRenderingObserver;
  59173. private _onAfterSpritesRenderingObserver;
  59174. private _onBeforePhysicsObserver;
  59175. private _onAfterPhysicsObserver;
  59176. private _onAfterAnimationsObserver;
  59177. private _onBeforeCameraRenderObserver;
  59178. private _onAfterCameraRenderObserver;
  59179. /**
  59180. * Gets the perf counter used for active meshes evaluation time
  59181. */
  59182. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59183. /**
  59184. * Gets the active meshes evaluation time capture status
  59185. */
  59186. get captureActiveMeshesEvaluationTime(): boolean;
  59187. /**
  59188. * Enable or disable the active meshes evaluation time capture
  59189. */
  59190. set captureActiveMeshesEvaluationTime(value: boolean);
  59191. /**
  59192. * Gets the perf counter used for render targets render time
  59193. */
  59194. get renderTargetsRenderTimeCounter(): PerfCounter;
  59195. /**
  59196. * Gets the render targets render time capture status
  59197. */
  59198. get captureRenderTargetsRenderTime(): boolean;
  59199. /**
  59200. * Enable or disable the render targets render time capture
  59201. */
  59202. set captureRenderTargetsRenderTime(value: boolean);
  59203. /**
  59204. * Gets the perf counter used for particles render time
  59205. */
  59206. get particlesRenderTimeCounter(): PerfCounter;
  59207. /**
  59208. * Gets the particles render time capture status
  59209. */
  59210. get captureParticlesRenderTime(): boolean;
  59211. /**
  59212. * Enable or disable the particles render time capture
  59213. */
  59214. set captureParticlesRenderTime(value: boolean);
  59215. /**
  59216. * Gets the perf counter used for sprites render time
  59217. */
  59218. get spritesRenderTimeCounter(): PerfCounter;
  59219. /**
  59220. * Gets the sprites render time capture status
  59221. */
  59222. get captureSpritesRenderTime(): boolean;
  59223. /**
  59224. * Enable or disable the sprites render time capture
  59225. */
  59226. set captureSpritesRenderTime(value: boolean);
  59227. /**
  59228. * Gets the perf counter used for physics time
  59229. */
  59230. get physicsTimeCounter(): PerfCounter;
  59231. /**
  59232. * Gets the physics time capture status
  59233. */
  59234. get capturePhysicsTime(): boolean;
  59235. /**
  59236. * Enable or disable the physics time capture
  59237. */
  59238. set capturePhysicsTime(value: boolean);
  59239. /**
  59240. * Gets the perf counter used for animations time
  59241. */
  59242. get animationsTimeCounter(): PerfCounter;
  59243. /**
  59244. * Gets the animations time capture status
  59245. */
  59246. get captureAnimationsTime(): boolean;
  59247. /**
  59248. * Enable or disable the animations time capture
  59249. */
  59250. set captureAnimationsTime(value: boolean);
  59251. /**
  59252. * Gets the perf counter used for frame time capture
  59253. */
  59254. get frameTimeCounter(): PerfCounter;
  59255. /**
  59256. * Gets the frame time capture status
  59257. */
  59258. get captureFrameTime(): boolean;
  59259. /**
  59260. * Enable or disable the frame time capture
  59261. */
  59262. set captureFrameTime(value: boolean);
  59263. /**
  59264. * Gets the perf counter used for inter-frames time capture
  59265. */
  59266. get interFrameTimeCounter(): PerfCounter;
  59267. /**
  59268. * Gets the inter-frames time capture status
  59269. */
  59270. get captureInterFrameTime(): boolean;
  59271. /**
  59272. * Enable or disable the inter-frames time capture
  59273. */
  59274. set captureInterFrameTime(value: boolean);
  59275. /**
  59276. * Gets the perf counter used for render time capture
  59277. */
  59278. get renderTimeCounter(): PerfCounter;
  59279. /**
  59280. * Gets the render time capture status
  59281. */
  59282. get captureRenderTime(): boolean;
  59283. /**
  59284. * Enable or disable the render time capture
  59285. */
  59286. set captureRenderTime(value: boolean);
  59287. /**
  59288. * Gets the perf counter used for camera render time capture
  59289. */
  59290. get cameraRenderTimeCounter(): PerfCounter;
  59291. /**
  59292. * Gets the camera render time capture status
  59293. */
  59294. get captureCameraRenderTime(): boolean;
  59295. /**
  59296. * Enable or disable the camera render time capture
  59297. */
  59298. set captureCameraRenderTime(value: boolean);
  59299. /**
  59300. * Gets the perf counter used for draw calls
  59301. */
  59302. get drawCallsCounter(): PerfCounter;
  59303. /**
  59304. * Instantiates a new scene instrumentation.
  59305. * This class can be used to get instrumentation data from a Babylon engine
  59306. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59307. * @param scene Defines the scene to instrument
  59308. */
  59309. constructor(
  59310. /**
  59311. * Defines the scene to instrument
  59312. */
  59313. scene: Scene);
  59314. /**
  59315. * Dispose and release associated resources.
  59316. */
  59317. dispose(): void;
  59318. }
  59319. }
  59320. declare module "babylonjs/Instrumentation/index" {
  59321. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59322. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59323. export * from "babylonjs/Instrumentation/timeToken";
  59324. }
  59325. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59326. /** @hidden */
  59327. export var glowMapGenerationPixelShader: {
  59328. name: string;
  59329. shader: string;
  59330. };
  59331. }
  59332. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59333. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59334. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59335. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59336. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59337. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59338. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59339. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59340. /** @hidden */
  59341. export var glowMapGenerationVertexShader: {
  59342. name: string;
  59343. shader: string;
  59344. };
  59345. }
  59346. declare module "babylonjs/Layers/effectLayer" {
  59347. import { Observable } from "babylonjs/Misc/observable";
  59348. import { Nullable } from "babylonjs/types";
  59349. import { Camera } from "babylonjs/Cameras/camera";
  59350. import { Scene } from "babylonjs/scene";
  59351. import { ISize } from "babylonjs/Maths/math.size";
  59352. import { Color4 } from "babylonjs/Maths/math.color";
  59353. import { Engine } from "babylonjs/Engines/engine";
  59354. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59356. import { Mesh } from "babylonjs/Meshes/mesh";
  59357. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59359. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59360. import { Effect } from "babylonjs/Materials/effect";
  59361. import { Material } from "babylonjs/Materials/material";
  59362. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59363. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59364. /**
  59365. * Effect layer options. This helps customizing the behaviour
  59366. * of the effect layer.
  59367. */
  59368. export interface IEffectLayerOptions {
  59369. /**
  59370. * Multiplication factor apply to the canvas size to compute the render target size
  59371. * used to generated the objects (the smaller the faster).
  59372. */
  59373. mainTextureRatio: number;
  59374. /**
  59375. * Enforces a fixed size texture to ensure effect stability across devices.
  59376. */
  59377. mainTextureFixedSize?: number;
  59378. /**
  59379. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59380. */
  59381. alphaBlendingMode: number;
  59382. /**
  59383. * The camera attached to the layer.
  59384. */
  59385. camera: Nullable<Camera>;
  59386. /**
  59387. * The rendering group to draw the layer in.
  59388. */
  59389. renderingGroupId: number;
  59390. }
  59391. /**
  59392. * The effect layer Helps adding post process effect blended with the main pass.
  59393. *
  59394. * This can be for instance use to generate glow or higlight effects on the scene.
  59395. *
  59396. * The effect layer class can not be used directly and is intented to inherited from to be
  59397. * customized per effects.
  59398. */
  59399. export abstract class EffectLayer {
  59400. private _vertexBuffers;
  59401. private _indexBuffer;
  59402. private _cachedDefines;
  59403. private _effectLayerMapGenerationEffect;
  59404. private _effectLayerOptions;
  59405. private _mergeEffect;
  59406. protected _scene: Scene;
  59407. protected _engine: Engine;
  59408. protected _maxSize: number;
  59409. protected _mainTextureDesiredSize: ISize;
  59410. protected _mainTexture: RenderTargetTexture;
  59411. protected _shouldRender: boolean;
  59412. protected _postProcesses: PostProcess[];
  59413. protected _textures: BaseTexture[];
  59414. protected _emissiveTextureAndColor: {
  59415. texture: Nullable<BaseTexture>;
  59416. color: Color4;
  59417. };
  59418. /**
  59419. * The name of the layer
  59420. */
  59421. name: string;
  59422. /**
  59423. * The clear color of the texture used to generate the glow map.
  59424. */
  59425. neutralColor: Color4;
  59426. /**
  59427. * Specifies whether the highlight layer is enabled or not.
  59428. */
  59429. isEnabled: boolean;
  59430. /**
  59431. * Gets the camera attached to the layer.
  59432. */
  59433. get camera(): Nullable<Camera>;
  59434. /**
  59435. * Gets the rendering group id the layer should render in.
  59436. */
  59437. get renderingGroupId(): number;
  59438. set renderingGroupId(renderingGroupId: number);
  59439. /**
  59440. * An event triggered when the effect layer has been disposed.
  59441. */
  59442. onDisposeObservable: Observable<EffectLayer>;
  59443. /**
  59444. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59445. */
  59446. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59447. /**
  59448. * An event triggered when the generated texture is being merged in the scene.
  59449. */
  59450. onBeforeComposeObservable: Observable<EffectLayer>;
  59451. /**
  59452. * An event triggered when the mesh is rendered into the effect render target.
  59453. */
  59454. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59455. /**
  59456. * An event triggered after the mesh has been rendered into the effect render target.
  59457. */
  59458. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59459. /**
  59460. * An event triggered when the generated texture has been merged in the scene.
  59461. */
  59462. onAfterComposeObservable: Observable<EffectLayer>;
  59463. /**
  59464. * An event triggered when the efffect layer changes its size.
  59465. */
  59466. onSizeChangedObservable: Observable<EffectLayer>;
  59467. /** @hidden */
  59468. static _SceneComponentInitialization: (scene: Scene) => void;
  59469. /**
  59470. * Instantiates a new effect Layer and references it in the scene.
  59471. * @param name The name of the layer
  59472. * @param scene The scene to use the layer in
  59473. */
  59474. constructor(
  59475. /** The Friendly of the effect in the scene */
  59476. name: string, scene: Scene);
  59477. /**
  59478. * Get the effect name of the layer.
  59479. * @return The effect name
  59480. */
  59481. abstract getEffectName(): string;
  59482. /**
  59483. * Checks for the readiness of the element composing the layer.
  59484. * @param subMesh the mesh to check for
  59485. * @param useInstances specify whether or not to use instances to render the mesh
  59486. * @return true if ready otherwise, false
  59487. */
  59488. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59489. /**
  59490. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59491. * @returns true if the effect requires stencil during the main canvas render pass.
  59492. */
  59493. abstract needStencil(): boolean;
  59494. /**
  59495. * Create the merge effect. This is the shader use to blit the information back
  59496. * to the main canvas at the end of the scene rendering.
  59497. * @returns The effect containing the shader used to merge the effect on the main canvas
  59498. */
  59499. protected abstract _createMergeEffect(): Effect;
  59500. /**
  59501. * Creates the render target textures and post processes used in the effect layer.
  59502. */
  59503. protected abstract _createTextureAndPostProcesses(): void;
  59504. /**
  59505. * Implementation specific of rendering the generating effect on the main canvas.
  59506. * @param effect The effect used to render through
  59507. */
  59508. protected abstract _internalRender(effect: Effect): void;
  59509. /**
  59510. * Sets the required values for both the emissive texture and and the main color.
  59511. */
  59512. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59513. /**
  59514. * Free any resources and references associated to a mesh.
  59515. * Internal use
  59516. * @param mesh The mesh to free.
  59517. */
  59518. abstract _disposeMesh(mesh: Mesh): void;
  59519. /**
  59520. * Serializes this layer (Glow or Highlight for example)
  59521. * @returns a serialized layer object
  59522. */
  59523. abstract serialize?(): any;
  59524. /**
  59525. * Initializes the effect layer with the required options.
  59526. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59527. */
  59528. protected _init(options: Partial<IEffectLayerOptions>): void;
  59529. /**
  59530. * Generates the index buffer of the full screen quad blending to the main canvas.
  59531. */
  59532. private _generateIndexBuffer;
  59533. /**
  59534. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59535. */
  59536. private _generateVertexBuffer;
  59537. /**
  59538. * Sets the main texture desired size which is the closest power of two
  59539. * of the engine canvas size.
  59540. */
  59541. private _setMainTextureSize;
  59542. /**
  59543. * Creates the main texture for the effect layer.
  59544. */
  59545. protected _createMainTexture(): void;
  59546. /**
  59547. * Adds specific effects defines.
  59548. * @param defines The defines to add specifics to.
  59549. */
  59550. protected _addCustomEffectDefines(defines: string[]): void;
  59551. /**
  59552. * Checks for the readiness of the element composing the layer.
  59553. * @param subMesh the mesh to check for
  59554. * @param useInstances specify whether or not to use instances to render the mesh
  59555. * @param emissiveTexture the associated emissive texture used to generate the glow
  59556. * @return true if ready otherwise, false
  59557. */
  59558. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59559. /**
  59560. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59561. */
  59562. render(): void;
  59563. /**
  59564. * Determine if a given mesh will be used in the current effect.
  59565. * @param mesh mesh to test
  59566. * @returns true if the mesh will be used
  59567. */
  59568. hasMesh(mesh: AbstractMesh): boolean;
  59569. /**
  59570. * Returns true if the layer contains information to display, otherwise false.
  59571. * @returns true if the glow layer should be rendered
  59572. */
  59573. shouldRender(): boolean;
  59574. /**
  59575. * Returns true if the mesh should render, otherwise false.
  59576. * @param mesh The mesh to render
  59577. * @returns true if it should render otherwise false
  59578. */
  59579. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59580. /**
  59581. * Returns true if the mesh can be rendered, otherwise false.
  59582. * @param mesh The mesh to render
  59583. * @param material The material used on the mesh
  59584. * @returns true if it can be rendered otherwise false
  59585. */
  59586. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59587. /**
  59588. * Returns true if the mesh should render, otherwise false.
  59589. * @param mesh The mesh to render
  59590. * @returns true if it should render otherwise false
  59591. */
  59592. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59593. /**
  59594. * Renders the submesh passed in parameter to the generation map.
  59595. */
  59596. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59597. /**
  59598. * Defines whether the current material of the mesh should be use to render the effect.
  59599. * @param mesh defines the current mesh to render
  59600. */
  59601. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59602. /**
  59603. * Rebuild the required buffers.
  59604. * @hidden Internal use only.
  59605. */
  59606. _rebuild(): void;
  59607. /**
  59608. * Dispose only the render target textures and post process.
  59609. */
  59610. private _disposeTextureAndPostProcesses;
  59611. /**
  59612. * Dispose the highlight layer and free resources.
  59613. */
  59614. dispose(): void;
  59615. /**
  59616. * Gets the class name of the effect layer
  59617. * @returns the string with the class name of the effect layer
  59618. */
  59619. getClassName(): string;
  59620. /**
  59621. * Creates an effect layer from parsed effect layer data
  59622. * @param parsedEffectLayer defines effect layer data
  59623. * @param scene defines the current scene
  59624. * @param rootUrl defines the root URL containing the effect layer information
  59625. * @returns a parsed effect Layer
  59626. */
  59627. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59628. }
  59629. }
  59630. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59631. import { Scene } from "babylonjs/scene";
  59632. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59633. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59634. import { AbstractScene } from "babylonjs/abstractScene";
  59635. module "babylonjs/abstractScene" {
  59636. interface AbstractScene {
  59637. /**
  59638. * The list of effect layers (highlights/glow) added to the scene
  59639. * @see http://doc.babylonjs.com/how_to/highlight_layer
  59640. * @see http://doc.babylonjs.com/how_to/glow_layer
  59641. */
  59642. effectLayers: Array<EffectLayer>;
  59643. /**
  59644. * Removes the given effect layer from this scene.
  59645. * @param toRemove defines the effect layer to remove
  59646. * @returns the index of the removed effect layer
  59647. */
  59648. removeEffectLayer(toRemove: EffectLayer): number;
  59649. /**
  59650. * Adds the given effect layer to this scene
  59651. * @param newEffectLayer defines the effect layer to add
  59652. */
  59653. addEffectLayer(newEffectLayer: EffectLayer): void;
  59654. }
  59655. }
  59656. /**
  59657. * Defines the layer scene component responsible to manage any effect layers
  59658. * in a given scene.
  59659. */
  59660. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59661. /**
  59662. * The component name helpfull to identify the component in the list of scene components.
  59663. */
  59664. readonly name: string;
  59665. /**
  59666. * The scene the component belongs to.
  59667. */
  59668. scene: Scene;
  59669. private _engine;
  59670. private _renderEffects;
  59671. private _needStencil;
  59672. private _previousStencilState;
  59673. /**
  59674. * Creates a new instance of the component for the given scene
  59675. * @param scene Defines the scene to register the component in
  59676. */
  59677. constructor(scene: Scene);
  59678. /**
  59679. * Registers the component in a given scene
  59680. */
  59681. register(): void;
  59682. /**
  59683. * Rebuilds the elements related to this component in case of
  59684. * context lost for instance.
  59685. */
  59686. rebuild(): void;
  59687. /**
  59688. * Serializes the component data to the specified json object
  59689. * @param serializationObject The object to serialize to
  59690. */
  59691. serialize(serializationObject: any): void;
  59692. /**
  59693. * Adds all the elements from the container to the scene
  59694. * @param container the container holding the elements
  59695. */
  59696. addFromContainer(container: AbstractScene): void;
  59697. /**
  59698. * Removes all the elements in the container from the scene
  59699. * @param container contains the elements to remove
  59700. * @param dispose if the removed element should be disposed (default: false)
  59701. */
  59702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59703. /**
  59704. * Disposes the component and the associated ressources.
  59705. */
  59706. dispose(): void;
  59707. private _isReadyForMesh;
  59708. private _renderMainTexture;
  59709. private _setStencil;
  59710. private _setStencilBack;
  59711. private _draw;
  59712. private _drawCamera;
  59713. private _drawRenderingGroup;
  59714. }
  59715. }
  59716. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59717. /** @hidden */
  59718. export var glowMapMergePixelShader: {
  59719. name: string;
  59720. shader: string;
  59721. };
  59722. }
  59723. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  59724. /** @hidden */
  59725. export var glowMapMergeVertexShader: {
  59726. name: string;
  59727. shader: string;
  59728. };
  59729. }
  59730. declare module "babylonjs/Layers/glowLayer" {
  59731. import { Nullable } from "babylonjs/types";
  59732. import { Camera } from "babylonjs/Cameras/camera";
  59733. import { Scene } from "babylonjs/scene";
  59734. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59736. import { Mesh } from "babylonjs/Meshes/mesh";
  59737. import { Texture } from "babylonjs/Materials/Textures/texture";
  59738. import { Effect } from "babylonjs/Materials/effect";
  59739. import { Material } from "babylonjs/Materials/material";
  59740. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59741. import { Color4 } from "babylonjs/Maths/math.color";
  59742. import "babylonjs/Shaders/glowMapMerge.fragment";
  59743. import "babylonjs/Shaders/glowMapMerge.vertex";
  59744. import "babylonjs/Layers/effectLayerSceneComponent";
  59745. module "babylonjs/abstractScene" {
  59746. interface AbstractScene {
  59747. /**
  59748. * Return a the first highlight layer of the scene with a given name.
  59749. * @param name The name of the highlight layer to look for.
  59750. * @return The highlight layer if found otherwise null.
  59751. */
  59752. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59753. }
  59754. }
  59755. /**
  59756. * Glow layer options. This helps customizing the behaviour
  59757. * of the glow layer.
  59758. */
  59759. export interface IGlowLayerOptions {
  59760. /**
  59761. * Multiplication factor apply to the canvas size to compute the render target size
  59762. * used to generated the glowing objects (the smaller the faster).
  59763. */
  59764. mainTextureRatio: number;
  59765. /**
  59766. * Enforces a fixed size texture to ensure resize independant blur.
  59767. */
  59768. mainTextureFixedSize?: number;
  59769. /**
  59770. * How big is the kernel of the blur texture.
  59771. */
  59772. blurKernelSize: number;
  59773. /**
  59774. * The camera attached to the layer.
  59775. */
  59776. camera: Nullable<Camera>;
  59777. /**
  59778. * Enable MSAA by chosing the number of samples.
  59779. */
  59780. mainTextureSamples?: number;
  59781. /**
  59782. * The rendering group to draw the layer in.
  59783. */
  59784. renderingGroupId: number;
  59785. }
  59786. /**
  59787. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59788. *
  59789. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59790. *
  59791. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59792. */
  59793. export class GlowLayer extends EffectLayer {
  59794. /**
  59795. * Effect Name of the layer.
  59796. */
  59797. static readonly EffectName: string;
  59798. /**
  59799. * The default blur kernel size used for the glow.
  59800. */
  59801. static DefaultBlurKernelSize: number;
  59802. /**
  59803. * The default texture size ratio used for the glow.
  59804. */
  59805. static DefaultTextureRatio: number;
  59806. /**
  59807. * Sets the kernel size of the blur.
  59808. */
  59809. set blurKernelSize(value: number);
  59810. /**
  59811. * Gets the kernel size of the blur.
  59812. */
  59813. get blurKernelSize(): number;
  59814. /**
  59815. * Sets the glow intensity.
  59816. */
  59817. set intensity(value: number);
  59818. /**
  59819. * Gets the glow intensity.
  59820. */
  59821. get intensity(): number;
  59822. private _options;
  59823. private _intensity;
  59824. private _horizontalBlurPostprocess1;
  59825. private _verticalBlurPostprocess1;
  59826. private _horizontalBlurPostprocess2;
  59827. private _verticalBlurPostprocess2;
  59828. private _blurTexture1;
  59829. private _blurTexture2;
  59830. private _postProcesses1;
  59831. private _postProcesses2;
  59832. private _includedOnlyMeshes;
  59833. private _excludedMeshes;
  59834. private _meshesUsingTheirOwnMaterials;
  59835. /**
  59836. * Callback used to let the user override the color selection on a per mesh basis
  59837. */
  59838. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59839. /**
  59840. * Callback used to let the user override the texture selection on a per mesh basis
  59841. */
  59842. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59843. /**
  59844. * Instantiates a new glow Layer and references it to the scene.
  59845. * @param name The name of the layer
  59846. * @param scene The scene to use the layer in
  59847. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59848. */
  59849. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59850. /**
  59851. * Get the effect name of the layer.
  59852. * @return The effect name
  59853. */
  59854. getEffectName(): string;
  59855. /**
  59856. * Create the merge effect. This is the shader use to blit the information back
  59857. * to the main canvas at the end of the scene rendering.
  59858. */
  59859. protected _createMergeEffect(): Effect;
  59860. /**
  59861. * Creates the render target textures and post processes used in the glow layer.
  59862. */
  59863. protected _createTextureAndPostProcesses(): void;
  59864. /**
  59865. * Checks for the readiness of the element composing the layer.
  59866. * @param subMesh the mesh to check for
  59867. * @param useInstances specify wether or not to use instances to render the mesh
  59868. * @param emissiveTexture the associated emissive texture used to generate the glow
  59869. * @return true if ready otherwise, false
  59870. */
  59871. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59872. /**
  59873. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59874. */
  59875. needStencil(): boolean;
  59876. /**
  59877. * Returns true if the mesh can be rendered, otherwise false.
  59878. * @param mesh The mesh to render
  59879. * @param material The material used on the mesh
  59880. * @returns true if it can be rendered otherwise false
  59881. */
  59882. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59883. /**
  59884. * Implementation specific of rendering the generating effect on the main canvas.
  59885. * @param effect The effect used to render through
  59886. */
  59887. protected _internalRender(effect: Effect): void;
  59888. /**
  59889. * Sets the required values for both the emissive texture and and the main color.
  59890. */
  59891. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59892. /**
  59893. * Returns true if the mesh should render, otherwise false.
  59894. * @param mesh The mesh to render
  59895. * @returns true if it should render otherwise false
  59896. */
  59897. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59898. /**
  59899. * Adds specific effects defines.
  59900. * @param defines The defines to add specifics to.
  59901. */
  59902. protected _addCustomEffectDefines(defines: string[]): void;
  59903. /**
  59904. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59905. * @param mesh The mesh to exclude from the glow layer
  59906. */
  59907. addExcludedMesh(mesh: Mesh): void;
  59908. /**
  59909. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59910. * @param mesh The mesh to remove
  59911. */
  59912. removeExcludedMesh(mesh: Mesh): void;
  59913. /**
  59914. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59915. * @param mesh The mesh to include in the glow layer
  59916. */
  59917. addIncludedOnlyMesh(mesh: Mesh): void;
  59918. /**
  59919. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59920. * @param mesh The mesh to remove
  59921. */
  59922. removeIncludedOnlyMesh(mesh: Mesh): void;
  59923. /**
  59924. * Determine if a given mesh will be used in the glow layer
  59925. * @param mesh The mesh to test
  59926. * @returns true if the mesh will be highlighted by the current glow layer
  59927. */
  59928. hasMesh(mesh: AbstractMesh): boolean;
  59929. /**
  59930. * Defines whether the current material of the mesh should be use to render the effect.
  59931. * @param mesh defines the current mesh to render
  59932. */
  59933. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59934. /**
  59935. * Add a mesh to be rendered through its own material and not with emissive only.
  59936. * @param mesh The mesh for which we need to use its material
  59937. */
  59938. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59939. /**
  59940. * Remove a mesh from being rendered through its own material and not with emissive only.
  59941. * @param mesh The mesh for which we need to not use its material
  59942. */
  59943. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59944. /**
  59945. * Free any resources and references associated to a mesh.
  59946. * Internal use
  59947. * @param mesh The mesh to free.
  59948. * @hidden
  59949. */
  59950. _disposeMesh(mesh: Mesh): void;
  59951. /**
  59952. * Gets the class name of the effect layer
  59953. * @returns the string with the class name of the effect layer
  59954. */
  59955. getClassName(): string;
  59956. /**
  59957. * Serializes this glow layer
  59958. * @returns a serialized glow layer object
  59959. */
  59960. serialize(): any;
  59961. /**
  59962. * Creates a Glow Layer from parsed glow layer data
  59963. * @param parsedGlowLayer defines glow layer data
  59964. * @param scene defines the current scene
  59965. * @param rootUrl defines the root URL containing the glow layer information
  59966. * @returns a parsed Glow Layer
  59967. */
  59968. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59969. }
  59970. }
  59971. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  59972. /** @hidden */
  59973. export var glowBlurPostProcessPixelShader: {
  59974. name: string;
  59975. shader: string;
  59976. };
  59977. }
  59978. declare module "babylonjs/Layers/highlightLayer" {
  59979. import { Observable } from "babylonjs/Misc/observable";
  59980. import { Nullable } from "babylonjs/types";
  59981. import { Camera } from "babylonjs/Cameras/camera";
  59982. import { Scene } from "babylonjs/scene";
  59983. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59985. import { Mesh } from "babylonjs/Meshes/mesh";
  59986. import { Effect } from "babylonjs/Materials/effect";
  59987. import { Material } from "babylonjs/Materials/material";
  59988. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59989. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59990. import "babylonjs/Shaders/glowMapMerge.fragment";
  59991. import "babylonjs/Shaders/glowMapMerge.vertex";
  59992. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  59993. module "babylonjs/abstractScene" {
  59994. interface AbstractScene {
  59995. /**
  59996. * Return a the first highlight layer of the scene with a given name.
  59997. * @param name The name of the highlight layer to look for.
  59998. * @return The highlight layer if found otherwise null.
  59999. */
  60000. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60001. }
  60002. }
  60003. /**
  60004. * Highlight layer options. This helps customizing the behaviour
  60005. * of the highlight layer.
  60006. */
  60007. export interface IHighlightLayerOptions {
  60008. /**
  60009. * Multiplication factor apply to the canvas size to compute the render target size
  60010. * used to generated the glowing objects (the smaller the faster).
  60011. */
  60012. mainTextureRatio: number;
  60013. /**
  60014. * Enforces a fixed size texture to ensure resize independant blur.
  60015. */
  60016. mainTextureFixedSize?: number;
  60017. /**
  60018. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60019. * of the picture to blur (the smaller the faster).
  60020. */
  60021. blurTextureSizeRatio: number;
  60022. /**
  60023. * How big in texel of the blur texture is the vertical blur.
  60024. */
  60025. blurVerticalSize: number;
  60026. /**
  60027. * How big in texel of the blur texture is the horizontal blur.
  60028. */
  60029. blurHorizontalSize: number;
  60030. /**
  60031. * Alpha blending mode used to apply the blur. Default is combine.
  60032. */
  60033. alphaBlendingMode: number;
  60034. /**
  60035. * The camera attached to the layer.
  60036. */
  60037. camera: Nullable<Camera>;
  60038. /**
  60039. * Should we display highlight as a solid stroke?
  60040. */
  60041. isStroke?: boolean;
  60042. /**
  60043. * The rendering group to draw the layer in.
  60044. */
  60045. renderingGroupId: number;
  60046. }
  60047. /**
  60048. * The highlight layer Helps adding a glow effect around a mesh.
  60049. *
  60050. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60051. * glowy meshes to your scene.
  60052. *
  60053. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60054. */
  60055. export class HighlightLayer extends EffectLayer {
  60056. name: string;
  60057. /**
  60058. * Effect Name of the highlight layer.
  60059. */
  60060. static readonly EffectName: string;
  60061. /**
  60062. * The neutral color used during the preparation of the glow effect.
  60063. * This is black by default as the blend operation is a blend operation.
  60064. */
  60065. static NeutralColor: Color4;
  60066. /**
  60067. * Stencil value used for glowing meshes.
  60068. */
  60069. static GlowingMeshStencilReference: number;
  60070. /**
  60071. * Stencil value used for the other meshes in the scene.
  60072. */
  60073. static NormalMeshStencilReference: number;
  60074. /**
  60075. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60076. */
  60077. innerGlow: boolean;
  60078. /**
  60079. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60080. */
  60081. outerGlow: boolean;
  60082. /**
  60083. * Specifies the horizontal size of the blur.
  60084. */
  60085. set blurHorizontalSize(value: number);
  60086. /**
  60087. * Specifies the vertical size of the blur.
  60088. */
  60089. set blurVerticalSize(value: number);
  60090. /**
  60091. * Gets the horizontal size of the blur.
  60092. */
  60093. get blurHorizontalSize(): number;
  60094. /**
  60095. * Gets the vertical size of the blur.
  60096. */
  60097. get blurVerticalSize(): number;
  60098. /**
  60099. * An event triggered when the highlight layer is being blurred.
  60100. */
  60101. onBeforeBlurObservable: Observable<HighlightLayer>;
  60102. /**
  60103. * An event triggered when the highlight layer has been blurred.
  60104. */
  60105. onAfterBlurObservable: Observable<HighlightLayer>;
  60106. private _instanceGlowingMeshStencilReference;
  60107. private _options;
  60108. private _downSamplePostprocess;
  60109. private _horizontalBlurPostprocess;
  60110. private _verticalBlurPostprocess;
  60111. private _blurTexture;
  60112. private _meshes;
  60113. private _excludedMeshes;
  60114. /**
  60115. * Instantiates a new highlight Layer and references it to the scene..
  60116. * @param name The name of the layer
  60117. * @param scene The scene to use the layer in
  60118. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60119. */
  60120. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60121. /**
  60122. * Get the effect name of the layer.
  60123. * @return The effect name
  60124. */
  60125. getEffectName(): string;
  60126. /**
  60127. * Create the merge effect. This is the shader use to blit the information back
  60128. * to the main canvas at the end of the scene rendering.
  60129. */
  60130. protected _createMergeEffect(): Effect;
  60131. /**
  60132. * Creates the render target textures and post processes used in the highlight layer.
  60133. */
  60134. protected _createTextureAndPostProcesses(): void;
  60135. /**
  60136. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60137. */
  60138. needStencil(): boolean;
  60139. /**
  60140. * Checks for the readiness of the element composing the layer.
  60141. * @param subMesh the mesh to check for
  60142. * @param useInstances specify wether or not to use instances to render the mesh
  60143. * @param emissiveTexture the associated emissive texture used to generate the glow
  60144. * @return true if ready otherwise, false
  60145. */
  60146. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60147. /**
  60148. * Implementation specific of rendering the generating effect on the main canvas.
  60149. * @param effect The effect used to render through
  60150. */
  60151. protected _internalRender(effect: Effect): void;
  60152. /**
  60153. * Returns true if the layer contains information to display, otherwise false.
  60154. */
  60155. shouldRender(): boolean;
  60156. /**
  60157. * Returns true if the mesh should render, otherwise false.
  60158. * @param mesh The mesh to render
  60159. * @returns true if it should render otherwise false
  60160. */
  60161. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60162. /**
  60163. * Adds specific effects defines.
  60164. * @param defines The defines to add specifics to.
  60165. */
  60166. protected _addCustomEffectDefines(defines: string[]): void;
  60167. /**
  60168. * Sets the required values for both the emissive texture and and the main color.
  60169. */
  60170. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60171. /**
  60172. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60173. * @param mesh The mesh to exclude from the highlight layer
  60174. */
  60175. addExcludedMesh(mesh: Mesh): void;
  60176. /**
  60177. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60178. * @param mesh The mesh to highlight
  60179. */
  60180. removeExcludedMesh(mesh: Mesh): void;
  60181. /**
  60182. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60183. * @param mesh mesh to test
  60184. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60185. */
  60186. hasMesh(mesh: AbstractMesh): boolean;
  60187. /**
  60188. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60189. * @param mesh The mesh to highlight
  60190. * @param color The color of the highlight
  60191. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60192. */
  60193. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60194. /**
  60195. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60196. * @param mesh The mesh to highlight
  60197. */
  60198. removeMesh(mesh: Mesh): void;
  60199. /**
  60200. * Remove all the meshes currently referenced in the highlight layer
  60201. */
  60202. removeAllMeshes(): void;
  60203. /**
  60204. * Force the stencil to the normal expected value for none glowing parts
  60205. */
  60206. private _defaultStencilReference;
  60207. /**
  60208. * Free any resources and references associated to a mesh.
  60209. * Internal use
  60210. * @param mesh The mesh to free.
  60211. * @hidden
  60212. */
  60213. _disposeMesh(mesh: Mesh): void;
  60214. /**
  60215. * Dispose the highlight layer and free resources.
  60216. */
  60217. dispose(): void;
  60218. /**
  60219. * Gets the class name of the effect layer
  60220. * @returns the string with the class name of the effect layer
  60221. */
  60222. getClassName(): string;
  60223. /**
  60224. * Serializes this Highlight layer
  60225. * @returns a serialized Highlight layer object
  60226. */
  60227. serialize(): any;
  60228. /**
  60229. * Creates a Highlight layer from parsed Highlight layer data
  60230. * @param parsedHightlightLayer defines the Highlight layer data
  60231. * @param scene defines the current scene
  60232. * @param rootUrl defines the root URL containing the Highlight layer information
  60233. * @returns a parsed Highlight layer
  60234. */
  60235. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60236. }
  60237. }
  60238. declare module "babylonjs/Layers/layerSceneComponent" {
  60239. import { Scene } from "babylonjs/scene";
  60240. import { ISceneComponent } from "babylonjs/sceneComponent";
  60241. import { Layer } from "babylonjs/Layers/layer";
  60242. import { AbstractScene } from "babylonjs/abstractScene";
  60243. module "babylonjs/abstractScene" {
  60244. interface AbstractScene {
  60245. /**
  60246. * The list of layers (background and foreground) of the scene
  60247. */
  60248. layers: Array<Layer>;
  60249. }
  60250. }
  60251. /**
  60252. * Defines the layer scene component responsible to manage any layers
  60253. * in a given scene.
  60254. */
  60255. export class LayerSceneComponent implements ISceneComponent {
  60256. /**
  60257. * The component name helpfull to identify the component in the list of scene components.
  60258. */
  60259. readonly name: string;
  60260. /**
  60261. * The scene the component belongs to.
  60262. */
  60263. scene: Scene;
  60264. private _engine;
  60265. /**
  60266. * Creates a new instance of the component for the given scene
  60267. * @param scene Defines the scene to register the component in
  60268. */
  60269. constructor(scene: Scene);
  60270. /**
  60271. * Registers the component in a given scene
  60272. */
  60273. register(): void;
  60274. /**
  60275. * Rebuilds the elements related to this component in case of
  60276. * context lost for instance.
  60277. */
  60278. rebuild(): void;
  60279. /**
  60280. * Disposes the component and the associated ressources.
  60281. */
  60282. dispose(): void;
  60283. private _draw;
  60284. private _drawCameraPredicate;
  60285. private _drawCameraBackground;
  60286. private _drawCameraForeground;
  60287. private _drawRenderTargetPredicate;
  60288. private _drawRenderTargetBackground;
  60289. private _drawRenderTargetForeground;
  60290. /**
  60291. * Adds all the elements from the container to the scene
  60292. * @param container the container holding the elements
  60293. */
  60294. addFromContainer(container: AbstractScene): void;
  60295. /**
  60296. * Removes all the elements in the container from the scene
  60297. * @param container contains the elements to remove
  60298. * @param dispose if the removed element should be disposed (default: false)
  60299. */
  60300. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60301. }
  60302. }
  60303. declare module "babylonjs/Shaders/layer.fragment" {
  60304. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60305. /** @hidden */
  60306. export var layerPixelShader: {
  60307. name: string;
  60308. shader: string;
  60309. };
  60310. }
  60311. declare module "babylonjs/Shaders/layer.vertex" {
  60312. /** @hidden */
  60313. export var layerVertexShader: {
  60314. name: string;
  60315. shader: string;
  60316. };
  60317. }
  60318. declare module "babylonjs/Layers/layer" {
  60319. import { Observable } from "babylonjs/Misc/observable";
  60320. import { Nullable } from "babylonjs/types";
  60321. import { Scene } from "babylonjs/scene";
  60322. import { Vector2 } from "babylonjs/Maths/math.vector";
  60323. import { Color4 } from "babylonjs/Maths/math.color";
  60324. import { Texture } from "babylonjs/Materials/Textures/texture";
  60325. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60326. import "babylonjs/Shaders/layer.fragment";
  60327. import "babylonjs/Shaders/layer.vertex";
  60328. /**
  60329. * This represents a full screen 2d layer.
  60330. * This can be useful to display a picture in the background of your scene for instance.
  60331. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60332. */
  60333. export class Layer {
  60334. /**
  60335. * Define the name of the layer.
  60336. */
  60337. name: string;
  60338. /**
  60339. * Define the texture the layer should display.
  60340. */
  60341. texture: Nullable<Texture>;
  60342. /**
  60343. * Is the layer in background or foreground.
  60344. */
  60345. isBackground: boolean;
  60346. /**
  60347. * Define the color of the layer (instead of texture).
  60348. */
  60349. color: Color4;
  60350. /**
  60351. * Define the scale of the layer in order to zoom in out of the texture.
  60352. */
  60353. scale: Vector2;
  60354. /**
  60355. * Define an offset for the layer in order to shift the texture.
  60356. */
  60357. offset: Vector2;
  60358. /**
  60359. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60360. */
  60361. alphaBlendingMode: number;
  60362. /**
  60363. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60364. * Alpha test will not mix with the background color in case of transparency.
  60365. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60366. */
  60367. alphaTest: boolean;
  60368. /**
  60369. * Define a mask to restrict the layer to only some of the scene cameras.
  60370. */
  60371. layerMask: number;
  60372. /**
  60373. * Define the list of render target the layer is visible into.
  60374. */
  60375. renderTargetTextures: RenderTargetTexture[];
  60376. /**
  60377. * Define if the layer is only used in renderTarget or if it also
  60378. * renders in the main frame buffer of the canvas.
  60379. */
  60380. renderOnlyInRenderTargetTextures: boolean;
  60381. private _scene;
  60382. private _vertexBuffers;
  60383. private _indexBuffer;
  60384. private _effect;
  60385. private _previousDefines;
  60386. /**
  60387. * An event triggered when the layer is disposed.
  60388. */
  60389. onDisposeObservable: Observable<Layer>;
  60390. private _onDisposeObserver;
  60391. /**
  60392. * Back compatibility with callback before the onDisposeObservable existed.
  60393. * The set callback will be triggered when the layer has been disposed.
  60394. */
  60395. set onDispose(callback: () => void);
  60396. /**
  60397. * An event triggered before rendering the scene
  60398. */
  60399. onBeforeRenderObservable: Observable<Layer>;
  60400. private _onBeforeRenderObserver;
  60401. /**
  60402. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60403. * The set callback will be triggered just before rendering the layer.
  60404. */
  60405. set onBeforeRender(callback: () => void);
  60406. /**
  60407. * An event triggered after rendering the scene
  60408. */
  60409. onAfterRenderObservable: Observable<Layer>;
  60410. private _onAfterRenderObserver;
  60411. /**
  60412. * Back compatibility with callback before the onAfterRenderObservable existed.
  60413. * The set callback will be triggered just after rendering the layer.
  60414. */
  60415. set onAfterRender(callback: () => void);
  60416. /**
  60417. * Instantiates a new layer.
  60418. * This represents a full screen 2d layer.
  60419. * This can be useful to display a picture in the background of your scene for instance.
  60420. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60421. * @param name Define the name of the layer in the scene
  60422. * @param imgUrl Define the url of the texture to display in the layer
  60423. * @param scene Define the scene the layer belongs to
  60424. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60425. * @param color Defines a color for the layer
  60426. */
  60427. constructor(
  60428. /**
  60429. * Define the name of the layer.
  60430. */
  60431. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60432. private _createIndexBuffer;
  60433. /** @hidden */
  60434. _rebuild(): void;
  60435. /**
  60436. * Renders the layer in the scene.
  60437. */
  60438. render(): void;
  60439. /**
  60440. * Disposes and releases the associated ressources.
  60441. */
  60442. dispose(): void;
  60443. }
  60444. }
  60445. declare module "babylonjs/Layers/index" {
  60446. export * from "babylonjs/Layers/effectLayer";
  60447. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60448. export * from "babylonjs/Layers/glowLayer";
  60449. export * from "babylonjs/Layers/highlightLayer";
  60450. export * from "babylonjs/Layers/layer";
  60451. export * from "babylonjs/Layers/layerSceneComponent";
  60452. }
  60453. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60454. /** @hidden */
  60455. export var lensFlarePixelShader: {
  60456. name: string;
  60457. shader: string;
  60458. };
  60459. }
  60460. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60461. /** @hidden */
  60462. export var lensFlareVertexShader: {
  60463. name: string;
  60464. shader: string;
  60465. };
  60466. }
  60467. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60468. import { Scene } from "babylonjs/scene";
  60469. import { Vector3 } from "babylonjs/Maths/math.vector";
  60470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60471. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60472. import "babylonjs/Shaders/lensFlare.fragment";
  60473. import "babylonjs/Shaders/lensFlare.vertex";
  60474. import { Viewport } from "babylonjs/Maths/math.viewport";
  60475. /**
  60476. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60477. * It is usually composed of several `lensFlare`.
  60478. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60479. */
  60480. export class LensFlareSystem {
  60481. /**
  60482. * Define the name of the lens flare system
  60483. */
  60484. name: string;
  60485. /**
  60486. * List of lens flares used in this system.
  60487. */
  60488. lensFlares: LensFlare[];
  60489. /**
  60490. * Define a limit from the border the lens flare can be visible.
  60491. */
  60492. borderLimit: number;
  60493. /**
  60494. * Define a viewport border we do not want to see the lens flare in.
  60495. */
  60496. viewportBorder: number;
  60497. /**
  60498. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60499. */
  60500. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60501. /**
  60502. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60503. */
  60504. layerMask: number;
  60505. /**
  60506. * Define the id of the lens flare system in the scene.
  60507. * (equal to name by default)
  60508. */
  60509. id: string;
  60510. private _scene;
  60511. private _emitter;
  60512. private _vertexBuffers;
  60513. private _indexBuffer;
  60514. private _effect;
  60515. private _positionX;
  60516. private _positionY;
  60517. private _isEnabled;
  60518. /** @hidden */
  60519. static _SceneComponentInitialization: (scene: Scene) => void;
  60520. /**
  60521. * Instantiates a lens flare system.
  60522. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60523. * It is usually composed of several `lensFlare`.
  60524. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60525. * @param name Define the name of the lens flare system in the scene
  60526. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60527. * @param scene Define the scene the lens flare system belongs to
  60528. */
  60529. constructor(
  60530. /**
  60531. * Define the name of the lens flare system
  60532. */
  60533. name: string, emitter: any, scene: Scene);
  60534. /**
  60535. * Define if the lens flare system is enabled.
  60536. */
  60537. get isEnabled(): boolean;
  60538. set isEnabled(value: boolean);
  60539. /**
  60540. * Get the scene the effects belongs to.
  60541. * @returns the scene holding the lens flare system
  60542. */
  60543. getScene(): Scene;
  60544. /**
  60545. * Get the emitter of the lens flare system.
  60546. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60547. * @returns the emitter of the lens flare system
  60548. */
  60549. getEmitter(): any;
  60550. /**
  60551. * Set the emitter of the lens flare system.
  60552. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60553. * @param newEmitter Define the new emitter of the system
  60554. */
  60555. setEmitter(newEmitter: any): void;
  60556. /**
  60557. * Get the lens flare system emitter position.
  60558. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60559. * @returns the position
  60560. */
  60561. getEmitterPosition(): Vector3;
  60562. /**
  60563. * @hidden
  60564. */
  60565. computeEffectivePosition(globalViewport: Viewport): boolean;
  60566. /** @hidden */
  60567. _isVisible(): boolean;
  60568. /**
  60569. * @hidden
  60570. */
  60571. render(): boolean;
  60572. /**
  60573. * Dispose and release the lens flare with its associated resources.
  60574. */
  60575. dispose(): void;
  60576. /**
  60577. * Parse a lens flare system from a JSON repressentation
  60578. * @param parsedLensFlareSystem Define the JSON to parse
  60579. * @param scene Define the scene the parsed system should be instantiated in
  60580. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60581. * @returns the parsed system
  60582. */
  60583. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60584. /**
  60585. * Serialize the current Lens Flare System into a JSON representation.
  60586. * @returns the serialized JSON
  60587. */
  60588. serialize(): any;
  60589. }
  60590. }
  60591. declare module "babylonjs/LensFlares/lensFlare" {
  60592. import { Nullable } from "babylonjs/types";
  60593. import { Color3 } from "babylonjs/Maths/math.color";
  60594. import { Texture } from "babylonjs/Materials/Textures/texture";
  60595. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60596. /**
  60597. * This represents one of the lens effect in a `lensFlareSystem`.
  60598. * It controls one of the indiviual texture used in the effect.
  60599. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60600. */
  60601. export class LensFlare {
  60602. /**
  60603. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60604. */
  60605. size: number;
  60606. /**
  60607. * 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.
  60608. */
  60609. position: number;
  60610. /**
  60611. * Define the lens color.
  60612. */
  60613. color: Color3;
  60614. /**
  60615. * Define the lens texture.
  60616. */
  60617. texture: Nullable<Texture>;
  60618. /**
  60619. * Define the alpha mode to render this particular lens.
  60620. */
  60621. alphaMode: number;
  60622. private _system;
  60623. /**
  60624. * Creates a new Lens Flare.
  60625. * This represents one of the lens effect in a `lensFlareSystem`.
  60626. * It controls one of the indiviual texture used in the effect.
  60627. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60628. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60629. * @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.
  60630. * @param color Define the lens color
  60631. * @param imgUrl Define the lens texture url
  60632. * @param system Define the `lensFlareSystem` this flare is part of
  60633. * @returns The newly created Lens Flare
  60634. */
  60635. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60636. /**
  60637. * Instantiates a new Lens Flare.
  60638. * This represents one of the lens effect in a `lensFlareSystem`.
  60639. * It controls one of the indiviual texture used in the effect.
  60640. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60641. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60642. * @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.
  60643. * @param color Define the lens color
  60644. * @param imgUrl Define the lens texture url
  60645. * @param system Define the `lensFlareSystem` this flare is part of
  60646. */
  60647. constructor(
  60648. /**
  60649. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60650. */
  60651. size: number,
  60652. /**
  60653. * 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.
  60654. */
  60655. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60656. /**
  60657. * Dispose and release the lens flare with its associated resources.
  60658. */
  60659. dispose(): void;
  60660. }
  60661. }
  60662. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60663. import { Nullable } from "babylonjs/types";
  60664. import { Scene } from "babylonjs/scene";
  60665. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60666. import { AbstractScene } from "babylonjs/abstractScene";
  60667. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60668. module "babylonjs/abstractScene" {
  60669. interface AbstractScene {
  60670. /**
  60671. * The list of lens flare system added to the scene
  60672. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60673. */
  60674. lensFlareSystems: Array<LensFlareSystem>;
  60675. /**
  60676. * Removes the given lens flare system from this scene.
  60677. * @param toRemove The lens flare system to remove
  60678. * @returns The index of the removed lens flare system
  60679. */
  60680. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60681. /**
  60682. * Adds the given lens flare system to this scene
  60683. * @param newLensFlareSystem The lens flare system to add
  60684. */
  60685. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60686. /**
  60687. * Gets a lens flare system using its name
  60688. * @param name defines the name to look for
  60689. * @returns the lens flare system or null if not found
  60690. */
  60691. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60692. /**
  60693. * Gets a lens flare system using its id
  60694. * @param id defines the id to look for
  60695. * @returns the lens flare system or null if not found
  60696. */
  60697. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60698. }
  60699. }
  60700. /**
  60701. * Defines the lens flare scene component responsible to manage any lens flares
  60702. * in a given scene.
  60703. */
  60704. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60705. /**
  60706. * The component name helpfull to identify the component in the list of scene components.
  60707. */
  60708. readonly name: string;
  60709. /**
  60710. * The scene the component belongs to.
  60711. */
  60712. scene: Scene;
  60713. /**
  60714. * Creates a new instance of the component for the given scene
  60715. * @param scene Defines the scene to register the component in
  60716. */
  60717. constructor(scene: Scene);
  60718. /**
  60719. * Registers the component in a given scene
  60720. */
  60721. register(): void;
  60722. /**
  60723. * Rebuilds the elements related to this component in case of
  60724. * context lost for instance.
  60725. */
  60726. rebuild(): void;
  60727. /**
  60728. * Adds all the elements from the container to the scene
  60729. * @param container the container holding the elements
  60730. */
  60731. addFromContainer(container: AbstractScene): void;
  60732. /**
  60733. * Removes all the elements in the container from the scene
  60734. * @param container contains the elements to remove
  60735. * @param dispose if the removed element should be disposed (default: false)
  60736. */
  60737. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60738. /**
  60739. * Serializes the component data to the specified json object
  60740. * @param serializationObject The object to serialize to
  60741. */
  60742. serialize(serializationObject: any): void;
  60743. /**
  60744. * Disposes the component and the associated ressources.
  60745. */
  60746. dispose(): void;
  60747. private _draw;
  60748. }
  60749. }
  60750. declare module "babylonjs/LensFlares/index" {
  60751. export * from "babylonjs/LensFlares/lensFlare";
  60752. export * from "babylonjs/LensFlares/lensFlareSystem";
  60753. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  60754. }
  60755. declare module "babylonjs/Shaders/depth.fragment" {
  60756. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60757. /** @hidden */
  60758. export var depthPixelShader: {
  60759. name: string;
  60760. shader: string;
  60761. };
  60762. }
  60763. declare module "babylonjs/Shaders/depth.vertex" {
  60764. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60765. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60766. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60767. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60768. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60769. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60770. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60771. /** @hidden */
  60772. export var depthVertexShader: {
  60773. name: string;
  60774. shader: string;
  60775. };
  60776. }
  60777. declare module "babylonjs/Rendering/depthRenderer" {
  60778. import { Nullable } from "babylonjs/types";
  60779. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60780. import { Scene } from "babylonjs/scene";
  60781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60782. import { Camera } from "babylonjs/Cameras/camera";
  60783. import "babylonjs/Shaders/depth.fragment";
  60784. import "babylonjs/Shaders/depth.vertex";
  60785. /**
  60786. * This represents a depth renderer in Babylon.
  60787. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60788. */
  60789. export class DepthRenderer {
  60790. private _scene;
  60791. private _depthMap;
  60792. private _effect;
  60793. private readonly _storeNonLinearDepth;
  60794. private readonly _clearColor;
  60795. /** Get if the depth renderer is using packed depth or not */
  60796. readonly isPacked: boolean;
  60797. private _cachedDefines;
  60798. private _camera;
  60799. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60800. enabled: boolean;
  60801. /**
  60802. * Specifiess that the depth renderer will only be used within
  60803. * the camera it is created for.
  60804. * This can help forcing its rendering during the camera processing.
  60805. */
  60806. useOnlyInActiveCamera: boolean;
  60807. /** @hidden */
  60808. static _SceneComponentInitialization: (scene: Scene) => void;
  60809. /**
  60810. * Instantiates a depth renderer
  60811. * @param scene The scene the renderer belongs to
  60812. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60813. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60814. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60815. */
  60816. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60817. /**
  60818. * Creates the depth rendering effect and checks if the effect is ready.
  60819. * @param subMesh The submesh to be used to render the depth map of
  60820. * @param useInstances If multiple world instances should be used
  60821. * @returns if the depth renderer is ready to render the depth map
  60822. */
  60823. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60824. /**
  60825. * Gets the texture which the depth map will be written to.
  60826. * @returns The depth map texture
  60827. */
  60828. getDepthMap(): RenderTargetTexture;
  60829. /**
  60830. * Disposes of the depth renderer.
  60831. */
  60832. dispose(): void;
  60833. }
  60834. }
  60835. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  60836. /** @hidden */
  60837. export var minmaxReduxPixelShader: {
  60838. name: string;
  60839. shader: string;
  60840. };
  60841. }
  60842. declare module "babylonjs/Misc/minMaxReducer" {
  60843. import { Nullable } from "babylonjs/types";
  60844. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60845. import { Camera } from "babylonjs/Cameras/camera";
  60846. import { Observer } from "babylonjs/Misc/observable";
  60847. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60848. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  60849. import { Observable } from "babylonjs/Misc/observable";
  60850. import "babylonjs/Shaders/minmaxRedux.fragment";
  60851. /**
  60852. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60853. * and maximum values from all values of the texture.
  60854. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60855. * The source values are read from the red channel of the texture.
  60856. */
  60857. export class MinMaxReducer {
  60858. /**
  60859. * Observable triggered when the computation has been performed
  60860. */
  60861. onAfterReductionPerformed: Observable<{
  60862. min: number;
  60863. max: number;
  60864. }>;
  60865. protected _camera: Camera;
  60866. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60867. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60868. protected _postProcessManager: PostProcessManager;
  60869. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60870. protected _forceFullscreenViewport: boolean;
  60871. /**
  60872. * Creates a min/max reducer
  60873. * @param camera The camera to use for the post processes
  60874. */
  60875. constructor(camera: Camera);
  60876. /**
  60877. * Gets the texture used to read the values from.
  60878. */
  60879. get sourceTexture(): Nullable<RenderTargetTexture>;
  60880. /**
  60881. * Sets the source texture to read the values from.
  60882. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60883. * because in such textures '1' value must not be taken into account to compute the maximum
  60884. * as this value is used to clear the texture.
  60885. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60886. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60887. * @param depthRedux Indicates if the texture is a depth texture or not
  60888. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60889. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60890. */
  60891. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60892. /**
  60893. * Defines the refresh rate of the computation.
  60894. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60895. */
  60896. get refreshRate(): number;
  60897. set refreshRate(value: number);
  60898. protected _activated: boolean;
  60899. /**
  60900. * Gets the activation status of the reducer
  60901. */
  60902. get activated(): boolean;
  60903. /**
  60904. * Activates the reduction computation.
  60905. * When activated, the observers registered in onAfterReductionPerformed are
  60906. * called after the compuation is performed
  60907. */
  60908. activate(): void;
  60909. /**
  60910. * Deactivates the reduction computation.
  60911. */
  60912. deactivate(): void;
  60913. /**
  60914. * Disposes the min/max reducer
  60915. * @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.
  60916. */
  60917. dispose(disposeAll?: boolean): void;
  60918. }
  60919. }
  60920. declare module "babylonjs/Misc/depthReducer" {
  60921. import { Nullable } from "babylonjs/types";
  60922. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60923. import { Camera } from "babylonjs/Cameras/camera";
  60924. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60925. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  60926. /**
  60927. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60928. */
  60929. export class DepthReducer extends MinMaxReducer {
  60930. private _depthRenderer;
  60931. private _depthRendererId;
  60932. /**
  60933. * Gets the depth renderer used for the computation.
  60934. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60935. */
  60936. get depthRenderer(): Nullable<DepthRenderer>;
  60937. /**
  60938. * Creates a depth reducer
  60939. * @param camera The camera used to render the depth texture
  60940. */
  60941. constructor(camera: Camera);
  60942. /**
  60943. * Sets the depth renderer to use to generate the depth map
  60944. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60945. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60946. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60947. */
  60948. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60949. /** @hidden */
  60950. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60951. /**
  60952. * Activates the reduction computation.
  60953. * When activated, the observers registered in onAfterReductionPerformed are
  60954. * called after the compuation is performed
  60955. */
  60956. activate(): void;
  60957. /**
  60958. * Deactivates the reduction computation.
  60959. */
  60960. deactivate(): void;
  60961. /**
  60962. * Disposes the depth reducer
  60963. * @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.
  60964. */
  60965. dispose(disposeAll?: boolean): void;
  60966. }
  60967. }
  60968. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  60969. import { Nullable } from "babylonjs/types";
  60970. import { Scene } from "babylonjs/scene";
  60971. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60972. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60974. import { Effect } from "babylonjs/Materials/effect";
  60975. import "babylonjs/Shaders/shadowMap.fragment";
  60976. import "babylonjs/Shaders/shadowMap.vertex";
  60977. import "babylonjs/Shaders/depthBoxBlur.fragment";
  60978. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  60979. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  60980. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  60981. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60982. /**
  60983. * A CSM implementation allowing casting shadows on large scenes.
  60984. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60985. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60986. */
  60987. export class CascadedShadowGenerator extends ShadowGenerator {
  60988. private static readonly frustumCornersNDCSpace;
  60989. /**
  60990. * Name of the CSM class
  60991. */
  60992. static CLASSNAME: string;
  60993. /**
  60994. * Defines the default number of cascades used by the CSM.
  60995. */
  60996. static readonly DEFAULT_CASCADES_COUNT: number;
  60997. /**
  60998. * Defines the minimum number of cascades used by the CSM.
  60999. */
  61000. static readonly MIN_CASCADES_COUNT: number;
  61001. /**
  61002. * Defines the maximum number of cascades used by the CSM.
  61003. */
  61004. static readonly MAX_CASCADES_COUNT: number;
  61005. protected _validateFilter(filter: number): number;
  61006. /**
  61007. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61008. */
  61009. penumbraDarkness: number;
  61010. private _numCascades;
  61011. /**
  61012. * Gets or set the number of cascades used by the CSM.
  61013. */
  61014. get numCascades(): number;
  61015. set numCascades(value: number);
  61016. /**
  61017. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61018. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61019. */
  61020. stabilizeCascades: boolean;
  61021. private _freezeShadowCastersBoundingInfo;
  61022. private _freezeShadowCastersBoundingInfoObservable;
  61023. /**
  61024. * Enables or disables the shadow casters bounding info computation.
  61025. * If your shadow casters don't move, you can disable this feature.
  61026. * If it is enabled, the bounding box computation is done every frame.
  61027. */
  61028. get freezeShadowCastersBoundingInfo(): boolean;
  61029. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61030. private _scbiMin;
  61031. private _scbiMax;
  61032. protected _computeShadowCastersBoundingInfo(): void;
  61033. protected _shadowCastersBoundingInfo: BoundingInfo;
  61034. /**
  61035. * Gets or sets the shadow casters bounding info.
  61036. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61037. * so that the system won't overwrite the bounds you provide
  61038. */
  61039. get shadowCastersBoundingInfo(): BoundingInfo;
  61040. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61041. protected _breaksAreDirty: boolean;
  61042. protected _minDistance: number;
  61043. protected _maxDistance: number;
  61044. /**
  61045. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61046. *
  61047. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61048. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61049. * @param min minimal distance for the breaks (default to 0.)
  61050. * @param max maximal distance for the breaks (default to 1.)
  61051. */
  61052. setMinMaxDistance(min: number, max: number): void;
  61053. /** Gets the minimal distance used in the cascade break computation */
  61054. get minDistance(): number;
  61055. /** Gets the maximal distance used in the cascade break computation */
  61056. get maxDistance(): number;
  61057. /**
  61058. * Gets the class name of that object
  61059. * @returns "CascadedShadowGenerator"
  61060. */
  61061. getClassName(): string;
  61062. private _cascadeMinExtents;
  61063. private _cascadeMaxExtents;
  61064. /**
  61065. * Gets a cascade minimum extents
  61066. * @param cascadeIndex index of the cascade
  61067. * @returns the minimum cascade extents
  61068. */
  61069. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61070. /**
  61071. * Gets a cascade maximum extents
  61072. * @param cascadeIndex index of the cascade
  61073. * @returns the maximum cascade extents
  61074. */
  61075. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61076. private _cascades;
  61077. private _currentLayer;
  61078. private _viewSpaceFrustumsZ;
  61079. private _viewMatrices;
  61080. private _projectionMatrices;
  61081. private _transformMatrices;
  61082. private _transformMatricesAsArray;
  61083. private _frustumLengths;
  61084. private _lightSizeUVCorrection;
  61085. private _depthCorrection;
  61086. private _frustumCornersWorldSpace;
  61087. private _frustumCenter;
  61088. private _shadowCameraPos;
  61089. private _shadowMaxZ;
  61090. /**
  61091. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61092. * It defaults to camera.maxZ
  61093. */
  61094. get shadowMaxZ(): number;
  61095. /**
  61096. * Sets the shadow max z distance.
  61097. */
  61098. set shadowMaxZ(value: number);
  61099. protected _debug: boolean;
  61100. /**
  61101. * Gets or sets the debug flag.
  61102. * When enabled, the cascades are materialized by different colors on the screen.
  61103. */
  61104. get debug(): boolean;
  61105. set debug(dbg: boolean);
  61106. private _depthClamp;
  61107. /**
  61108. * Gets or sets the depth clamping value.
  61109. *
  61110. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61111. * to account for the shadow casters far away.
  61112. *
  61113. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61114. */
  61115. get depthClamp(): boolean;
  61116. set depthClamp(value: boolean);
  61117. private _cascadeBlendPercentage;
  61118. /**
  61119. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61120. * It defaults to 0.1 (10% blending).
  61121. */
  61122. get cascadeBlendPercentage(): number;
  61123. set cascadeBlendPercentage(value: number);
  61124. private _lambda;
  61125. /**
  61126. * Gets or set the lambda parameter.
  61127. * This parameter is used to split the camera frustum and create the cascades.
  61128. * 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.
  61129. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61130. */
  61131. get lambda(): number;
  61132. set lambda(value: number);
  61133. /**
  61134. * Gets the view matrix corresponding to a given cascade
  61135. * @param cascadeNum cascade to retrieve the view matrix from
  61136. * @returns the cascade view matrix
  61137. */
  61138. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61139. /**
  61140. * Gets the projection matrix corresponding to a given cascade
  61141. * @param cascadeNum cascade to retrieve the projection matrix from
  61142. * @returns the cascade projection matrix
  61143. */
  61144. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61145. /**
  61146. * Gets the transformation matrix corresponding to a given cascade
  61147. * @param cascadeNum cascade to retrieve the transformation matrix from
  61148. * @returns the cascade transformation matrix
  61149. */
  61150. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61151. private _depthRenderer;
  61152. /**
  61153. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61154. *
  61155. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61156. *
  61157. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61158. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61159. * @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
  61160. */
  61161. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61162. private _depthReducer;
  61163. private _autoCalcDepthBounds;
  61164. /**
  61165. * Gets or sets the autoCalcDepthBounds property.
  61166. *
  61167. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61168. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61169. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61170. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61171. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61172. */
  61173. get autoCalcDepthBounds(): boolean;
  61174. set autoCalcDepthBounds(value: boolean);
  61175. /**
  61176. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61177. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61178. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61179. * for setting the refresh rate on the renderer yourself!
  61180. */
  61181. get autoCalcDepthBoundsRefreshRate(): number;
  61182. set autoCalcDepthBoundsRefreshRate(value: number);
  61183. /**
  61184. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61185. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61186. * you change the camera near/far planes!
  61187. */
  61188. splitFrustum(): void;
  61189. private _splitFrustum;
  61190. private _computeMatrices;
  61191. private _computeFrustumInWorldSpace;
  61192. private _computeCascadeFrustum;
  61193. /**
  61194. * Support test.
  61195. */
  61196. static get IsSupported(): boolean;
  61197. /** @hidden */
  61198. static _SceneComponentInitialization: (scene: Scene) => void;
  61199. /**
  61200. * Creates a Cascaded Shadow Generator object.
  61201. * A ShadowGenerator is the required tool to use the shadows.
  61202. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61203. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61204. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61205. * @param light The directional light object generating the shadows.
  61206. * @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.
  61207. */
  61208. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61209. protected _initializeGenerator(): void;
  61210. protected _createTargetRenderTexture(): void;
  61211. protected _initializeShadowMap(): void;
  61212. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61213. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61214. /**
  61215. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61216. * @param defines Defines of the material we want to update
  61217. * @param lightIndex Index of the light in the enabled light list of the material
  61218. */
  61219. prepareDefines(defines: any, lightIndex: number): void;
  61220. /**
  61221. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61222. * defined in the generator but impacting the effect).
  61223. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61224. * @param effect The effect we are binfing the information for
  61225. */
  61226. bindShadowLight(lightIndex: string, effect: Effect): void;
  61227. /**
  61228. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61229. * (eq to view projection * shadow projection matrices)
  61230. * @returns The transform matrix used to create the shadow map
  61231. */
  61232. getTransformMatrix(): Matrix;
  61233. /**
  61234. * Disposes the ShadowGenerator.
  61235. * Returns nothing.
  61236. */
  61237. dispose(): void;
  61238. /**
  61239. * Serializes the shadow generator setup to a json object.
  61240. * @returns The serialized JSON object
  61241. */
  61242. serialize(): any;
  61243. /**
  61244. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61245. * @param parsedShadowGenerator The JSON object to parse
  61246. * @param scene The scene to create the shadow map for
  61247. * @returns The parsed shadow generator
  61248. */
  61249. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61250. }
  61251. }
  61252. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61253. import { Scene } from "babylonjs/scene";
  61254. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61255. import { AbstractScene } from "babylonjs/abstractScene";
  61256. /**
  61257. * Defines the shadow generator component responsible to manage any shadow generators
  61258. * in a given scene.
  61259. */
  61260. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61261. /**
  61262. * The component name helpfull to identify the component in the list of scene components.
  61263. */
  61264. readonly name: string;
  61265. /**
  61266. * The scene the component belongs to.
  61267. */
  61268. scene: Scene;
  61269. /**
  61270. * Creates a new instance of the component for the given scene
  61271. * @param scene Defines the scene to register the component in
  61272. */
  61273. constructor(scene: Scene);
  61274. /**
  61275. * Registers the component in a given scene
  61276. */
  61277. register(): void;
  61278. /**
  61279. * Rebuilds the elements related to this component in case of
  61280. * context lost for instance.
  61281. */
  61282. rebuild(): void;
  61283. /**
  61284. * Serializes the component data to the specified json object
  61285. * @param serializationObject The object to serialize to
  61286. */
  61287. serialize(serializationObject: any): void;
  61288. /**
  61289. * Adds all the elements from the container to the scene
  61290. * @param container the container holding the elements
  61291. */
  61292. addFromContainer(container: AbstractScene): void;
  61293. /**
  61294. * Removes all the elements in the container from the scene
  61295. * @param container contains the elements to remove
  61296. * @param dispose if the removed element should be disposed (default: false)
  61297. */
  61298. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61299. /**
  61300. * Rebuilds the elements related to this component in case of
  61301. * context lost for instance.
  61302. */
  61303. dispose(): void;
  61304. private _gatherRenderTargets;
  61305. }
  61306. }
  61307. declare module "babylonjs/Lights/Shadows/index" {
  61308. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61309. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61310. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61311. }
  61312. declare module "babylonjs/Lights/pointLight" {
  61313. import { Scene } from "babylonjs/scene";
  61314. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61315. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61316. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61317. import { Effect } from "babylonjs/Materials/effect";
  61318. /**
  61319. * A point light is a light defined by an unique point in world space.
  61320. * The light is emitted in every direction from this point.
  61321. * A good example of a point light is a standard light bulb.
  61322. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61323. */
  61324. export class PointLight extends ShadowLight {
  61325. private _shadowAngle;
  61326. /**
  61327. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61328. * This specifies what angle the shadow will use to be created.
  61329. *
  61330. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61331. */
  61332. get shadowAngle(): number;
  61333. /**
  61334. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61335. * This specifies what angle the shadow will use to be created.
  61336. *
  61337. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61338. */
  61339. set shadowAngle(value: number);
  61340. /**
  61341. * Gets the direction if it has been set.
  61342. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61343. */
  61344. get direction(): Vector3;
  61345. /**
  61346. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61347. */
  61348. set direction(value: Vector3);
  61349. /**
  61350. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61351. * A PointLight emits the light in every direction.
  61352. * It can cast shadows.
  61353. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61354. * ```javascript
  61355. * var pointLight = new PointLight("pl", camera.position, scene);
  61356. * ```
  61357. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61358. * @param name The light friendly name
  61359. * @param position The position of the point light in the scene
  61360. * @param scene The scene the lights belongs to
  61361. */
  61362. constructor(name: string, position: Vector3, scene: Scene);
  61363. /**
  61364. * Returns the string "PointLight"
  61365. * @returns the class name
  61366. */
  61367. getClassName(): string;
  61368. /**
  61369. * Returns the integer 0.
  61370. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61371. */
  61372. getTypeID(): number;
  61373. /**
  61374. * Specifies wether or not the shadowmap should be a cube texture.
  61375. * @returns true if the shadowmap needs to be a cube texture.
  61376. */
  61377. needCube(): boolean;
  61378. /**
  61379. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61380. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61381. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61382. */
  61383. getShadowDirection(faceIndex?: number): Vector3;
  61384. /**
  61385. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61386. * - fov = PI / 2
  61387. * - aspect ratio : 1.0
  61388. * - z-near and far equal to the active camera minZ and maxZ.
  61389. * Returns the PointLight.
  61390. */
  61391. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61392. protected _buildUniformLayout(): void;
  61393. /**
  61394. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61395. * @param effect The effect to update
  61396. * @param lightIndex The index of the light in the effect to update
  61397. * @returns The point light
  61398. */
  61399. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61400. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61401. /**
  61402. * Prepares the list of defines specific to the light type.
  61403. * @param defines the list of defines
  61404. * @param lightIndex defines the index of the light for the effect
  61405. */
  61406. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61407. }
  61408. }
  61409. declare module "babylonjs/Lights/index" {
  61410. export * from "babylonjs/Lights/light";
  61411. export * from "babylonjs/Lights/shadowLight";
  61412. export * from "babylonjs/Lights/Shadows/index";
  61413. export * from "babylonjs/Lights/directionalLight";
  61414. export * from "babylonjs/Lights/hemisphericLight";
  61415. export * from "babylonjs/Lights/pointLight";
  61416. export * from "babylonjs/Lights/spotLight";
  61417. }
  61418. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61419. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61420. /**
  61421. * Header information of HDR texture files.
  61422. */
  61423. export interface HDRInfo {
  61424. /**
  61425. * The height of the texture in pixels.
  61426. */
  61427. height: number;
  61428. /**
  61429. * The width of the texture in pixels.
  61430. */
  61431. width: number;
  61432. /**
  61433. * The index of the beginning of the data in the binary file.
  61434. */
  61435. dataPosition: number;
  61436. }
  61437. /**
  61438. * This groups tools to convert HDR texture to native colors array.
  61439. */
  61440. export class HDRTools {
  61441. private static Ldexp;
  61442. private static Rgbe2float;
  61443. private static readStringLine;
  61444. /**
  61445. * Reads header information from an RGBE texture stored in a native array.
  61446. * More information on this format are available here:
  61447. * https://en.wikipedia.org/wiki/RGBE_image_format
  61448. *
  61449. * @param uint8array The binary file stored in native array.
  61450. * @return The header information.
  61451. */
  61452. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61453. /**
  61454. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61455. * This RGBE texture needs to store the information as a panorama.
  61456. *
  61457. * More information on this format are available here:
  61458. * https://en.wikipedia.org/wiki/RGBE_image_format
  61459. *
  61460. * @param buffer The binary file stored in an array buffer.
  61461. * @param size The expected size of the extracted cubemap.
  61462. * @return The Cube Map information.
  61463. */
  61464. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61465. /**
  61466. * Returns the pixels data extracted from an RGBE texture.
  61467. * This pixels will be stored left to right up to down in the R G B order in one array.
  61468. *
  61469. * More information on this format are available here:
  61470. * https://en.wikipedia.org/wiki/RGBE_image_format
  61471. *
  61472. * @param uint8array The binary file stored in an array buffer.
  61473. * @param hdrInfo The header information of the file.
  61474. * @return The pixels data in RGB right to left up to down order.
  61475. */
  61476. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61477. private static RGBE_ReadPixels_RLE;
  61478. }
  61479. }
  61480. declare module "babylonjs/Materials/effectRenderer" {
  61481. import { Nullable } from "babylonjs/types";
  61482. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61483. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61484. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61485. import { Viewport } from "babylonjs/Maths/math.viewport";
  61486. import { Observable } from "babylonjs/Misc/observable";
  61487. import { Effect } from "babylonjs/Materials/effect";
  61488. import "babylonjs/Shaders/postprocess.vertex";
  61489. /**
  61490. * Effect Render Options
  61491. */
  61492. export interface IEffectRendererOptions {
  61493. /**
  61494. * Defines the vertices positions.
  61495. */
  61496. positions?: number[];
  61497. /**
  61498. * Defines the indices.
  61499. */
  61500. indices?: number[];
  61501. }
  61502. /**
  61503. * Helper class to render one or more effects.
  61504. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61505. */
  61506. export class EffectRenderer {
  61507. private engine;
  61508. private static _DefaultOptions;
  61509. private _vertexBuffers;
  61510. private _indexBuffer;
  61511. private _fullscreenViewport;
  61512. /**
  61513. * Creates an effect renderer
  61514. * @param engine the engine to use for rendering
  61515. * @param options defines the options of the effect renderer
  61516. */
  61517. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61518. /**
  61519. * Sets the current viewport in normalized coordinates 0-1
  61520. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61521. */
  61522. setViewport(viewport?: Viewport): void;
  61523. /**
  61524. * Binds the embedded attributes buffer to the effect.
  61525. * @param effect Defines the effect to bind the attributes for
  61526. */
  61527. bindBuffers(effect: Effect): void;
  61528. /**
  61529. * Sets the current effect wrapper to use during draw.
  61530. * The effect needs to be ready before calling this api.
  61531. * This also sets the default full screen position attribute.
  61532. * @param effectWrapper Defines the effect to draw with
  61533. */
  61534. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61535. /**
  61536. * Restores engine states
  61537. */
  61538. restoreStates(): void;
  61539. /**
  61540. * Draws a full screen quad.
  61541. */
  61542. draw(): void;
  61543. private isRenderTargetTexture;
  61544. /**
  61545. * renders one or more effects to a specified texture
  61546. * @param effectWrapper the effect to renderer
  61547. * @param outputTexture texture to draw to, if null it will render to the screen.
  61548. */
  61549. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61550. /**
  61551. * Disposes of the effect renderer
  61552. */
  61553. dispose(): void;
  61554. }
  61555. /**
  61556. * Options to create an EffectWrapper
  61557. */
  61558. interface EffectWrapperCreationOptions {
  61559. /**
  61560. * Engine to use to create the effect
  61561. */
  61562. engine: ThinEngine;
  61563. /**
  61564. * Fragment shader for the effect
  61565. */
  61566. fragmentShader: string;
  61567. /**
  61568. * Use the shader store instead of direct source code
  61569. */
  61570. useShaderStore?: boolean;
  61571. /**
  61572. * Vertex shader for the effect
  61573. */
  61574. vertexShader?: string;
  61575. /**
  61576. * Attributes to use in the shader
  61577. */
  61578. attributeNames?: Array<string>;
  61579. /**
  61580. * Uniforms to use in the shader
  61581. */
  61582. uniformNames?: Array<string>;
  61583. /**
  61584. * Texture sampler names to use in the shader
  61585. */
  61586. samplerNames?: Array<string>;
  61587. /**
  61588. * Defines to use in the shader
  61589. */
  61590. defines?: Array<string>;
  61591. /**
  61592. * Callback when effect is compiled
  61593. */
  61594. onCompiled?: Nullable<(effect: Effect) => void>;
  61595. /**
  61596. * The friendly name of the effect displayed in Spector.
  61597. */
  61598. name?: string;
  61599. }
  61600. /**
  61601. * Wraps an effect to be used for rendering
  61602. */
  61603. export class EffectWrapper {
  61604. /**
  61605. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61606. */
  61607. onApplyObservable: Observable<{}>;
  61608. /**
  61609. * The underlying effect
  61610. */
  61611. effect: Effect;
  61612. /**
  61613. * Creates an effect to be renderer
  61614. * @param creationOptions options to create the effect
  61615. */
  61616. constructor(creationOptions: EffectWrapperCreationOptions);
  61617. /**
  61618. * Disposes of the effect wrapper
  61619. */
  61620. dispose(): void;
  61621. }
  61622. }
  61623. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61624. /** @hidden */
  61625. export var hdrFilteringVertexShader: {
  61626. name: string;
  61627. shader: string;
  61628. };
  61629. }
  61630. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61631. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61632. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61633. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61634. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61635. /** @hidden */
  61636. export var hdrFilteringPixelShader: {
  61637. name: string;
  61638. shader: string;
  61639. };
  61640. }
  61641. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61642. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61643. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61644. import { Nullable } from "babylonjs/types";
  61645. import "babylonjs/Shaders/hdrFiltering.vertex";
  61646. import "babylonjs/Shaders/hdrFiltering.fragment";
  61647. /**
  61648. * Options for texture filtering
  61649. */
  61650. interface IHDRFilteringOptions {
  61651. /**
  61652. * Scales pixel intensity for the input HDR map.
  61653. */
  61654. hdrScale?: number;
  61655. /**
  61656. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61657. */
  61658. quality?: number;
  61659. }
  61660. /**
  61661. * Filters HDR maps to get correct renderings of PBR reflections
  61662. */
  61663. export class HDRFiltering {
  61664. private _engine;
  61665. private _effectRenderer;
  61666. private _effectWrapper;
  61667. private _lodGenerationOffset;
  61668. private _lodGenerationScale;
  61669. /**
  61670. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61671. * you care about baking speed.
  61672. */
  61673. quality: number;
  61674. /**
  61675. * Scales pixel intensity for the input HDR map.
  61676. */
  61677. hdrScale: number;
  61678. /**
  61679. * Instantiates HDR filter for reflection maps
  61680. *
  61681. * @param engine Thin engine
  61682. * @param options Options
  61683. */
  61684. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61685. private _createRenderTarget;
  61686. private _prefilterInternal;
  61687. private _createEffect;
  61688. /**
  61689. * Get a value indicating if the filter is ready to be used
  61690. * @param texture Texture to filter
  61691. * @returns true if the filter is ready
  61692. */
  61693. isReady(texture: BaseTexture): boolean;
  61694. /**
  61695. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61696. * Prefiltering will be invoked at the end of next rendering pass.
  61697. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61698. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61699. * @param texture Texture to filter
  61700. * @param onFinished Callback when filtering is done
  61701. * @return Promise called when prefiltering is done
  61702. */
  61703. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61704. }
  61705. }
  61706. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61707. import { Nullable } from "babylonjs/types";
  61708. import { Scene } from "babylonjs/scene";
  61709. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61711. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61712. import "babylonjs/Engines/Extensions/engine.rawTexture";
  61713. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  61714. /**
  61715. * This represents a texture coming from an HDR input.
  61716. *
  61717. * The only supported format is currently panorama picture stored in RGBE format.
  61718. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61719. */
  61720. export class HDRCubeTexture extends BaseTexture {
  61721. private static _facesMapping;
  61722. private _generateHarmonics;
  61723. private _noMipmap;
  61724. private _prefilterOnLoad;
  61725. private _textureMatrix;
  61726. private _size;
  61727. private _onLoad;
  61728. private _onError;
  61729. /**
  61730. * The texture URL.
  61731. */
  61732. url: string;
  61733. /**
  61734. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  61735. */
  61736. coordinatesMode: number;
  61737. protected _isBlocking: boolean;
  61738. /**
  61739. * Sets wether or not the texture is blocking during loading.
  61740. */
  61741. set isBlocking(value: boolean);
  61742. /**
  61743. * Gets wether or not the texture is blocking during loading.
  61744. */
  61745. get isBlocking(): boolean;
  61746. protected _rotationY: number;
  61747. /**
  61748. * Sets texture matrix rotation angle around Y axis in radians.
  61749. */
  61750. set rotationY(value: number);
  61751. /**
  61752. * Gets texture matrix rotation angle around Y axis radians.
  61753. */
  61754. get rotationY(): number;
  61755. /**
  61756. * Gets or sets the center of the bounding box associated with the cube texture
  61757. * It must define where the camera used to render the texture was set
  61758. */
  61759. boundingBoxPosition: Vector3;
  61760. private _boundingBoxSize;
  61761. /**
  61762. * Gets or sets the size of the bounding box associated with the cube texture
  61763. * When defined, the cubemap will switch to local mode
  61764. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61765. * @example https://www.babylonjs-playground.com/#RNASML
  61766. */
  61767. set boundingBoxSize(value: Vector3);
  61768. get boundingBoxSize(): Vector3;
  61769. /**
  61770. * Instantiates an HDRTexture from the following parameters.
  61771. *
  61772. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61773. * @param sceneOrEngine The scene or engine the texture will be used in
  61774. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61775. * @param noMipmap Forces to not generate the mipmap if true
  61776. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61777. * @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)
  61778. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61779. */
  61780. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61781. /**
  61782. * Get the current class name of the texture useful for serialization or dynamic coding.
  61783. * @returns "HDRCubeTexture"
  61784. */
  61785. getClassName(): string;
  61786. /**
  61787. * Occurs when the file is raw .hdr file.
  61788. */
  61789. private loadTexture;
  61790. clone(): HDRCubeTexture;
  61791. delayLoad(): void;
  61792. /**
  61793. * Get the texture reflection matrix used to rotate/transform the reflection.
  61794. * @returns the reflection matrix
  61795. */
  61796. getReflectionTextureMatrix(): Matrix;
  61797. /**
  61798. * Set the texture reflection matrix used to rotate/transform the reflection.
  61799. * @param value Define the reflection matrix to set
  61800. */
  61801. setReflectionTextureMatrix(value: Matrix): void;
  61802. /**
  61803. * Parses a JSON representation of an HDR Texture in order to create the texture
  61804. * @param parsedTexture Define the JSON representation
  61805. * @param scene Define the scene the texture should be created in
  61806. * @param rootUrl Define the root url in case we need to load relative dependencies
  61807. * @returns the newly created texture after parsing
  61808. */
  61809. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61810. serialize(): any;
  61811. }
  61812. }
  61813. declare module "babylonjs/Physics/physicsEngine" {
  61814. import { Nullable } from "babylonjs/types";
  61815. import { Vector3 } from "babylonjs/Maths/math.vector";
  61816. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61817. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  61818. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  61819. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61820. /**
  61821. * Class used to control physics engine
  61822. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61823. */
  61824. export class PhysicsEngine implements IPhysicsEngine {
  61825. private _physicsPlugin;
  61826. /**
  61827. * Global value used to control the smallest number supported by the simulation
  61828. */
  61829. static Epsilon: number;
  61830. private _impostors;
  61831. private _joints;
  61832. private _subTimeStep;
  61833. /**
  61834. * Gets the gravity vector used by the simulation
  61835. */
  61836. gravity: Vector3;
  61837. /**
  61838. * Factory used to create the default physics plugin.
  61839. * @returns The default physics plugin
  61840. */
  61841. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61842. /**
  61843. * Creates a new Physics Engine
  61844. * @param gravity defines the gravity vector used by the simulation
  61845. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61846. */
  61847. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61848. /**
  61849. * Sets the gravity vector used by the simulation
  61850. * @param gravity defines the gravity vector to use
  61851. */
  61852. setGravity(gravity: Vector3): void;
  61853. /**
  61854. * Set the time step of the physics engine.
  61855. * Default is 1/60.
  61856. * To slow it down, enter 1/600 for example.
  61857. * To speed it up, 1/30
  61858. * @param newTimeStep defines the new timestep to apply to this world.
  61859. */
  61860. setTimeStep(newTimeStep?: number): void;
  61861. /**
  61862. * Get the time step of the physics engine.
  61863. * @returns the current time step
  61864. */
  61865. getTimeStep(): number;
  61866. /**
  61867. * Set the sub time step of the physics engine.
  61868. * Default is 0 meaning there is no sub steps
  61869. * To increase physics resolution precision, set a small value (like 1 ms)
  61870. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61871. */
  61872. setSubTimeStep(subTimeStep?: number): void;
  61873. /**
  61874. * Get the sub time step of the physics engine.
  61875. * @returns the current sub time step
  61876. */
  61877. getSubTimeStep(): number;
  61878. /**
  61879. * Release all resources
  61880. */
  61881. dispose(): void;
  61882. /**
  61883. * Gets the name of the current physics plugin
  61884. * @returns the name of the plugin
  61885. */
  61886. getPhysicsPluginName(): string;
  61887. /**
  61888. * Adding a new impostor for the impostor tracking.
  61889. * This will be done by the impostor itself.
  61890. * @param impostor the impostor to add
  61891. */
  61892. addImpostor(impostor: PhysicsImpostor): void;
  61893. /**
  61894. * Remove an impostor from the engine.
  61895. * This impostor and its mesh will not longer be updated by the physics engine.
  61896. * @param impostor the impostor to remove
  61897. */
  61898. removeImpostor(impostor: PhysicsImpostor): void;
  61899. /**
  61900. * Add a joint to the physics engine
  61901. * @param mainImpostor defines the main impostor to which the joint is added.
  61902. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61903. * @param joint defines the joint that will connect both impostors.
  61904. */
  61905. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61906. /**
  61907. * Removes a joint from the simulation
  61908. * @param mainImpostor defines the impostor used with the joint
  61909. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61910. * @param joint defines the joint to remove
  61911. */
  61912. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61913. /**
  61914. * Called by the scene. No need to call it.
  61915. * @param delta defines the timespam between frames
  61916. */
  61917. _step(delta: number): void;
  61918. /**
  61919. * Gets the current plugin used to run the simulation
  61920. * @returns current plugin
  61921. */
  61922. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61923. /**
  61924. * Gets the list of physic impostors
  61925. * @returns an array of PhysicsImpostor
  61926. */
  61927. getImpostors(): Array<PhysicsImpostor>;
  61928. /**
  61929. * Gets the impostor for a physics enabled object
  61930. * @param object defines the object impersonated by the impostor
  61931. * @returns the PhysicsImpostor or null if not found
  61932. */
  61933. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61934. /**
  61935. * Gets the impostor for a physics body object
  61936. * @param body defines physics body used by the impostor
  61937. * @returns the PhysicsImpostor or null if not found
  61938. */
  61939. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61940. /**
  61941. * Does a raycast in the physics world
  61942. * @param from when should the ray start?
  61943. * @param to when should the ray end?
  61944. * @returns PhysicsRaycastResult
  61945. */
  61946. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61947. }
  61948. }
  61949. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  61950. import { Nullable } from "babylonjs/types";
  61951. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  61952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61953. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  61954. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61955. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  61956. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  61957. /** @hidden */
  61958. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61959. private _useDeltaForWorldStep;
  61960. world: any;
  61961. name: string;
  61962. private _physicsMaterials;
  61963. private _fixedTimeStep;
  61964. private _cannonRaycastResult;
  61965. private _raycastResult;
  61966. private _physicsBodysToRemoveAfterStep;
  61967. private _firstFrame;
  61968. BJSCANNON: any;
  61969. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61970. setGravity(gravity: Vector3): void;
  61971. setTimeStep(timeStep: number): void;
  61972. getTimeStep(): number;
  61973. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61974. private _removeMarkedPhysicsBodiesFromWorld;
  61975. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61976. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61977. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61978. private _processChildMeshes;
  61979. removePhysicsBody(impostor: PhysicsImpostor): void;
  61980. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61981. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61982. private _addMaterial;
  61983. private _checkWithEpsilon;
  61984. private _createShape;
  61985. private _createHeightmap;
  61986. private _minus90X;
  61987. private _plus90X;
  61988. private _tmpPosition;
  61989. private _tmpDeltaPosition;
  61990. private _tmpUnityRotation;
  61991. private _updatePhysicsBodyTransformation;
  61992. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61993. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61994. isSupported(): boolean;
  61995. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61996. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61997. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61998. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61999. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62000. getBodyMass(impostor: PhysicsImpostor): number;
  62001. getBodyFriction(impostor: PhysicsImpostor): number;
  62002. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62003. getBodyRestitution(impostor: PhysicsImpostor): number;
  62004. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62005. sleepBody(impostor: PhysicsImpostor): void;
  62006. wakeUpBody(impostor: PhysicsImpostor): void;
  62007. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62008. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62009. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62010. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62011. getRadius(impostor: PhysicsImpostor): number;
  62012. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62013. dispose(): void;
  62014. private _extendNamespace;
  62015. /**
  62016. * Does a raycast in the physics world
  62017. * @param from when should the ray start?
  62018. * @param to when should the ray end?
  62019. * @returns PhysicsRaycastResult
  62020. */
  62021. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62022. }
  62023. }
  62024. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62025. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62026. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62027. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62029. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62030. import { Nullable } from "babylonjs/types";
  62031. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62032. /** @hidden */
  62033. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62034. private _useDeltaForWorldStep;
  62035. world: any;
  62036. name: string;
  62037. BJSOIMO: any;
  62038. private _raycastResult;
  62039. private _fixedTimeStep;
  62040. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62041. setGravity(gravity: Vector3): void;
  62042. setTimeStep(timeStep: number): void;
  62043. getTimeStep(): number;
  62044. private _tmpImpostorsArray;
  62045. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62046. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62047. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62048. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62049. private _tmpPositionVector;
  62050. removePhysicsBody(impostor: PhysicsImpostor): void;
  62051. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62052. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62053. isSupported(): boolean;
  62054. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62055. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62056. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62057. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62058. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62059. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62060. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62061. getBodyMass(impostor: PhysicsImpostor): number;
  62062. getBodyFriction(impostor: PhysicsImpostor): number;
  62063. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62064. getBodyRestitution(impostor: PhysicsImpostor): number;
  62065. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62066. sleepBody(impostor: PhysicsImpostor): void;
  62067. wakeUpBody(impostor: PhysicsImpostor): void;
  62068. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62069. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62070. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62071. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62072. getRadius(impostor: PhysicsImpostor): number;
  62073. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62074. dispose(): void;
  62075. /**
  62076. * Does a raycast in the physics world
  62077. * @param from when should the ray start?
  62078. * @param to when should the ray end?
  62079. * @returns PhysicsRaycastResult
  62080. */
  62081. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62082. }
  62083. }
  62084. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62085. import { Nullable } from "babylonjs/types";
  62086. import { Scene } from "babylonjs/scene";
  62087. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62088. import { Color4 } from "babylonjs/Maths/math.color";
  62089. import { Mesh } from "babylonjs/Meshes/mesh";
  62090. /**
  62091. * Class containing static functions to help procedurally build meshes
  62092. */
  62093. export class RibbonBuilder {
  62094. /**
  62095. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62096. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62097. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62098. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62099. * * 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
  62100. * * 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
  62101. * * 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
  62102. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62103. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62104. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62105. * * 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
  62106. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62107. * * 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
  62108. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62110. * @param name defines the name of the mesh
  62111. * @param options defines the options used to create the mesh
  62112. * @param scene defines the hosting scene
  62113. * @returns the ribbon mesh
  62114. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62115. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62116. */
  62117. static CreateRibbon(name: string, options: {
  62118. pathArray: Vector3[][];
  62119. closeArray?: boolean;
  62120. closePath?: boolean;
  62121. offset?: number;
  62122. updatable?: boolean;
  62123. sideOrientation?: number;
  62124. frontUVs?: Vector4;
  62125. backUVs?: Vector4;
  62126. instance?: Mesh;
  62127. invertUV?: boolean;
  62128. uvs?: Vector2[];
  62129. colors?: Color4[];
  62130. }, scene?: Nullable<Scene>): Mesh;
  62131. }
  62132. }
  62133. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62134. import { Nullable } from "babylonjs/types";
  62135. import { Scene } from "babylonjs/scene";
  62136. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62137. import { Mesh } from "babylonjs/Meshes/mesh";
  62138. /**
  62139. * Class containing static functions to help procedurally build meshes
  62140. */
  62141. export class ShapeBuilder {
  62142. /**
  62143. * 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.
  62144. * * 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.
  62145. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62146. * * 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.
  62147. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62148. * * 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
  62149. * * 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
  62150. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62155. * @param name defines the name of the mesh
  62156. * @param options defines the options used to create the mesh
  62157. * @param scene defines the hosting scene
  62158. * @returns the extruded shape mesh
  62159. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62161. */
  62162. static ExtrudeShape(name: string, options: {
  62163. shape: Vector3[];
  62164. path: Vector3[];
  62165. scale?: number;
  62166. rotation?: number;
  62167. cap?: number;
  62168. updatable?: boolean;
  62169. sideOrientation?: number;
  62170. frontUVs?: Vector4;
  62171. backUVs?: Vector4;
  62172. instance?: Mesh;
  62173. invertUV?: boolean;
  62174. }, scene?: Nullable<Scene>): Mesh;
  62175. /**
  62176. * Creates an custom extruded shape mesh.
  62177. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62178. * * 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.
  62179. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62180. * * 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
  62181. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62182. * * 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
  62183. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62184. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62185. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62186. * * 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
  62187. * * 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
  62188. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62191. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62193. * @param name defines the name of the mesh
  62194. * @param options defines the options used to create the mesh
  62195. * @param scene defines the hosting scene
  62196. * @returns the custom extruded shape mesh
  62197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62198. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62199. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62200. */
  62201. static ExtrudeShapeCustom(name: string, options: {
  62202. shape: Vector3[];
  62203. path: Vector3[];
  62204. scaleFunction?: any;
  62205. rotationFunction?: any;
  62206. ribbonCloseArray?: boolean;
  62207. ribbonClosePath?: boolean;
  62208. cap?: number;
  62209. updatable?: boolean;
  62210. sideOrientation?: number;
  62211. frontUVs?: Vector4;
  62212. backUVs?: Vector4;
  62213. instance?: Mesh;
  62214. invertUV?: boolean;
  62215. }, scene?: Nullable<Scene>): Mesh;
  62216. private static _ExtrudeShapeGeneric;
  62217. }
  62218. }
  62219. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62220. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62221. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62222. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62223. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62224. import { Nullable } from "babylonjs/types";
  62225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62226. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62227. /**
  62228. * AmmoJS Physics plugin
  62229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62230. * @see https://github.com/kripken/ammo.js/
  62231. */
  62232. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62233. private _useDeltaForWorldStep;
  62234. /**
  62235. * Reference to the Ammo library
  62236. */
  62237. bjsAMMO: any;
  62238. /**
  62239. * Created ammoJS world which physics bodies are added to
  62240. */
  62241. world: any;
  62242. /**
  62243. * Name of the plugin
  62244. */
  62245. name: string;
  62246. private _timeStep;
  62247. private _fixedTimeStep;
  62248. private _maxSteps;
  62249. private _tmpQuaternion;
  62250. private _tmpAmmoTransform;
  62251. private _tmpAmmoQuaternion;
  62252. private _tmpAmmoConcreteContactResultCallback;
  62253. private _collisionConfiguration;
  62254. private _dispatcher;
  62255. private _overlappingPairCache;
  62256. private _solver;
  62257. private _softBodySolver;
  62258. private _tmpAmmoVectorA;
  62259. private _tmpAmmoVectorB;
  62260. private _tmpAmmoVectorC;
  62261. private _tmpAmmoVectorD;
  62262. private _tmpContactCallbackResult;
  62263. private _tmpAmmoVectorRCA;
  62264. private _tmpAmmoVectorRCB;
  62265. private _raycastResult;
  62266. private static readonly DISABLE_COLLISION_FLAG;
  62267. private static readonly KINEMATIC_FLAG;
  62268. private static readonly DISABLE_DEACTIVATION_FLAG;
  62269. /**
  62270. * Initializes the ammoJS plugin
  62271. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62272. * @param ammoInjection can be used to inject your own ammo reference
  62273. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62274. */
  62275. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62276. /**
  62277. * Sets the gravity of the physics world (m/(s^2))
  62278. * @param gravity Gravity to set
  62279. */
  62280. setGravity(gravity: Vector3): void;
  62281. /**
  62282. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62283. * @param timeStep timestep to use in seconds
  62284. */
  62285. setTimeStep(timeStep: number): void;
  62286. /**
  62287. * 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)
  62288. * @param fixedTimeStep fixedTimeStep to use in seconds
  62289. */
  62290. setFixedTimeStep(fixedTimeStep: number): void;
  62291. /**
  62292. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62293. * @param maxSteps the maximum number of steps by the physics engine per frame
  62294. */
  62295. setMaxSteps(maxSteps: number): void;
  62296. /**
  62297. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62298. * @returns the current timestep in seconds
  62299. */
  62300. getTimeStep(): number;
  62301. /**
  62302. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62303. */
  62304. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62305. private _isImpostorInContact;
  62306. private _isImpostorPairInContact;
  62307. private _stepSimulation;
  62308. /**
  62309. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62310. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62311. * After the step the babylon meshes are set to the position of the physics imposters
  62312. * @param delta amount of time to step forward
  62313. * @param impostors array of imposters to update before/after the step
  62314. */
  62315. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62316. /**
  62317. * Update babylon mesh to match physics world object
  62318. * @param impostor imposter to match
  62319. */
  62320. private _afterSoftStep;
  62321. /**
  62322. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62323. * @param impostor imposter to match
  62324. */
  62325. private _ropeStep;
  62326. /**
  62327. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62328. * @param impostor imposter to match
  62329. */
  62330. private _softbodyOrClothStep;
  62331. private _tmpMatrix;
  62332. /**
  62333. * Applies an impulse on the imposter
  62334. * @param impostor imposter to apply impulse to
  62335. * @param force amount of force to be applied to the imposter
  62336. * @param contactPoint the location to apply the impulse on the imposter
  62337. */
  62338. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62339. /**
  62340. * Applies a force on the imposter
  62341. * @param impostor imposter to apply force
  62342. * @param force amount of force to be applied to the imposter
  62343. * @param contactPoint the location to apply the force on the imposter
  62344. */
  62345. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62346. /**
  62347. * Creates a physics body using the plugin
  62348. * @param impostor the imposter to create the physics body on
  62349. */
  62350. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62351. /**
  62352. * Removes the physics body from the imposter and disposes of the body's memory
  62353. * @param impostor imposter to remove the physics body from
  62354. */
  62355. removePhysicsBody(impostor: PhysicsImpostor): void;
  62356. /**
  62357. * Generates a joint
  62358. * @param impostorJoint the imposter joint to create the joint with
  62359. */
  62360. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62361. /**
  62362. * Removes a joint
  62363. * @param impostorJoint the imposter joint to remove the joint from
  62364. */
  62365. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62366. private _addMeshVerts;
  62367. /**
  62368. * Initialise the soft body vertices to match its object's (mesh) vertices
  62369. * Softbody vertices (nodes) are in world space and to match this
  62370. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62371. * @param impostor to create the softbody for
  62372. */
  62373. private _softVertexData;
  62374. /**
  62375. * Create an impostor's soft body
  62376. * @param impostor to create the softbody for
  62377. */
  62378. private _createSoftbody;
  62379. /**
  62380. * Create cloth for an impostor
  62381. * @param impostor to create the softbody for
  62382. */
  62383. private _createCloth;
  62384. /**
  62385. * Create rope for an impostor
  62386. * @param impostor to create the softbody for
  62387. */
  62388. private _createRope;
  62389. /**
  62390. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62391. * @param impostor to create the custom physics shape for
  62392. */
  62393. private _createCustom;
  62394. private _addHullVerts;
  62395. private _createShape;
  62396. /**
  62397. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62398. * @param impostor imposter containing the physics body and babylon object
  62399. */
  62400. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62401. /**
  62402. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62403. * @param impostor imposter containing the physics body and babylon object
  62404. * @param newPosition new position
  62405. * @param newRotation new rotation
  62406. */
  62407. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62408. /**
  62409. * If this plugin is supported
  62410. * @returns true if its supported
  62411. */
  62412. isSupported(): boolean;
  62413. /**
  62414. * Sets the linear velocity of the physics body
  62415. * @param impostor imposter to set the velocity on
  62416. * @param velocity velocity to set
  62417. */
  62418. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62419. /**
  62420. * Sets the angular velocity of the physics body
  62421. * @param impostor imposter to set the velocity on
  62422. * @param velocity velocity to set
  62423. */
  62424. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62425. /**
  62426. * gets the linear velocity
  62427. * @param impostor imposter to get linear velocity from
  62428. * @returns linear velocity
  62429. */
  62430. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62431. /**
  62432. * gets the angular velocity
  62433. * @param impostor imposter to get angular velocity from
  62434. * @returns angular velocity
  62435. */
  62436. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62437. /**
  62438. * Sets the mass of physics body
  62439. * @param impostor imposter to set the mass on
  62440. * @param mass mass to set
  62441. */
  62442. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62443. /**
  62444. * Gets the mass of the physics body
  62445. * @param impostor imposter to get the mass from
  62446. * @returns mass
  62447. */
  62448. getBodyMass(impostor: PhysicsImpostor): number;
  62449. /**
  62450. * Gets friction of the impostor
  62451. * @param impostor impostor to get friction from
  62452. * @returns friction value
  62453. */
  62454. getBodyFriction(impostor: PhysicsImpostor): number;
  62455. /**
  62456. * Sets friction of the impostor
  62457. * @param impostor impostor to set friction on
  62458. * @param friction friction value
  62459. */
  62460. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62461. /**
  62462. * Gets restitution of the impostor
  62463. * @param impostor impostor to get restitution from
  62464. * @returns restitution value
  62465. */
  62466. getBodyRestitution(impostor: PhysicsImpostor): number;
  62467. /**
  62468. * Sets resitution of the impostor
  62469. * @param impostor impostor to set resitution on
  62470. * @param restitution resitution value
  62471. */
  62472. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62473. /**
  62474. * Gets pressure inside the impostor
  62475. * @param impostor impostor to get pressure from
  62476. * @returns pressure value
  62477. */
  62478. getBodyPressure(impostor: PhysicsImpostor): number;
  62479. /**
  62480. * Sets pressure inside a soft body impostor
  62481. * Cloth and rope must remain 0 pressure
  62482. * @param impostor impostor to set pressure on
  62483. * @param pressure pressure value
  62484. */
  62485. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62486. /**
  62487. * Gets stiffness of the impostor
  62488. * @param impostor impostor to get stiffness from
  62489. * @returns pressure value
  62490. */
  62491. getBodyStiffness(impostor: PhysicsImpostor): number;
  62492. /**
  62493. * Sets stiffness of the impostor
  62494. * @param impostor impostor to set stiffness on
  62495. * @param stiffness stiffness value from 0 to 1
  62496. */
  62497. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62498. /**
  62499. * Gets velocityIterations of the impostor
  62500. * @param impostor impostor to get velocity iterations from
  62501. * @returns velocityIterations value
  62502. */
  62503. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62504. /**
  62505. * Sets velocityIterations of the impostor
  62506. * @param impostor impostor to set velocity iterations on
  62507. * @param velocityIterations velocityIterations value
  62508. */
  62509. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62510. /**
  62511. * Gets positionIterations of the impostor
  62512. * @param impostor impostor to get position iterations from
  62513. * @returns positionIterations value
  62514. */
  62515. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62516. /**
  62517. * Sets positionIterations of the impostor
  62518. * @param impostor impostor to set position on
  62519. * @param positionIterations positionIterations value
  62520. */
  62521. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62522. /**
  62523. * Append an anchor to a cloth object
  62524. * @param impostor is the cloth impostor to add anchor to
  62525. * @param otherImpostor is the rigid impostor to anchor to
  62526. * @param width ratio across width from 0 to 1
  62527. * @param height ratio up height from 0 to 1
  62528. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62529. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62530. */
  62531. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62532. /**
  62533. * Append an hook to a rope object
  62534. * @param impostor is the rope impostor to add hook to
  62535. * @param otherImpostor is the rigid impostor to hook to
  62536. * @param length ratio along the rope from 0 to 1
  62537. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62538. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62539. */
  62540. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62541. /**
  62542. * Sleeps the physics body and stops it from being active
  62543. * @param impostor impostor to sleep
  62544. */
  62545. sleepBody(impostor: PhysicsImpostor): void;
  62546. /**
  62547. * Activates the physics body
  62548. * @param impostor impostor to activate
  62549. */
  62550. wakeUpBody(impostor: PhysicsImpostor): void;
  62551. /**
  62552. * Updates the distance parameters of the joint
  62553. * @param joint joint to update
  62554. * @param maxDistance maximum distance of the joint
  62555. * @param minDistance minimum distance of the joint
  62556. */
  62557. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62558. /**
  62559. * Sets a motor on the joint
  62560. * @param joint joint to set motor on
  62561. * @param speed speed of the motor
  62562. * @param maxForce maximum force of the motor
  62563. * @param motorIndex index of the motor
  62564. */
  62565. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62566. /**
  62567. * Sets the motors limit
  62568. * @param joint joint to set limit on
  62569. * @param upperLimit upper limit
  62570. * @param lowerLimit lower limit
  62571. */
  62572. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62573. /**
  62574. * Syncs the position and rotation of a mesh with the impostor
  62575. * @param mesh mesh to sync
  62576. * @param impostor impostor to update the mesh with
  62577. */
  62578. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62579. /**
  62580. * Gets the radius of the impostor
  62581. * @param impostor impostor to get radius from
  62582. * @returns the radius
  62583. */
  62584. getRadius(impostor: PhysicsImpostor): number;
  62585. /**
  62586. * Gets the box size of the impostor
  62587. * @param impostor impostor to get box size from
  62588. * @param result the resulting box size
  62589. */
  62590. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62591. /**
  62592. * Disposes of the impostor
  62593. */
  62594. dispose(): void;
  62595. /**
  62596. * Does a raycast in the physics world
  62597. * @param from when should the ray start?
  62598. * @param to when should the ray end?
  62599. * @returns PhysicsRaycastResult
  62600. */
  62601. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62602. }
  62603. }
  62604. declare module "babylonjs/Probes/reflectionProbe" {
  62605. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62606. import { Vector3 } from "babylonjs/Maths/math.vector";
  62607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62608. import { Nullable } from "babylonjs/types";
  62609. import { Scene } from "babylonjs/scene";
  62610. module "babylonjs/abstractScene" {
  62611. interface AbstractScene {
  62612. /**
  62613. * The list of reflection probes added to the scene
  62614. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62615. */
  62616. reflectionProbes: Array<ReflectionProbe>;
  62617. /**
  62618. * Removes the given reflection probe from this scene.
  62619. * @param toRemove The reflection probe to remove
  62620. * @returns The index of the removed reflection probe
  62621. */
  62622. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62623. /**
  62624. * Adds the given reflection probe to this scene.
  62625. * @param newReflectionProbe The reflection probe to add
  62626. */
  62627. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62628. }
  62629. }
  62630. /**
  62631. * Class used to generate realtime reflection / refraction cube textures
  62632. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62633. */
  62634. export class ReflectionProbe {
  62635. /** defines the name of the probe */
  62636. name: string;
  62637. private _scene;
  62638. private _renderTargetTexture;
  62639. private _projectionMatrix;
  62640. private _viewMatrix;
  62641. private _target;
  62642. private _add;
  62643. private _attachedMesh;
  62644. private _invertYAxis;
  62645. /** Gets or sets probe position (center of the cube map) */
  62646. position: Vector3;
  62647. /**
  62648. * Creates a new reflection probe
  62649. * @param name defines the name of the probe
  62650. * @param size defines the texture resolution (for each face)
  62651. * @param scene defines the hosting scene
  62652. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62653. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62654. */
  62655. constructor(
  62656. /** defines the name of the probe */
  62657. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62658. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62659. get samples(): number;
  62660. set samples(value: number);
  62661. /** Gets or sets the refresh rate to use (on every frame by default) */
  62662. get refreshRate(): number;
  62663. set refreshRate(value: number);
  62664. /**
  62665. * Gets the hosting scene
  62666. * @returns a Scene
  62667. */
  62668. getScene(): Scene;
  62669. /** Gets the internal CubeTexture used to render to */
  62670. get cubeTexture(): RenderTargetTexture;
  62671. /** Gets the list of meshes to render */
  62672. get renderList(): Nullable<AbstractMesh[]>;
  62673. /**
  62674. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62675. * @param mesh defines the mesh to attach to
  62676. */
  62677. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62678. /**
  62679. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62680. * @param renderingGroupId The rendering group id corresponding to its index
  62681. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62682. */
  62683. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62684. /**
  62685. * Clean all associated resources
  62686. */
  62687. dispose(): void;
  62688. /**
  62689. * Converts the reflection probe information to a readable string for debug purpose.
  62690. * @param fullDetails Supports for multiple levels of logging within scene loading
  62691. * @returns the human readable reflection probe info
  62692. */
  62693. toString(fullDetails?: boolean): string;
  62694. /**
  62695. * Get the class name of the relfection probe.
  62696. * @returns "ReflectionProbe"
  62697. */
  62698. getClassName(): string;
  62699. /**
  62700. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62701. * @returns The JSON representation of the texture
  62702. */
  62703. serialize(): any;
  62704. /**
  62705. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62706. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62707. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62708. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62709. * @returns The parsed reflection probe if successful
  62710. */
  62711. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62712. }
  62713. }
  62714. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  62715. /** @hidden */
  62716. export var _BabylonLoaderRegistered: boolean;
  62717. /**
  62718. * Helps setting up some configuration for the babylon file loader.
  62719. */
  62720. export class BabylonFileLoaderConfiguration {
  62721. /**
  62722. * The loader does not allow injecting custom physix engine into the plugins.
  62723. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62724. * So you could set this variable to your engine import to make it work.
  62725. */
  62726. static LoaderInjectedPhysicsEngine: any;
  62727. }
  62728. }
  62729. declare module "babylonjs/Loading/Plugins/index" {
  62730. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  62731. }
  62732. declare module "babylonjs/Loading/index" {
  62733. export * from "babylonjs/Loading/loadingScreen";
  62734. export * from "babylonjs/Loading/Plugins/index";
  62735. export * from "babylonjs/Loading/sceneLoader";
  62736. export * from "babylonjs/Loading/sceneLoaderFlags";
  62737. }
  62738. declare module "babylonjs/Materials/Background/index" {
  62739. export * from "babylonjs/Materials/Background/backgroundMaterial";
  62740. }
  62741. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  62742. import { Scene } from "babylonjs/scene";
  62743. import { Color3 } from "babylonjs/Maths/math.color";
  62744. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62745. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62746. /**
  62747. * The Physically based simple base material of BJS.
  62748. *
  62749. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62750. * It is used as the base class for both the specGloss and metalRough conventions.
  62751. */
  62752. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62753. /**
  62754. * Number of Simultaneous lights allowed on the material.
  62755. */
  62756. maxSimultaneousLights: number;
  62757. /**
  62758. * If sets to true, disables all the lights affecting the material.
  62759. */
  62760. disableLighting: boolean;
  62761. /**
  62762. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62763. */
  62764. environmentTexture: BaseTexture;
  62765. /**
  62766. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62767. */
  62768. invertNormalMapX: boolean;
  62769. /**
  62770. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62771. */
  62772. invertNormalMapY: boolean;
  62773. /**
  62774. * Normal map used in the model.
  62775. */
  62776. normalTexture: BaseTexture;
  62777. /**
  62778. * Emissivie color used to self-illuminate the model.
  62779. */
  62780. emissiveColor: Color3;
  62781. /**
  62782. * Emissivie texture used to self-illuminate the model.
  62783. */
  62784. emissiveTexture: BaseTexture;
  62785. /**
  62786. * Occlusion Channel Strenght.
  62787. */
  62788. occlusionStrength: number;
  62789. /**
  62790. * Occlusion Texture of the material (adding extra occlusion effects).
  62791. */
  62792. occlusionTexture: BaseTexture;
  62793. /**
  62794. * Defines the alpha limits in alpha test mode.
  62795. */
  62796. alphaCutOff: number;
  62797. /**
  62798. * Gets the current double sided mode.
  62799. */
  62800. get doubleSided(): boolean;
  62801. /**
  62802. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62803. */
  62804. set doubleSided(value: boolean);
  62805. /**
  62806. * Stores the pre-calculated light information of a mesh in a texture.
  62807. */
  62808. lightmapTexture: BaseTexture;
  62809. /**
  62810. * If true, the light map contains occlusion information instead of lighting info.
  62811. */
  62812. useLightmapAsShadowmap: boolean;
  62813. /**
  62814. * Instantiates a new PBRMaterial instance.
  62815. *
  62816. * @param name The material name
  62817. * @param scene The scene the material will be use in.
  62818. */
  62819. constructor(name: string, scene: Scene);
  62820. getClassName(): string;
  62821. }
  62822. }
  62823. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  62824. import { Scene } from "babylonjs/scene";
  62825. import { Color3 } from "babylonjs/Maths/math.color";
  62826. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62827. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62828. /**
  62829. * The PBR material of BJS following the metal roughness convention.
  62830. *
  62831. * This fits to the PBR convention in the GLTF definition:
  62832. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62833. */
  62834. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62835. /**
  62836. * The base color has two different interpretations depending on the value of metalness.
  62837. * When the material is a metal, the base color is the specific measured reflectance value
  62838. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62839. * of the material.
  62840. */
  62841. baseColor: Color3;
  62842. /**
  62843. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62844. * well as opacity information in the alpha channel.
  62845. */
  62846. baseTexture: BaseTexture;
  62847. /**
  62848. * Specifies the metallic scalar value of the material.
  62849. * Can also be used to scale the metalness values of the metallic texture.
  62850. */
  62851. metallic: number;
  62852. /**
  62853. * Specifies the roughness scalar value of the material.
  62854. * Can also be used to scale the roughness values of the metallic texture.
  62855. */
  62856. roughness: number;
  62857. /**
  62858. * Texture containing both the metallic value in the B channel and the
  62859. * roughness value in the G channel to keep better precision.
  62860. */
  62861. metallicRoughnessTexture: BaseTexture;
  62862. /**
  62863. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62864. *
  62865. * @param name The material name
  62866. * @param scene The scene the material will be use in.
  62867. */
  62868. constructor(name: string, scene: Scene);
  62869. /**
  62870. * Return the currrent class name of the material.
  62871. */
  62872. getClassName(): string;
  62873. /**
  62874. * Makes a duplicate of the current material.
  62875. * @param name - name to use for the new material.
  62876. */
  62877. clone(name: string): PBRMetallicRoughnessMaterial;
  62878. /**
  62879. * Serialize the material to a parsable JSON object.
  62880. */
  62881. serialize(): any;
  62882. /**
  62883. * Parses a JSON object correponding to the serialize function.
  62884. */
  62885. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62886. }
  62887. }
  62888. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  62889. import { Scene } from "babylonjs/scene";
  62890. import { Color3 } from "babylonjs/Maths/math.color";
  62891. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62892. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62893. /**
  62894. * The PBR material of BJS following the specular glossiness convention.
  62895. *
  62896. * This fits to the PBR convention in the GLTF definition:
  62897. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62898. */
  62899. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62900. /**
  62901. * Specifies the diffuse color of the material.
  62902. */
  62903. diffuseColor: Color3;
  62904. /**
  62905. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62906. * channel.
  62907. */
  62908. diffuseTexture: BaseTexture;
  62909. /**
  62910. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62911. */
  62912. specularColor: Color3;
  62913. /**
  62914. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62915. */
  62916. glossiness: number;
  62917. /**
  62918. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62919. */
  62920. specularGlossinessTexture: BaseTexture;
  62921. /**
  62922. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62923. *
  62924. * @param name The material name
  62925. * @param scene The scene the material will be use in.
  62926. */
  62927. constructor(name: string, scene: Scene);
  62928. /**
  62929. * Return the currrent class name of the material.
  62930. */
  62931. getClassName(): string;
  62932. /**
  62933. * Makes a duplicate of the current material.
  62934. * @param name - name to use for the new material.
  62935. */
  62936. clone(name: string): PBRSpecularGlossinessMaterial;
  62937. /**
  62938. * Serialize the material to a parsable JSON object.
  62939. */
  62940. serialize(): any;
  62941. /**
  62942. * Parses a JSON object correponding to the serialize function.
  62943. */
  62944. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62945. }
  62946. }
  62947. declare module "babylonjs/Materials/PBR/index" {
  62948. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  62949. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  62950. export * from "babylonjs/Materials/PBR/pbrMaterial";
  62951. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  62952. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  62953. }
  62954. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  62955. import { Nullable } from "babylonjs/types";
  62956. import { Scene } from "babylonjs/scene";
  62957. import { Matrix } from "babylonjs/Maths/math.vector";
  62958. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62959. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62960. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62961. /**
  62962. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62963. * It can help converting any input color in a desired output one. This can then be used to create effects
  62964. * from sepia, black and white to sixties or futuristic rendering...
  62965. *
  62966. * The only supported format is currently 3dl.
  62967. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62968. */
  62969. export class ColorGradingTexture extends BaseTexture {
  62970. /**
  62971. * The texture URL.
  62972. */
  62973. url: string;
  62974. /**
  62975. * Empty line regex stored for GC.
  62976. */
  62977. private static _noneEmptyLineRegex;
  62978. private _textureMatrix;
  62979. private _onLoad;
  62980. /**
  62981. * Instantiates a ColorGradingTexture from the following parameters.
  62982. *
  62983. * @param url The location of the color gradind data (currently only supporting 3dl)
  62984. * @param sceneOrEngine The scene or engine the texture will be used in
  62985. * @param onLoad defines a callback triggered when the texture has been loaded
  62986. */
  62987. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62988. /**
  62989. * Fires the onload event from the constructor if requested.
  62990. */
  62991. private _triggerOnLoad;
  62992. /**
  62993. * Returns the texture matrix used in most of the material.
  62994. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62995. */
  62996. getTextureMatrix(): Matrix;
  62997. /**
  62998. * Occurs when the file being loaded is a .3dl LUT file.
  62999. */
  63000. private load3dlTexture;
  63001. /**
  63002. * Starts the loading process of the texture.
  63003. */
  63004. private loadTexture;
  63005. /**
  63006. * Clones the color gradind texture.
  63007. */
  63008. clone(): ColorGradingTexture;
  63009. /**
  63010. * Called during delayed load for textures.
  63011. */
  63012. delayLoad(): void;
  63013. /**
  63014. * Parses a color grading texture serialized by Babylon.
  63015. * @param parsedTexture The texture information being parsedTexture
  63016. * @param scene The scene to load the texture in
  63017. * @param rootUrl The root url of the data assets to load
  63018. * @return A color gradind texture
  63019. */
  63020. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63021. /**
  63022. * Serializes the LUT texture to json format.
  63023. */
  63024. serialize(): any;
  63025. }
  63026. }
  63027. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63028. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63029. import { Scene } from "babylonjs/scene";
  63030. import { Nullable } from "babylonjs/types";
  63031. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63032. /**
  63033. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63034. */
  63035. export class EquiRectangularCubeTexture extends BaseTexture {
  63036. /** The six faces of the cube. */
  63037. private static _FacesMapping;
  63038. private _noMipmap;
  63039. private _onLoad;
  63040. private _onError;
  63041. /** The size of the cubemap. */
  63042. private _size;
  63043. /** The buffer of the image. */
  63044. private _buffer;
  63045. /** The width of the input image. */
  63046. private _width;
  63047. /** The height of the input image. */
  63048. private _height;
  63049. /** The URL to the image. */
  63050. url: string;
  63051. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63052. coordinatesMode: number;
  63053. /**
  63054. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63055. * @param url The location of the image
  63056. * @param scene The scene the texture will be used in
  63057. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63058. * @param noMipmap Forces to not generate the mipmap if true
  63059. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63060. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63061. * @param onLoad — defines a callback called when texture is loaded
  63062. * @param onError — defines a callback called if there is an error
  63063. */
  63064. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63065. /**
  63066. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63067. */
  63068. private loadImage;
  63069. /**
  63070. * Convert the image buffer into a cubemap and create a CubeTexture.
  63071. */
  63072. private loadTexture;
  63073. /**
  63074. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63075. * @param buffer The ArrayBuffer that should be converted.
  63076. * @returns The buffer as Float32Array.
  63077. */
  63078. private getFloat32ArrayFromArrayBuffer;
  63079. /**
  63080. * Get the current class name of the texture useful for serialization or dynamic coding.
  63081. * @returns "EquiRectangularCubeTexture"
  63082. */
  63083. getClassName(): string;
  63084. /**
  63085. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63086. * @returns A clone of the current EquiRectangularCubeTexture.
  63087. */
  63088. clone(): EquiRectangularCubeTexture;
  63089. }
  63090. }
  63091. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63092. import { Nullable } from "babylonjs/types";
  63093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63094. import { Matrix } from "babylonjs/Maths/math.vector";
  63095. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63096. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63097. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63098. import { Scene } from "babylonjs/scene";
  63099. /**
  63100. * Defines the options related to the creation of an HtmlElementTexture
  63101. */
  63102. export interface IHtmlElementTextureOptions {
  63103. /**
  63104. * Defines wether mip maps should be created or not.
  63105. */
  63106. generateMipMaps?: boolean;
  63107. /**
  63108. * Defines the sampling mode of the texture.
  63109. */
  63110. samplingMode?: number;
  63111. /**
  63112. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63113. */
  63114. engine: Nullable<ThinEngine>;
  63115. /**
  63116. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63117. */
  63118. scene: Nullable<Scene>;
  63119. }
  63120. /**
  63121. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63122. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63123. * is automatically managed.
  63124. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63125. * in your application.
  63126. *
  63127. * As the update is not automatic, you need to call them manually.
  63128. */
  63129. export class HtmlElementTexture extends BaseTexture {
  63130. /**
  63131. * The texture URL.
  63132. */
  63133. element: HTMLVideoElement | HTMLCanvasElement;
  63134. private static readonly DefaultOptions;
  63135. private _textureMatrix;
  63136. private _isVideo;
  63137. private _generateMipMaps;
  63138. private _samplingMode;
  63139. /**
  63140. * Instantiates a HtmlElementTexture from the following parameters.
  63141. *
  63142. * @param name Defines the name of the texture
  63143. * @param element Defines the video or canvas the texture is filled with
  63144. * @param options Defines the other none mandatory texture creation options
  63145. */
  63146. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63147. private _createInternalTexture;
  63148. /**
  63149. * Returns the texture matrix used in most of the material.
  63150. */
  63151. getTextureMatrix(): Matrix;
  63152. /**
  63153. * Updates the content of the texture.
  63154. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63155. */
  63156. update(invertY?: Nullable<boolean>): void;
  63157. }
  63158. }
  63159. declare module "babylonjs/Misc/tga" {
  63160. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63161. /**
  63162. * Based on jsTGALoader - Javascript loader for TGA file
  63163. * By Vincent Thibault
  63164. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63165. */
  63166. export class TGATools {
  63167. private static _TYPE_INDEXED;
  63168. private static _TYPE_RGB;
  63169. private static _TYPE_GREY;
  63170. private static _TYPE_RLE_INDEXED;
  63171. private static _TYPE_RLE_RGB;
  63172. private static _TYPE_RLE_GREY;
  63173. private static _ORIGIN_MASK;
  63174. private static _ORIGIN_SHIFT;
  63175. private static _ORIGIN_BL;
  63176. private static _ORIGIN_BR;
  63177. private static _ORIGIN_UL;
  63178. private static _ORIGIN_UR;
  63179. /**
  63180. * Gets the header of a TGA file
  63181. * @param data defines the TGA data
  63182. * @returns the header
  63183. */
  63184. static GetTGAHeader(data: Uint8Array): any;
  63185. /**
  63186. * Uploads TGA content to a Babylon Texture
  63187. * @hidden
  63188. */
  63189. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63190. /** @hidden */
  63191. 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;
  63192. /** @hidden */
  63193. 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;
  63194. /** @hidden */
  63195. 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;
  63196. /** @hidden */
  63197. 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;
  63198. /** @hidden */
  63199. 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;
  63200. /** @hidden */
  63201. 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;
  63202. }
  63203. }
  63204. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63205. import { Nullable } from "babylonjs/types";
  63206. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63207. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63208. /**
  63209. * Implementation of the TGA Texture Loader.
  63210. * @hidden
  63211. */
  63212. export class _TGATextureLoader implements IInternalTextureLoader {
  63213. /**
  63214. * Defines wether the loader supports cascade loading the different faces.
  63215. */
  63216. readonly supportCascades: boolean;
  63217. /**
  63218. * This returns if the loader support the current file information.
  63219. * @param extension defines the file extension of the file being loaded
  63220. * @returns true if the loader can load the specified file
  63221. */
  63222. canLoad(extension: string): boolean;
  63223. /**
  63224. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63225. * @param data contains the texture data
  63226. * @param texture defines the BabylonJS internal texture
  63227. * @param createPolynomials will be true if polynomials have been requested
  63228. * @param onLoad defines the callback to trigger once the texture is ready
  63229. * @param onError defines the callback to trigger in case of error
  63230. */
  63231. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63232. /**
  63233. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63234. * @param data contains the texture data
  63235. * @param texture defines the BabylonJS internal texture
  63236. * @param callback defines the method to call once ready to upload
  63237. */
  63238. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63239. }
  63240. }
  63241. declare module "babylonjs/Misc/basis" {
  63242. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63243. /**
  63244. * Info about the .basis files
  63245. */
  63246. class BasisFileInfo {
  63247. /**
  63248. * If the file has alpha
  63249. */
  63250. hasAlpha: boolean;
  63251. /**
  63252. * Info about each image of the basis file
  63253. */
  63254. images: Array<{
  63255. levels: Array<{
  63256. width: number;
  63257. height: number;
  63258. transcodedPixels: ArrayBufferView;
  63259. }>;
  63260. }>;
  63261. }
  63262. /**
  63263. * Result of transcoding a basis file
  63264. */
  63265. class TranscodeResult {
  63266. /**
  63267. * Info about the .basis file
  63268. */
  63269. fileInfo: BasisFileInfo;
  63270. /**
  63271. * Format to use when loading the file
  63272. */
  63273. format: number;
  63274. }
  63275. /**
  63276. * Configuration options for the Basis transcoder
  63277. */
  63278. export class BasisTranscodeConfiguration {
  63279. /**
  63280. * Supported compression formats used to determine the supported output format of the transcoder
  63281. */
  63282. supportedCompressionFormats?: {
  63283. /**
  63284. * etc1 compression format
  63285. */
  63286. etc1?: boolean;
  63287. /**
  63288. * s3tc compression format
  63289. */
  63290. s3tc?: boolean;
  63291. /**
  63292. * pvrtc compression format
  63293. */
  63294. pvrtc?: boolean;
  63295. /**
  63296. * etc2 compression format
  63297. */
  63298. etc2?: boolean;
  63299. };
  63300. /**
  63301. * If mipmap levels should be loaded for transcoded images (Default: true)
  63302. */
  63303. loadMipmapLevels?: boolean;
  63304. /**
  63305. * Index of a single image to load (Default: all images)
  63306. */
  63307. loadSingleImage?: number;
  63308. }
  63309. /**
  63310. * Used to load .Basis files
  63311. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63312. */
  63313. export class BasisTools {
  63314. private static _IgnoreSupportedFormats;
  63315. /**
  63316. * URL to use when loading the basis transcoder
  63317. */
  63318. static JSModuleURL: string;
  63319. /**
  63320. * URL to use when loading the wasm module for the transcoder
  63321. */
  63322. static WasmModuleURL: string;
  63323. /**
  63324. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63325. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63326. * @returns internal format corresponding to the Basis format
  63327. */
  63328. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63329. private static _WorkerPromise;
  63330. private static _Worker;
  63331. private static _actionId;
  63332. private static _CreateWorkerAsync;
  63333. /**
  63334. * Transcodes a loaded image file to compressed pixel data
  63335. * @param data image data to transcode
  63336. * @param config configuration options for the transcoding
  63337. * @returns a promise resulting in the transcoded image
  63338. */
  63339. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63340. /**
  63341. * Loads a texture from the transcode result
  63342. * @param texture texture load to
  63343. * @param transcodeResult the result of transcoding the basis file to load from
  63344. */
  63345. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63346. }
  63347. }
  63348. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63349. import { Nullable } from "babylonjs/types";
  63350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63351. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63352. /**
  63353. * Loader for .basis file format
  63354. */
  63355. export class _BasisTextureLoader implements IInternalTextureLoader {
  63356. /**
  63357. * Defines whether the loader supports cascade loading the different faces.
  63358. */
  63359. readonly supportCascades: boolean;
  63360. /**
  63361. * This returns if the loader support the current file information.
  63362. * @param extension defines the file extension of the file being loaded
  63363. * @returns true if the loader can load the specified file
  63364. */
  63365. canLoad(extension: string): boolean;
  63366. /**
  63367. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63368. * @param data contains the texture data
  63369. * @param texture defines the BabylonJS internal texture
  63370. * @param createPolynomials will be true if polynomials have been requested
  63371. * @param onLoad defines the callback to trigger once the texture is ready
  63372. * @param onError defines the callback to trigger in case of error
  63373. */
  63374. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63375. /**
  63376. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63377. * @param data contains the texture data
  63378. * @param texture defines the BabylonJS internal texture
  63379. * @param callback defines the method to call once ready to upload
  63380. */
  63381. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63382. }
  63383. }
  63384. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63385. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63386. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63387. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63388. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63389. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63390. }
  63391. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63392. import { Vector2 } from "babylonjs/Maths/math.vector";
  63393. /**
  63394. * Defines the basic options interface of a TexturePacker Frame
  63395. */
  63396. export interface ITexturePackerFrame {
  63397. /**
  63398. * The frame ID
  63399. */
  63400. id: number;
  63401. /**
  63402. * The frames Scale
  63403. */
  63404. scale: Vector2;
  63405. /**
  63406. * The Frames offset
  63407. */
  63408. offset: Vector2;
  63409. }
  63410. /**
  63411. * This is a support class for frame Data on texture packer sets.
  63412. */
  63413. export class TexturePackerFrame implements ITexturePackerFrame {
  63414. /**
  63415. * The frame ID
  63416. */
  63417. id: number;
  63418. /**
  63419. * The frames Scale
  63420. */
  63421. scale: Vector2;
  63422. /**
  63423. * The Frames offset
  63424. */
  63425. offset: Vector2;
  63426. /**
  63427. * Initializes a texture package frame.
  63428. * @param id The numerical frame identifier
  63429. * @param scale Scalar Vector2 for UV frame
  63430. * @param offset Vector2 for the frame position in UV units.
  63431. * @returns TexturePackerFrame
  63432. */
  63433. constructor(id: number, scale: Vector2, offset: Vector2);
  63434. }
  63435. }
  63436. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63438. import { Scene } from "babylonjs/scene";
  63439. import { Nullable } from "babylonjs/types";
  63440. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63441. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63442. /**
  63443. * Defines the basic options interface of a TexturePacker
  63444. */
  63445. export interface ITexturePackerOptions {
  63446. /**
  63447. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63448. */
  63449. map?: string[];
  63450. /**
  63451. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63452. */
  63453. uvsIn?: string;
  63454. /**
  63455. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63456. */
  63457. uvsOut?: string;
  63458. /**
  63459. * number representing the layout style. Defaults to LAYOUT_STRIP
  63460. */
  63461. layout?: number;
  63462. /**
  63463. * number of columns if using custom column count layout(2). This defaults to 4.
  63464. */
  63465. colnum?: number;
  63466. /**
  63467. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63468. */
  63469. updateInputMeshes?: boolean;
  63470. /**
  63471. * boolean flag to dispose all the source textures. Defaults to true.
  63472. */
  63473. disposeSources?: boolean;
  63474. /**
  63475. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63476. */
  63477. fillBlanks?: boolean;
  63478. /**
  63479. * string value representing the context fill style color. Defaults to 'black'.
  63480. */
  63481. customFillColor?: string;
  63482. /**
  63483. * Width and Height Value of each Frame in the TexturePacker Sets
  63484. */
  63485. frameSize?: number;
  63486. /**
  63487. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63488. */
  63489. paddingRatio?: number;
  63490. /**
  63491. * Number that declares the fill method for the padding gutter.
  63492. */
  63493. paddingMode?: number;
  63494. /**
  63495. * If in SUBUV_COLOR padding mode what color to use.
  63496. */
  63497. paddingColor?: Color3 | Color4;
  63498. }
  63499. /**
  63500. * Defines the basic interface of a TexturePacker JSON File
  63501. */
  63502. export interface ITexturePackerJSON {
  63503. /**
  63504. * The frame ID
  63505. */
  63506. name: string;
  63507. /**
  63508. * The base64 channel data
  63509. */
  63510. sets: any;
  63511. /**
  63512. * The options of the Packer
  63513. */
  63514. options: ITexturePackerOptions;
  63515. /**
  63516. * The frame data of the Packer
  63517. */
  63518. frames: Array<number>;
  63519. }
  63520. /**
  63521. * This is a support class that generates a series of packed texture sets.
  63522. * @see https://doc.babylonjs.com/babylon101/materials
  63523. */
  63524. export class TexturePacker {
  63525. /** Packer Layout Constant 0 */
  63526. static readonly LAYOUT_STRIP: number;
  63527. /** Packer Layout Constant 1 */
  63528. static readonly LAYOUT_POWER2: number;
  63529. /** Packer Layout Constant 2 */
  63530. static readonly LAYOUT_COLNUM: number;
  63531. /** Packer Layout Constant 0 */
  63532. static readonly SUBUV_WRAP: number;
  63533. /** Packer Layout Constant 1 */
  63534. static readonly SUBUV_EXTEND: number;
  63535. /** Packer Layout Constant 2 */
  63536. static readonly SUBUV_COLOR: number;
  63537. /** The Name of the Texture Package */
  63538. name: string;
  63539. /** The scene scope of the TexturePacker */
  63540. scene: Scene;
  63541. /** The Meshes to target */
  63542. meshes: AbstractMesh[];
  63543. /** Arguments passed with the Constructor */
  63544. options: ITexturePackerOptions;
  63545. /** The promise that is started upon initialization */
  63546. promise: Nullable<Promise<TexturePacker | string>>;
  63547. /** The Container object for the channel sets that are generated */
  63548. sets: object;
  63549. /** The Container array for the frames that are generated */
  63550. frames: TexturePackerFrame[];
  63551. /** The expected number of textures the system is parsing. */
  63552. private _expecting;
  63553. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63554. private _paddingValue;
  63555. /**
  63556. * Initializes a texture package series from an array of meshes or a single mesh.
  63557. * @param name The name of the package
  63558. * @param meshes The target meshes to compose the package from
  63559. * @param options The arguments that texture packer should follow while building.
  63560. * @param scene The scene which the textures are scoped to.
  63561. * @returns TexturePacker
  63562. */
  63563. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63564. /**
  63565. * Starts the package process
  63566. * @param resolve The promises resolution function
  63567. * @returns TexturePacker
  63568. */
  63569. private _createFrames;
  63570. /**
  63571. * Calculates the Size of the Channel Sets
  63572. * @returns Vector2
  63573. */
  63574. private _calculateSize;
  63575. /**
  63576. * Calculates the UV data for the frames.
  63577. * @param baseSize the base frameSize
  63578. * @param padding the base frame padding
  63579. * @param dtSize size of the Dynamic Texture for that channel
  63580. * @param dtUnits is 1/dtSize
  63581. * @param update flag to update the input meshes
  63582. */
  63583. private _calculateMeshUVFrames;
  63584. /**
  63585. * Calculates the frames Offset.
  63586. * @param index of the frame
  63587. * @returns Vector2
  63588. */
  63589. private _getFrameOffset;
  63590. /**
  63591. * Updates a Mesh to the frame data
  63592. * @param mesh that is the target
  63593. * @param frameID or the frame index
  63594. */
  63595. private _updateMeshUV;
  63596. /**
  63597. * Updates a Meshes materials to use the texture packer channels
  63598. * @param m is the mesh to target
  63599. * @param force all channels on the packer to be set.
  63600. */
  63601. private _updateTextureReferences;
  63602. /**
  63603. * Public method to set a Mesh to a frame
  63604. * @param m that is the target
  63605. * @param frameID or the frame index
  63606. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63607. */
  63608. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63609. /**
  63610. * Starts the async promise to compile the texture packer.
  63611. * @returns Promise<void>
  63612. */
  63613. processAsync(): Promise<void>;
  63614. /**
  63615. * Disposes all textures associated with this packer
  63616. */
  63617. dispose(): void;
  63618. /**
  63619. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63620. * @param imageType is the image type to use.
  63621. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63622. */
  63623. download(imageType?: string, quality?: number): void;
  63624. /**
  63625. * Public method to load a texturePacker JSON file.
  63626. * @param data of the JSON file in string format.
  63627. */
  63628. updateFromJSON(data: string): void;
  63629. }
  63630. }
  63631. declare module "babylonjs/Materials/Textures/Packer/index" {
  63632. export * from "babylonjs/Materials/Textures/Packer/packer";
  63633. export * from "babylonjs/Materials/Textures/Packer/frame";
  63634. }
  63635. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63636. import { Scene } from "babylonjs/scene";
  63637. import { Texture } from "babylonjs/Materials/Textures/texture";
  63638. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63639. /**
  63640. * 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.
  63641. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63642. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63643. */
  63644. export class CustomProceduralTexture extends ProceduralTexture {
  63645. private _animate;
  63646. private _time;
  63647. private _config;
  63648. private _texturePath;
  63649. /**
  63650. * Instantiates a new Custom Procedural Texture.
  63651. * 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.
  63652. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63653. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63654. * @param name Define the name of the texture
  63655. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63656. * @param size Define the size of the texture to create
  63657. * @param scene Define the scene the texture belongs to
  63658. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63659. * @param generateMipMaps Define if the texture should creates mip maps or not
  63660. */
  63661. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63662. private _loadJson;
  63663. /**
  63664. * Is the texture ready to be used ? (rendered at least once)
  63665. * @returns true if ready, otherwise, false.
  63666. */
  63667. isReady(): boolean;
  63668. /**
  63669. * Render the texture to its associated render target.
  63670. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63671. */
  63672. render(useCameraPostProcess?: boolean): void;
  63673. /**
  63674. * Update the list of dependant textures samplers in the shader.
  63675. */
  63676. updateTextures(): void;
  63677. /**
  63678. * Update the uniform values of the procedural texture in the shader.
  63679. */
  63680. updateShaderUniforms(): void;
  63681. /**
  63682. * Define if the texture animates or not.
  63683. */
  63684. get animate(): boolean;
  63685. set animate(value: boolean);
  63686. }
  63687. }
  63688. declare module "babylonjs/Shaders/noise.fragment" {
  63689. /** @hidden */
  63690. export var noisePixelShader: {
  63691. name: string;
  63692. shader: string;
  63693. };
  63694. }
  63695. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63696. import { Nullable } from "babylonjs/types";
  63697. import { Scene } from "babylonjs/scene";
  63698. import { Texture } from "babylonjs/Materials/Textures/texture";
  63699. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63700. import "babylonjs/Shaders/noise.fragment";
  63701. /**
  63702. * Class used to generate noise procedural textures
  63703. */
  63704. export class NoiseProceduralTexture extends ProceduralTexture {
  63705. private _time;
  63706. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63707. brightness: number;
  63708. /** Defines the number of octaves to process */
  63709. octaves: number;
  63710. /** Defines the level of persistence (0.8 by default) */
  63711. persistence: number;
  63712. /** Gets or sets animation speed factor (default is 1) */
  63713. animationSpeedFactor: number;
  63714. /**
  63715. * Creates a new NoiseProceduralTexture
  63716. * @param name defines the name fo the texture
  63717. * @param size defines the size of the texture (default is 256)
  63718. * @param scene defines the hosting scene
  63719. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63720. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63721. */
  63722. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63723. private _updateShaderUniforms;
  63724. protected _getDefines(): string;
  63725. /** Generate the current state of the procedural texture */
  63726. render(useCameraPostProcess?: boolean): void;
  63727. /**
  63728. * Serializes this noise procedural texture
  63729. * @returns a serialized noise procedural texture object
  63730. */
  63731. serialize(): any;
  63732. /**
  63733. * Clone the texture.
  63734. * @returns the cloned texture
  63735. */
  63736. clone(): NoiseProceduralTexture;
  63737. /**
  63738. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63739. * @param parsedTexture defines parsed texture data
  63740. * @param scene defines the current scene
  63741. * @param rootUrl defines the root URL containing noise procedural texture information
  63742. * @returns a parsed NoiseProceduralTexture
  63743. */
  63744. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63745. }
  63746. }
  63747. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  63748. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  63749. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  63750. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63751. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  63752. }
  63753. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  63754. import { Nullable } from "babylonjs/types";
  63755. import { Scene } from "babylonjs/scene";
  63756. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  63757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63758. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  63759. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63760. /**
  63761. * Raw cube texture where the raw buffers are passed in
  63762. */
  63763. export class RawCubeTexture extends CubeTexture {
  63764. /**
  63765. * Creates a cube texture where the raw buffers are passed in.
  63766. * @param scene defines the scene the texture is attached to
  63767. * @param data defines the array of data to use to create each face
  63768. * @param size defines the size of the textures
  63769. * @param format defines the format of the data
  63770. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63771. * @param generateMipMaps defines if the engine should generate the mip levels
  63772. * @param invertY defines if data must be stored with Y axis inverted
  63773. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63774. * @param compression defines the compression used (null by default)
  63775. */
  63776. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63777. /**
  63778. * Updates the raw cube texture.
  63779. * @param data defines the data to store
  63780. * @param format defines the data format
  63781. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63782. * @param invertY defines if data must be stored with Y axis inverted
  63783. * @param compression defines the compression used (null by default)
  63784. * @param level defines which level of the texture to update
  63785. */
  63786. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63787. /**
  63788. * Updates a raw cube texture with RGBD encoded data.
  63789. * @param data defines the array of data [mipmap][face] to use to create each face
  63790. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63791. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63792. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63793. * @returns a promsie that resolves when the operation is complete
  63794. */
  63795. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63796. /**
  63797. * Clones the raw cube texture.
  63798. * @return a new cube texture
  63799. */
  63800. clone(): CubeTexture;
  63801. /** @hidden */
  63802. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63803. }
  63804. }
  63805. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  63806. import { Scene } from "babylonjs/scene";
  63807. import { Texture } from "babylonjs/Materials/Textures/texture";
  63808. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63809. /**
  63810. * Class used to store 2D array textures containing user data
  63811. */
  63812. export class RawTexture2DArray extends Texture {
  63813. /** Gets or sets the texture format to use */
  63814. format: number;
  63815. /**
  63816. * Create a new RawTexture2DArray
  63817. * @param data defines the data of the texture
  63818. * @param width defines the width of the texture
  63819. * @param height defines the height of the texture
  63820. * @param depth defines the number of layers of the texture
  63821. * @param format defines the texture format to use
  63822. * @param scene defines the hosting scene
  63823. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63824. * @param invertY defines if texture must be stored with Y axis inverted
  63825. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63826. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63827. */
  63828. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63829. /** Gets or sets the texture format to use */
  63830. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63831. /**
  63832. * Update the texture with new data
  63833. * @param data defines the data to store in the texture
  63834. */
  63835. update(data: ArrayBufferView): void;
  63836. }
  63837. }
  63838. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  63839. import { Scene } from "babylonjs/scene";
  63840. import { Texture } from "babylonjs/Materials/Textures/texture";
  63841. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63842. /**
  63843. * Class used to store 3D textures containing user data
  63844. */
  63845. export class RawTexture3D extends Texture {
  63846. /** Gets or sets the texture format to use */
  63847. format: number;
  63848. /**
  63849. * Create a new RawTexture3D
  63850. * @param data defines the data of the texture
  63851. * @param width defines the width of the texture
  63852. * @param height defines the height of the texture
  63853. * @param depth defines the depth of the texture
  63854. * @param format defines the texture format to use
  63855. * @param scene defines the hosting scene
  63856. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63857. * @param invertY defines if texture must be stored with Y axis inverted
  63858. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63859. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63860. */
  63861. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63862. /** Gets or sets the texture format to use */
  63863. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63864. /**
  63865. * Update the texture with new data
  63866. * @param data defines the data to store in the texture
  63867. */
  63868. update(data: ArrayBufferView): void;
  63869. }
  63870. }
  63871. declare module "babylonjs/Materials/Textures/refractionTexture" {
  63872. import { Scene } from "babylonjs/scene";
  63873. import { Plane } from "babylonjs/Maths/math.plane";
  63874. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63875. /**
  63876. * Creates a refraction texture used by refraction channel of the standard material.
  63877. * It is like a mirror but to see through a material.
  63878. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63879. */
  63880. export class RefractionTexture extends RenderTargetTexture {
  63881. /**
  63882. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63883. * 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.
  63884. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63885. */
  63886. refractionPlane: Plane;
  63887. /**
  63888. * Define how deep under the surface we should see.
  63889. */
  63890. depth: number;
  63891. /**
  63892. * Creates a refraction texture used by refraction channel of the standard material.
  63893. * It is like a mirror but to see through a material.
  63894. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63895. * @param name Define the texture name
  63896. * @param size Define the size of the underlying texture
  63897. * @param scene Define the scene the refraction belongs to
  63898. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63899. */
  63900. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63901. /**
  63902. * Clone the refraction texture.
  63903. * @returns the cloned texture
  63904. */
  63905. clone(): RefractionTexture;
  63906. /**
  63907. * Serialize the texture to a JSON representation you could use in Parse later on
  63908. * @returns the serialized JSON representation
  63909. */
  63910. serialize(): any;
  63911. }
  63912. }
  63913. declare module "babylonjs/Materials/Textures/index" {
  63914. export * from "babylonjs/Materials/Textures/baseTexture";
  63915. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  63916. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  63917. export * from "babylonjs/Materials/Textures/cubeTexture";
  63918. export * from "babylonjs/Materials/Textures/dynamicTexture";
  63919. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  63920. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  63921. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  63922. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  63923. export * from "babylonjs/Materials/Textures/internalTexture";
  63924. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  63925. export * from "babylonjs/Materials/Textures/Loaders/index";
  63926. export * from "babylonjs/Materials/Textures/mirrorTexture";
  63927. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  63928. export * from "babylonjs/Materials/Textures/Packer/index";
  63929. export * from "babylonjs/Materials/Textures/Procedurals/index";
  63930. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  63931. export * from "babylonjs/Materials/Textures/rawTexture";
  63932. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  63933. export * from "babylonjs/Materials/Textures/rawTexture3D";
  63934. export * from "babylonjs/Materials/Textures/refractionTexture";
  63935. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  63936. export * from "babylonjs/Materials/Textures/texture";
  63937. export * from "babylonjs/Materials/Textures/videoTexture";
  63938. }
  63939. declare module "babylonjs/Materials/Node/Enums/index" {
  63940. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  63941. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  63942. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  63943. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  63944. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  63945. }
  63946. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  63947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63950. import { Mesh } from "babylonjs/Meshes/mesh";
  63951. import { Effect } from "babylonjs/Materials/effect";
  63952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63953. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  63954. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63955. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63956. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  63957. /**
  63958. * Block used to add support for vertex skinning (bones)
  63959. */
  63960. export class BonesBlock extends NodeMaterialBlock {
  63961. /**
  63962. * Creates a new BonesBlock
  63963. * @param name defines the block name
  63964. */
  63965. constructor(name: string);
  63966. /**
  63967. * Initialize the block and prepare the context for build
  63968. * @param state defines the state that will be used for the build
  63969. */
  63970. initialize(state: NodeMaterialBuildState): void;
  63971. /**
  63972. * Gets the current class name
  63973. * @returns the class name
  63974. */
  63975. getClassName(): string;
  63976. /**
  63977. * Gets the matrix indices input component
  63978. */
  63979. get matricesIndices(): NodeMaterialConnectionPoint;
  63980. /**
  63981. * Gets the matrix weights input component
  63982. */
  63983. get matricesWeights(): NodeMaterialConnectionPoint;
  63984. /**
  63985. * Gets the extra matrix indices input component
  63986. */
  63987. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63988. /**
  63989. * Gets the extra matrix weights input component
  63990. */
  63991. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the world input component
  63994. */
  63995. get world(): NodeMaterialConnectionPoint;
  63996. /**
  63997. * Gets the output component
  63998. */
  63999. get output(): NodeMaterialConnectionPoint;
  64000. autoConfigure(material: NodeMaterial): void;
  64001. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64003. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64004. protected _buildBlock(state: NodeMaterialBuildState): this;
  64005. }
  64006. }
  64007. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64009. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64010. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64012. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64013. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64014. /**
  64015. * Block used to add support for instances
  64016. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64017. */
  64018. export class InstancesBlock extends NodeMaterialBlock {
  64019. /**
  64020. * Creates a new InstancesBlock
  64021. * @param name defines the block name
  64022. */
  64023. constructor(name: string);
  64024. /**
  64025. * Gets the current class name
  64026. * @returns the class name
  64027. */
  64028. getClassName(): string;
  64029. /**
  64030. * Gets the first world row input component
  64031. */
  64032. get world0(): NodeMaterialConnectionPoint;
  64033. /**
  64034. * Gets the second world row input component
  64035. */
  64036. get world1(): NodeMaterialConnectionPoint;
  64037. /**
  64038. * Gets the third world row input component
  64039. */
  64040. get world2(): NodeMaterialConnectionPoint;
  64041. /**
  64042. * Gets the forth world row input component
  64043. */
  64044. get world3(): NodeMaterialConnectionPoint;
  64045. /**
  64046. * Gets the world input component
  64047. */
  64048. get world(): NodeMaterialConnectionPoint;
  64049. /**
  64050. * Gets the output component
  64051. */
  64052. get output(): NodeMaterialConnectionPoint;
  64053. /**
  64054. * Gets the isntanceID component
  64055. */
  64056. get instanceID(): NodeMaterialConnectionPoint;
  64057. autoConfigure(material: NodeMaterial): void;
  64058. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64059. protected _buildBlock(state: NodeMaterialBuildState): this;
  64060. }
  64061. }
  64062. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64066. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64067. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64068. import { Effect } from "babylonjs/Materials/effect";
  64069. import { Mesh } from "babylonjs/Meshes/mesh";
  64070. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64072. /**
  64073. * Block used to add morph targets support to vertex shader
  64074. */
  64075. export class MorphTargetsBlock extends NodeMaterialBlock {
  64076. private _repeatableContentAnchor;
  64077. /**
  64078. * Create a new MorphTargetsBlock
  64079. * @param name defines the block name
  64080. */
  64081. constructor(name: string);
  64082. /**
  64083. * Gets the current class name
  64084. * @returns the class name
  64085. */
  64086. getClassName(): string;
  64087. /**
  64088. * Gets the position input component
  64089. */
  64090. get position(): NodeMaterialConnectionPoint;
  64091. /**
  64092. * Gets the normal input component
  64093. */
  64094. get normal(): NodeMaterialConnectionPoint;
  64095. /**
  64096. * Gets the tangent input component
  64097. */
  64098. get tangent(): NodeMaterialConnectionPoint;
  64099. /**
  64100. * Gets the tangent input component
  64101. */
  64102. get uv(): NodeMaterialConnectionPoint;
  64103. /**
  64104. * Gets the position output component
  64105. */
  64106. get positionOutput(): NodeMaterialConnectionPoint;
  64107. /**
  64108. * Gets the normal output component
  64109. */
  64110. get normalOutput(): NodeMaterialConnectionPoint;
  64111. /**
  64112. * Gets the tangent output component
  64113. */
  64114. get tangentOutput(): NodeMaterialConnectionPoint;
  64115. /**
  64116. * Gets the tangent output component
  64117. */
  64118. get uvOutput(): NodeMaterialConnectionPoint;
  64119. initialize(state: NodeMaterialBuildState): void;
  64120. autoConfigure(material: NodeMaterial): void;
  64121. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64122. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64123. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64124. protected _buildBlock(state: NodeMaterialBuildState): this;
  64125. }
  64126. }
  64127. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64131. import { Nullable } from "babylonjs/types";
  64132. import { Scene } from "babylonjs/scene";
  64133. import { Effect } from "babylonjs/Materials/effect";
  64134. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64135. import { Mesh } from "babylonjs/Meshes/mesh";
  64136. import { Light } from "babylonjs/Lights/light";
  64137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64138. /**
  64139. * Block used to get data information from a light
  64140. */
  64141. export class LightInformationBlock extends NodeMaterialBlock {
  64142. private _lightDataUniformName;
  64143. private _lightColorUniformName;
  64144. private _lightTypeDefineName;
  64145. /**
  64146. * Gets or sets the light associated with this block
  64147. */
  64148. light: Nullable<Light>;
  64149. /**
  64150. * Creates a new LightInformationBlock
  64151. * @param name defines the block name
  64152. */
  64153. constructor(name: string);
  64154. /**
  64155. * Gets the current class name
  64156. * @returns the class name
  64157. */
  64158. getClassName(): string;
  64159. /**
  64160. * Gets the world position input component
  64161. */
  64162. get worldPosition(): NodeMaterialConnectionPoint;
  64163. /**
  64164. * Gets the direction output component
  64165. */
  64166. get direction(): NodeMaterialConnectionPoint;
  64167. /**
  64168. * Gets the direction output component
  64169. */
  64170. get color(): NodeMaterialConnectionPoint;
  64171. /**
  64172. * Gets the direction output component
  64173. */
  64174. get intensity(): NodeMaterialConnectionPoint;
  64175. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64177. protected _buildBlock(state: NodeMaterialBuildState): this;
  64178. serialize(): any;
  64179. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64180. }
  64181. }
  64182. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64183. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64184. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64185. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64186. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64187. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64188. }
  64189. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64190. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64191. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64192. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64194. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64195. import { Effect } from "babylonjs/Materials/effect";
  64196. import { Mesh } from "babylonjs/Meshes/mesh";
  64197. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64198. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64199. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64200. /**
  64201. * Block used to add image processing support to fragment shader
  64202. */
  64203. export class ImageProcessingBlock extends NodeMaterialBlock {
  64204. /**
  64205. * Create a new ImageProcessingBlock
  64206. * @param name defines the block name
  64207. */
  64208. constructor(name: string);
  64209. /**
  64210. * Gets the current class name
  64211. * @returns the class name
  64212. */
  64213. getClassName(): string;
  64214. /**
  64215. * Gets the color input component
  64216. */
  64217. get color(): NodeMaterialConnectionPoint;
  64218. /**
  64219. * Gets the output component
  64220. */
  64221. get output(): NodeMaterialConnectionPoint;
  64222. /**
  64223. * Initialize the block and prepare the context for build
  64224. * @param state defines the state that will be used for the build
  64225. */
  64226. initialize(state: NodeMaterialBuildState): void;
  64227. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64228. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64229. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64230. protected _buildBlock(state: NodeMaterialBuildState): this;
  64231. }
  64232. }
  64233. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64234. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64235. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64236. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64237. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64239. import { Effect } from "babylonjs/Materials/effect";
  64240. import { Mesh } from "babylonjs/Meshes/mesh";
  64241. import { Scene } from "babylonjs/scene";
  64242. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64243. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64244. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64245. /**
  64246. * Block used to pertub normals based on a normal map
  64247. */
  64248. export class PerturbNormalBlock extends NodeMaterialBlock {
  64249. private _tangentSpaceParameterName;
  64250. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64251. invertX: boolean;
  64252. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64253. invertY: boolean;
  64254. /**
  64255. * Create a new PerturbNormalBlock
  64256. * @param name defines the block name
  64257. */
  64258. constructor(name: string);
  64259. /**
  64260. * Gets the current class name
  64261. * @returns the class name
  64262. */
  64263. getClassName(): string;
  64264. /**
  64265. * Gets the world position input component
  64266. */
  64267. get worldPosition(): NodeMaterialConnectionPoint;
  64268. /**
  64269. * Gets the world normal input component
  64270. */
  64271. get worldNormal(): NodeMaterialConnectionPoint;
  64272. /**
  64273. * Gets the world tangent input component
  64274. */
  64275. get worldTangent(): NodeMaterialConnectionPoint;
  64276. /**
  64277. * Gets the uv input component
  64278. */
  64279. get uv(): NodeMaterialConnectionPoint;
  64280. /**
  64281. * Gets the normal map color input component
  64282. */
  64283. get normalMapColor(): NodeMaterialConnectionPoint;
  64284. /**
  64285. * Gets the strength input component
  64286. */
  64287. get strength(): NodeMaterialConnectionPoint;
  64288. /**
  64289. * Gets the output component
  64290. */
  64291. get output(): NodeMaterialConnectionPoint;
  64292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64294. autoConfigure(material: NodeMaterial): void;
  64295. protected _buildBlock(state: NodeMaterialBuildState): this;
  64296. protected _dumpPropertiesCode(): string;
  64297. serialize(): any;
  64298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64299. }
  64300. }
  64301. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64305. /**
  64306. * Block used to discard a pixel if a value is smaller than a cutoff
  64307. */
  64308. export class DiscardBlock extends NodeMaterialBlock {
  64309. /**
  64310. * Create a new DiscardBlock
  64311. * @param name defines the block name
  64312. */
  64313. constructor(name: string);
  64314. /**
  64315. * Gets the current class name
  64316. * @returns the class name
  64317. */
  64318. getClassName(): string;
  64319. /**
  64320. * Gets the color input component
  64321. */
  64322. get value(): NodeMaterialConnectionPoint;
  64323. /**
  64324. * Gets the cutoff input component
  64325. */
  64326. get cutoff(): NodeMaterialConnectionPoint;
  64327. protected _buildBlock(state: NodeMaterialBuildState): this;
  64328. }
  64329. }
  64330. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64334. /**
  64335. * Block used to test if the fragment shader is front facing
  64336. */
  64337. export class FrontFacingBlock extends NodeMaterialBlock {
  64338. /**
  64339. * Creates a new FrontFacingBlock
  64340. * @param name defines the block name
  64341. */
  64342. constructor(name: string);
  64343. /**
  64344. * Gets the current class name
  64345. * @returns the class name
  64346. */
  64347. getClassName(): string;
  64348. /**
  64349. * Gets the output component
  64350. */
  64351. get output(): NodeMaterialConnectionPoint;
  64352. protected _buildBlock(state: NodeMaterialBuildState): this;
  64353. }
  64354. }
  64355. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64356. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64357. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64358. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64359. /**
  64360. * Block used to get the derivative value on x and y of a given input
  64361. */
  64362. export class DerivativeBlock extends NodeMaterialBlock {
  64363. /**
  64364. * Create a new DerivativeBlock
  64365. * @param name defines the block name
  64366. */
  64367. constructor(name: string);
  64368. /**
  64369. * Gets the current class name
  64370. * @returns the class name
  64371. */
  64372. getClassName(): string;
  64373. /**
  64374. * Gets the input component
  64375. */
  64376. get input(): NodeMaterialConnectionPoint;
  64377. /**
  64378. * Gets the derivative output on x
  64379. */
  64380. get dx(): NodeMaterialConnectionPoint;
  64381. /**
  64382. * Gets the derivative output on y
  64383. */
  64384. get dy(): NodeMaterialConnectionPoint;
  64385. protected _buildBlock(state: NodeMaterialBuildState): this;
  64386. }
  64387. }
  64388. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64389. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64390. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64391. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64392. /**
  64393. * Block used to make gl_FragCoord available
  64394. */
  64395. export class FragCoordBlock extends NodeMaterialBlock {
  64396. /**
  64397. * Creates a new FragCoordBlock
  64398. * @param name defines the block name
  64399. */
  64400. constructor(name: string);
  64401. /**
  64402. * Gets the current class name
  64403. * @returns the class name
  64404. */
  64405. getClassName(): string;
  64406. /**
  64407. * Gets the xy component
  64408. */
  64409. get xy(): NodeMaterialConnectionPoint;
  64410. /**
  64411. * Gets the xyz component
  64412. */
  64413. get xyz(): NodeMaterialConnectionPoint;
  64414. /**
  64415. * Gets the xyzw component
  64416. */
  64417. get xyzw(): NodeMaterialConnectionPoint;
  64418. /**
  64419. * Gets the x component
  64420. */
  64421. get x(): NodeMaterialConnectionPoint;
  64422. /**
  64423. * Gets the y component
  64424. */
  64425. get y(): NodeMaterialConnectionPoint;
  64426. /**
  64427. * Gets the z component
  64428. */
  64429. get z(): NodeMaterialConnectionPoint;
  64430. /**
  64431. * Gets the w component
  64432. */
  64433. get output(): NodeMaterialConnectionPoint;
  64434. protected writeOutputs(state: NodeMaterialBuildState): string;
  64435. protected _buildBlock(state: NodeMaterialBuildState): this;
  64436. }
  64437. }
  64438. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64439. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64440. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64441. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64442. import { Effect } from "babylonjs/Materials/effect";
  64443. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64444. import { Mesh } from "babylonjs/Meshes/mesh";
  64445. /**
  64446. * Block used to get the screen sizes
  64447. */
  64448. export class ScreenSizeBlock extends NodeMaterialBlock {
  64449. private _varName;
  64450. private _scene;
  64451. /**
  64452. * Creates a new ScreenSizeBlock
  64453. * @param name defines the block name
  64454. */
  64455. constructor(name: string);
  64456. /**
  64457. * Gets the current class name
  64458. * @returns the class name
  64459. */
  64460. getClassName(): string;
  64461. /**
  64462. * Gets the xy component
  64463. */
  64464. get xy(): NodeMaterialConnectionPoint;
  64465. /**
  64466. * Gets the x component
  64467. */
  64468. get x(): NodeMaterialConnectionPoint;
  64469. /**
  64470. * Gets the y component
  64471. */
  64472. get y(): NodeMaterialConnectionPoint;
  64473. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64474. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64475. protected _buildBlock(state: NodeMaterialBuildState): this;
  64476. }
  64477. }
  64478. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64479. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64480. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64481. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64482. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64483. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64484. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64485. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64486. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64487. }
  64488. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64489. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64490. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64491. import { Mesh } from "babylonjs/Meshes/mesh";
  64492. import { Effect } from "babylonjs/Materials/effect";
  64493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64495. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64496. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64497. /**
  64498. * Block used to add support for scene fog
  64499. */
  64500. export class FogBlock extends NodeMaterialBlock {
  64501. private _fogDistanceName;
  64502. private _fogParameters;
  64503. /**
  64504. * Create a new FogBlock
  64505. * @param name defines the block name
  64506. */
  64507. constructor(name: string);
  64508. /**
  64509. * Gets the current class name
  64510. * @returns the class name
  64511. */
  64512. getClassName(): string;
  64513. /**
  64514. * Gets the world position input component
  64515. */
  64516. get worldPosition(): NodeMaterialConnectionPoint;
  64517. /**
  64518. * Gets the view input component
  64519. */
  64520. get view(): NodeMaterialConnectionPoint;
  64521. /**
  64522. * Gets the color input component
  64523. */
  64524. get input(): NodeMaterialConnectionPoint;
  64525. /**
  64526. * Gets the fog color input component
  64527. */
  64528. get fogColor(): NodeMaterialConnectionPoint;
  64529. /**
  64530. * Gets the output component
  64531. */
  64532. get output(): NodeMaterialConnectionPoint;
  64533. autoConfigure(material: NodeMaterial): void;
  64534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64535. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64536. protected _buildBlock(state: NodeMaterialBuildState): this;
  64537. }
  64538. }
  64539. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64544. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64545. import { Effect } from "babylonjs/Materials/effect";
  64546. import { Mesh } from "babylonjs/Meshes/mesh";
  64547. import { Light } from "babylonjs/Lights/light";
  64548. import { Nullable } from "babylonjs/types";
  64549. import { Scene } from "babylonjs/scene";
  64550. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64551. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64552. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64553. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64554. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64555. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64556. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64557. /**
  64558. * Block used to add light in the fragment shader
  64559. */
  64560. export class LightBlock extends NodeMaterialBlock {
  64561. private _lightId;
  64562. /**
  64563. * Gets or sets the light associated with this block
  64564. */
  64565. light: Nullable<Light>;
  64566. /**
  64567. * Create a new LightBlock
  64568. * @param name defines the block name
  64569. */
  64570. constructor(name: string);
  64571. /**
  64572. * Gets the current class name
  64573. * @returns the class name
  64574. */
  64575. getClassName(): string;
  64576. /**
  64577. * Gets the world position input component
  64578. */
  64579. get worldPosition(): NodeMaterialConnectionPoint;
  64580. /**
  64581. * Gets the world normal input component
  64582. */
  64583. get worldNormal(): NodeMaterialConnectionPoint;
  64584. /**
  64585. * Gets the camera (or eye) position component
  64586. */
  64587. get cameraPosition(): NodeMaterialConnectionPoint;
  64588. /**
  64589. * Gets the glossiness component
  64590. */
  64591. get glossiness(): NodeMaterialConnectionPoint;
  64592. /**
  64593. * Gets the glossinness power component
  64594. */
  64595. get glossPower(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the diffuse color component
  64598. */
  64599. get diffuseColor(): NodeMaterialConnectionPoint;
  64600. /**
  64601. * Gets the specular color component
  64602. */
  64603. get specularColor(): NodeMaterialConnectionPoint;
  64604. /**
  64605. * Gets the diffuse output component
  64606. */
  64607. get diffuseOutput(): NodeMaterialConnectionPoint;
  64608. /**
  64609. * Gets the specular output component
  64610. */
  64611. get specularOutput(): NodeMaterialConnectionPoint;
  64612. /**
  64613. * Gets the shadow output component
  64614. */
  64615. get shadow(): NodeMaterialConnectionPoint;
  64616. autoConfigure(material: NodeMaterial): void;
  64617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64618. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64620. private _injectVertexCode;
  64621. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64622. serialize(): any;
  64623. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64624. }
  64625. }
  64626. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64629. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64630. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64631. /**
  64632. * Block used to read a reflection texture from a sampler
  64633. */
  64634. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64635. /**
  64636. * Create a new ReflectionTextureBlock
  64637. * @param name defines the block name
  64638. */
  64639. constructor(name: string);
  64640. /**
  64641. * Gets the current class name
  64642. * @returns the class name
  64643. */
  64644. getClassName(): string;
  64645. /**
  64646. * Gets the world position input component
  64647. */
  64648. get position(): NodeMaterialConnectionPoint;
  64649. /**
  64650. * Gets the world position input component
  64651. */
  64652. get worldPosition(): NodeMaterialConnectionPoint;
  64653. /**
  64654. * Gets the world normal input component
  64655. */
  64656. get worldNormal(): NodeMaterialConnectionPoint;
  64657. /**
  64658. * Gets the world input component
  64659. */
  64660. get world(): NodeMaterialConnectionPoint;
  64661. /**
  64662. * Gets the camera (or eye) position component
  64663. */
  64664. get cameraPosition(): NodeMaterialConnectionPoint;
  64665. /**
  64666. * Gets the view input component
  64667. */
  64668. get view(): NodeMaterialConnectionPoint;
  64669. /**
  64670. * Gets the rgb output component
  64671. */
  64672. get rgb(): NodeMaterialConnectionPoint;
  64673. /**
  64674. * Gets the r output component
  64675. */
  64676. get r(): NodeMaterialConnectionPoint;
  64677. /**
  64678. * Gets the g output component
  64679. */
  64680. get g(): NodeMaterialConnectionPoint;
  64681. /**
  64682. * Gets the b output component
  64683. */
  64684. get b(): NodeMaterialConnectionPoint;
  64685. autoConfigure(material: NodeMaterial): void;
  64686. protected _buildBlock(state: NodeMaterialBuildState): this;
  64687. }
  64688. }
  64689. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64690. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64691. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64692. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64693. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64694. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64695. }
  64696. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64697. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64698. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64699. }
  64700. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64704. /**
  64705. * Block used to add 2 vectors
  64706. */
  64707. export class AddBlock extends NodeMaterialBlock {
  64708. /**
  64709. * Creates a new AddBlock
  64710. * @param name defines the block name
  64711. */
  64712. constructor(name: string);
  64713. /**
  64714. * Gets the current class name
  64715. * @returns the class name
  64716. */
  64717. getClassName(): string;
  64718. /**
  64719. * Gets the left operand input component
  64720. */
  64721. get left(): NodeMaterialConnectionPoint;
  64722. /**
  64723. * Gets the right operand input component
  64724. */
  64725. get right(): NodeMaterialConnectionPoint;
  64726. /**
  64727. * Gets the output component
  64728. */
  64729. get output(): NodeMaterialConnectionPoint;
  64730. protected _buildBlock(state: NodeMaterialBuildState): this;
  64731. }
  64732. }
  64733. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  64734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64737. /**
  64738. * Block used to scale a vector by a float
  64739. */
  64740. export class ScaleBlock extends NodeMaterialBlock {
  64741. /**
  64742. * Creates a new ScaleBlock
  64743. * @param name defines the block name
  64744. */
  64745. constructor(name: string);
  64746. /**
  64747. * Gets the current class name
  64748. * @returns the class name
  64749. */
  64750. getClassName(): string;
  64751. /**
  64752. * Gets the input component
  64753. */
  64754. get input(): NodeMaterialConnectionPoint;
  64755. /**
  64756. * Gets the factor input component
  64757. */
  64758. get factor(): NodeMaterialConnectionPoint;
  64759. /**
  64760. * Gets the output component
  64761. */
  64762. get output(): NodeMaterialConnectionPoint;
  64763. protected _buildBlock(state: NodeMaterialBuildState): this;
  64764. }
  64765. }
  64766. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  64767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64770. import { Scene } from "babylonjs/scene";
  64771. /**
  64772. * Block used to clamp a float
  64773. */
  64774. export class ClampBlock extends NodeMaterialBlock {
  64775. /** Gets or sets the minimum range */
  64776. minimum: number;
  64777. /** Gets or sets the maximum range */
  64778. maximum: number;
  64779. /**
  64780. * Creates a new ClampBlock
  64781. * @param name defines the block name
  64782. */
  64783. constructor(name: string);
  64784. /**
  64785. * Gets the current class name
  64786. * @returns the class name
  64787. */
  64788. getClassName(): string;
  64789. /**
  64790. * Gets the value input component
  64791. */
  64792. get value(): NodeMaterialConnectionPoint;
  64793. /**
  64794. * Gets the output component
  64795. */
  64796. get output(): NodeMaterialConnectionPoint;
  64797. protected _buildBlock(state: NodeMaterialBuildState): this;
  64798. protected _dumpPropertiesCode(): string;
  64799. serialize(): any;
  64800. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64801. }
  64802. }
  64803. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  64804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64806. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64807. /**
  64808. * Block used to apply a cross product between 2 vectors
  64809. */
  64810. export class CrossBlock extends NodeMaterialBlock {
  64811. /**
  64812. * Creates a new CrossBlock
  64813. * @param name defines the block name
  64814. */
  64815. constructor(name: string);
  64816. /**
  64817. * Gets the current class name
  64818. * @returns the class name
  64819. */
  64820. getClassName(): string;
  64821. /**
  64822. * Gets the left operand input component
  64823. */
  64824. get left(): NodeMaterialConnectionPoint;
  64825. /**
  64826. * Gets the right operand input component
  64827. */
  64828. get right(): NodeMaterialConnectionPoint;
  64829. /**
  64830. * Gets the output component
  64831. */
  64832. get output(): NodeMaterialConnectionPoint;
  64833. protected _buildBlock(state: NodeMaterialBuildState): this;
  64834. }
  64835. }
  64836. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  64837. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64838. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64839. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64840. /**
  64841. * Block used to apply a dot product between 2 vectors
  64842. */
  64843. export class DotBlock extends NodeMaterialBlock {
  64844. /**
  64845. * Creates a new DotBlock
  64846. * @param name defines the block name
  64847. */
  64848. constructor(name: string);
  64849. /**
  64850. * Gets the current class name
  64851. * @returns the class name
  64852. */
  64853. getClassName(): string;
  64854. /**
  64855. * Gets the left operand input component
  64856. */
  64857. get left(): NodeMaterialConnectionPoint;
  64858. /**
  64859. * Gets the right operand input component
  64860. */
  64861. get right(): NodeMaterialConnectionPoint;
  64862. /**
  64863. * Gets the output component
  64864. */
  64865. get output(): NodeMaterialConnectionPoint;
  64866. protected _buildBlock(state: NodeMaterialBuildState): this;
  64867. }
  64868. }
  64869. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  64870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64872. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64873. /**
  64874. * Block used to normalize a vector
  64875. */
  64876. export class NormalizeBlock extends NodeMaterialBlock {
  64877. /**
  64878. * Creates a new NormalizeBlock
  64879. * @param name defines the block name
  64880. */
  64881. constructor(name: string);
  64882. /**
  64883. * Gets the current class name
  64884. * @returns the class name
  64885. */
  64886. getClassName(): string;
  64887. /**
  64888. * Gets the input component
  64889. */
  64890. get input(): NodeMaterialConnectionPoint;
  64891. /**
  64892. * Gets the output component
  64893. */
  64894. get output(): NodeMaterialConnectionPoint;
  64895. protected _buildBlock(state: NodeMaterialBuildState): this;
  64896. }
  64897. }
  64898. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  64899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64902. import { Scene } from "babylonjs/scene";
  64903. /**
  64904. * Operations supported by the Trigonometry block
  64905. */
  64906. export enum TrigonometryBlockOperations {
  64907. /** Cos */
  64908. Cos = 0,
  64909. /** Sin */
  64910. Sin = 1,
  64911. /** Abs */
  64912. Abs = 2,
  64913. /** Exp */
  64914. Exp = 3,
  64915. /** Exp2 */
  64916. Exp2 = 4,
  64917. /** Round */
  64918. Round = 5,
  64919. /** Floor */
  64920. Floor = 6,
  64921. /** Ceiling */
  64922. Ceiling = 7,
  64923. /** Square root */
  64924. Sqrt = 8,
  64925. /** Log */
  64926. Log = 9,
  64927. /** Tangent */
  64928. Tan = 10,
  64929. /** Arc tangent */
  64930. ArcTan = 11,
  64931. /** Arc cosinus */
  64932. ArcCos = 12,
  64933. /** Arc sinus */
  64934. ArcSin = 13,
  64935. /** Fraction */
  64936. Fract = 14,
  64937. /** Sign */
  64938. Sign = 15,
  64939. /** To radians (from degrees) */
  64940. Radians = 16,
  64941. /** To degrees (from radians) */
  64942. Degrees = 17
  64943. }
  64944. /**
  64945. * Block used to apply trigonometry operation to floats
  64946. */
  64947. export class TrigonometryBlock extends NodeMaterialBlock {
  64948. /**
  64949. * Gets or sets the operation applied by the block
  64950. */
  64951. operation: TrigonometryBlockOperations;
  64952. /**
  64953. * Creates a new TrigonometryBlock
  64954. * @param name defines the block name
  64955. */
  64956. constructor(name: string);
  64957. /**
  64958. * Gets the current class name
  64959. * @returns the class name
  64960. */
  64961. getClassName(): string;
  64962. /**
  64963. * Gets the input component
  64964. */
  64965. get input(): NodeMaterialConnectionPoint;
  64966. /**
  64967. * Gets the output component
  64968. */
  64969. get output(): NodeMaterialConnectionPoint;
  64970. protected _buildBlock(state: NodeMaterialBuildState): this;
  64971. serialize(): any;
  64972. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64973. protected _dumpPropertiesCode(): string;
  64974. }
  64975. }
  64976. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  64977. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64978. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64979. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64980. /**
  64981. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64982. */
  64983. export class ColorMergerBlock extends NodeMaterialBlock {
  64984. /**
  64985. * Create a new ColorMergerBlock
  64986. * @param name defines the block name
  64987. */
  64988. constructor(name: string);
  64989. /**
  64990. * Gets the current class name
  64991. * @returns the class name
  64992. */
  64993. getClassName(): string;
  64994. /**
  64995. * Gets the rgb component (input)
  64996. */
  64997. get rgbIn(): NodeMaterialConnectionPoint;
  64998. /**
  64999. * Gets the r component (input)
  65000. */
  65001. get r(): NodeMaterialConnectionPoint;
  65002. /**
  65003. * Gets the g component (input)
  65004. */
  65005. get g(): NodeMaterialConnectionPoint;
  65006. /**
  65007. * Gets the b component (input)
  65008. */
  65009. get b(): NodeMaterialConnectionPoint;
  65010. /**
  65011. * Gets the a component (input)
  65012. */
  65013. get a(): NodeMaterialConnectionPoint;
  65014. /**
  65015. * Gets the rgba component (output)
  65016. */
  65017. get rgba(): NodeMaterialConnectionPoint;
  65018. /**
  65019. * Gets the rgb component (output)
  65020. */
  65021. get rgbOut(): NodeMaterialConnectionPoint;
  65022. /**
  65023. * Gets the rgb component (output)
  65024. * @deprecated Please use rgbOut instead.
  65025. */
  65026. get rgb(): NodeMaterialConnectionPoint;
  65027. protected _buildBlock(state: NodeMaterialBuildState): this;
  65028. }
  65029. }
  65030. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65031. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65032. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65033. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65034. /**
  65035. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65036. */
  65037. export class VectorSplitterBlock extends NodeMaterialBlock {
  65038. /**
  65039. * Create a new VectorSplitterBlock
  65040. * @param name defines the block name
  65041. */
  65042. constructor(name: string);
  65043. /**
  65044. * Gets the current class name
  65045. * @returns the class name
  65046. */
  65047. getClassName(): string;
  65048. /**
  65049. * Gets the xyzw component (input)
  65050. */
  65051. get xyzw(): NodeMaterialConnectionPoint;
  65052. /**
  65053. * Gets the xyz component (input)
  65054. */
  65055. get xyzIn(): NodeMaterialConnectionPoint;
  65056. /**
  65057. * Gets the xy component (input)
  65058. */
  65059. get xyIn(): NodeMaterialConnectionPoint;
  65060. /**
  65061. * Gets the xyz component (output)
  65062. */
  65063. get xyzOut(): NodeMaterialConnectionPoint;
  65064. /**
  65065. * Gets the xy component (output)
  65066. */
  65067. get xyOut(): NodeMaterialConnectionPoint;
  65068. /**
  65069. * Gets the x component (output)
  65070. */
  65071. get x(): NodeMaterialConnectionPoint;
  65072. /**
  65073. * Gets the y component (output)
  65074. */
  65075. get y(): NodeMaterialConnectionPoint;
  65076. /**
  65077. * Gets the z component (output)
  65078. */
  65079. get z(): NodeMaterialConnectionPoint;
  65080. /**
  65081. * Gets the w component (output)
  65082. */
  65083. get w(): NodeMaterialConnectionPoint;
  65084. protected _inputRename(name: string): string;
  65085. protected _outputRename(name: string): string;
  65086. protected _buildBlock(state: NodeMaterialBuildState): this;
  65087. }
  65088. }
  65089. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65093. /**
  65094. * Block used to lerp between 2 values
  65095. */
  65096. export class LerpBlock extends NodeMaterialBlock {
  65097. /**
  65098. * Creates a new LerpBlock
  65099. * @param name defines the block name
  65100. */
  65101. constructor(name: string);
  65102. /**
  65103. * Gets the current class name
  65104. * @returns the class name
  65105. */
  65106. getClassName(): string;
  65107. /**
  65108. * Gets the left operand input component
  65109. */
  65110. get left(): NodeMaterialConnectionPoint;
  65111. /**
  65112. * Gets the right operand input component
  65113. */
  65114. get right(): NodeMaterialConnectionPoint;
  65115. /**
  65116. * Gets the gradient operand input component
  65117. */
  65118. get gradient(): NodeMaterialConnectionPoint;
  65119. /**
  65120. * Gets the output component
  65121. */
  65122. get output(): NodeMaterialConnectionPoint;
  65123. protected _buildBlock(state: NodeMaterialBuildState): this;
  65124. }
  65125. }
  65126. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65130. /**
  65131. * Block used to divide 2 vectors
  65132. */
  65133. export class DivideBlock extends NodeMaterialBlock {
  65134. /**
  65135. * Creates a new DivideBlock
  65136. * @param name defines the block name
  65137. */
  65138. constructor(name: string);
  65139. /**
  65140. * Gets the current class name
  65141. * @returns the class name
  65142. */
  65143. getClassName(): string;
  65144. /**
  65145. * Gets the left operand input component
  65146. */
  65147. get left(): NodeMaterialConnectionPoint;
  65148. /**
  65149. * Gets the right operand input component
  65150. */
  65151. get right(): NodeMaterialConnectionPoint;
  65152. /**
  65153. * Gets the output component
  65154. */
  65155. get output(): NodeMaterialConnectionPoint;
  65156. protected _buildBlock(state: NodeMaterialBuildState): this;
  65157. }
  65158. }
  65159. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65160. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65161. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65162. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65163. /**
  65164. * Block used to subtract 2 vectors
  65165. */
  65166. export class SubtractBlock extends NodeMaterialBlock {
  65167. /**
  65168. * Creates a new SubtractBlock
  65169. * @param name defines the block name
  65170. */
  65171. constructor(name: string);
  65172. /**
  65173. * Gets the current class name
  65174. * @returns the class name
  65175. */
  65176. getClassName(): string;
  65177. /**
  65178. * Gets the left operand input component
  65179. */
  65180. get left(): NodeMaterialConnectionPoint;
  65181. /**
  65182. * Gets the right operand input component
  65183. */
  65184. get right(): NodeMaterialConnectionPoint;
  65185. /**
  65186. * Gets the output component
  65187. */
  65188. get output(): NodeMaterialConnectionPoint;
  65189. protected _buildBlock(state: NodeMaterialBuildState): this;
  65190. }
  65191. }
  65192. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65196. /**
  65197. * Block used to step a value
  65198. */
  65199. export class StepBlock extends NodeMaterialBlock {
  65200. /**
  65201. * Creates a new StepBlock
  65202. * @param name defines the block name
  65203. */
  65204. constructor(name: string);
  65205. /**
  65206. * Gets the current class name
  65207. * @returns the class name
  65208. */
  65209. getClassName(): string;
  65210. /**
  65211. * Gets the value operand input component
  65212. */
  65213. get value(): NodeMaterialConnectionPoint;
  65214. /**
  65215. * Gets the edge operand input component
  65216. */
  65217. get edge(): NodeMaterialConnectionPoint;
  65218. /**
  65219. * Gets the output component
  65220. */
  65221. get output(): NodeMaterialConnectionPoint;
  65222. protected _buildBlock(state: NodeMaterialBuildState): this;
  65223. }
  65224. }
  65225. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65229. /**
  65230. * Block used to get the opposite (1 - x) of a value
  65231. */
  65232. export class OneMinusBlock extends NodeMaterialBlock {
  65233. /**
  65234. * Creates a new OneMinusBlock
  65235. * @param name defines the block name
  65236. */
  65237. constructor(name: string);
  65238. /**
  65239. * Gets the current class name
  65240. * @returns the class name
  65241. */
  65242. getClassName(): string;
  65243. /**
  65244. * Gets the input component
  65245. */
  65246. get input(): NodeMaterialConnectionPoint;
  65247. /**
  65248. * Gets the output component
  65249. */
  65250. get output(): NodeMaterialConnectionPoint;
  65251. protected _buildBlock(state: NodeMaterialBuildState): this;
  65252. }
  65253. }
  65254. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65258. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65259. /**
  65260. * Block used to get the view direction
  65261. */
  65262. export class ViewDirectionBlock extends NodeMaterialBlock {
  65263. /**
  65264. * Creates a new ViewDirectionBlock
  65265. * @param name defines the block name
  65266. */
  65267. constructor(name: string);
  65268. /**
  65269. * Gets the current class name
  65270. * @returns the class name
  65271. */
  65272. getClassName(): string;
  65273. /**
  65274. * Gets the world position component
  65275. */
  65276. get worldPosition(): NodeMaterialConnectionPoint;
  65277. /**
  65278. * Gets the camera position component
  65279. */
  65280. get cameraPosition(): NodeMaterialConnectionPoint;
  65281. /**
  65282. * Gets the output component
  65283. */
  65284. get output(): NodeMaterialConnectionPoint;
  65285. autoConfigure(material: NodeMaterial): void;
  65286. protected _buildBlock(state: NodeMaterialBuildState): this;
  65287. }
  65288. }
  65289. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65293. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65294. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65295. /**
  65296. * Block used to compute fresnel value
  65297. */
  65298. export class FresnelBlock extends NodeMaterialBlock {
  65299. /**
  65300. * Create a new FresnelBlock
  65301. * @param name defines the block name
  65302. */
  65303. constructor(name: string);
  65304. /**
  65305. * Gets the current class name
  65306. * @returns the class name
  65307. */
  65308. getClassName(): string;
  65309. /**
  65310. * Gets the world normal input component
  65311. */
  65312. get worldNormal(): NodeMaterialConnectionPoint;
  65313. /**
  65314. * Gets the view direction input component
  65315. */
  65316. get viewDirection(): NodeMaterialConnectionPoint;
  65317. /**
  65318. * Gets the bias input component
  65319. */
  65320. get bias(): NodeMaterialConnectionPoint;
  65321. /**
  65322. * Gets the camera (or eye) position component
  65323. */
  65324. get power(): NodeMaterialConnectionPoint;
  65325. /**
  65326. * Gets the fresnel output component
  65327. */
  65328. get fresnel(): NodeMaterialConnectionPoint;
  65329. autoConfigure(material: NodeMaterial): void;
  65330. protected _buildBlock(state: NodeMaterialBuildState): this;
  65331. }
  65332. }
  65333. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65337. /**
  65338. * Block used to get the max of 2 values
  65339. */
  65340. export class MaxBlock extends NodeMaterialBlock {
  65341. /**
  65342. * Creates a new MaxBlock
  65343. * @param name defines the block name
  65344. */
  65345. constructor(name: string);
  65346. /**
  65347. * Gets the current class name
  65348. * @returns the class name
  65349. */
  65350. getClassName(): string;
  65351. /**
  65352. * Gets the left operand input component
  65353. */
  65354. get left(): NodeMaterialConnectionPoint;
  65355. /**
  65356. * Gets the right operand input component
  65357. */
  65358. get right(): NodeMaterialConnectionPoint;
  65359. /**
  65360. * Gets the output component
  65361. */
  65362. get output(): NodeMaterialConnectionPoint;
  65363. protected _buildBlock(state: NodeMaterialBuildState): this;
  65364. }
  65365. }
  65366. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65370. /**
  65371. * Block used to get the min of 2 values
  65372. */
  65373. export class MinBlock extends NodeMaterialBlock {
  65374. /**
  65375. * Creates a new MinBlock
  65376. * @param name defines the block name
  65377. */
  65378. constructor(name: string);
  65379. /**
  65380. * Gets the current class name
  65381. * @returns the class name
  65382. */
  65383. getClassName(): string;
  65384. /**
  65385. * Gets the left operand input component
  65386. */
  65387. get left(): NodeMaterialConnectionPoint;
  65388. /**
  65389. * Gets the right operand input component
  65390. */
  65391. get right(): NodeMaterialConnectionPoint;
  65392. /**
  65393. * Gets the output component
  65394. */
  65395. get output(): NodeMaterialConnectionPoint;
  65396. protected _buildBlock(state: NodeMaterialBuildState): this;
  65397. }
  65398. }
  65399. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65403. /**
  65404. * Block used to get the distance between 2 values
  65405. */
  65406. export class DistanceBlock extends NodeMaterialBlock {
  65407. /**
  65408. * Creates a new DistanceBlock
  65409. * @param name defines the block name
  65410. */
  65411. constructor(name: string);
  65412. /**
  65413. * Gets the current class name
  65414. * @returns the class name
  65415. */
  65416. getClassName(): string;
  65417. /**
  65418. * Gets the left operand input component
  65419. */
  65420. get left(): NodeMaterialConnectionPoint;
  65421. /**
  65422. * Gets the right operand input component
  65423. */
  65424. get right(): NodeMaterialConnectionPoint;
  65425. /**
  65426. * Gets the output component
  65427. */
  65428. get output(): NodeMaterialConnectionPoint;
  65429. protected _buildBlock(state: NodeMaterialBuildState): this;
  65430. }
  65431. }
  65432. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65436. /**
  65437. * Block used to get the length of a vector
  65438. */
  65439. export class LengthBlock extends NodeMaterialBlock {
  65440. /**
  65441. * Creates a new LengthBlock
  65442. * @param name defines the block name
  65443. */
  65444. constructor(name: string);
  65445. /**
  65446. * Gets the current class name
  65447. * @returns the class name
  65448. */
  65449. getClassName(): string;
  65450. /**
  65451. * Gets the value input component
  65452. */
  65453. get value(): NodeMaterialConnectionPoint;
  65454. /**
  65455. * Gets the output component
  65456. */
  65457. get output(): NodeMaterialConnectionPoint;
  65458. protected _buildBlock(state: NodeMaterialBuildState): this;
  65459. }
  65460. }
  65461. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65465. /**
  65466. * Block used to get negative version of a value (i.e. x * -1)
  65467. */
  65468. export class NegateBlock extends NodeMaterialBlock {
  65469. /**
  65470. * Creates a new NegateBlock
  65471. * @param name defines the block name
  65472. */
  65473. constructor(name: string);
  65474. /**
  65475. * Gets the current class name
  65476. * @returns the class name
  65477. */
  65478. getClassName(): string;
  65479. /**
  65480. * Gets the value input component
  65481. */
  65482. get value(): NodeMaterialConnectionPoint;
  65483. /**
  65484. * Gets the output component
  65485. */
  65486. get output(): NodeMaterialConnectionPoint;
  65487. protected _buildBlock(state: NodeMaterialBuildState): this;
  65488. }
  65489. }
  65490. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65491. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65493. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65494. /**
  65495. * Block used to get the value of the first parameter raised to the power of the second
  65496. */
  65497. export class PowBlock extends NodeMaterialBlock {
  65498. /**
  65499. * Creates a new PowBlock
  65500. * @param name defines the block name
  65501. */
  65502. constructor(name: string);
  65503. /**
  65504. * Gets the current class name
  65505. * @returns the class name
  65506. */
  65507. getClassName(): string;
  65508. /**
  65509. * Gets the value operand input component
  65510. */
  65511. get value(): NodeMaterialConnectionPoint;
  65512. /**
  65513. * Gets the power operand input component
  65514. */
  65515. get power(): NodeMaterialConnectionPoint;
  65516. /**
  65517. * Gets the output component
  65518. */
  65519. get output(): NodeMaterialConnectionPoint;
  65520. protected _buildBlock(state: NodeMaterialBuildState): this;
  65521. }
  65522. }
  65523. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65527. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65528. /**
  65529. * Block used to get a random number
  65530. */
  65531. export class RandomNumberBlock extends NodeMaterialBlock {
  65532. /**
  65533. * Creates a new RandomNumberBlock
  65534. * @param name defines the block name
  65535. */
  65536. constructor(name: string);
  65537. /**
  65538. * Gets the current class name
  65539. * @returns the class name
  65540. */
  65541. getClassName(): string;
  65542. /**
  65543. * Gets the seed input component
  65544. */
  65545. get seed(): NodeMaterialConnectionPoint;
  65546. /**
  65547. * Gets the output component
  65548. */
  65549. get output(): NodeMaterialConnectionPoint;
  65550. protected _buildBlock(state: NodeMaterialBuildState): this;
  65551. }
  65552. }
  65553. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65557. /**
  65558. * Block used to compute arc tangent of 2 values
  65559. */
  65560. export class ArcTan2Block extends NodeMaterialBlock {
  65561. /**
  65562. * Creates a new ArcTan2Block
  65563. * @param name defines the block name
  65564. */
  65565. constructor(name: string);
  65566. /**
  65567. * Gets the current class name
  65568. * @returns the class name
  65569. */
  65570. getClassName(): string;
  65571. /**
  65572. * Gets the x operand input component
  65573. */
  65574. get x(): NodeMaterialConnectionPoint;
  65575. /**
  65576. * Gets the y operand input component
  65577. */
  65578. get y(): NodeMaterialConnectionPoint;
  65579. /**
  65580. * Gets the output component
  65581. */
  65582. get output(): NodeMaterialConnectionPoint;
  65583. protected _buildBlock(state: NodeMaterialBuildState): this;
  65584. }
  65585. }
  65586. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65590. /**
  65591. * Block used to smooth step a value
  65592. */
  65593. export class SmoothStepBlock extends NodeMaterialBlock {
  65594. /**
  65595. * Creates a new SmoothStepBlock
  65596. * @param name defines the block name
  65597. */
  65598. constructor(name: string);
  65599. /**
  65600. * Gets the current class name
  65601. * @returns the class name
  65602. */
  65603. getClassName(): string;
  65604. /**
  65605. * Gets the value operand input component
  65606. */
  65607. get value(): NodeMaterialConnectionPoint;
  65608. /**
  65609. * Gets the first edge operand input component
  65610. */
  65611. get edge0(): NodeMaterialConnectionPoint;
  65612. /**
  65613. * Gets the second edge operand input component
  65614. */
  65615. get edge1(): NodeMaterialConnectionPoint;
  65616. /**
  65617. * Gets the output component
  65618. */
  65619. get output(): NodeMaterialConnectionPoint;
  65620. protected _buildBlock(state: NodeMaterialBuildState): this;
  65621. }
  65622. }
  65623. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65624. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65625. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65626. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65627. /**
  65628. * Block used to get the reciprocal (1 / x) of a value
  65629. */
  65630. export class ReciprocalBlock extends NodeMaterialBlock {
  65631. /**
  65632. * Creates a new ReciprocalBlock
  65633. * @param name defines the block name
  65634. */
  65635. constructor(name: string);
  65636. /**
  65637. * Gets the current class name
  65638. * @returns the class name
  65639. */
  65640. getClassName(): string;
  65641. /**
  65642. * Gets the input component
  65643. */
  65644. get input(): NodeMaterialConnectionPoint;
  65645. /**
  65646. * Gets the output component
  65647. */
  65648. get output(): NodeMaterialConnectionPoint;
  65649. protected _buildBlock(state: NodeMaterialBuildState): this;
  65650. }
  65651. }
  65652. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65656. /**
  65657. * Block used to replace a color by another one
  65658. */
  65659. export class ReplaceColorBlock extends NodeMaterialBlock {
  65660. /**
  65661. * Creates a new ReplaceColorBlock
  65662. * @param name defines the block name
  65663. */
  65664. constructor(name: string);
  65665. /**
  65666. * Gets the current class name
  65667. * @returns the class name
  65668. */
  65669. getClassName(): string;
  65670. /**
  65671. * Gets the value input component
  65672. */
  65673. get value(): NodeMaterialConnectionPoint;
  65674. /**
  65675. * Gets the reference input component
  65676. */
  65677. get reference(): NodeMaterialConnectionPoint;
  65678. /**
  65679. * Gets the distance input component
  65680. */
  65681. get distance(): NodeMaterialConnectionPoint;
  65682. /**
  65683. * Gets the replacement input component
  65684. */
  65685. get replacement(): NodeMaterialConnectionPoint;
  65686. /**
  65687. * Gets the output component
  65688. */
  65689. get output(): NodeMaterialConnectionPoint;
  65690. protected _buildBlock(state: NodeMaterialBuildState): this;
  65691. }
  65692. }
  65693. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65695. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65696. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65697. /**
  65698. * Block used to posterize a value
  65699. * @see https://en.wikipedia.org/wiki/Posterization
  65700. */
  65701. export class PosterizeBlock extends NodeMaterialBlock {
  65702. /**
  65703. * Creates a new PosterizeBlock
  65704. * @param name defines the block name
  65705. */
  65706. constructor(name: string);
  65707. /**
  65708. * Gets the current class name
  65709. * @returns the class name
  65710. */
  65711. getClassName(): string;
  65712. /**
  65713. * Gets the value input component
  65714. */
  65715. get value(): NodeMaterialConnectionPoint;
  65716. /**
  65717. * Gets the steps input component
  65718. */
  65719. get steps(): NodeMaterialConnectionPoint;
  65720. /**
  65721. * Gets the output component
  65722. */
  65723. get output(): NodeMaterialConnectionPoint;
  65724. protected _buildBlock(state: NodeMaterialBuildState): this;
  65725. }
  65726. }
  65727. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  65728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65731. import { Scene } from "babylonjs/scene";
  65732. /**
  65733. * Operations supported by the Wave block
  65734. */
  65735. export enum WaveBlockKind {
  65736. /** SawTooth */
  65737. SawTooth = 0,
  65738. /** Square */
  65739. Square = 1,
  65740. /** Triangle */
  65741. Triangle = 2
  65742. }
  65743. /**
  65744. * Block used to apply wave operation to floats
  65745. */
  65746. export class WaveBlock extends NodeMaterialBlock {
  65747. /**
  65748. * Gets or sets the kibnd of wave to be applied by the block
  65749. */
  65750. kind: WaveBlockKind;
  65751. /**
  65752. * Creates a new WaveBlock
  65753. * @param name defines the block name
  65754. */
  65755. constructor(name: string);
  65756. /**
  65757. * Gets the current class name
  65758. * @returns the class name
  65759. */
  65760. getClassName(): string;
  65761. /**
  65762. * Gets the input component
  65763. */
  65764. get input(): NodeMaterialConnectionPoint;
  65765. /**
  65766. * Gets the output component
  65767. */
  65768. get output(): NodeMaterialConnectionPoint;
  65769. protected _buildBlock(state: NodeMaterialBuildState): this;
  65770. serialize(): any;
  65771. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65772. }
  65773. }
  65774. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  65775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65776. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65778. import { Color3 } from "babylonjs/Maths/math.color";
  65779. import { Scene } from "babylonjs/scene";
  65780. /**
  65781. * Class used to store a color step for the GradientBlock
  65782. */
  65783. export class GradientBlockColorStep {
  65784. /**
  65785. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65786. */
  65787. step: number;
  65788. /**
  65789. * Gets or sets the color associated with this step
  65790. */
  65791. color: Color3;
  65792. /**
  65793. * Creates a new GradientBlockColorStep
  65794. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65795. * @param color defines the color associated with this step
  65796. */
  65797. constructor(
  65798. /**
  65799. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  65800. */
  65801. step: number,
  65802. /**
  65803. * Gets or sets the color associated with this step
  65804. */
  65805. color: Color3);
  65806. }
  65807. /**
  65808. * Block used to return a color from a gradient based on an input value between 0 and 1
  65809. */
  65810. export class GradientBlock extends NodeMaterialBlock {
  65811. /**
  65812. * Gets or sets the list of color steps
  65813. */
  65814. colorSteps: GradientBlockColorStep[];
  65815. /**
  65816. * Creates a new GradientBlock
  65817. * @param name defines the block name
  65818. */
  65819. constructor(name: string);
  65820. /**
  65821. * Gets the current class name
  65822. * @returns the class name
  65823. */
  65824. getClassName(): string;
  65825. /**
  65826. * Gets the gradient input component
  65827. */
  65828. get gradient(): NodeMaterialConnectionPoint;
  65829. /**
  65830. * Gets the output component
  65831. */
  65832. get output(): NodeMaterialConnectionPoint;
  65833. private _writeColorConstant;
  65834. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65835. serialize(): any;
  65836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65837. protected _dumpPropertiesCode(): string;
  65838. }
  65839. }
  65840. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  65841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65844. /**
  65845. * Block used to normalize lerp between 2 values
  65846. */
  65847. export class NLerpBlock extends NodeMaterialBlock {
  65848. /**
  65849. * Creates a new NLerpBlock
  65850. * @param name defines the block name
  65851. */
  65852. constructor(name: string);
  65853. /**
  65854. * Gets the current class name
  65855. * @returns the class name
  65856. */
  65857. getClassName(): string;
  65858. /**
  65859. * Gets the left operand input component
  65860. */
  65861. get left(): NodeMaterialConnectionPoint;
  65862. /**
  65863. * Gets the right operand input component
  65864. */
  65865. get right(): NodeMaterialConnectionPoint;
  65866. /**
  65867. * Gets the gradient operand input component
  65868. */
  65869. get gradient(): NodeMaterialConnectionPoint;
  65870. /**
  65871. * Gets the output component
  65872. */
  65873. get output(): NodeMaterialConnectionPoint;
  65874. protected _buildBlock(state: NodeMaterialBuildState): this;
  65875. }
  65876. }
  65877. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  65878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65881. import { Scene } from "babylonjs/scene";
  65882. /**
  65883. * block used to Generate a Worley Noise 3D Noise Pattern
  65884. */
  65885. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65886. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65887. manhattanDistance: boolean;
  65888. /**
  65889. * Creates a new WorleyNoise3DBlock
  65890. * @param name defines the block name
  65891. */
  65892. constructor(name: string);
  65893. /**
  65894. * Gets the current class name
  65895. * @returns the class name
  65896. */
  65897. getClassName(): string;
  65898. /**
  65899. * Gets the seed input component
  65900. */
  65901. get seed(): NodeMaterialConnectionPoint;
  65902. /**
  65903. * Gets the jitter input component
  65904. */
  65905. get jitter(): NodeMaterialConnectionPoint;
  65906. /**
  65907. * Gets the output component
  65908. */
  65909. get output(): NodeMaterialConnectionPoint;
  65910. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65911. /**
  65912. * Exposes the properties to the UI?
  65913. */
  65914. protected _dumpPropertiesCode(): string;
  65915. /**
  65916. * Exposes the properties to the Seralize?
  65917. */
  65918. serialize(): any;
  65919. /**
  65920. * Exposes the properties to the deseralize?
  65921. */
  65922. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65923. }
  65924. }
  65925. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  65926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65927. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65928. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65929. /**
  65930. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65931. */
  65932. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65933. /**
  65934. * Creates a new SimplexPerlin3DBlock
  65935. * @param name defines the block name
  65936. */
  65937. constructor(name: string);
  65938. /**
  65939. * Gets the current class name
  65940. * @returns the class name
  65941. */
  65942. getClassName(): string;
  65943. /**
  65944. * Gets the seed operand input component
  65945. */
  65946. get seed(): NodeMaterialConnectionPoint;
  65947. /**
  65948. * Gets the output component
  65949. */
  65950. get output(): NodeMaterialConnectionPoint;
  65951. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65952. }
  65953. }
  65954. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  65955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65958. /**
  65959. * Block used to blend normals
  65960. */
  65961. export class NormalBlendBlock extends NodeMaterialBlock {
  65962. /**
  65963. * Creates a new NormalBlendBlock
  65964. * @param name defines the block name
  65965. */
  65966. constructor(name: string);
  65967. /**
  65968. * Gets the current class name
  65969. * @returns the class name
  65970. */
  65971. getClassName(): string;
  65972. /**
  65973. * Gets the first input component
  65974. */
  65975. get normalMap0(): NodeMaterialConnectionPoint;
  65976. /**
  65977. * Gets the second input component
  65978. */
  65979. get normalMap1(): NodeMaterialConnectionPoint;
  65980. /**
  65981. * Gets the output component
  65982. */
  65983. get output(): NodeMaterialConnectionPoint;
  65984. protected _buildBlock(state: NodeMaterialBuildState): this;
  65985. }
  65986. }
  65987. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  65988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65991. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65992. /**
  65993. * Block used to rotate a 2d vector by a given angle
  65994. */
  65995. export class Rotate2dBlock extends NodeMaterialBlock {
  65996. /**
  65997. * Creates a new Rotate2dBlock
  65998. * @param name defines the block name
  65999. */
  66000. constructor(name: string);
  66001. /**
  66002. * Gets the current class name
  66003. * @returns the class name
  66004. */
  66005. getClassName(): string;
  66006. /**
  66007. * Gets the input vector
  66008. */
  66009. get input(): NodeMaterialConnectionPoint;
  66010. /**
  66011. * Gets the input angle
  66012. */
  66013. get angle(): NodeMaterialConnectionPoint;
  66014. /**
  66015. * Gets the output component
  66016. */
  66017. get output(): NodeMaterialConnectionPoint;
  66018. autoConfigure(material: NodeMaterial): void;
  66019. protected _buildBlock(state: NodeMaterialBuildState): this;
  66020. }
  66021. }
  66022. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66023. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66024. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66025. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66026. /**
  66027. * Block used to get the reflected vector from a direction and a normal
  66028. */
  66029. export class ReflectBlock extends NodeMaterialBlock {
  66030. /**
  66031. * Creates a new ReflectBlock
  66032. * @param name defines the block name
  66033. */
  66034. constructor(name: string);
  66035. /**
  66036. * Gets the current class name
  66037. * @returns the class name
  66038. */
  66039. getClassName(): string;
  66040. /**
  66041. * Gets the incident component
  66042. */
  66043. get incident(): NodeMaterialConnectionPoint;
  66044. /**
  66045. * Gets the normal component
  66046. */
  66047. get normal(): NodeMaterialConnectionPoint;
  66048. /**
  66049. * Gets the output component
  66050. */
  66051. get output(): NodeMaterialConnectionPoint;
  66052. protected _buildBlock(state: NodeMaterialBuildState): this;
  66053. }
  66054. }
  66055. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66059. /**
  66060. * Block used to get the refracted vector from a direction and a normal
  66061. */
  66062. export class RefractBlock extends NodeMaterialBlock {
  66063. /**
  66064. * Creates a new RefractBlock
  66065. * @param name defines the block name
  66066. */
  66067. constructor(name: string);
  66068. /**
  66069. * Gets the current class name
  66070. * @returns the class name
  66071. */
  66072. getClassName(): string;
  66073. /**
  66074. * Gets the incident component
  66075. */
  66076. get incident(): NodeMaterialConnectionPoint;
  66077. /**
  66078. * Gets the normal component
  66079. */
  66080. get normal(): NodeMaterialConnectionPoint;
  66081. /**
  66082. * Gets the index of refraction component
  66083. */
  66084. get ior(): NodeMaterialConnectionPoint;
  66085. /**
  66086. * Gets the output component
  66087. */
  66088. get output(): NodeMaterialConnectionPoint;
  66089. protected _buildBlock(state: NodeMaterialBuildState): this;
  66090. }
  66091. }
  66092. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66096. /**
  66097. * Block used to desaturate a color
  66098. */
  66099. export class DesaturateBlock extends NodeMaterialBlock {
  66100. /**
  66101. * Creates a new DesaturateBlock
  66102. * @param name defines the block name
  66103. */
  66104. constructor(name: string);
  66105. /**
  66106. * Gets the current class name
  66107. * @returns the class name
  66108. */
  66109. getClassName(): string;
  66110. /**
  66111. * Gets the color operand input component
  66112. */
  66113. get color(): NodeMaterialConnectionPoint;
  66114. /**
  66115. * Gets the level operand input component
  66116. */
  66117. get level(): NodeMaterialConnectionPoint;
  66118. /**
  66119. * Gets the output component
  66120. */
  66121. get output(): NodeMaterialConnectionPoint;
  66122. protected _buildBlock(state: NodeMaterialBuildState): this;
  66123. }
  66124. }
  66125. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66126. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66127. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66128. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66129. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66130. import { Nullable } from "babylonjs/types";
  66131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66132. import { Scene } from "babylonjs/scene";
  66133. /**
  66134. * Block used to implement the ambient occlusion module of the PBR material
  66135. */
  66136. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66137. /**
  66138. * Create a new AmbientOcclusionBlock
  66139. * @param name defines the block name
  66140. */
  66141. constructor(name: string);
  66142. /**
  66143. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66144. */
  66145. useAmbientInGrayScale: boolean;
  66146. /**
  66147. * Initialize the block and prepare the context for build
  66148. * @param state defines the state that will be used for the build
  66149. */
  66150. initialize(state: NodeMaterialBuildState): void;
  66151. /**
  66152. * Gets the current class name
  66153. * @returns the class name
  66154. */
  66155. getClassName(): string;
  66156. /**
  66157. * Gets the texture input component
  66158. */
  66159. get texture(): NodeMaterialConnectionPoint;
  66160. /**
  66161. * Gets the texture intensity component
  66162. */
  66163. get intensity(): NodeMaterialConnectionPoint;
  66164. /**
  66165. * Gets the direct light intensity input component
  66166. */
  66167. get directLightIntensity(): NodeMaterialConnectionPoint;
  66168. /**
  66169. * Gets the ambient occlusion object output component
  66170. */
  66171. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66172. /**
  66173. * Gets the main code of the block (fragment side)
  66174. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66175. * @returns the shader code
  66176. */
  66177. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66179. protected _buildBlock(state: NodeMaterialBuildState): this;
  66180. protected _dumpPropertiesCode(): string;
  66181. serialize(): any;
  66182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66183. }
  66184. }
  66185. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66186. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66187. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66188. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66189. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66191. import { Nullable } from "babylonjs/types";
  66192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66193. import { Mesh } from "babylonjs/Meshes/mesh";
  66194. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66195. import { Effect } from "babylonjs/Materials/effect";
  66196. import { Scene } from "babylonjs/scene";
  66197. /**
  66198. * Block used to implement the reflection module of the PBR material
  66199. */
  66200. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66201. /** @hidden */
  66202. _defineLODReflectionAlpha: string;
  66203. /** @hidden */
  66204. _defineLinearSpecularReflection: string;
  66205. private _vEnvironmentIrradianceName;
  66206. /** @hidden */
  66207. _vReflectionMicrosurfaceInfosName: string;
  66208. /** @hidden */
  66209. _vReflectionInfosName: string;
  66210. /** @hidden */
  66211. _vReflectionFilteringInfoName: string;
  66212. private _scene;
  66213. /**
  66214. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66215. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66216. * It's less burden on the user side in the editor part.
  66217. */
  66218. /** @hidden */
  66219. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66220. /** @hidden */
  66221. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66222. /** @hidden */
  66223. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66224. /**
  66225. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66226. * diffuse part of the IBL.
  66227. */
  66228. useSphericalHarmonics: boolean;
  66229. /**
  66230. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66231. */
  66232. forceIrradianceInFragment: boolean;
  66233. /**
  66234. * Create a new ReflectionBlock
  66235. * @param name defines the block name
  66236. */
  66237. constructor(name: string);
  66238. /**
  66239. * Gets the current class name
  66240. * @returns the class name
  66241. */
  66242. getClassName(): string;
  66243. /**
  66244. * Gets the position input component
  66245. */
  66246. get position(): NodeMaterialConnectionPoint;
  66247. /**
  66248. * Gets the world position input component
  66249. */
  66250. get worldPosition(): NodeMaterialConnectionPoint;
  66251. /**
  66252. * Gets the world normal input component
  66253. */
  66254. get worldNormal(): NodeMaterialConnectionPoint;
  66255. /**
  66256. * Gets the world input component
  66257. */
  66258. get world(): NodeMaterialConnectionPoint;
  66259. /**
  66260. * Gets the camera (or eye) position component
  66261. */
  66262. get cameraPosition(): NodeMaterialConnectionPoint;
  66263. /**
  66264. * Gets the view input component
  66265. */
  66266. get view(): NodeMaterialConnectionPoint;
  66267. /**
  66268. * Gets the color input component
  66269. */
  66270. get color(): NodeMaterialConnectionPoint;
  66271. /**
  66272. * Gets the reflection object output component
  66273. */
  66274. get reflection(): NodeMaterialConnectionPoint;
  66275. /**
  66276. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66277. */
  66278. get hasTexture(): boolean;
  66279. /**
  66280. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66281. */
  66282. get reflectionColor(): string;
  66283. protected _getTexture(): Nullable<BaseTexture>;
  66284. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66285. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66286. /**
  66287. * Gets the code to inject in the vertex shader
  66288. * @param state current state of the node material building
  66289. * @returns the shader code
  66290. */
  66291. handleVertexSide(state: NodeMaterialBuildState): string;
  66292. /**
  66293. * Gets the main code of the block (fragment side)
  66294. * @param state current state of the node material building
  66295. * @param normalVarName name of the existing variable corresponding to the normal
  66296. * @returns the shader code
  66297. */
  66298. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66299. protected _buildBlock(state: NodeMaterialBuildState): this;
  66300. protected _dumpPropertiesCode(): string;
  66301. serialize(): any;
  66302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66303. }
  66304. }
  66305. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66308. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66309. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66311. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66312. import { Scene } from "babylonjs/scene";
  66313. import { Nullable } from "babylonjs/types";
  66314. /**
  66315. * Block used to implement the sheen module of the PBR material
  66316. */
  66317. export class SheenBlock extends NodeMaterialBlock {
  66318. /**
  66319. * Create a new SheenBlock
  66320. * @param name defines the block name
  66321. */
  66322. constructor(name: string);
  66323. /**
  66324. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66325. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66326. * making it easier to setup and tweak the effect
  66327. */
  66328. albedoScaling: boolean;
  66329. /**
  66330. * Defines if the sheen is linked to the sheen color.
  66331. */
  66332. linkSheenWithAlbedo: boolean;
  66333. /**
  66334. * Initialize the block and prepare the context for build
  66335. * @param state defines the state that will be used for the build
  66336. */
  66337. initialize(state: NodeMaterialBuildState): void;
  66338. /**
  66339. * Gets the current class name
  66340. * @returns the class name
  66341. */
  66342. getClassName(): string;
  66343. /**
  66344. * Gets the intensity input component
  66345. */
  66346. get intensity(): NodeMaterialConnectionPoint;
  66347. /**
  66348. * Gets the color input component
  66349. */
  66350. get color(): NodeMaterialConnectionPoint;
  66351. /**
  66352. * Gets the roughness input component
  66353. */
  66354. get roughness(): NodeMaterialConnectionPoint;
  66355. /**
  66356. * Gets the sheen object output component
  66357. */
  66358. get sheen(): NodeMaterialConnectionPoint;
  66359. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66360. /**
  66361. * Gets the main code of the block (fragment side)
  66362. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66363. * @returns the shader code
  66364. */
  66365. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66366. protected _buildBlock(state: NodeMaterialBuildState): this;
  66367. protected _dumpPropertiesCode(): string;
  66368. serialize(): any;
  66369. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66370. }
  66371. }
  66372. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66373. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66374. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66375. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66378. import { Scene } from "babylonjs/scene";
  66379. import { Nullable } from "babylonjs/types";
  66380. import { Mesh } from "babylonjs/Meshes/mesh";
  66381. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66382. import { Effect } from "babylonjs/Materials/effect";
  66383. /**
  66384. * Block used to implement the reflectivity module of the PBR material
  66385. */
  66386. export class ReflectivityBlock extends NodeMaterialBlock {
  66387. private _metallicReflectanceColor;
  66388. private _metallicF0Factor;
  66389. /** @hidden */
  66390. _vMetallicReflectanceFactorsName: string;
  66391. /**
  66392. * The property below is set by the main PBR block prior to calling methods of this class.
  66393. */
  66394. /** @hidden */
  66395. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66396. /**
  66397. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66398. */
  66399. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66400. /**
  66401. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66402. */
  66403. useMetallnessFromMetallicTextureBlue: boolean;
  66404. /**
  66405. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66406. */
  66407. useRoughnessFromMetallicTextureAlpha: boolean;
  66408. /**
  66409. * Specifies if the metallic texture contains the roughness information in its green channel.
  66410. */
  66411. useRoughnessFromMetallicTextureGreen: boolean;
  66412. /**
  66413. * Create a new ReflectivityBlock
  66414. * @param name defines the block name
  66415. */
  66416. constructor(name: string);
  66417. /**
  66418. * Initialize the block and prepare the context for build
  66419. * @param state defines the state that will be used for the build
  66420. */
  66421. initialize(state: NodeMaterialBuildState): void;
  66422. /**
  66423. * Gets the current class name
  66424. * @returns the class name
  66425. */
  66426. getClassName(): string;
  66427. /**
  66428. * Gets the metallic input component
  66429. */
  66430. get metallic(): NodeMaterialConnectionPoint;
  66431. /**
  66432. * Gets the roughness input component
  66433. */
  66434. get roughness(): NodeMaterialConnectionPoint;
  66435. /**
  66436. * Gets the texture input component
  66437. */
  66438. get texture(): NodeMaterialConnectionPoint;
  66439. /**
  66440. * Gets the reflectivity object output component
  66441. */
  66442. get reflectivity(): NodeMaterialConnectionPoint;
  66443. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66444. /**
  66445. * Gets the main code of the block (fragment side)
  66446. * @param state current state of the node material building
  66447. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66448. * @returns the shader code
  66449. */
  66450. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66451. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66452. protected _buildBlock(state: NodeMaterialBuildState): this;
  66453. protected _dumpPropertiesCode(): string;
  66454. serialize(): any;
  66455. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66456. }
  66457. }
  66458. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66459. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66460. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66461. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66462. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66464. /**
  66465. * Block used to implement the anisotropy module of the PBR material
  66466. */
  66467. export class AnisotropyBlock extends NodeMaterialBlock {
  66468. /**
  66469. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66470. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66471. * It's less burden on the user side in the editor part.
  66472. */
  66473. /** @hidden */
  66474. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66475. /** @hidden */
  66476. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66477. /**
  66478. * Create a new AnisotropyBlock
  66479. * @param name defines the block name
  66480. */
  66481. constructor(name: string);
  66482. /**
  66483. * Initialize the block and prepare the context for build
  66484. * @param state defines the state that will be used for the build
  66485. */
  66486. initialize(state: NodeMaterialBuildState): void;
  66487. /**
  66488. * Gets the current class name
  66489. * @returns the class name
  66490. */
  66491. getClassName(): string;
  66492. /**
  66493. * Gets the intensity input component
  66494. */
  66495. get intensity(): NodeMaterialConnectionPoint;
  66496. /**
  66497. * Gets the direction input component
  66498. */
  66499. get direction(): NodeMaterialConnectionPoint;
  66500. /**
  66501. * Gets the texture input component
  66502. */
  66503. get texture(): NodeMaterialConnectionPoint;
  66504. /**
  66505. * Gets the uv input component
  66506. */
  66507. get uv(): NodeMaterialConnectionPoint;
  66508. /**
  66509. * Gets the worldTangent input component
  66510. */
  66511. get worldTangent(): NodeMaterialConnectionPoint;
  66512. /**
  66513. * Gets the anisotropy object output component
  66514. */
  66515. get anisotropy(): NodeMaterialConnectionPoint;
  66516. private _generateTBNSpace;
  66517. /**
  66518. * Gets the main code of the block (fragment side)
  66519. * @param state current state of the node material building
  66520. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66521. * @returns the shader code
  66522. */
  66523. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66525. protected _buildBlock(state: NodeMaterialBuildState): this;
  66526. }
  66527. }
  66528. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66532. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66534. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66535. import { Nullable } from "babylonjs/types";
  66536. import { Mesh } from "babylonjs/Meshes/mesh";
  66537. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66538. import { Effect } from "babylonjs/Materials/effect";
  66539. /**
  66540. * Block used to implement the clear coat module of the PBR material
  66541. */
  66542. export class ClearCoatBlock extends NodeMaterialBlock {
  66543. private _scene;
  66544. /**
  66545. * Create a new ClearCoatBlock
  66546. * @param name defines the block name
  66547. */
  66548. constructor(name: string);
  66549. /**
  66550. * Initialize the block and prepare the context for build
  66551. * @param state defines the state that will be used for the build
  66552. */
  66553. initialize(state: NodeMaterialBuildState): void;
  66554. /**
  66555. * Gets the current class name
  66556. * @returns the class name
  66557. */
  66558. getClassName(): string;
  66559. /**
  66560. * Gets the intensity input component
  66561. */
  66562. get intensity(): NodeMaterialConnectionPoint;
  66563. /**
  66564. * Gets the roughness input component
  66565. */
  66566. get roughness(): NodeMaterialConnectionPoint;
  66567. /**
  66568. * Gets the ior input component
  66569. */
  66570. get ior(): NodeMaterialConnectionPoint;
  66571. /**
  66572. * Gets the texture input component
  66573. */
  66574. get texture(): NodeMaterialConnectionPoint;
  66575. /**
  66576. * Gets the bump texture input component
  66577. */
  66578. get bumpTexture(): NodeMaterialConnectionPoint;
  66579. /**
  66580. * Gets the uv input component
  66581. */
  66582. get uv(): NodeMaterialConnectionPoint;
  66583. /**
  66584. * Gets the tint color input component
  66585. */
  66586. get tintColor(): NodeMaterialConnectionPoint;
  66587. /**
  66588. * Gets the tint "at distance" input component
  66589. */
  66590. get tintAtDistance(): NodeMaterialConnectionPoint;
  66591. /**
  66592. * Gets the tint thickness input component
  66593. */
  66594. get tintThickness(): NodeMaterialConnectionPoint;
  66595. /**
  66596. * Gets the world tangent input component
  66597. */
  66598. get worldTangent(): NodeMaterialConnectionPoint;
  66599. /**
  66600. * Gets the clear coat object output component
  66601. */
  66602. get clearcoat(): NodeMaterialConnectionPoint;
  66603. autoConfigure(material: NodeMaterial): void;
  66604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66605. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66606. private _generateTBNSpace;
  66607. /**
  66608. * Gets the main code of the block (fragment side)
  66609. * @param state current state of the node material building
  66610. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66611. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66612. * @param worldPosVarName name of the variable holding the world position
  66613. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66614. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66615. * @param worldNormalVarName name of the variable holding the world normal
  66616. * @returns the shader code
  66617. */
  66618. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66619. protected _buildBlock(state: NodeMaterialBuildState): this;
  66620. }
  66621. }
  66622. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66623. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66624. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66626. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66628. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66629. import { Nullable } from "babylonjs/types";
  66630. /**
  66631. * Block used to implement the sub surface module of the PBR material
  66632. */
  66633. export class SubSurfaceBlock extends NodeMaterialBlock {
  66634. /**
  66635. * Create a new SubSurfaceBlock
  66636. * @param name defines the block name
  66637. */
  66638. constructor(name: string);
  66639. /**
  66640. * Stores the intensity of the different subsurface effects in the thickness texture.
  66641. * * the green channel is the translucency intensity.
  66642. * * the blue channel is the scattering intensity.
  66643. * * the alpha channel is the refraction intensity.
  66644. */
  66645. useMaskFromThicknessTexture: boolean;
  66646. /**
  66647. * Initialize the block and prepare the context for build
  66648. * @param state defines the state that will be used for the build
  66649. */
  66650. initialize(state: NodeMaterialBuildState): void;
  66651. /**
  66652. * Gets the current class name
  66653. * @returns the class name
  66654. */
  66655. getClassName(): string;
  66656. /**
  66657. * Gets the min thickness input component
  66658. */
  66659. get minThickness(): NodeMaterialConnectionPoint;
  66660. /**
  66661. * Gets the max thickness input component
  66662. */
  66663. get maxThickness(): NodeMaterialConnectionPoint;
  66664. /**
  66665. * Gets the thickness texture component
  66666. */
  66667. get thicknessTexture(): NodeMaterialConnectionPoint;
  66668. /**
  66669. * Gets the tint color input component
  66670. */
  66671. get tintColor(): NodeMaterialConnectionPoint;
  66672. /**
  66673. * Gets the translucency intensity input component
  66674. */
  66675. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66676. /**
  66677. * Gets the translucency diffusion distance input component
  66678. */
  66679. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66680. /**
  66681. * Gets the refraction object parameters
  66682. */
  66683. get refraction(): NodeMaterialConnectionPoint;
  66684. /**
  66685. * Gets the sub surface object output component
  66686. */
  66687. get subsurface(): NodeMaterialConnectionPoint;
  66688. autoConfigure(material: NodeMaterial): void;
  66689. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66690. /**
  66691. * Gets the main code of the block (fragment side)
  66692. * @param state current state of the node material building
  66693. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66694. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66695. * @param worldPosVarName name of the variable holding the world position
  66696. * @returns the shader code
  66697. */
  66698. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66699. protected _buildBlock(state: NodeMaterialBuildState): this;
  66700. }
  66701. }
  66702. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  66703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66706. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66707. import { Light } from "babylonjs/Lights/light";
  66708. import { Nullable } from "babylonjs/types";
  66709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66710. import { Effect } from "babylonjs/Materials/effect";
  66711. import { Mesh } from "babylonjs/Meshes/mesh";
  66712. import { Scene } from "babylonjs/scene";
  66713. /**
  66714. * Block used to implement the PBR metallic/roughness model
  66715. */
  66716. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66717. /**
  66718. * Gets or sets the light associated with this block
  66719. */
  66720. light: Nullable<Light>;
  66721. private _lightId;
  66722. private _scene;
  66723. private _environmentBRDFTexture;
  66724. private _environmentBrdfSamplerName;
  66725. private _vNormalWName;
  66726. private _invertNormalName;
  66727. /**
  66728. * Create a new ReflectionBlock
  66729. * @param name defines the block name
  66730. */
  66731. constructor(name: string);
  66732. /**
  66733. * Intensity of the direct lights e.g. the four lights available in your scene.
  66734. * This impacts both the direct diffuse and specular highlights.
  66735. */
  66736. directIntensity: number;
  66737. /**
  66738. * Intensity of the environment e.g. how much the environment will light the object
  66739. * either through harmonics for rough material or through the refelction for shiny ones.
  66740. */
  66741. environmentIntensity: number;
  66742. /**
  66743. * This is a special control allowing the reduction of the specular highlights coming from the
  66744. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66745. */
  66746. specularIntensity: number;
  66747. /**
  66748. * Defines the falloff type used in this material.
  66749. * It by default is Physical.
  66750. */
  66751. lightFalloff: number;
  66752. /**
  66753. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  66754. */
  66755. useAlphaFromAlbedoTexture: boolean;
  66756. /**
  66757. * Specifies that alpha test should be used
  66758. */
  66759. useAlphaTest: boolean;
  66760. /**
  66761. * Defines the alpha limits in alpha test mode.
  66762. */
  66763. alphaTestCutoff: number;
  66764. /**
  66765. * Specifies that alpha blending should be used
  66766. */
  66767. useAlphaBlending: boolean;
  66768. /**
  66769. * Defines if the alpha value should be determined via the rgb values.
  66770. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  66771. */
  66772. opacityRGB: boolean;
  66773. /**
  66774. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66775. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66776. */
  66777. useRadianceOverAlpha: boolean;
  66778. /**
  66779. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66780. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66781. */
  66782. useSpecularOverAlpha: boolean;
  66783. /**
  66784. * Enables specular anti aliasing in the PBR shader.
  66785. * It will both interacts on the Geometry for analytical and IBL lighting.
  66786. * It also prefilter the roughness map based on the bump values.
  66787. */
  66788. enableSpecularAntiAliasing: boolean;
  66789. /**
  66790. * Enables realtime filtering on the texture.
  66791. */
  66792. realTimeFiltering: boolean;
  66793. /**
  66794. * Quality switch for realtime filtering
  66795. */
  66796. realTimeFilteringQuality: number;
  66797. /**
  66798. * Defines if the material uses energy conservation.
  66799. */
  66800. useEnergyConservation: boolean;
  66801. /**
  66802. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66803. * too much the area relying on ambient texture to define their ambient occlusion.
  66804. */
  66805. useRadianceOcclusion: boolean;
  66806. /**
  66807. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66808. * makes the reflect vector face the model (under horizon).
  66809. */
  66810. useHorizonOcclusion: boolean;
  66811. /**
  66812. * If set to true, no lighting calculations will be applied.
  66813. */
  66814. unlit: boolean;
  66815. /**
  66816. * Force normal to face away from face.
  66817. */
  66818. forceNormalForward: boolean;
  66819. /**
  66820. * Defines the material debug mode.
  66821. * It helps seeing only some components of the material while troubleshooting.
  66822. */
  66823. debugMode: number;
  66824. /**
  66825. * Specify from where on screen the debug mode should start.
  66826. * The value goes from -1 (full screen) to 1 (not visible)
  66827. * It helps with side by side comparison against the final render
  66828. * This defaults to 0
  66829. */
  66830. debugLimit: number;
  66831. /**
  66832. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66833. * You can use the factor to better multiply the final value.
  66834. */
  66835. debugFactor: number;
  66836. /**
  66837. * Initialize the block and prepare the context for build
  66838. * @param state defines the state that will be used for the build
  66839. */
  66840. initialize(state: NodeMaterialBuildState): void;
  66841. /**
  66842. * Gets the current class name
  66843. * @returns the class name
  66844. */
  66845. getClassName(): string;
  66846. /**
  66847. * Gets the world position input component
  66848. */
  66849. get worldPosition(): NodeMaterialConnectionPoint;
  66850. /**
  66851. * Gets the world normal input component
  66852. */
  66853. get worldNormal(): NodeMaterialConnectionPoint;
  66854. /**
  66855. * Gets the perturbed normal input component
  66856. */
  66857. get perturbedNormal(): NodeMaterialConnectionPoint;
  66858. /**
  66859. * Gets the camera position input component
  66860. */
  66861. get cameraPosition(): NodeMaterialConnectionPoint;
  66862. /**
  66863. * Gets the base color input component
  66864. */
  66865. get baseColor(): NodeMaterialConnectionPoint;
  66866. /**
  66867. * Gets the opacity texture input component
  66868. */
  66869. get opacityTexture(): NodeMaterialConnectionPoint;
  66870. /**
  66871. * Gets the ambient color input component
  66872. */
  66873. get ambientColor(): NodeMaterialConnectionPoint;
  66874. /**
  66875. * Gets the reflectivity object parameters
  66876. */
  66877. get reflectivity(): NodeMaterialConnectionPoint;
  66878. /**
  66879. * Gets the ambient occlusion object parameters
  66880. */
  66881. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66882. /**
  66883. * Gets the reflection object parameters
  66884. */
  66885. get reflection(): NodeMaterialConnectionPoint;
  66886. /**
  66887. * Gets the sheen object parameters
  66888. */
  66889. get sheen(): NodeMaterialConnectionPoint;
  66890. /**
  66891. * Gets the clear coat object parameters
  66892. */
  66893. get clearcoat(): NodeMaterialConnectionPoint;
  66894. /**
  66895. * Gets the sub surface object parameters
  66896. */
  66897. get subsurface(): NodeMaterialConnectionPoint;
  66898. /**
  66899. * Gets the anisotropy object parameters
  66900. */
  66901. get anisotropy(): NodeMaterialConnectionPoint;
  66902. /**
  66903. * Gets the ambient output component
  66904. */
  66905. get ambient(): NodeMaterialConnectionPoint;
  66906. /**
  66907. * Gets the diffuse output component
  66908. */
  66909. get diffuse(): NodeMaterialConnectionPoint;
  66910. /**
  66911. * Gets the specular output component
  66912. */
  66913. get specular(): NodeMaterialConnectionPoint;
  66914. /**
  66915. * Gets the sheen output component
  66916. */
  66917. get sheenDir(): NodeMaterialConnectionPoint;
  66918. /**
  66919. * Gets the clear coat output component
  66920. */
  66921. get clearcoatDir(): NodeMaterialConnectionPoint;
  66922. /**
  66923. * Gets the indirect diffuse output component
  66924. */
  66925. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66926. /**
  66927. * Gets the indirect specular output component
  66928. */
  66929. get specularIndirect(): NodeMaterialConnectionPoint;
  66930. /**
  66931. * Gets the indirect sheen output component
  66932. */
  66933. get sheenIndirect(): NodeMaterialConnectionPoint;
  66934. /**
  66935. * Gets the indirect clear coat output component
  66936. */
  66937. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66938. /**
  66939. * Gets the refraction output component
  66940. */
  66941. get refraction(): NodeMaterialConnectionPoint;
  66942. /**
  66943. * Gets the global lighting output component
  66944. */
  66945. get lighting(): NodeMaterialConnectionPoint;
  66946. /**
  66947. * Gets the shadow output component
  66948. */
  66949. get shadow(): NodeMaterialConnectionPoint;
  66950. /**
  66951. * Gets the alpha output component
  66952. */
  66953. get alpha(): NodeMaterialConnectionPoint;
  66954. autoConfigure(material: NodeMaterial): void;
  66955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66956. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66958. private _injectVertexCode;
  66959. /**
  66960. * Gets the code corresponding to the albedo/opacity module
  66961. * @returns the shader code
  66962. */
  66963. getAlbedoOpacityCode(): string;
  66964. protected _buildBlock(state: NodeMaterialBuildState): this;
  66965. protected _dumpPropertiesCode(): string;
  66966. serialize(): any;
  66967. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66968. }
  66969. }
  66970. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  66971. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  66972. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  66973. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  66974. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  66975. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  66976. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66977. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  66978. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  66979. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  66980. }
  66981. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  66982. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  66983. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  66984. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  66985. }
  66986. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  66987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66990. /**
  66991. * Block used to compute value of one parameter modulo another
  66992. */
  66993. export class ModBlock extends NodeMaterialBlock {
  66994. /**
  66995. * Creates a new ModBlock
  66996. * @param name defines the block name
  66997. */
  66998. constructor(name: string);
  66999. /**
  67000. * Gets the current class name
  67001. * @returns the class name
  67002. */
  67003. getClassName(): string;
  67004. /**
  67005. * Gets the left operand input component
  67006. */
  67007. get left(): NodeMaterialConnectionPoint;
  67008. /**
  67009. * Gets the right operand input component
  67010. */
  67011. get right(): NodeMaterialConnectionPoint;
  67012. /**
  67013. * Gets the output component
  67014. */
  67015. get output(): NodeMaterialConnectionPoint;
  67016. protected _buildBlock(state: NodeMaterialBuildState): this;
  67017. }
  67018. }
  67019. declare module "babylonjs/Materials/Node/Blocks/index" {
  67020. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67021. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67022. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67023. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67024. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67025. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67026. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67027. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67028. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67029. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67030. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67031. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67032. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67033. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67034. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67035. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67036. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67037. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67038. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67039. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67040. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67041. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67042. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67043. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67044. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67045. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67046. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67047. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67048. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67049. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67050. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67051. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67052. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67053. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67054. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67055. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67056. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67057. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67058. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67059. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67060. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67061. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67062. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67063. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67064. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67065. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67066. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67067. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67068. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67069. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67070. }
  67071. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67072. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67073. }
  67074. declare module "babylonjs/Materials/Node/index" {
  67075. export * from "babylonjs/Materials/Node/Enums/index";
  67076. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67077. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67078. export * from "babylonjs/Materials/Node/nodeMaterial";
  67079. export * from "babylonjs/Materials/Node/Blocks/index";
  67080. export * from "babylonjs/Materials/Node/Optimizers/index";
  67081. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67082. }
  67083. declare module "babylonjs/Materials/index" {
  67084. export * from "babylonjs/Materials/Background/index";
  67085. export * from "babylonjs/Materials/colorCurves";
  67086. export * from "babylonjs/Materials/iEffectFallbacks";
  67087. export * from "babylonjs/Materials/effectFallbacks";
  67088. export * from "babylonjs/Materials/effect";
  67089. export * from "babylonjs/Materials/fresnelParameters";
  67090. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67091. export * from "babylonjs/Materials/material";
  67092. export * from "babylonjs/Materials/materialDefines";
  67093. export * from "babylonjs/Materials/materialHelper";
  67094. export * from "babylonjs/Materials/multiMaterial";
  67095. export * from "babylonjs/Materials/PBR/index";
  67096. export * from "babylonjs/Materials/pushMaterial";
  67097. export * from "babylonjs/Materials/shaderMaterial";
  67098. export * from "babylonjs/Materials/standardMaterial";
  67099. export * from "babylonjs/Materials/Textures/index";
  67100. export * from "babylonjs/Materials/uniformBuffer";
  67101. export * from "babylonjs/Materials/materialFlags";
  67102. export * from "babylonjs/Materials/Node/index";
  67103. export * from "babylonjs/Materials/effectRenderer";
  67104. export * from "babylonjs/Materials/shadowDepthWrapper";
  67105. }
  67106. declare module "babylonjs/Maths/index" {
  67107. export * from "babylonjs/Maths/math.scalar";
  67108. export * from "babylonjs/Maths/math";
  67109. export * from "babylonjs/Maths/sphericalPolynomial";
  67110. }
  67111. declare module "babylonjs/Misc/workerPool" {
  67112. import { IDisposable } from "babylonjs/scene";
  67113. /**
  67114. * Helper class to push actions to a pool of workers.
  67115. */
  67116. export class WorkerPool implements IDisposable {
  67117. private _workerInfos;
  67118. private _pendingActions;
  67119. /**
  67120. * Constructor
  67121. * @param workers Array of workers to use for actions
  67122. */
  67123. constructor(workers: Array<Worker>);
  67124. /**
  67125. * Terminates all workers and clears any pending actions.
  67126. */
  67127. dispose(): void;
  67128. /**
  67129. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67130. * pended until a worker has completed its action.
  67131. * @param action The action to perform. Call onComplete when the action is complete.
  67132. */
  67133. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67134. private _execute;
  67135. }
  67136. }
  67137. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67138. import { IDisposable } from "babylonjs/scene";
  67139. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67140. /**
  67141. * Configuration for Draco compression
  67142. */
  67143. export interface IDracoCompressionConfiguration {
  67144. /**
  67145. * Configuration for the decoder.
  67146. */
  67147. decoder: {
  67148. /**
  67149. * The url to the WebAssembly module.
  67150. */
  67151. wasmUrl?: string;
  67152. /**
  67153. * The url to the WebAssembly binary.
  67154. */
  67155. wasmBinaryUrl?: string;
  67156. /**
  67157. * The url to the fallback JavaScript module.
  67158. */
  67159. fallbackUrl?: string;
  67160. };
  67161. }
  67162. /**
  67163. * Draco compression (https://google.github.io/draco/)
  67164. *
  67165. * This class wraps the Draco module.
  67166. *
  67167. * **Encoder**
  67168. *
  67169. * The encoder is not currently implemented.
  67170. *
  67171. * **Decoder**
  67172. *
  67173. * 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.
  67174. *
  67175. * To update the configuration, use the following code:
  67176. * ```javascript
  67177. * DracoCompression.Configuration = {
  67178. * decoder: {
  67179. * wasmUrl: "<url to the WebAssembly library>",
  67180. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67181. * fallbackUrl: "<url to the fallback JavaScript library>",
  67182. * }
  67183. * };
  67184. * ```
  67185. *
  67186. * 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.
  67187. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67188. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67189. *
  67190. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67191. * ```javascript
  67192. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67193. * ```
  67194. *
  67195. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67196. */
  67197. export class DracoCompression implements IDisposable {
  67198. private _workerPoolPromise?;
  67199. private _decoderModulePromise?;
  67200. /**
  67201. * The configuration. Defaults to the following urls:
  67202. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67203. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67204. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67205. */
  67206. static Configuration: IDracoCompressionConfiguration;
  67207. /**
  67208. * Returns true if the decoder configuration is available.
  67209. */
  67210. static get DecoderAvailable(): boolean;
  67211. /**
  67212. * Default number of workers to create when creating the draco compression object.
  67213. */
  67214. static DefaultNumWorkers: number;
  67215. private static GetDefaultNumWorkers;
  67216. private static _Default;
  67217. /**
  67218. * Default instance for the draco compression object.
  67219. */
  67220. static get Default(): DracoCompression;
  67221. /**
  67222. * Constructor
  67223. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67224. */
  67225. constructor(numWorkers?: number);
  67226. /**
  67227. * Stop all async operations and release resources.
  67228. */
  67229. dispose(): void;
  67230. /**
  67231. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67232. * @returns a promise that resolves when ready
  67233. */
  67234. whenReadyAsync(): Promise<void>;
  67235. /**
  67236. * Decode Draco compressed mesh data to vertex data.
  67237. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67238. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67239. * @returns A promise that resolves with the decoded vertex data
  67240. */
  67241. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67242. [kind: string]: number;
  67243. }): Promise<VertexData>;
  67244. }
  67245. }
  67246. declare module "babylonjs/Meshes/Compression/index" {
  67247. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67248. }
  67249. declare module "babylonjs/Meshes/csg" {
  67250. import { Nullable } from "babylonjs/types";
  67251. import { Scene } from "babylonjs/scene";
  67252. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67253. import { Mesh } from "babylonjs/Meshes/mesh";
  67254. import { Material } from "babylonjs/Materials/material";
  67255. /**
  67256. * Class for building Constructive Solid Geometry
  67257. */
  67258. export class CSG {
  67259. private polygons;
  67260. /**
  67261. * The world matrix
  67262. */
  67263. matrix: Matrix;
  67264. /**
  67265. * Stores the position
  67266. */
  67267. position: Vector3;
  67268. /**
  67269. * Stores the rotation
  67270. */
  67271. rotation: Vector3;
  67272. /**
  67273. * Stores the rotation quaternion
  67274. */
  67275. rotationQuaternion: Nullable<Quaternion>;
  67276. /**
  67277. * Stores the scaling vector
  67278. */
  67279. scaling: Vector3;
  67280. /**
  67281. * Convert the Mesh to CSG
  67282. * @param mesh The Mesh to convert to CSG
  67283. * @returns A new CSG from the Mesh
  67284. */
  67285. static FromMesh(mesh: Mesh): CSG;
  67286. /**
  67287. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67288. * @param polygons Polygons used to construct a CSG solid
  67289. */
  67290. private static FromPolygons;
  67291. /**
  67292. * Clones, or makes a deep copy, of the CSG
  67293. * @returns A new CSG
  67294. */
  67295. clone(): CSG;
  67296. /**
  67297. * Unions this CSG with another CSG
  67298. * @param csg The CSG to union against this CSG
  67299. * @returns The unioned CSG
  67300. */
  67301. union(csg: CSG): CSG;
  67302. /**
  67303. * Unions this CSG with another CSG in place
  67304. * @param csg The CSG to union against this CSG
  67305. */
  67306. unionInPlace(csg: CSG): void;
  67307. /**
  67308. * Subtracts this CSG with another CSG
  67309. * @param csg The CSG to subtract against this CSG
  67310. * @returns A new CSG
  67311. */
  67312. subtract(csg: CSG): CSG;
  67313. /**
  67314. * Subtracts this CSG with another CSG in place
  67315. * @param csg The CSG to subtact against this CSG
  67316. */
  67317. subtractInPlace(csg: CSG): void;
  67318. /**
  67319. * Intersect this CSG with another CSG
  67320. * @param csg The CSG to intersect against this CSG
  67321. * @returns A new CSG
  67322. */
  67323. intersect(csg: CSG): CSG;
  67324. /**
  67325. * Intersects this CSG with another CSG in place
  67326. * @param csg The CSG to intersect against this CSG
  67327. */
  67328. intersectInPlace(csg: CSG): void;
  67329. /**
  67330. * Return a new CSG solid with solid and empty space switched. This solid is
  67331. * not modified.
  67332. * @returns A new CSG solid with solid and empty space switched
  67333. */
  67334. inverse(): CSG;
  67335. /**
  67336. * Inverses the CSG in place
  67337. */
  67338. inverseInPlace(): void;
  67339. /**
  67340. * This is used to keep meshes transformations so they can be restored
  67341. * when we build back a Babylon Mesh
  67342. * NB : All CSG operations are performed in world coordinates
  67343. * @param csg The CSG to copy the transform attributes from
  67344. * @returns This CSG
  67345. */
  67346. copyTransformAttributes(csg: CSG): CSG;
  67347. /**
  67348. * Build Raw mesh from CSG
  67349. * Coordinates here are in world space
  67350. * @param name The name of the mesh geometry
  67351. * @param scene The Scene
  67352. * @param keepSubMeshes Specifies if the submeshes should be kept
  67353. * @returns A new Mesh
  67354. */
  67355. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67356. /**
  67357. * Build Mesh from CSG taking material and transforms into account
  67358. * @param name The name of the Mesh
  67359. * @param material The material of the Mesh
  67360. * @param scene The Scene
  67361. * @param keepSubMeshes Specifies if submeshes should be kept
  67362. * @returns The new Mesh
  67363. */
  67364. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67365. }
  67366. }
  67367. declare module "babylonjs/Meshes/trailMesh" {
  67368. import { Mesh } from "babylonjs/Meshes/mesh";
  67369. import { Scene } from "babylonjs/scene";
  67370. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67371. /**
  67372. * Class used to create a trail following a mesh
  67373. */
  67374. export class TrailMesh extends Mesh {
  67375. private _generator;
  67376. private _autoStart;
  67377. private _running;
  67378. private _diameter;
  67379. private _length;
  67380. private _sectionPolygonPointsCount;
  67381. private _sectionVectors;
  67382. private _sectionNormalVectors;
  67383. private _beforeRenderObserver;
  67384. /**
  67385. * @constructor
  67386. * @param name The value used by scene.getMeshByName() to do a lookup.
  67387. * @param generator The mesh or transform node to generate a trail.
  67388. * @param scene The scene to add this mesh to.
  67389. * @param diameter Diameter of trailing mesh. Default is 1.
  67390. * @param length Length of trailing mesh. Default is 60.
  67391. * @param autoStart Automatically start trailing mesh. Default true.
  67392. */
  67393. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67394. /**
  67395. * "TrailMesh"
  67396. * @returns "TrailMesh"
  67397. */
  67398. getClassName(): string;
  67399. private _createMesh;
  67400. /**
  67401. * Start trailing mesh.
  67402. */
  67403. start(): void;
  67404. /**
  67405. * Stop trailing mesh.
  67406. */
  67407. stop(): void;
  67408. /**
  67409. * Update trailing mesh geometry.
  67410. */
  67411. update(): void;
  67412. /**
  67413. * Returns a new TrailMesh object.
  67414. * @param name is a string, the name given to the new mesh
  67415. * @param newGenerator use new generator object for cloned trail mesh
  67416. * @returns a new mesh
  67417. */
  67418. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67419. /**
  67420. * Serializes this trail mesh
  67421. * @param serializationObject object to write serialization to
  67422. */
  67423. serialize(serializationObject: any): void;
  67424. /**
  67425. * Parses a serialized trail mesh
  67426. * @param parsedMesh the serialized mesh
  67427. * @param scene the scene to create the trail mesh in
  67428. * @returns the created trail mesh
  67429. */
  67430. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67431. }
  67432. }
  67433. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67434. import { Nullable } from "babylonjs/types";
  67435. import { Scene } from "babylonjs/scene";
  67436. import { Vector4 } from "babylonjs/Maths/math.vector";
  67437. import { Color4 } from "babylonjs/Maths/math.color";
  67438. import { Mesh } from "babylonjs/Meshes/mesh";
  67439. /**
  67440. * Class containing static functions to help procedurally build meshes
  67441. */
  67442. export class TiledBoxBuilder {
  67443. /**
  67444. * Creates a box mesh
  67445. * 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)
  67446. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67450. * @param name defines the name of the mesh
  67451. * @param options defines the options used to create the mesh
  67452. * @param scene defines the hosting scene
  67453. * @returns the box mesh
  67454. */
  67455. static CreateTiledBox(name: string, options: {
  67456. pattern?: number;
  67457. width?: number;
  67458. height?: number;
  67459. depth?: number;
  67460. tileSize?: number;
  67461. tileWidth?: number;
  67462. tileHeight?: number;
  67463. alignHorizontal?: number;
  67464. alignVertical?: number;
  67465. faceUV?: Vector4[];
  67466. faceColors?: Color4[];
  67467. sideOrientation?: number;
  67468. updatable?: boolean;
  67469. }, scene?: Nullable<Scene>): Mesh;
  67470. }
  67471. }
  67472. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67473. import { Vector4 } from "babylonjs/Maths/math.vector";
  67474. import { Mesh } from "babylonjs/Meshes/mesh";
  67475. /**
  67476. * Class containing static functions to help procedurally build meshes
  67477. */
  67478. export class TorusKnotBuilder {
  67479. /**
  67480. * Creates a torus knot mesh
  67481. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67482. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67483. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67484. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67486. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67488. * @param name defines the name of the mesh
  67489. * @param options defines the options used to create the mesh
  67490. * @param scene defines the hosting scene
  67491. * @returns the torus knot mesh
  67492. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67493. */
  67494. static CreateTorusKnot(name: string, options: {
  67495. radius?: number;
  67496. tube?: number;
  67497. radialSegments?: number;
  67498. tubularSegments?: number;
  67499. p?: number;
  67500. q?: number;
  67501. updatable?: boolean;
  67502. sideOrientation?: number;
  67503. frontUVs?: Vector4;
  67504. backUVs?: Vector4;
  67505. }, scene: any): Mesh;
  67506. }
  67507. }
  67508. declare module "babylonjs/Meshes/polygonMesh" {
  67509. import { Scene } from "babylonjs/scene";
  67510. import { Vector2 } from "babylonjs/Maths/math.vector";
  67511. import { Mesh } from "babylonjs/Meshes/mesh";
  67512. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67513. import { Path2 } from "babylonjs/Maths/math.path";
  67514. /**
  67515. * Polygon
  67516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67517. */
  67518. export class Polygon {
  67519. /**
  67520. * Creates a rectangle
  67521. * @param xmin bottom X coord
  67522. * @param ymin bottom Y coord
  67523. * @param xmax top X coord
  67524. * @param ymax top Y coord
  67525. * @returns points that make the resulting rectation
  67526. */
  67527. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67528. /**
  67529. * Creates a circle
  67530. * @param radius radius of circle
  67531. * @param cx scale in x
  67532. * @param cy scale in y
  67533. * @param numberOfSides number of sides that make up the circle
  67534. * @returns points that make the resulting circle
  67535. */
  67536. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67537. /**
  67538. * Creates a polygon from input string
  67539. * @param input Input polygon data
  67540. * @returns the parsed points
  67541. */
  67542. static Parse(input: string): Vector2[];
  67543. /**
  67544. * Starts building a polygon from x and y coordinates
  67545. * @param x x coordinate
  67546. * @param y y coordinate
  67547. * @returns the started path2
  67548. */
  67549. static StartingAt(x: number, y: number): Path2;
  67550. }
  67551. /**
  67552. * Builds a polygon
  67553. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67554. */
  67555. export class PolygonMeshBuilder {
  67556. private _points;
  67557. private _outlinepoints;
  67558. private _holes;
  67559. private _name;
  67560. private _scene;
  67561. private _epoints;
  67562. private _eholes;
  67563. private _addToepoint;
  67564. /**
  67565. * Babylon reference to the earcut plugin.
  67566. */
  67567. bjsEarcut: any;
  67568. /**
  67569. * Creates a PolygonMeshBuilder
  67570. * @param name name of the builder
  67571. * @param contours Path of the polygon
  67572. * @param scene scene to add to when creating the mesh
  67573. * @param earcutInjection can be used to inject your own earcut reference
  67574. */
  67575. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67576. /**
  67577. * Adds a whole within the polygon
  67578. * @param hole Array of points defining the hole
  67579. * @returns this
  67580. */
  67581. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67582. /**
  67583. * Creates the polygon
  67584. * @param updatable If the mesh should be updatable
  67585. * @param depth The depth of the mesh created
  67586. * @returns the created mesh
  67587. */
  67588. build(updatable?: boolean, depth?: number): Mesh;
  67589. /**
  67590. * Creates the polygon
  67591. * @param depth The depth of the mesh created
  67592. * @returns the created VertexData
  67593. */
  67594. buildVertexData(depth?: number): VertexData;
  67595. /**
  67596. * Adds a side to the polygon
  67597. * @param positions points that make the polygon
  67598. * @param normals normals of the polygon
  67599. * @param uvs uvs of the polygon
  67600. * @param indices indices of the polygon
  67601. * @param bounds bounds of the polygon
  67602. * @param points points of the polygon
  67603. * @param depth depth of the polygon
  67604. * @param flip flip of the polygon
  67605. */
  67606. private addSide;
  67607. }
  67608. }
  67609. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67610. import { Scene } from "babylonjs/scene";
  67611. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67612. import { Color4 } from "babylonjs/Maths/math.color";
  67613. import { Mesh } from "babylonjs/Meshes/mesh";
  67614. import { Nullable } from "babylonjs/types";
  67615. /**
  67616. * Class containing static functions to help procedurally build meshes
  67617. */
  67618. export class PolygonBuilder {
  67619. /**
  67620. * Creates a polygon mesh
  67621. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67622. * * 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
  67623. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67625. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67626. * * Remember you can only change the shape positions, not their number when updating a polygon
  67627. * @param name defines the name of the mesh
  67628. * @param options defines the options used to create the mesh
  67629. * @param scene defines the hosting scene
  67630. * @param earcutInjection can be used to inject your own earcut reference
  67631. * @returns the polygon mesh
  67632. */
  67633. static CreatePolygon(name: string, options: {
  67634. shape: Vector3[];
  67635. holes?: Vector3[][];
  67636. depth?: number;
  67637. faceUV?: Vector4[];
  67638. faceColors?: Color4[];
  67639. updatable?: boolean;
  67640. sideOrientation?: number;
  67641. frontUVs?: Vector4;
  67642. backUVs?: Vector4;
  67643. wrap?: boolean;
  67644. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67645. /**
  67646. * Creates an extruded polygon mesh, with depth in the Y direction.
  67647. * * 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)
  67648. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67649. * @param name defines the name of the mesh
  67650. * @param options defines the options used to create the mesh
  67651. * @param scene defines the hosting scene
  67652. * @param earcutInjection can be used to inject your own earcut reference
  67653. * @returns the polygon mesh
  67654. */
  67655. static ExtrudePolygon(name: string, options: {
  67656. shape: Vector3[];
  67657. holes?: Vector3[][];
  67658. depth?: number;
  67659. faceUV?: Vector4[];
  67660. faceColors?: Color4[];
  67661. updatable?: boolean;
  67662. sideOrientation?: number;
  67663. frontUVs?: Vector4;
  67664. backUVs?: Vector4;
  67665. wrap?: boolean;
  67666. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67667. }
  67668. }
  67669. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67670. import { Scene } from "babylonjs/scene";
  67671. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67672. import { Mesh } from "babylonjs/Meshes/mesh";
  67673. import { Nullable } from "babylonjs/types";
  67674. /**
  67675. * Class containing static functions to help procedurally build meshes
  67676. */
  67677. export class LatheBuilder {
  67678. /**
  67679. * Creates lathe mesh.
  67680. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67681. * * 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
  67682. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67683. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67684. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67685. * * 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
  67686. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67687. * * 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
  67688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67690. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67692. * @param name defines the name of the mesh
  67693. * @param options defines the options used to create the mesh
  67694. * @param scene defines the hosting scene
  67695. * @returns the lathe mesh
  67696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67697. */
  67698. static CreateLathe(name: string, options: {
  67699. shape: Vector3[];
  67700. radius?: number;
  67701. tessellation?: number;
  67702. clip?: number;
  67703. arc?: number;
  67704. closed?: boolean;
  67705. updatable?: boolean;
  67706. sideOrientation?: number;
  67707. frontUVs?: Vector4;
  67708. backUVs?: Vector4;
  67709. cap?: number;
  67710. invertUV?: boolean;
  67711. }, scene?: Nullable<Scene>): Mesh;
  67712. }
  67713. }
  67714. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  67715. import { Nullable } from "babylonjs/types";
  67716. import { Scene } from "babylonjs/scene";
  67717. import { Vector4 } from "babylonjs/Maths/math.vector";
  67718. import { Mesh } from "babylonjs/Meshes/mesh";
  67719. /**
  67720. * Class containing static functions to help procedurally build meshes
  67721. */
  67722. export class TiledPlaneBuilder {
  67723. /**
  67724. * Creates a tiled plane mesh
  67725. * * The parameter `pattern` will, depending on value, do nothing or
  67726. * * * flip (reflect about central vertical) alternate tiles across and up
  67727. * * * flip every tile on alternate rows
  67728. * * * rotate (180 degs) alternate tiles across and up
  67729. * * * rotate every tile on alternate rows
  67730. * * * flip and rotate alternate tiles across and up
  67731. * * * flip and rotate every tile on alternate rows
  67732. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67733. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67734. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67735. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67736. * * 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)
  67737. * * 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)
  67738. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67739. * @param name defines the name of the mesh
  67740. * @param options defines the options used to create the mesh
  67741. * @param scene defines the hosting scene
  67742. * @returns the box mesh
  67743. */
  67744. static CreateTiledPlane(name: string, options: {
  67745. pattern?: number;
  67746. tileSize?: number;
  67747. tileWidth?: number;
  67748. tileHeight?: number;
  67749. size?: number;
  67750. width?: number;
  67751. height?: number;
  67752. alignHorizontal?: number;
  67753. alignVertical?: number;
  67754. sideOrientation?: number;
  67755. frontUVs?: Vector4;
  67756. backUVs?: Vector4;
  67757. updatable?: boolean;
  67758. }, scene?: Nullable<Scene>): Mesh;
  67759. }
  67760. }
  67761. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  67762. import { Nullable } from "babylonjs/types";
  67763. import { Scene } from "babylonjs/scene";
  67764. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67765. import { Mesh } from "babylonjs/Meshes/mesh";
  67766. /**
  67767. * Class containing static functions to help procedurally build meshes
  67768. */
  67769. export class TubeBuilder {
  67770. /**
  67771. * Creates a tube mesh.
  67772. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67773. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67774. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67775. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67776. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67777. * * 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)
  67778. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67779. * * 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
  67780. * * 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
  67781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67783. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67785. * @param name defines the name of the mesh
  67786. * @param options defines the options used to create the mesh
  67787. * @param scene defines the hosting scene
  67788. * @returns the tube mesh
  67789. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67790. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67791. */
  67792. static CreateTube(name: string, options: {
  67793. path: Vector3[];
  67794. radius?: number;
  67795. tessellation?: number;
  67796. radiusFunction?: {
  67797. (i: number, distance: number): number;
  67798. };
  67799. cap?: number;
  67800. arc?: number;
  67801. updatable?: boolean;
  67802. sideOrientation?: number;
  67803. frontUVs?: Vector4;
  67804. backUVs?: Vector4;
  67805. instance?: Mesh;
  67806. invertUV?: boolean;
  67807. }, scene?: Nullable<Scene>): Mesh;
  67808. }
  67809. }
  67810. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  67811. import { Scene } from "babylonjs/scene";
  67812. import { Vector4 } from "babylonjs/Maths/math.vector";
  67813. import { Mesh } from "babylonjs/Meshes/mesh";
  67814. import { Nullable } from "babylonjs/types";
  67815. /**
  67816. * Class containing static functions to help procedurally build meshes
  67817. */
  67818. export class IcoSphereBuilder {
  67819. /**
  67820. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67821. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67822. * * 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`)
  67823. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67824. * * 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
  67825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67828. * @param name defines the name of the mesh
  67829. * @param options defines the options used to create the mesh
  67830. * @param scene defines the hosting scene
  67831. * @returns the icosahedron mesh
  67832. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67833. */
  67834. static CreateIcoSphere(name: string, options: {
  67835. radius?: number;
  67836. radiusX?: number;
  67837. radiusY?: number;
  67838. radiusZ?: number;
  67839. flat?: boolean;
  67840. subdivisions?: number;
  67841. sideOrientation?: number;
  67842. frontUVs?: Vector4;
  67843. backUVs?: Vector4;
  67844. updatable?: boolean;
  67845. }, scene?: Nullable<Scene>): Mesh;
  67846. }
  67847. }
  67848. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  67849. import { Vector3 } from "babylonjs/Maths/math.vector";
  67850. import { Mesh } from "babylonjs/Meshes/mesh";
  67851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67852. /**
  67853. * Class containing static functions to help procedurally build meshes
  67854. */
  67855. export class DecalBuilder {
  67856. /**
  67857. * Creates a decal mesh.
  67858. * 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
  67859. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67860. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67861. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67862. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67863. * @param name defines the name of the mesh
  67864. * @param sourceMesh defines the mesh where the decal must be applied
  67865. * @param options defines the options used to create the mesh
  67866. * @param scene defines the hosting scene
  67867. * @returns the decal mesh
  67868. * @see https://doc.babylonjs.com/how_to/decals
  67869. */
  67870. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67871. position?: Vector3;
  67872. normal?: Vector3;
  67873. size?: Vector3;
  67874. angle?: number;
  67875. }): Mesh;
  67876. }
  67877. }
  67878. declare module "babylonjs/Meshes/meshBuilder" {
  67879. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  67880. import { Nullable } from "babylonjs/types";
  67881. import { Scene } from "babylonjs/scene";
  67882. import { Mesh } from "babylonjs/Meshes/mesh";
  67883. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  67884. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  67885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67886. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  67887. import { Plane } from "babylonjs/Maths/math.plane";
  67888. /**
  67889. * Class containing static functions to help procedurally build meshes
  67890. */
  67891. export class MeshBuilder {
  67892. /**
  67893. * Creates a box mesh
  67894. * * The parameter `size` sets the size (float) of each box side (default 1)
  67895. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67896. * * 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)
  67897. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67901. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67902. * @param name defines the name of the mesh
  67903. * @param options defines the options used to create the mesh
  67904. * @param scene defines the hosting scene
  67905. * @returns the box mesh
  67906. */
  67907. static CreateBox(name: string, options: {
  67908. size?: number;
  67909. width?: number;
  67910. height?: number;
  67911. depth?: number;
  67912. faceUV?: Vector4[];
  67913. faceColors?: Color4[];
  67914. sideOrientation?: number;
  67915. frontUVs?: Vector4;
  67916. backUVs?: Vector4;
  67917. wrap?: boolean;
  67918. topBaseAt?: number;
  67919. bottomBaseAt?: number;
  67920. updatable?: boolean;
  67921. }, scene?: Nullable<Scene>): Mesh;
  67922. /**
  67923. * Creates a tiled box mesh
  67924. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67925. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67926. * @param name defines the name of the mesh
  67927. * @param options defines the options used to create the mesh
  67928. * @param scene defines the hosting scene
  67929. * @returns the tiled box mesh
  67930. */
  67931. static CreateTiledBox(name: string, options: {
  67932. pattern?: number;
  67933. size?: number;
  67934. width?: number;
  67935. height?: number;
  67936. depth: number;
  67937. tileSize?: number;
  67938. tileWidth?: number;
  67939. tileHeight?: number;
  67940. faceUV?: Vector4[];
  67941. faceColors?: Color4[];
  67942. alignHorizontal?: number;
  67943. alignVertical?: number;
  67944. sideOrientation?: number;
  67945. updatable?: boolean;
  67946. }, scene?: Nullable<Scene>): Mesh;
  67947. /**
  67948. * Creates a sphere mesh
  67949. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67950. * * 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`)
  67951. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67952. * * 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
  67953. * * 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)
  67954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67957. * @param name defines the name of the mesh
  67958. * @param options defines the options used to create the mesh
  67959. * @param scene defines the hosting scene
  67960. * @returns the sphere mesh
  67961. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67962. */
  67963. static CreateSphere(name: string, options: {
  67964. segments?: number;
  67965. diameter?: number;
  67966. diameterX?: number;
  67967. diameterY?: number;
  67968. diameterZ?: number;
  67969. arc?: number;
  67970. slice?: number;
  67971. sideOrientation?: number;
  67972. frontUVs?: Vector4;
  67973. backUVs?: Vector4;
  67974. updatable?: boolean;
  67975. }, scene?: Nullable<Scene>): Mesh;
  67976. /**
  67977. * Creates a plane polygonal mesh. By default, this is a disc
  67978. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67979. * * 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
  67980. * * 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
  67981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67984. * @param name defines the name of the mesh
  67985. * @param options defines the options used to create the mesh
  67986. * @param scene defines the hosting scene
  67987. * @returns the plane polygonal mesh
  67988. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67989. */
  67990. static CreateDisc(name: string, options: {
  67991. radius?: number;
  67992. tessellation?: number;
  67993. arc?: number;
  67994. updatable?: boolean;
  67995. sideOrientation?: number;
  67996. frontUVs?: Vector4;
  67997. backUVs?: Vector4;
  67998. }, scene?: Nullable<Scene>): Mesh;
  67999. /**
  68000. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68001. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68002. * * 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`)
  68003. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68004. * * 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
  68005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68008. * @param name defines the name of the mesh
  68009. * @param options defines the options used to create the mesh
  68010. * @param scene defines the hosting scene
  68011. * @returns the icosahedron mesh
  68012. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68013. */
  68014. static CreateIcoSphere(name: string, options: {
  68015. radius?: number;
  68016. radiusX?: number;
  68017. radiusY?: number;
  68018. radiusZ?: number;
  68019. flat?: boolean;
  68020. subdivisions?: number;
  68021. sideOrientation?: number;
  68022. frontUVs?: Vector4;
  68023. backUVs?: Vector4;
  68024. updatable?: boolean;
  68025. }, scene?: Nullable<Scene>): Mesh;
  68026. /**
  68027. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68028. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68029. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68030. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68031. * * 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
  68032. * * 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
  68033. * * 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
  68034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68037. * * 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
  68038. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68039. * * 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
  68040. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68042. * @param name defines the name of the mesh
  68043. * @param options defines the options used to create the mesh
  68044. * @param scene defines the hosting scene
  68045. * @returns the ribbon mesh
  68046. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68048. */
  68049. static CreateRibbon(name: string, options: {
  68050. pathArray: Vector3[][];
  68051. closeArray?: boolean;
  68052. closePath?: boolean;
  68053. offset?: number;
  68054. updatable?: boolean;
  68055. sideOrientation?: number;
  68056. frontUVs?: Vector4;
  68057. backUVs?: Vector4;
  68058. instance?: Mesh;
  68059. invertUV?: boolean;
  68060. uvs?: Vector2[];
  68061. colors?: Color4[];
  68062. }, scene?: Nullable<Scene>): Mesh;
  68063. /**
  68064. * Creates a cylinder or a cone mesh
  68065. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68066. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68067. * * 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.
  68068. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68069. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68070. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68071. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68072. * * 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).
  68073. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68074. * * 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).
  68075. * * 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
  68076. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68077. * * 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
  68078. * * 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.
  68079. * * If `enclose` is false, a ring surface is one element.
  68080. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68081. * * 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
  68082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68083. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68085. * @param name defines the name of the mesh
  68086. * @param options defines the options used to create the mesh
  68087. * @param scene defines the hosting scene
  68088. * @returns the cylinder mesh
  68089. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68090. */
  68091. static CreateCylinder(name: string, options: {
  68092. height?: number;
  68093. diameterTop?: number;
  68094. diameterBottom?: number;
  68095. diameter?: number;
  68096. tessellation?: number;
  68097. subdivisions?: number;
  68098. arc?: number;
  68099. faceColors?: Color4[];
  68100. faceUV?: Vector4[];
  68101. updatable?: boolean;
  68102. hasRings?: boolean;
  68103. enclose?: boolean;
  68104. cap?: number;
  68105. sideOrientation?: number;
  68106. frontUVs?: Vector4;
  68107. backUVs?: Vector4;
  68108. }, scene?: Nullable<Scene>): Mesh;
  68109. /**
  68110. * Creates a torus mesh
  68111. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68112. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68113. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68117. * @param name defines the name of the mesh
  68118. * @param options defines the options used to create the mesh
  68119. * @param scene defines the hosting scene
  68120. * @returns the torus mesh
  68121. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68122. */
  68123. static CreateTorus(name: string, options: {
  68124. diameter?: number;
  68125. thickness?: number;
  68126. tessellation?: number;
  68127. updatable?: boolean;
  68128. sideOrientation?: number;
  68129. frontUVs?: Vector4;
  68130. backUVs?: Vector4;
  68131. }, scene?: Nullable<Scene>): Mesh;
  68132. /**
  68133. * Creates a torus knot mesh
  68134. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68135. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68136. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68137. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68141. * @param name defines the name of the mesh
  68142. * @param options defines the options used to create the mesh
  68143. * @param scene defines the hosting scene
  68144. * @returns the torus knot mesh
  68145. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68146. */
  68147. static CreateTorusKnot(name: string, options: {
  68148. radius?: number;
  68149. tube?: number;
  68150. radialSegments?: number;
  68151. tubularSegments?: number;
  68152. p?: number;
  68153. q?: number;
  68154. updatable?: boolean;
  68155. sideOrientation?: number;
  68156. frontUVs?: Vector4;
  68157. backUVs?: Vector4;
  68158. }, scene?: Nullable<Scene>): Mesh;
  68159. /**
  68160. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68161. * * 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
  68162. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68163. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68164. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68165. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68166. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68167. * * 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
  68168. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68171. * @param name defines the name of the new line system
  68172. * @param options defines the options used to create the line system
  68173. * @param scene defines the hosting scene
  68174. * @returns a new line system mesh
  68175. */
  68176. static CreateLineSystem(name: string, options: {
  68177. lines: Vector3[][];
  68178. updatable?: boolean;
  68179. instance?: Nullable<LinesMesh>;
  68180. colors?: Nullable<Color4[][]>;
  68181. useVertexAlpha?: boolean;
  68182. }, scene: Nullable<Scene>): LinesMesh;
  68183. /**
  68184. * Creates a line mesh
  68185. * 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
  68186. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68187. * * The parameter `points` is an array successive Vector3
  68188. * * 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
  68189. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68190. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68191. * * When updating an instance, remember that only point positions can change, not the number of points
  68192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68193. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68194. * @param name defines the name of the new line system
  68195. * @param options defines the options used to create the line system
  68196. * @param scene defines the hosting scene
  68197. * @returns a new line mesh
  68198. */
  68199. static CreateLines(name: string, options: {
  68200. points: Vector3[];
  68201. updatable?: boolean;
  68202. instance?: Nullable<LinesMesh>;
  68203. colors?: Color4[];
  68204. useVertexAlpha?: boolean;
  68205. }, scene?: Nullable<Scene>): LinesMesh;
  68206. /**
  68207. * Creates a dashed line mesh
  68208. * * 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
  68209. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68210. * * The parameter `points` is an array successive Vector3
  68211. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68212. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68213. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68214. * * 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
  68215. * * When updating an instance, remember that only point positions can change, not the number of points
  68216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68217. * @param name defines the name of the mesh
  68218. * @param options defines the options used to create the mesh
  68219. * @param scene defines the hosting scene
  68220. * @returns the dashed line mesh
  68221. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68222. */
  68223. static CreateDashedLines(name: string, options: {
  68224. points: Vector3[];
  68225. dashSize?: number;
  68226. gapSize?: number;
  68227. dashNb?: number;
  68228. updatable?: boolean;
  68229. instance?: LinesMesh;
  68230. }, scene?: Nullable<Scene>): LinesMesh;
  68231. /**
  68232. * 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.
  68233. * * 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.
  68234. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68235. * * 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.
  68236. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68237. * * 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
  68238. * * 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
  68239. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68242. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68244. * @param name defines the name of the mesh
  68245. * @param options defines the options used to create the mesh
  68246. * @param scene defines the hosting scene
  68247. * @returns the extruded shape mesh
  68248. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68250. */
  68251. static ExtrudeShape(name: string, options: {
  68252. shape: Vector3[];
  68253. path: Vector3[];
  68254. scale?: number;
  68255. rotation?: number;
  68256. cap?: number;
  68257. updatable?: boolean;
  68258. sideOrientation?: number;
  68259. frontUVs?: Vector4;
  68260. backUVs?: Vector4;
  68261. instance?: Mesh;
  68262. invertUV?: boolean;
  68263. }, scene?: Nullable<Scene>): Mesh;
  68264. /**
  68265. * Creates an custom extruded shape mesh.
  68266. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68267. * * 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.
  68268. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68269. * * 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
  68270. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68271. * * 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
  68272. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68273. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68274. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68275. * * 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
  68276. * * 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
  68277. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68280. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68282. * @param name defines the name of the mesh
  68283. * @param options defines the options used to create the mesh
  68284. * @param scene defines the hosting scene
  68285. * @returns the custom extruded shape mesh
  68286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68287. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68288. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68289. */
  68290. static ExtrudeShapeCustom(name: string, options: {
  68291. shape: Vector3[];
  68292. path: Vector3[];
  68293. scaleFunction?: any;
  68294. rotationFunction?: any;
  68295. ribbonCloseArray?: boolean;
  68296. ribbonClosePath?: boolean;
  68297. cap?: number;
  68298. updatable?: boolean;
  68299. sideOrientation?: number;
  68300. frontUVs?: Vector4;
  68301. backUVs?: Vector4;
  68302. instance?: Mesh;
  68303. invertUV?: boolean;
  68304. }, scene?: Nullable<Scene>): Mesh;
  68305. /**
  68306. * Creates lathe mesh.
  68307. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68308. * * 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
  68309. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68310. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68311. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68312. * * 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
  68313. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68314. * * 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
  68315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68316. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68317. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68319. * @param name defines the name of the mesh
  68320. * @param options defines the options used to create the mesh
  68321. * @param scene defines the hosting scene
  68322. * @returns the lathe mesh
  68323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68324. */
  68325. static CreateLathe(name: string, options: {
  68326. shape: Vector3[];
  68327. radius?: number;
  68328. tessellation?: number;
  68329. clip?: number;
  68330. arc?: number;
  68331. closed?: boolean;
  68332. updatable?: boolean;
  68333. sideOrientation?: number;
  68334. frontUVs?: Vector4;
  68335. backUVs?: Vector4;
  68336. cap?: number;
  68337. invertUV?: boolean;
  68338. }, scene?: Nullable<Scene>): Mesh;
  68339. /**
  68340. * Creates a tiled plane mesh
  68341. * * You can set a limited pattern arrangement with the tiles
  68342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68345. * @param name defines the name of the mesh
  68346. * @param options defines the options used to create the mesh
  68347. * @param scene defines the hosting scene
  68348. * @returns the plane mesh
  68349. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68350. */
  68351. static CreateTiledPlane(name: string, options: {
  68352. pattern?: number;
  68353. tileSize?: number;
  68354. tileWidth?: number;
  68355. tileHeight?: number;
  68356. size?: number;
  68357. width?: number;
  68358. height?: number;
  68359. alignHorizontal?: number;
  68360. alignVertical?: number;
  68361. sideOrientation?: number;
  68362. frontUVs?: Vector4;
  68363. backUVs?: Vector4;
  68364. updatable?: boolean;
  68365. }, scene?: Nullable<Scene>): Mesh;
  68366. /**
  68367. * Creates a plane mesh
  68368. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68369. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68370. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68372. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68374. * @param name defines the name of the mesh
  68375. * @param options defines the options used to create the mesh
  68376. * @param scene defines the hosting scene
  68377. * @returns the plane mesh
  68378. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68379. */
  68380. static CreatePlane(name: string, options: {
  68381. size?: number;
  68382. width?: number;
  68383. height?: number;
  68384. sideOrientation?: number;
  68385. frontUVs?: Vector4;
  68386. backUVs?: Vector4;
  68387. updatable?: boolean;
  68388. sourcePlane?: Plane;
  68389. }, scene?: Nullable<Scene>): Mesh;
  68390. /**
  68391. * Creates a ground mesh
  68392. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68393. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68395. * @param name defines the name of the mesh
  68396. * @param options defines the options used to create the mesh
  68397. * @param scene defines the hosting scene
  68398. * @returns the ground mesh
  68399. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68400. */
  68401. static CreateGround(name: string, options: {
  68402. width?: number;
  68403. height?: number;
  68404. subdivisions?: number;
  68405. subdivisionsX?: number;
  68406. subdivisionsY?: number;
  68407. updatable?: boolean;
  68408. }, scene?: Nullable<Scene>): Mesh;
  68409. /**
  68410. * Creates a tiled ground mesh
  68411. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68412. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68413. * * 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
  68414. * * 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
  68415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68416. * @param name defines the name of the mesh
  68417. * @param options defines the options used to create the mesh
  68418. * @param scene defines the hosting scene
  68419. * @returns the tiled ground mesh
  68420. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68421. */
  68422. static CreateTiledGround(name: string, options: {
  68423. xmin: number;
  68424. zmin: number;
  68425. xmax: number;
  68426. zmax: number;
  68427. subdivisions?: {
  68428. w: number;
  68429. h: number;
  68430. };
  68431. precision?: {
  68432. w: number;
  68433. h: number;
  68434. };
  68435. updatable?: boolean;
  68436. }, scene?: Nullable<Scene>): Mesh;
  68437. /**
  68438. * Creates a ground mesh from a height map
  68439. * * The parameter `url` sets the URL of the height map image resource.
  68440. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68441. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68442. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68443. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68444. * * 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.
  68445. * * 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).
  68446. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68448. * @param name defines the name of the mesh
  68449. * @param url defines the url to the height map
  68450. * @param options defines the options used to create the mesh
  68451. * @param scene defines the hosting scene
  68452. * @returns the ground mesh
  68453. * @see https://doc.babylonjs.com/babylon101/height_map
  68454. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68455. */
  68456. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68457. width?: number;
  68458. height?: number;
  68459. subdivisions?: number;
  68460. minHeight?: number;
  68461. maxHeight?: number;
  68462. colorFilter?: Color3;
  68463. alphaFilter?: number;
  68464. updatable?: boolean;
  68465. onReady?: (mesh: GroundMesh) => void;
  68466. }, scene?: Nullable<Scene>): GroundMesh;
  68467. /**
  68468. * Creates a polygon mesh
  68469. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68470. * * 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
  68471. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68474. * * Remember you can only change the shape positions, not their number when updating a polygon
  68475. * @param name defines the name of the mesh
  68476. * @param options defines the options used to create the mesh
  68477. * @param scene defines the hosting scene
  68478. * @param earcutInjection can be used to inject your own earcut reference
  68479. * @returns the polygon mesh
  68480. */
  68481. static CreatePolygon(name: string, options: {
  68482. shape: Vector3[];
  68483. holes?: Vector3[][];
  68484. depth?: number;
  68485. faceUV?: Vector4[];
  68486. faceColors?: Color4[];
  68487. updatable?: boolean;
  68488. sideOrientation?: number;
  68489. frontUVs?: Vector4;
  68490. backUVs?: Vector4;
  68491. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68492. /**
  68493. * Creates an extruded polygon mesh, with depth in the Y direction.
  68494. * * 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)
  68495. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68496. * @param name defines the name of the mesh
  68497. * @param options defines the options used to create the mesh
  68498. * @param scene defines the hosting scene
  68499. * @param earcutInjection can be used to inject your own earcut reference
  68500. * @returns the polygon mesh
  68501. */
  68502. static ExtrudePolygon(name: string, options: {
  68503. shape: Vector3[];
  68504. holes?: Vector3[][];
  68505. depth?: number;
  68506. faceUV?: Vector4[];
  68507. faceColors?: Color4[];
  68508. updatable?: boolean;
  68509. sideOrientation?: number;
  68510. frontUVs?: Vector4;
  68511. backUVs?: Vector4;
  68512. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68513. /**
  68514. * Creates a tube mesh.
  68515. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68516. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68517. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68518. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68519. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68520. * * 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)
  68521. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68522. * * 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
  68523. * * 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
  68524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68525. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68526. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68528. * @param name defines the name of the mesh
  68529. * @param options defines the options used to create the mesh
  68530. * @param scene defines the hosting scene
  68531. * @returns the tube mesh
  68532. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68533. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68534. */
  68535. static CreateTube(name: string, options: {
  68536. path: Vector3[];
  68537. radius?: number;
  68538. tessellation?: number;
  68539. radiusFunction?: {
  68540. (i: number, distance: number): number;
  68541. };
  68542. cap?: number;
  68543. arc?: number;
  68544. updatable?: boolean;
  68545. sideOrientation?: number;
  68546. frontUVs?: Vector4;
  68547. backUVs?: Vector4;
  68548. instance?: Mesh;
  68549. invertUV?: boolean;
  68550. }, scene?: Nullable<Scene>): Mesh;
  68551. /**
  68552. * Creates a polyhedron mesh
  68553. * * 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
  68554. * * The parameter `size` (positive float, default 1) sets the polygon size
  68555. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68556. * * 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`
  68557. * * 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
  68558. * * 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)`)
  68559. * * 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
  68560. * * 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
  68561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68562. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68564. * @param name defines the name of the mesh
  68565. * @param options defines the options used to create the mesh
  68566. * @param scene defines the hosting scene
  68567. * @returns the polyhedron mesh
  68568. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68569. */
  68570. static CreatePolyhedron(name: string, options: {
  68571. type?: number;
  68572. size?: number;
  68573. sizeX?: number;
  68574. sizeY?: number;
  68575. sizeZ?: number;
  68576. custom?: any;
  68577. faceUV?: Vector4[];
  68578. faceColors?: Color4[];
  68579. flat?: boolean;
  68580. updatable?: boolean;
  68581. sideOrientation?: number;
  68582. frontUVs?: Vector4;
  68583. backUVs?: Vector4;
  68584. }, scene?: Nullable<Scene>): Mesh;
  68585. /**
  68586. * Creates a decal mesh.
  68587. * 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
  68588. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68589. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68590. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68591. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68592. * @param name defines the name of the mesh
  68593. * @param sourceMesh defines the mesh where the decal must be applied
  68594. * @param options defines the options used to create the mesh
  68595. * @param scene defines the hosting scene
  68596. * @returns the decal mesh
  68597. * @see https://doc.babylonjs.com/how_to/decals
  68598. */
  68599. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68600. position?: Vector3;
  68601. normal?: Vector3;
  68602. size?: Vector3;
  68603. angle?: number;
  68604. }): Mesh;
  68605. }
  68606. }
  68607. declare module "babylonjs/Meshes/meshSimplification" {
  68608. import { Mesh } from "babylonjs/Meshes/mesh";
  68609. /**
  68610. * A simplifier interface for future simplification implementations
  68611. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68612. */
  68613. export interface ISimplifier {
  68614. /**
  68615. * Simplification of a given mesh according to the given settings.
  68616. * Since this requires computation, it is assumed that the function runs async.
  68617. * @param settings The settings of the simplification, including quality and distance
  68618. * @param successCallback A callback that will be called after the mesh was simplified.
  68619. * @param errorCallback in case of an error, this callback will be called. optional.
  68620. */
  68621. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68622. }
  68623. /**
  68624. * Expected simplification settings.
  68625. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68626. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68627. */
  68628. export interface ISimplificationSettings {
  68629. /**
  68630. * Gets or sets the expected quality
  68631. */
  68632. quality: number;
  68633. /**
  68634. * Gets or sets the distance when this optimized version should be used
  68635. */
  68636. distance: number;
  68637. /**
  68638. * Gets an already optimized mesh
  68639. */
  68640. optimizeMesh?: boolean;
  68641. }
  68642. /**
  68643. * Class used to specify simplification options
  68644. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68645. */
  68646. export class SimplificationSettings implements ISimplificationSettings {
  68647. /** expected quality */
  68648. quality: number;
  68649. /** distance when this optimized version should be used */
  68650. distance: number;
  68651. /** already optimized mesh */
  68652. optimizeMesh?: boolean | undefined;
  68653. /**
  68654. * Creates a SimplificationSettings
  68655. * @param quality expected quality
  68656. * @param distance distance when this optimized version should be used
  68657. * @param optimizeMesh already optimized mesh
  68658. */
  68659. constructor(
  68660. /** expected quality */
  68661. quality: number,
  68662. /** distance when this optimized version should be used */
  68663. distance: number,
  68664. /** already optimized mesh */
  68665. optimizeMesh?: boolean | undefined);
  68666. }
  68667. /**
  68668. * Interface used to define a simplification task
  68669. */
  68670. export interface ISimplificationTask {
  68671. /**
  68672. * Array of settings
  68673. */
  68674. settings: Array<ISimplificationSettings>;
  68675. /**
  68676. * Simplification type
  68677. */
  68678. simplificationType: SimplificationType;
  68679. /**
  68680. * Mesh to simplify
  68681. */
  68682. mesh: Mesh;
  68683. /**
  68684. * Callback called on success
  68685. */
  68686. successCallback?: () => void;
  68687. /**
  68688. * Defines if parallel processing can be used
  68689. */
  68690. parallelProcessing: boolean;
  68691. }
  68692. /**
  68693. * Queue used to order the simplification tasks
  68694. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68695. */
  68696. export class SimplificationQueue {
  68697. private _simplificationArray;
  68698. /**
  68699. * Gets a boolean indicating that the process is still running
  68700. */
  68701. running: boolean;
  68702. /**
  68703. * Creates a new queue
  68704. */
  68705. constructor();
  68706. /**
  68707. * Adds a new simplification task
  68708. * @param task defines a task to add
  68709. */
  68710. addTask(task: ISimplificationTask): void;
  68711. /**
  68712. * Execute next task
  68713. */
  68714. executeNext(): void;
  68715. /**
  68716. * Execute a simplification task
  68717. * @param task defines the task to run
  68718. */
  68719. runSimplification(task: ISimplificationTask): void;
  68720. private getSimplifier;
  68721. }
  68722. /**
  68723. * The implemented types of simplification
  68724. * At the moment only Quadratic Error Decimation is implemented
  68725. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68726. */
  68727. export enum SimplificationType {
  68728. /** Quadratic error decimation */
  68729. QUADRATIC = 0
  68730. }
  68731. /**
  68732. * An implementation of the Quadratic Error simplification algorithm.
  68733. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68734. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68735. * @author RaananW
  68736. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68737. */
  68738. export class QuadraticErrorSimplification implements ISimplifier {
  68739. private _mesh;
  68740. private triangles;
  68741. private vertices;
  68742. private references;
  68743. private _reconstructedMesh;
  68744. /** Gets or sets the number pf sync interations */
  68745. syncIterations: number;
  68746. /** Gets or sets the aggressiveness of the simplifier */
  68747. aggressiveness: number;
  68748. /** Gets or sets the number of allowed iterations for decimation */
  68749. decimationIterations: number;
  68750. /** Gets or sets the espilon to use for bounding box computation */
  68751. boundingBoxEpsilon: number;
  68752. /**
  68753. * Creates a new QuadraticErrorSimplification
  68754. * @param _mesh defines the target mesh
  68755. */
  68756. constructor(_mesh: Mesh);
  68757. /**
  68758. * Simplification of a given mesh according to the given settings.
  68759. * Since this requires computation, it is assumed that the function runs async.
  68760. * @param settings The settings of the simplification, including quality and distance
  68761. * @param successCallback A callback that will be called after the mesh was simplified.
  68762. */
  68763. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68764. private runDecimation;
  68765. private initWithMesh;
  68766. private init;
  68767. private reconstructMesh;
  68768. private initDecimatedMesh;
  68769. private isFlipped;
  68770. private updateTriangles;
  68771. private identifyBorder;
  68772. private updateMesh;
  68773. private vertexError;
  68774. private calculateError;
  68775. }
  68776. }
  68777. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  68778. import { Scene } from "babylonjs/scene";
  68779. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  68780. import { ISceneComponent } from "babylonjs/sceneComponent";
  68781. module "babylonjs/scene" {
  68782. interface Scene {
  68783. /** @hidden (Backing field) */
  68784. _simplificationQueue: SimplificationQueue;
  68785. /**
  68786. * Gets or sets the simplification queue attached to the scene
  68787. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68788. */
  68789. simplificationQueue: SimplificationQueue;
  68790. }
  68791. }
  68792. module "babylonjs/Meshes/mesh" {
  68793. interface Mesh {
  68794. /**
  68795. * Simplify the mesh according to the given array of settings.
  68796. * Function will return immediately and will simplify async
  68797. * @param settings a collection of simplification settings
  68798. * @param parallelProcessing should all levels calculate parallel or one after the other
  68799. * @param simplificationType the type of simplification to run
  68800. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68801. * @returns the current mesh
  68802. */
  68803. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68804. }
  68805. }
  68806. /**
  68807. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68808. * created in a scene
  68809. */
  68810. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68811. /**
  68812. * The component name helpfull to identify the component in the list of scene components.
  68813. */
  68814. readonly name: string;
  68815. /**
  68816. * The scene the component belongs to.
  68817. */
  68818. scene: Scene;
  68819. /**
  68820. * Creates a new instance of the component for the given scene
  68821. * @param scene Defines the scene to register the component in
  68822. */
  68823. constructor(scene: Scene);
  68824. /**
  68825. * Registers the component in a given scene
  68826. */
  68827. register(): void;
  68828. /**
  68829. * Rebuilds the elements related to this component in case of
  68830. * context lost for instance.
  68831. */
  68832. rebuild(): void;
  68833. /**
  68834. * Disposes the component and the associated ressources
  68835. */
  68836. dispose(): void;
  68837. private _beforeCameraUpdate;
  68838. }
  68839. }
  68840. declare module "babylonjs/Meshes/Builders/index" {
  68841. export * from "babylonjs/Meshes/Builders/boxBuilder";
  68842. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  68843. export * from "babylonjs/Meshes/Builders/discBuilder";
  68844. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  68845. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  68846. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  68847. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  68848. export * from "babylonjs/Meshes/Builders/torusBuilder";
  68849. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  68850. export * from "babylonjs/Meshes/Builders/linesBuilder";
  68851. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  68852. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  68853. export * from "babylonjs/Meshes/Builders/latheBuilder";
  68854. export * from "babylonjs/Meshes/Builders/planeBuilder";
  68855. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  68856. export * from "babylonjs/Meshes/Builders/groundBuilder";
  68857. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  68858. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  68859. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  68860. export * from "babylonjs/Meshes/Builders/decalBuilder";
  68861. }
  68862. declare module "babylonjs/Meshes/thinInstanceMesh" {
  68863. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  68864. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  68865. import { Matrix } from "babylonjs/Maths/math.vector";
  68866. module "babylonjs/Meshes/mesh" {
  68867. interface Mesh {
  68868. /**
  68869. * Creates a new thin instance
  68870. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68871. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68872. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68873. */
  68874. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68875. /**
  68876. * Adds the transformation (matrix) of the current mesh as a thin instance
  68877. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68878. * @returns the thin instance index number
  68879. */
  68880. thinInstanceAddSelf(refresh: boolean): number;
  68881. /**
  68882. * Registers a custom attribute to be used with thin instances
  68883. * @param kind name of the attribute
  68884. * @param stride size in floats of the attribute
  68885. */
  68886. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68887. /**
  68888. * Sets the matrix of a thin instance
  68889. * @param index index of the thin instance
  68890. * @param matrix matrix to set
  68891. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68892. */
  68893. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68894. /**
  68895. * Sets the value of a custom attribute for a thin instance
  68896. * @param kind name of the attribute
  68897. * @param index index of the thin instance
  68898. * @param value value to set
  68899. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  68900. */
  68901. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68902. /**
  68903. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  68904. */
  68905. thinInstanceCount: number;
  68906. /**
  68907. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68908. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68909. * @param buffer buffer to set
  68910. * @param stride size in floats of each value of the buffer
  68911. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68912. */
  68913. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68914. /**
  68915. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68916. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68917. */
  68918. thinInstanceBufferUpdated(kind: string): void;
  68919. /**
  68920. * Refreshes the bounding info, taking into account all the thin instances defined
  68921. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68922. */
  68923. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68924. /** @hidden */
  68925. _thinInstanceInitializeUserStorage(): void;
  68926. /** @hidden */
  68927. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68928. /** @hidden */
  68929. _userThinInstanceBuffersStorage: {
  68930. data: {
  68931. [key: string]: Float32Array;
  68932. };
  68933. sizes: {
  68934. [key: string]: number;
  68935. };
  68936. vertexBuffers: {
  68937. [key: string]: Nullable<VertexBuffer>;
  68938. };
  68939. strides: {
  68940. [key: string]: number;
  68941. };
  68942. };
  68943. }
  68944. }
  68945. }
  68946. declare module "babylonjs/Meshes/index" {
  68947. export * from "babylonjs/Meshes/abstractMesh";
  68948. export * from "babylonjs/Meshes/buffer";
  68949. export * from "babylonjs/Meshes/Compression/index";
  68950. export * from "babylonjs/Meshes/csg";
  68951. export * from "babylonjs/Meshes/geometry";
  68952. export * from "babylonjs/Meshes/groundMesh";
  68953. export * from "babylonjs/Meshes/trailMesh";
  68954. export * from "babylonjs/Meshes/instancedMesh";
  68955. export * from "babylonjs/Meshes/linesMesh";
  68956. export * from "babylonjs/Meshes/mesh";
  68957. export * from "babylonjs/Meshes/mesh.vertexData";
  68958. export * from "babylonjs/Meshes/meshBuilder";
  68959. export * from "babylonjs/Meshes/meshSimplification";
  68960. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  68961. export * from "babylonjs/Meshes/polygonMesh";
  68962. export * from "babylonjs/Meshes/subMesh";
  68963. export * from "babylonjs/Meshes/meshLODLevel";
  68964. export * from "babylonjs/Meshes/transformNode";
  68965. export * from "babylonjs/Meshes/Builders/index";
  68966. export * from "babylonjs/Meshes/dataBuffer";
  68967. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  68968. import "babylonjs/Meshes/thinInstanceMesh";
  68969. export * from "babylonjs/Meshes/thinInstanceMesh";
  68970. }
  68971. declare module "babylonjs/Morph/index" {
  68972. export * from "babylonjs/Morph/morphTarget";
  68973. export * from "babylonjs/Morph/morphTargetManager";
  68974. }
  68975. declare module "babylonjs/Navigation/INavigationEngine" {
  68976. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68977. import { Vector3 } from "babylonjs/Maths/math";
  68978. import { Mesh } from "babylonjs/Meshes/mesh";
  68979. import { Scene } from "babylonjs/scene";
  68980. /**
  68981. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68982. */
  68983. export interface INavigationEnginePlugin {
  68984. /**
  68985. * plugin name
  68986. */
  68987. name: string;
  68988. /**
  68989. * Creates a navigation mesh
  68990. * @param meshes array of all the geometry used to compute the navigatio mesh
  68991. * @param parameters bunch of parameters used to filter geometry
  68992. */
  68993. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68994. /**
  68995. * Create a navigation mesh debug mesh
  68996. * @param scene is where the mesh will be added
  68997. * @returns debug display mesh
  68998. */
  68999. createDebugNavMesh(scene: Scene): Mesh;
  69000. /**
  69001. * Get a navigation mesh constrained position, closest to the parameter position
  69002. * @param position world position
  69003. * @returns the closest point to position constrained by the navigation mesh
  69004. */
  69005. getClosestPoint(position: Vector3): Vector3;
  69006. /**
  69007. * Get a navigation mesh constrained position, closest to the parameter position
  69008. * @param position world position
  69009. * @param result output the closest point to position constrained by the navigation mesh
  69010. */
  69011. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69012. /**
  69013. * Get a navigation mesh constrained position, within a particular radius
  69014. * @param position world position
  69015. * @param maxRadius the maximum distance to the constrained world position
  69016. * @returns the closest point to position constrained by the navigation mesh
  69017. */
  69018. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69019. /**
  69020. * Get a navigation mesh constrained position, within a particular radius
  69021. * @param position world position
  69022. * @param maxRadius the maximum distance to the constrained world position
  69023. * @param result output the closest point to position constrained by the navigation mesh
  69024. */
  69025. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69026. /**
  69027. * Compute the final position from a segment made of destination-position
  69028. * @param position world position
  69029. * @param destination world position
  69030. * @returns the resulting point along the navmesh
  69031. */
  69032. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69033. /**
  69034. * Compute the final position from a segment made of destination-position
  69035. * @param position world position
  69036. * @param destination world position
  69037. * @param result output the resulting point along the navmesh
  69038. */
  69039. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69040. /**
  69041. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69042. * @param start world position
  69043. * @param end world position
  69044. * @returns array containing world position composing the path
  69045. */
  69046. computePath(start: Vector3, end: Vector3): Vector3[];
  69047. /**
  69048. * If this plugin is supported
  69049. * @returns true if plugin is supported
  69050. */
  69051. isSupported(): boolean;
  69052. /**
  69053. * Create a new Crowd so you can add agents
  69054. * @param maxAgents the maximum agent count in the crowd
  69055. * @param maxAgentRadius the maximum radius an agent can have
  69056. * @param scene to attach the crowd to
  69057. * @returns the crowd you can add agents to
  69058. */
  69059. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69060. /**
  69061. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69062. * The queries will try to find a solution within those bounds
  69063. * default is (1,1,1)
  69064. * @param extent x,y,z value that define the extent around the queries point of reference
  69065. */
  69066. setDefaultQueryExtent(extent: Vector3): void;
  69067. /**
  69068. * Get the Bounding box extent specified by setDefaultQueryExtent
  69069. * @returns the box extent values
  69070. */
  69071. getDefaultQueryExtent(): Vector3;
  69072. /**
  69073. * build the navmesh from a previously saved state using getNavmeshData
  69074. * @param data the Uint8Array returned by getNavmeshData
  69075. */
  69076. buildFromNavmeshData(data: Uint8Array): void;
  69077. /**
  69078. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69079. * @returns data the Uint8Array that can be saved and reused
  69080. */
  69081. getNavmeshData(): Uint8Array;
  69082. /**
  69083. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69084. * @param result output the box extent values
  69085. */
  69086. getDefaultQueryExtentToRef(result: Vector3): void;
  69087. /**
  69088. * Release all resources
  69089. */
  69090. dispose(): void;
  69091. }
  69092. /**
  69093. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69094. */
  69095. export interface ICrowd {
  69096. /**
  69097. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69098. * You can attach anything to that node. The node position is updated in the scene update tick.
  69099. * @param pos world position that will be constrained by the navigation mesh
  69100. * @param parameters agent parameters
  69101. * @param transform hooked to the agent that will be update by the scene
  69102. * @returns agent index
  69103. */
  69104. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69105. /**
  69106. * Returns the agent position in world space
  69107. * @param index agent index returned by addAgent
  69108. * @returns world space position
  69109. */
  69110. getAgentPosition(index: number): Vector3;
  69111. /**
  69112. * Gets the agent position result in world space
  69113. * @param index agent index returned by addAgent
  69114. * @param result output world space position
  69115. */
  69116. getAgentPositionToRef(index: number, result: Vector3): void;
  69117. /**
  69118. * Gets the agent velocity in world space
  69119. * @param index agent index returned by addAgent
  69120. * @returns world space velocity
  69121. */
  69122. getAgentVelocity(index: number): Vector3;
  69123. /**
  69124. * Gets the agent velocity result in world space
  69125. * @param index agent index returned by addAgent
  69126. * @param result output world space velocity
  69127. */
  69128. getAgentVelocityToRef(index: number, result: Vector3): void;
  69129. /**
  69130. * remove a particular agent previously created
  69131. * @param index agent index returned by addAgent
  69132. */
  69133. removeAgent(index: number): void;
  69134. /**
  69135. * get the list of all agents attached to this crowd
  69136. * @returns list of agent indices
  69137. */
  69138. getAgents(): number[];
  69139. /**
  69140. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69141. * @param deltaTime in seconds
  69142. */
  69143. update(deltaTime: number): void;
  69144. /**
  69145. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69146. * @param index agent index returned by addAgent
  69147. * @param destination targeted world position
  69148. */
  69149. agentGoto(index: number, destination: Vector3): void;
  69150. /**
  69151. * Teleport the agent to a new position
  69152. * @param index agent index returned by addAgent
  69153. * @param destination targeted world position
  69154. */
  69155. agentTeleport(index: number, destination: Vector3): void;
  69156. /**
  69157. * Update agent parameters
  69158. * @param index agent index returned by addAgent
  69159. * @param parameters agent parameters
  69160. */
  69161. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69162. /**
  69163. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69164. * The queries will try to find a solution within those bounds
  69165. * default is (1,1,1)
  69166. * @param extent x,y,z value that define the extent around the queries point of reference
  69167. */
  69168. setDefaultQueryExtent(extent: Vector3): void;
  69169. /**
  69170. * Get the Bounding box extent specified by setDefaultQueryExtent
  69171. * @returns the box extent values
  69172. */
  69173. getDefaultQueryExtent(): Vector3;
  69174. /**
  69175. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69176. * @param result output the box extent values
  69177. */
  69178. getDefaultQueryExtentToRef(result: Vector3): void;
  69179. /**
  69180. * Release all resources
  69181. */
  69182. dispose(): void;
  69183. }
  69184. /**
  69185. * Configures an agent
  69186. */
  69187. export interface IAgentParameters {
  69188. /**
  69189. * Agent radius. [Limit: >= 0]
  69190. */
  69191. radius: number;
  69192. /**
  69193. * Agent height. [Limit: > 0]
  69194. */
  69195. height: number;
  69196. /**
  69197. * Maximum allowed acceleration. [Limit: >= 0]
  69198. */
  69199. maxAcceleration: number;
  69200. /**
  69201. * Maximum allowed speed. [Limit: >= 0]
  69202. */
  69203. maxSpeed: number;
  69204. /**
  69205. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69206. */
  69207. collisionQueryRange: number;
  69208. /**
  69209. * The path visibility optimization range. [Limit: > 0]
  69210. */
  69211. pathOptimizationRange: number;
  69212. /**
  69213. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69214. */
  69215. separationWeight: number;
  69216. }
  69217. /**
  69218. * Configures the navigation mesh creation
  69219. */
  69220. export interface INavMeshParameters {
  69221. /**
  69222. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69223. */
  69224. cs: number;
  69225. /**
  69226. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69227. */
  69228. ch: number;
  69229. /**
  69230. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69231. */
  69232. walkableSlopeAngle: number;
  69233. /**
  69234. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69235. * be considered walkable. [Limit: >= 3] [Units: vx]
  69236. */
  69237. walkableHeight: number;
  69238. /**
  69239. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69240. */
  69241. walkableClimb: number;
  69242. /**
  69243. * The distance to erode/shrink the walkable area of the heightfield away from
  69244. * obstructions. [Limit: >=0] [Units: vx]
  69245. */
  69246. walkableRadius: number;
  69247. /**
  69248. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69249. */
  69250. maxEdgeLen: number;
  69251. /**
  69252. * The maximum distance a simplfied contour's border edges should deviate
  69253. * the original raw contour. [Limit: >=0] [Units: vx]
  69254. */
  69255. maxSimplificationError: number;
  69256. /**
  69257. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69258. */
  69259. minRegionArea: number;
  69260. /**
  69261. * Any regions with a span count smaller than this value will, if possible,
  69262. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69263. */
  69264. mergeRegionArea: number;
  69265. /**
  69266. * The maximum number of vertices allowed for polygons generated during the
  69267. * contour to polygon conversion process. [Limit: >= 3]
  69268. */
  69269. maxVertsPerPoly: number;
  69270. /**
  69271. * Sets the sampling distance to use when generating the detail mesh.
  69272. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69273. */
  69274. detailSampleDist: number;
  69275. /**
  69276. * The maximum distance the detail mesh surface should deviate from heightfield
  69277. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69278. */
  69279. detailSampleMaxError: number;
  69280. }
  69281. }
  69282. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69283. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69284. import { Mesh } from "babylonjs/Meshes/mesh";
  69285. import { Scene } from "babylonjs/scene";
  69286. import { Vector3 } from "babylonjs/Maths/math";
  69287. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69288. /**
  69289. * RecastJS navigation plugin
  69290. */
  69291. export class RecastJSPlugin implements INavigationEnginePlugin {
  69292. /**
  69293. * Reference to the Recast library
  69294. */
  69295. bjsRECAST: any;
  69296. /**
  69297. * plugin name
  69298. */
  69299. name: string;
  69300. /**
  69301. * the first navmesh created. We might extend this to support multiple navmeshes
  69302. */
  69303. navMesh: any;
  69304. /**
  69305. * Initializes the recastJS plugin
  69306. * @param recastInjection can be used to inject your own recast reference
  69307. */
  69308. constructor(recastInjection?: any);
  69309. /**
  69310. * Creates a navigation mesh
  69311. * @param meshes array of all the geometry used to compute the navigatio mesh
  69312. * @param parameters bunch of parameters used to filter geometry
  69313. */
  69314. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69315. /**
  69316. * Create a navigation mesh debug mesh
  69317. * @param scene is where the mesh will be added
  69318. * @returns debug display mesh
  69319. */
  69320. createDebugNavMesh(scene: Scene): Mesh;
  69321. /**
  69322. * Get a navigation mesh constrained position, closest to the parameter position
  69323. * @param position world position
  69324. * @returns the closest point to position constrained by the navigation mesh
  69325. */
  69326. getClosestPoint(position: Vector3): Vector3;
  69327. /**
  69328. * Get a navigation mesh constrained position, closest to the parameter position
  69329. * @param position world position
  69330. * @param result output the closest point to position constrained by the navigation mesh
  69331. */
  69332. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69333. /**
  69334. * Get a navigation mesh constrained position, within a particular radius
  69335. * @param position world position
  69336. * @param maxRadius the maximum distance to the constrained world position
  69337. * @returns the closest point to position constrained by the navigation mesh
  69338. */
  69339. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69340. /**
  69341. * Get a navigation mesh constrained position, within a particular radius
  69342. * @param position world position
  69343. * @param maxRadius the maximum distance to the constrained world position
  69344. * @param result output the closest point to position constrained by the navigation mesh
  69345. */
  69346. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69347. /**
  69348. * Compute the final position from a segment made of destination-position
  69349. * @param position world position
  69350. * @param destination world position
  69351. * @returns the resulting point along the navmesh
  69352. */
  69353. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69354. /**
  69355. * Compute the final position from a segment made of destination-position
  69356. * @param position world position
  69357. * @param destination world position
  69358. * @param result output the resulting point along the navmesh
  69359. */
  69360. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69361. /**
  69362. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69363. * @param start world position
  69364. * @param end world position
  69365. * @returns array containing world position composing the path
  69366. */
  69367. computePath(start: Vector3, end: Vector3): Vector3[];
  69368. /**
  69369. * Create a new Crowd so you can add agents
  69370. * @param maxAgents the maximum agent count in the crowd
  69371. * @param maxAgentRadius the maximum radius an agent can have
  69372. * @param scene to attach the crowd to
  69373. * @returns the crowd you can add agents to
  69374. */
  69375. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69376. /**
  69377. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69378. * The queries will try to find a solution within those bounds
  69379. * default is (1,1,1)
  69380. * @param extent x,y,z value that define the extent around the queries point of reference
  69381. */
  69382. setDefaultQueryExtent(extent: Vector3): void;
  69383. /**
  69384. * Get the Bounding box extent specified by setDefaultQueryExtent
  69385. * @returns the box extent values
  69386. */
  69387. getDefaultQueryExtent(): Vector3;
  69388. /**
  69389. * build the navmesh from a previously saved state using getNavmeshData
  69390. * @param data the Uint8Array returned by getNavmeshData
  69391. */
  69392. buildFromNavmeshData(data: Uint8Array): void;
  69393. /**
  69394. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69395. * @returns data the Uint8Array that can be saved and reused
  69396. */
  69397. getNavmeshData(): Uint8Array;
  69398. /**
  69399. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69400. * @param result output the box extent values
  69401. */
  69402. getDefaultQueryExtentToRef(result: Vector3): void;
  69403. /**
  69404. * Disposes
  69405. */
  69406. dispose(): void;
  69407. /**
  69408. * If this plugin is supported
  69409. * @returns true if plugin is supported
  69410. */
  69411. isSupported(): boolean;
  69412. }
  69413. /**
  69414. * Recast detour crowd implementation
  69415. */
  69416. export class RecastJSCrowd implements ICrowd {
  69417. /**
  69418. * Recast/detour plugin
  69419. */
  69420. bjsRECASTPlugin: RecastJSPlugin;
  69421. /**
  69422. * Link to the detour crowd
  69423. */
  69424. recastCrowd: any;
  69425. /**
  69426. * One transform per agent
  69427. */
  69428. transforms: TransformNode[];
  69429. /**
  69430. * All agents created
  69431. */
  69432. agents: number[];
  69433. /**
  69434. * Link to the scene is kept to unregister the crowd from the scene
  69435. */
  69436. private _scene;
  69437. /**
  69438. * Observer for crowd updates
  69439. */
  69440. private _onBeforeAnimationsObserver;
  69441. /**
  69442. * Constructor
  69443. * @param plugin recastJS plugin
  69444. * @param maxAgents the maximum agent count in the crowd
  69445. * @param maxAgentRadius the maximum radius an agent can have
  69446. * @param scene to attach the crowd to
  69447. * @returns the crowd you can add agents to
  69448. */
  69449. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69450. /**
  69451. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69452. * You can attach anything to that node. The node position is updated in the scene update tick.
  69453. * @param pos world position that will be constrained by the navigation mesh
  69454. * @param parameters agent parameters
  69455. * @param transform hooked to the agent that will be update by the scene
  69456. * @returns agent index
  69457. */
  69458. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69459. /**
  69460. * Returns the agent position in world space
  69461. * @param index agent index returned by addAgent
  69462. * @returns world space position
  69463. */
  69464. getAgentPosition(index: number): Vector3;
  69465. /**
  69466. * Returns the agent position result in world space
  69467. * @param index agent index returned by addAgent
  69468. * @param result output world space position
  69469. */
  69470. getAgentPositionToRef(index: number, result: Vector3): void;
  69471. /**
  69472. * Returns the agent velocity in world space
  69473. * @param index agent index returned by addAgent
  69474. * @returns world space velocity
  69475. */
  69476. getAgentVelocity(index: number): Vector3;
  69477. /**
  69478. * Returns the agent velocity result in world space
  69479. * @param index agent index returned by addAgent
  69480. * @param result output world space velocity
  69481. */
  69482. getAgentVelocityToRef(index: number, result: Vector3): void;
  69483. /**
  69484. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69485. * @param index agent index returned by addAgent
  69486. * @param destination targeted world position
  69487. */
  69488. agentGoto(index: number, destination: Vector3): void;
  69489. /**
  69490. * Teleport the agent to a new position
  69491. * @param index agent index returned by addAgent
  69492. * @param destination targeted world position
  69493. */
  69494. agentTeleport(index: number, destination: Vector3): void;
  69495. /**
  69496. * Update agent parameters
  69497. * @param index agent index returned by addAgent
  69498. * @param parameters agent parameters
  69499. */
  69500. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69501. /**
  69502. * remove a particular agent previously created
  69503. * @param index agent index returned by addAgent
  69504. */
  69505. removeAgent(index: number): void;
  69506. /**
  69507. * get the list of all agents attached to this crowd
  69508. * @returns list of agent indices
  69509. */
  69510. getAgents(): number[];
  69511. /**
  69512. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69513. * @param deltaTime in seconds
  69514. */
  69515. update(deltaTime: number): void;
  69516. /**
  69517. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69518. * The queries will try to find a solution within those bounds
  69519. * default is (1,1,1)
  69520. * @param extent x,y,z value that define the extent around the queries point of reference
  69521. */
  69522. setDefaultQueryExtent(extent: Vector3): void;
  69523. /**
  69524. * Get the Bounding box extent specified by setDefaultQueryExtent
  69525. * @returns the box extent values
  69526. */
  69527. getDefaultQueryExtent(): Vector3;
  69528. /**
  69529. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69530. * @param result output the box extent values
  69531. */
  69532. getDefaultQueryExtentToRef(result: Vector3): void;
  69533. /**
  69534. * Release all resources
  69535. */
  69536. dispose(): void;
  69537. }
  69538. }
  69539. declare module "babylonjs/Navigation/Plugins/index" {
  69540. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69541. }
  69542. declare module "babylonjs/Navigation/index" {
  69543. export * from "babylonjs/Navigation/INavigationEngine";
  69544. export * from "babylonjs/Navigation/Plugins/index";
  69545. }
  69546. declare module "babylonjs/Offline/database" {
  69547. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69548. /**
  69549. * Class used to enable access to IndexedDB
  69550. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69551. */
  69552. export class Database implements IOfflineProvider {
  69553. private _callbackManifestChecked;
  69554. private _currentSceneUrl;
  69555. private _db;
  69556. private _enableSceneOffline;
  69557. private _enableTexturesOffline;
  69558. private _manifestVersionFound;
  69559. private _mustUpdateRessources;
  69560. private _hasReachedQuota;
  69561. private _isSupported;
  69562. private _idbFactory;
  69563. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69564. private static IsUASupportingBlobStorage;
  69565. /**
  69566. * Gets a boolean indicating if Database storate is enabled (off by default)
  69567. */
  69568. static IDBStorageEnabled: boolean;
  69569. /**
  69570. * Gets a boolean indicating if scene must be saved in the database
  69571. */
  69572. get enableSceneOffline(): boolean;
  69573. /**
  69574. * Gets a boolean indicating if textures must be saved in the database
  69575. */
  69576. get enableTexturesOffline(): boolean;
  69577. /**
  69578. * Creates a new Database
  69579. * @param urlToScene defines the url to load the scene
  69580. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69581. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69582. */
  69583. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69584. private static _ParseURL;
  69585. private static _ReturnFullUrlLocation;
  69586. private _checkManifestFile;
  69587. /**
  69588. * Open the database and make it available
  69589. * @param successCallback defines the callback to call on success
  69590. * @param errorCallback defines the callback to call on error
  69591. */
  69592. open(successCallback: () => void, errorCallback: () => void): void;
  69593. /**
  69594. * Loads an image from the database
  69595. * @param url defines the url to load from
  69596. * @param image defines the target DOM image
  69597. */
  69598. loadImage(url: string, image: HTMLImageElement): void;
  69599. private _loadImageFromDBAsync;
  69600. private _saveImageIntoDBAsync;
  69601. private _checkVersionFromDB;
  69602. private _loadVersionFromDBAsync;
  69603. private _saveVersionIntoDBAsync;
  69604. /**
  69605. * Loads a file from database
  69606. * @param url defines the URL to load from
  69607. * @param sceneLoaded defines a callback to call on success
  69608. * @param progressCallBack defines a callback to call when progress changed
  69609. * @param errorCallback defines a callback to call on error
  69610. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69611. */
  69612. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69613. private _loadFileAsync;
  69614. private _saveFileAsync;
  69615. /**
  69616. * Validates if xhr data is correct
  69617. * @param xhr defines the request to validate
  69618. * @param dataType defines the expected data type
  69619. * @returns true if data is correct
  69620. */
  69621. private static _ValidateXHRData;
  69622. }
  69623. }
  69624. declare module "babylonjs/Offline/index" {
  69625. export * from "babylonjs/Offline/database";
  69626. export * from "babylonjs/Offline/IOfflineProvider";
  69627. }
  69628. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69629. /** @hidden */
  69630. export var gpuUpdateParticlesPixelShader: {
  69631. name: string;
  69632. shader: string;
  69633. };
  69634. }
  69635. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69636. /** @hidden */
  69637. export var gpuUpdateParticlesVertexShader: {
  69638. name: string;
  69639. shader: string;
  69640. };
  69641. }
  69642. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69643. /** @hidden */
  69644. export var clipPlaneFragmentDeclaration2: {
  69645. name: string;
  69646. shader: string;
  69647. };
  69648. }
  69649. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69650. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69651. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69652. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69653. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69654. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69655. /** @hidden */
  69656. export var gpuRenderParticlesPixelShader: {
  69657. name: string;
  69658. shader: string;
  69659. };
  69660. }
  69661. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69662. /** @hidden */
  69663. export var clipPlaneVertexDeclaration2: {
  69664. name: string;
  69665. shader: string;
  69666. };
  69667. }
  69668. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69669. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69670. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69671. /** @hidden */
  69672. export var gpuRenderParticlesVertexShader: {
  69673. name: string;
  69674. shader: string;
  69675. };
  69676. }
  69677. declare module "babylonjs/Particles/gpuParticleSystem" {
  69678. import { Nullable } from "babylonjs/types";
  69679. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69680. import { Observable } from "babylonjs/Misc/observable";
  69681. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69682. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69683. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69684. import { Scene, IDisposable } from "babylonjs/scene";
  69685. import { Effect } from "babylonjs/Materials/effect";
  69686. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69687. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69688. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69689. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69690. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69691. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69692. /**
  69693. * This represents a GPU particle system in Babylon
  69694. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69695. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69696. */
  69697. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69698. /**
  69699. * The layer mask we are rendering the particles through.
  69700. */
  69701. layerMask: number;
  69702. private _capacity;
  69703. private _activeCount;
  69704. private _currentActiveCount;
  69705. private _accumulatedCount;
  69706. private _renderEffect;
  69707. private _updateEffect;
  69708. private _buffer0;
  69709. private _buffer1;
  69710. private _spriteBuffer;
  69711. private _updateVAO;
  69712. private _renderVAO;
  69713. private _targetIndex;
  69714. private _sourceBuffer;
  69715. private _targetBuffer;
  69716. private _engine;
  69717. private _currentRenderId;
  69718. private _started;
  69719. private _stopped;
  69720. private _timeDelta;
  69721. private _randomTexture;
  69722. private _randomTexture2;
  69723. private _attributesStrideSize;
  69724. private _updateEffectOptions;
  69725. private _randomTextureSize;
  69726. private _actualFrame;
  69727. private _customEffect;
  69728. private readonly _rawTextureWidth;
  69729. /**
  69730. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69731. */
  69732. static get IsSupported(): boolean;
  69733. /**
  69734. * An event triggered when the system is disposed.
  69735. */
  69736. onDisposeObservable: Observable<IParticleSystem>;
  69737. /**
  69738. * Gets the maximum number of particles active at the same time.
  69739. * @returns The max number of active particles.
  69740. */
  69741. getCapacity(): number;
  69742. /**
  69743. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69744. * to override the particles.
  69745. */
  69746. forceDepthWrite: boolean;
  69747. /**
  69748. * Gets or set the number of active particles
  69749. */
  69750. get activeParticleCount(): number;
  69751. set activeParticleCount(value: number);
  69752. private _preWarmDone;
  69753. /**
  69754. * Specifies if the particles are updated in emitter local space or world space.
  69755. */
  69756. isLocal: boolean;
  69757. /**
  69758. * Is this system ready to be used/rendered
  69759. * @return true if the system is ready
  69760. */
  69761. isReady(): boolean;
  69762. /**
  69763. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69764. * @returns True if it has been started, otherwise false.
  69765. */
  69766. isStarted(): boolean;
  69767. /**
  69768. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69769. * @returns True if it has been stopped, otherwise false.
  69770. */
  69771. isStopped(): boolean;
  69772. /**
  69773. * Gets a boolean indicating that the system is stopping
  69774. * @returns true if the system is currently stopping
  69775. */
  69776. isStopping(): boolean;
  69777. /**
  69778. * Gets the number of particles active at the same time.
  69779. * @returns The number of active particles.
  69780. */
  69781. getActiveCount(): number;
  69782. /**
  69783. * Starts the particle system and begins to emit
  69784. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69785. */
  69786. start(delay?: number): void;
  69787. /**
  69788. * Stops the particle system.
  69789. */
  69790. stop(): void;
  69791. /**
  69792. * Remove all active particles
  69793. */
  69794. reset(): void;
  69795. /**
  69796. * Returns the string "GPUParticleSystem"
  69797. * @returns a string containing the class name
  69798. */
  69799. getClassName(): string;
  69800. /**
  69801. * Gets the custom effect used to render the particles
  69802. * @param blendMode Blend mode for which the effect should be retrieved
  69803. * @returns The effect
  69804. */
  69805. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69806. /**
  69807. * Sets the custom effect used to render the particles
  69808. * @param effect The effect to set
  69809. * @param blendMode Blend mode for which the effect should be set
  69810. */
  69811. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69812. /** @hidden */
  69813. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69814. /**
  69815. * Observable that will be called just before the particles are drawn
  69816. */
  69817. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69818. /**
  69819. * Gets the name of the particle vertex shader
  69820. */
  69821. get vertexShaderName(): string;
  69822. private _colorGradientsTexture;
  69823. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69824. /**
  69825. * Adds a new color gradient
  69826. * @param gradient defines the gradient to use (between 0 and 1)
  69827. * @param color1 defines the color to affect to the specified gradient
  69828. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69829. * @returns the current particle system
  69830. */
  69831. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69832. private _refreshColorGradient;
  69833. /** Force the system to rebuild all gradients that need to be resync */
  69834. forceRefreshGradients(): void;
  69835. /**
  69836. * Remove a specific color gradient
  69837. * @param gradient defines the gradient to remove
  69838. * @returns the current particle system
  69839. */
  69840. removeColorGradient(gradient: number): GPUParticleSystem;
  69841. private _angularSpeedGradientsTexture;
  69842. private _sizeGradientsTexture;
  69843. private _velocityGradientsTexture;
  69844. private _limitVelocityGradientsTexture;
  69845. private _dragGradientsTexture;
  69846. private _addFactorGradient;
  69847. /**
  69848. * Adds a new size gradient
  69849. * @param gradient defines the gradient to use (between 0 and 1)
  69850. * @param factor defines the size factor to affect to the specified gradient
  69851. * @returns the current particle system
  69852. */
  69853. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69854. /**
  69855. * Remove a specific size gradient
  69856. * @param gradient defines the gradient to remove
  69857. * @returns the current particle system
  69858. */
  69859. removeSizeGradient(gradient: number): GPUParticleSystem;
  69860. private _refreshFactorGradient;
  69861. /**
  69862. * Adds a new angular speed gradient
  69863. * @param gradient defines the gradient to use (between 0 and 1)
  69864. * @param factor defines the angular speed to affect to the specified gradient
  69865. * @returns the current particle system
  69866. */
  69867. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69868. /**
  69869. * Remove a specific angular speed gradient
  69870. * @param gradient defines the gradient to remove
  69871. * @returns the current particle system
  69872. */
  69873. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69874. /**
  69875. * Adds a new velocity gradient
  69876. * @param gradient defines the gradient to use (between 0 and 1)
  69877. * @param factor defines the velocity to affect to the specified gradient
  69878. * @returns the current particle system
  69879. */
  69880. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69881. /**
  69882. * Remove a specific velocity gradient
  69883. * @param gradient defines the gradient to remove
  69884. * @returns the current particle system
  69885. */
  69886. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69887. /**
  69888. * Adds a new limit velocity gradient
  69889. * @param gradient defines the gradient to use (between 0 and 1)
  69890. * @param factor defines the limit velocity value to affect to the specified gradient
  69891. * @returns the current particle system
  69892. */
  69893. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69894. /**
  69895. * Remove a specific limit velocity gradient
  69896. * @param gradient defines the gradient to remove
  69897. * @returns the current particle system
  69898. */
  69899. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69900. /**
  69901. * Adds a new drag gradient
  69902. * @param gradient defines the gradient to use (between 0 and 1)
  69903. * @param factor defines the drag value to affect to the specified gradient
  69904. * @returns the current particle system
  69905. */
  69906. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69907. /**
  69908. * Remove a specific drag gradient
  69909. * @param gradient defines the gradient to remove
  69910. * @returns the current particle system
  69911. */
  69912. removeDragGradient(gradient: number): GPUParticleSystem;
  69913. /**
  69914. * Not supported by GPUParticleSystem
  69915. * @param gradient defines the gradient to use (between 0 and 1)
  69916. * @param factor defines the emit rate value to affect to the specified gradient
  69917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69918. * @returns the current particle system
  69919. */
  69920. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69921. /**
  69922. * Not supported by GPUParticleSystem
  69923. * @param gradient defines the gradient to remove
  69924. * @returns the current particle system
  69925. */
  69926. removeEmitRateGradient(gradient: number): IParticleSystem;
  69927. /**
  69928. * Not supported by GPUParticleSystem
  69929. * @param gradient defines the gradient to use (between 0 and 1)
  69930. * @param factor defines the start size value to affect to the specified gradient
  69931. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69932. * @returns the current particle system
  69933. */
  69934. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69935. /**
  69936. * Not supported by GPUParticleSystem
  69937. * @param gradient defines the gradient to remove
  69938. * @returns the current particle system
  69939. */
  69940. removeStartSizeGradient(gradient: number): IParticleSystem;
  69941. /**
  69942. * Not supported by GPUParticleSystem
  69943. * @param gradient defines the gradient to use (between 0 and 1)
  69944. * @param min defines the color remap minimal range
  69945. * @param max defines the color remap maximal range
  69946. * @returns the current particle system
  69947. */
  69948. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69949. /**
  69950. * Not supported by GPUParticleSystem
  69951. * @param gradient defines the gradient to remove
  69952. * @returns the current particle system
  69953. */
  69954. removeColorRemapGradient(): IParticleSystem;
  69955. /**
  69956. * Not supported by GPUParticleSystem
  69957. * @param gradient defines the gradient to use (between 0 and 1)
  69958. * @param min defines the alpha remap minimal range
  69959. * @param max defines the alpha remap maximal range
  69960. * @returns the current particle system
  69961. */
  69962. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69963. /**
  69964. * Not supported by GPUParticleSystem
  69965. * @param gradient defines the gradient to remove
  69966. * @returns the current particle system
  69967. */
  69968. removeAlphaRemapGradient(): IParticleSystem;
  69969. /**
  69970. * Not supported by GPUParticleSystem
  69971. * @param gradient defines the gradient to use (between 0 and 1)
  69972. * @param color defines the color to affect to the specified gradient
  69973. * @returns the current particle system
  69974. */
  69975. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69976. /**
  69977. * Not supported by GPUParticleSystem
  69978. * @param gradient defines the gradient to remove
  69979. * @returns the current particle system
  69980. */
  69981. removeRampGradient(): IParticleSystem;
  69982. /**
  69983. * Not supported by GPUParticleSystem
  69984. * @returns the list of ramp gradients
  69985. */
  69986. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69987. /**
  69988. * Not supported by GPUParticleSystem
  69989. * Gets or sets a boolean indicating that ramp gradients must be used
  69990. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69991. */
  69992. get useRampGradients(): boolean;
  69993. set useRampGradients(value: boolean);
  69994. /**
  69995. * Not supported by GPUParticleSystem
  69996. * @param gradient defines the gradient to use (between 0 and 1)
  69997. * @param factor defines the life time factor to affect to the specified gradient
  69998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69999. * @returns the current particle system
  70000. */
  70001. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70002. /**
  70003. * Not supported by GPUParticleSystem
  70004. * @param gradient defines the gradient to remove
  70005. * @returns the current particle system
  70006. */
  70007. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70008. /**
  70009. * Instantiates a GPU particle system.
  70010. * 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.
  70011. * @param name The name of the particle system
  70012. * @param options The options used to create the system
  70013. * @param scene The scene the particle system belongs to
  70014. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70015. * @param customEffect a custom effect used to change the way particles are rendered by default
  70016. */
  70017. constructor(name: string, options: Partial<{
  70018. capacity: number;
  70019. randomTextureSize: number;
  70020. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70021. protected _reset(): void;
  70022. private _createUpdateVAO;
  70023. private _createRenderVAO;
  70024. private _initialize;
  70025. /** @hidden */
  70026. _recreateUpdateEffect(): void;
  70027. private _getEffect;
  70028. /**
  70029. * Fill the defines array according to the current settings of the particle system
  70030. * @param defines Array to be updated
  70031. * @param blendMode blend mode to take into account when updating the array
  70032. */
  70033. fillDefines(defines: Array<string>, blendMode?: number): void;
  70034. /**
  70035. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70036. * @param uniforms Uniforms array to fill
  70037. * @param attributes Attributes array to fill
  70038. * @param samplers Samplers array to fill
  70039. */
  70040. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70041. /** @hidden */
  70042. _recreateRenderEffect(): Effect;
  70043. /**
  70044. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70045. * @param preWarm defines if we are in the pre-warmimg phase
  70046. */
  70047. animate(preWarm?: boolean): void;
  70048. private _createFactorGradientTexture;
  70049. private _createSizeGradientTexture;
  70050. private _createAngularSpeedGradientTexture;
  70051. private _createVelocityGradientTexture;
  70052. private _createLimitVelocityGradientTexture;
  70053. private _createDragGradientTexture;
  70054. private _createColorGradientTexture;
  70055. /**
  70056. * Renders the particle system in its current state
  70057. * @param preWarm defines if the system should only update the particles but not render them
  70058. * @returns the current number of particles
  70059. */
  70060. render(preWarm?: boolean): number;
  70061. /**
  70062. * Rebuilds the particle system
  70063. */
  70064. rebuild(): void;
  70065. private _releaseBuffers;
  70066. private _releaseVAOs;
  70067. /**
  70068. * Disposes the particle system and free the associated resources
  70069. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70070. */
  70071. dispose(disposeTexture?: boolean): void;
  70072. /**
  70073. * Clones the particle system.
  70074. * @param name The name of the cloned object
  70075. * @param newEmitter The new emitter to use
  70076. * @returns the cloned particle system
  70077. */
  70078. clone(name: string, newEmitter: any): GPUParticleSystem;
  70079. /**
  70080. * Serializes the particle system to a JSON object
  70081. * @param serializeTexture defines if the texture must be serialized as well
  70082. * @returns the JSON object
  70083. */
  70084. serialize(serializeTexture?: boolean): any;
  70085. /**
  70086. * Parses a JSON object to create a GPU particle system.
  70087. * @param parsedParticleSystem The JSON object to parse
  70088. * @param scene The scene to create the particle system in
  70089. * @param rootUrl The root url to use to load external dependencies like texture
  70090. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70091. * @returns the parsed GPU particle system
  70092. */
  70093. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70094. }
  70095. }
  70096. declare module "babylonjs/Particles/particleSystemSet" {
  70097. import { Nullable } from "babylonjs/types";
  70098. import { Color3 } from "babylonjs/Maths/math.color";
  70099. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70101. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70102. import { Scene, IDisposable } from "babylonjs/scene";
  70103. /**
  70104. * Represents a set of particle systems working together to create a specific effect
  70105. */
  70106. export class ParticleSystemSet implements IDisposable {
  70107. /**
  70108. * Gets or sets base Assets URL
  70109. */
  70110. static BaseAssetsUrl: string;
  70111. private _emitterCreationOptions;
  70112. private _emitterNode;
  70113. /**
  70114. * Gets the particle system list
  70115. */
  70116. systems: IParticleSystem[];
  70117. /**
  70118. * Gets the emitter node used with this set
  70119. */
  70120. get emitterNode(): Nullable<TransformNode>;
  70121. /**
  70122. * Creates a new emitter mesh as a sphere
  70123. * @param options defines the options used to create the sphere
  70124. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70125. * @param scene defines the hosting scene
  70126. */
  70127. setEmitterAsSphere(options: {
  70128. diameter: number;
  70129. segments: number;
  70130. color: Color3;
  70131. }, renderingGroupId: number, scene: Scene): void;
  70132. /**
  70133. * Starts all particle systems of the set
  70134. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70135. */
  70136. start(emitter?: AbstractMesh): void;
  70137. /**
  70138. * Release all associated resources
  70139. */
  70140. dispose(): void;
  70141. /**
  70142. * Serialize the set into a JSON compatible object
  70143. * @param serializeTexture defines if the texture must be serialized as well
  70144. * @returns a JSON compatible representation of the set
  70145. */
  70146. serialize(serializeTexture?: boolean): any;
  70147. /**
  70148. * Parse a new ParticleSystemSet from a serialized source
  70149. * @param data defines a JSON compatible representation of the set
  70150. * @param scene defines the hosting scene
  70151. * @param gpu defines if we want GPU particles or CPU particles
  70152. * @returns a new ParticleSystemSet
  70153. */
  70154. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70155. }
  70156. }
  70157. declare module "babylonjs/Particles/particleHelper" {
  70158. import { Nullable } from "babylonjs/types";
  70159. import { Scene } from "babylonjs/scene";
  70160. import { Vector3 } from "babylonjs/Maths/math.vector";
  70161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70162. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70163. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70164. /**
  70165. * This class is made for on one-liner static method to help creating particle system set.
  70166. */
  70167. export class ParticleHelper {
  70168. /**
  70169. * Gets or sets base Assets URL
  70170. */
  70171. static BaseAssetsUrl: string;
  70172. /** Define the Url to load snippets */
  70173. static SnippetUrl: string;
  70174. /**
  70175. * Create a default particle system that you can tweak
  70176. * @param emitter defines the emitter to use
  70177. * @param capacity defines the system capacity (default is 500 particles)
  70178. * @param scene defines the hosting scene
  70179. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70180. * @returns the new Particle system
  70181. */
  70182. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70183. /**
  70184. * This is the main static method (one-liner) of this helper to create different particle systems
  70185. * @param type This string represents the type to the particle system to create
  70186. * @param scene The scene where the particle system should live
  70187. * @param gpu If the system will use gpu
  70188. * @returns the ParticleSystemSet created
  70189. */
  70190. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70191. /**
  70192. * Static function used to export a particle system to a ParticleSystemSet variable.
  70193. * Please note that the emitter shape is not exported
  70194. * @param systems defines the particle systems to export
  70195. * @returns the created particle system set
  70196. */
  70197. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70198. /**
  70199. * Creates a particle system from a snippet saved in a remote file
  70200. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70201. * @param url defines the url to load from
  70202. * @param scene defines the hosting scene
  70203. * @param gpu If the system will use gpu
  70204. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70205. * @returns a promise that will resolve to the new particle system
  70206. */
  70207. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70208. /**
  70209. * Creates a particle system from a snippet saved by the particle system editor
  70210. * @param snippetId defines the snippet to load
  70211. * @param scene defines the hosting scene
  70212. * @param gpu If the system will use gpu
  70213. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70214. * @returns a promise that will resolve to the new particle system
  70215. */
  70216. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70217. }
  70218. }
  70219. declare module "babylonjs/Particles/particleSystemComponent" {
  70220. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70221. import { Effect } from "babylonjs/Materials/effect";
  70222. import "babylonjs/Shaders/particles.vertex";
  70223. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70224. module "babylonjs/Engines/engine" {
  70225. interface Engine {
  70226. /**
  70227. * Create an effect to use with particle systems.
  70228. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70229. * the particle system for which you want to create a custom effect in the last parameter
  70230. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70231. * @param uniformsNames defines a list of attribute names
  70232. * @param samplers defines an array of string used to represent textures
  70233. * @param defines defines the string containing the defines to use to compile the shaders
  70234. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70235. * @param onCompiled defines a function to call when the effect creation is successful
  70236. * @param onError defines a function to call when the effect creation has failed
  70237. * @param particleSystem the particle system you want to create the effect for
  70238. * @returns the new Effect
  70239. */
  70240. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70241. }
  70242. }
  70243. module "babylonjs/Meshes/mesh" {
  70244. interface Mesh {
  70245. /**
  70246. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70247. * @returns an array of IParticleSystem
  70248. */
  70249. getEmittedParticleSystems(): IParticleSystem[];
  70250. /**
  70251. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70252. * @returns an array of IParticleSystem
  70253. */
  70254. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70255. }
  70256. }
  70257. }
  70258. declare module "babylonjs/Particles/pointsCloudSystem" {
  70259. import { Color4 } from "babylonjs/Maths/math";
  70260. import { Mesh } from "babylonjs/Meshes/mesh";
  70261. import { Scene, IDisposable } from "babylonjs/scene";
  70262. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70263. /** Defines the 4 color options */
  70264. export enum PointColor {
  70265. /** color value */
  70266. Color = 2,
  70267. /** uv value */
  70268. UV = 1,
  70269. /** random value */
  70270. Random = 0,
  70271. /** stated value */
  70272. Stated = 3
  70273. }
  70274. /**
  70275. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70276. * 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.
  70277. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70278. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70279. *
  70280. * Full documentation here : TO BE ENTERED
  70281. */
  70282. export class PointsCloudSystem implements IDisposable {
  70283. /**
  70284. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70285. * Example : var p = SPS.particles[i];
  70286. */
  70287. particles: CloudPoint[];
  70288. /**
  70289. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70290. */
  70291. nbParticles: number;
  70292. /**
  70293. * This a counter for your own usage. It's not set by any SPS functions.
  70294. */
  70295. counter: number;
  70296. /**
  70297. * The PCS name. This name is also given to the underlying mesh.
  70298. */
  70299. name: string;
  70300. /**
  70301. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70302. */
  70303. mesh: Mesh;
  70304. /**
  70305. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70306. * Please read :
  70307. */
  70308. vars: any;
  70309. /**
  70310. * @hidden
  70311. */
  70312. _size: number;
  70313. private _scene;
  70314. private _promises;
  70315. private _positions;
  70316. private _indices;
  70317. private _normals;
  70318. private _colors;
  70319. private _uvs;
  70320. private _indices32;
  70321. private _positions32;
  70322. private _colors32;
  70323. private _uvs32;
  70324. private _updatable;
  70325. private _isVisibilityBoxLocked;
  70326. private _alwaysVisible;
  70327. private _groups;
  70328. private _groupCounter;
  70329. private _computeParticleColor;
  70330. private _computeParticleTexture;
  70331. private _computeParticleRotation;
  70332. private _computeBoundingBox;
  70333. private _isReady;
  70334. /**
  70335. * Creates a PCS (Points Cloud System) object
  70336. * @param name (String) is the PCS name, this will be the underlying mesh name
  70337. * @param pointSize (number) is the size for each point
  70338. * @param scene (Scene) is the scene in which the PCS is added
  70339. * @param options defines the options of the PCS e.g.
  70340. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70341. */
  70342. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70343. updatable?: boolean;
  70344. });
  70345. /**
  70346. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70347. * If no points were added to the PCS, the returned mesh is just a single point.
  70348. * @returns a promise for the created mesh
  70349. */
  70350. buildMeshAsync(): Promise<Mesh>;
  70351. /**
  70352. * @hidden
  70353. */
  70354. private _buildMesh;
  70355. private _addParticle;
  70356. private _randomUnitVector;
  70357. private _getColorIndicesForCoord;
  70358. private _setPointsColorOrUV;
  70359. private _colorFromTexture;
  70360. private _calculateDensity;
  70361. /**
  70362. * Adds points to the PCS in random positions within a unit sphere
  70363. * @param nb (positive integer) the number of particles to be created from this model
  70364. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70365. * @returns the number of groups in the system
  70366. */
  70367. addPoints(nb: number, pointFunction?: any): number;
  70368. /**
  70369. * Adds points to the PCS from the surface of the model shape
  70370. * @param mesh is any Mesh object that will be used as a surface model for the points
  70371. * @param nb (positive integer) the number of particles to be created from this model
  70372. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70373. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70374. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70375. * @returns the number of groups in the system
  70376. */
  70377. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70378. /**
  70379. * Adds points to the PCS inside the model shape
  70380. * @param mesh is any Mesh object that will be used as a surface model for the points
  70381. * @param nb (positive integer) the number of particles to be created from this model
  70382. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70383. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70384. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70385. * @returns the number of groups in the system
  70386. */
  70387. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70388. /**
  70389. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70390. * This method calls `updateParticle()` for each particle of the SPS.
  70391. * For an animated SPS, it is usually called within the render loop.
  70392. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70393. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70394. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70395. * @returns the PCS.
  70396. */
  70397. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70398. /**
  70399. * Disposes the PCS.
  70400. */
  70401. dispose(): void;
  70402. /**
  70403. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70404. * doc :
  70405. * @returns the PCS.
  70406. */
  70407. refreshVisibleSize(): PointsCloudSystem;
  70408. /**
  70409. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70410. * @param size the size (float) of the visibility box
  70411. * note : this doesn't lock the PCS mesh bounding box.
  70412. * doc :
  70413. */
  70414. setVisibilityBox(size: number): void;
  70415. /**
  70416. * Gets whether the PCS is always visible or not
  70417. * doc :
  70418. */
  70419. get isAlwaysVisible(): boolean;
  70420. /**
  70421. * Sets the PCS as always visible or not
  70422. * doc :
  70423. */
  70424. set isAlwaysVisible(val: boolean);
  70425. /**
  70426. * Tells to `setParticles()` to compute the particle rotations or not
  70427. * Default value : false. The PCS is faster when it's set to false
  70428. * Note : particle rotations are only applied to parent particles
  70429. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70430. */
  70431. set computeParticleRotation(val: boolean);
  70432. /**
  70433. * Tells to `setParticles()` to compute the particle colors or not.
  70434. * Default value : true. The PCS is faster when it's set to false.
  70435. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70436. */
  70437. set computeParticleColor(val: boolean);
  70438. set computeParticleTexture(val: boolean);
  70439. /**
  70440. * Gets if `setParticles()` computes the particle colors or not.
  70441. * Default value : false. The PCS is faster when it's set to false.
  70442. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70443. */
  70444. get computeParticleColor(): boolean;
  70445. /**
  70446. * Gets if `setParticles()` computes the particle textures or not.
  70447. * Default value : false. The PCS is faster when it's set to false.
  70448. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70449. */
  70450. get computeParticleTexture(): boolean;
  70451. /**
  70452. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70453. */
  70454. set computeBoundingBox(val: boolean);
  70455. /**
  70456. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70457. */
  70458. get computeBoundingBox(): boolean;
  70459. /**
  70460. * This function does nothing. It may be overwritten to set all the particle first values.
  70461. * The PCS doesn't call this function, you may have to call it by your own.
  70462. * doc :
  70463. */
  70464. initParticles(): void;
  70465. /**
  70466. * This function does nothing. It may be overwritten to recycle a particle
  70467. * The PCS doesn't call this function, you can to call it
  70468. * doc :
  70469. * @param particle The particle to recycle
  70470. * @returns the recycled particle
  70471. */
  70472. recycleParticle(particle: CloudPoint): CloudPoint;
  70473. /**
  70474. * Updates a particle : this function should be overwritten by the user.
  70475. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70476. * doc :
  70477. * @example : just set a particle position or velocity and recycle conditions
  70478. * @param particle The particle to update
  70479. * @returns the updated particle
  70480. */
  70481. updateParticle(particle: CloudPoint): CloudPoint;
  70482. /**
  70483. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70484. * This does nothing and may be overwritten by the user.
  70485. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70486. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70487. * @param update the boolean update value actually passed to setParticles()
  70488. */
  70489. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70490. /**
  70491. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70492. * This will be passed three parameters.
  70493. * This does nothing and may be overwritten by the user.
  70494. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70495. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70496. * @param update the boolean update value actually passed to setParticles()
  70497. */
  70498. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70499. }
  70500. }
  70501. declare module "babylonjs/Particles/cloudPoint" {
  70502. import { Nullable } from "babylonjs/types";
  70503. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70504. import { Mesh } from "babylonjs/Meshes/mesh";
  70505. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70506. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70507. /**
  70508. * Represents one particle of a points cloud system.
  70509. */
  70510. export class CloudPoint {
  70511. /**
  70512. * particle global index
  70513. */
  70514. idx: number;
  70515. /**
  70516. * The color of the particle
  70517. */
  70518. color: Nullable<Color4>;
  70519. /**
  70520. * The world space position of the particle.
  70521. */
  70522. position: Vector3;
  70523. /**
  70524. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70525. */
  70526. rotation: Vector3;
  70527. /**
  70528. * The world space rotation quaternion of the particle.
  70529. */
  70530. rotationQuaternion: Nullable<Quaternion>;
  70531. /**
  70532. * The uv of the particle.
  70533. */
  70534. uv: Nullable<Vector2>;
  70535. /**
  70536. * The current speed of the particle.
  70537. */
  70538. velocity: Vector3;
  70539. /**
  70540. * The pivot point in the particle local space.
  70541. */
  70542. pivot: Vector3;
  70543. /**
  70544. * Must the particle be translated from its pivot point in its local space ?
  70545. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70546. * Default : false
  70547. */
  70548. translateFromPivot: boolean;
  70549. /**
  70550. * Index of this particle in the global "positions" array (Internal use)
  70551. * @hidden
  70552. */
  70553. _pos: number;
  70554. /**
  70555. * @hidden Index of this particle in the global "indices" array (Internal use)
  70556. */
  70557. _ind: number;
  70558. /**
  70559. * Group this particle belongs to
  70560. */
  70561. _group: PointsGroup;
  70562. /**
  70563. * Group id of this particle
  70564. */
  70565. groupId: number;
  70566. /**
  70567. * Index of the particle in its group id (Internal use)
  70568. */
  70569. idxInGroup: number;
  70570. /**
  70571. * @hidden Particle BoundingInfo object (Internal use)
  70572. */
  70573. _boundingInfo: BoundingInfo;
  70574. /**
  70575. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70576. */
  70577. _pcs: PointsCloudSystem;
  70578. /**
  70579. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70580. */
  70581. _stillInvisible: boolean;
  70582. /**
  70583. * @hidden Last computed particle rotation matrix
  70584. */
  70585. _rotationMatrix: number[];
  70586. /**
  70587. * Parent particle Id, if any.
  70588. * Default null.
  70589. */
  70590. parentId: Nullable<number>;
  70591. /**
  70592. * @hidden Internal global position in the PCS.
  70593. */
  70594. _globalPosition: Vector3;
  70595. /**
  70596. * Creates a Point Cloud object.
  70597. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70598. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70599. * @param group (PointsGroup) is the group the particle belongs to
  70600. * @param groupId (integer) is the group identifier in the PCS.
  70601. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70602. * @param pcs defines the PCS it is associated to
  70603. */
  70604. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70605. /**
  70606. * get point size
  70607. */
  70608. get size(): Vector3;
  70609. /**
  70610. * Set point size
  70611. */
  70612. set size(scale: Vector3);
  70613. /**
  70614. * Legacy support, changed quaternion to rotationQuaternion
  70615. */
  70616. get quaternion(): Nullable<Quaternion>;
  70617. /**
  70618. * Legacy support, changed quaternion to rotationQuaternion
  70619. */
  70620. set quaternion(q: Nullable<Quaternion>);
  70621. /**
  70622. * Returns a boolean. True if the particle intersects a mesh, else false
  70623. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70624. * @param target is the object (point or mesh) what the intersection is computed against
  70625. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70626. * @returns true if it intersects
  70627. */
  70628. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70629. /**
  70630. * get the rotation matrix of the particle
  70631. * @hidden
  70632. */
  70633. getRotationMatrix(m: Matrix): void;
  70634. }
  70635. /**
  70636. * Represents a group of points in a points cloud system
  70637. * * PCS internal tool, don't use it manually.
  70638. */
  70639. export class PointsGroup {
  70640. /**
  70641. * The group id
  70642. * @hidden
  70643. */
  70644. groupID: number;
  70645. /**
  70646. * image data for group (internal use)
  70647. * @hidden
  70648. */
  70649. _groupImageData: Nullable<ArrayBufferView>;
  70650. /**
  70651. * Image Width (internal use)
  70652. * @hidden
  70653. */
  70654. _groupImgWidth: number;
  70655. /**
  70656. * Image Height (internal use)
  70657. * @hidden
  70658. */
  70659. _groupImgHeight: number;
  70660. /**
  70661. * Custom position function (internal use)
  70662. * @hidden
  70663. */
  70664. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70665. /**
  70666. * density per facet for surface points
  70667. * @hidden
  70668. */
  70669. _groupDensity: number[];
  70670. /**
  70671. * Only when points are colored by texture carries pointer to texture list array
  70672. * @hidden
  70673. */
  70674. _textureNb: number;
  70675. /**
  70676. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70677. * PCS internal tool, don't use it manually.
  70678. * @hidden
  70679. */
  70680. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70681. }
  70682. }
  70683. declare module "babylonjs/Particles/index" {
  70684. export * from "babylonjs/Particles/baseParticleSystem";
  70685. export * from "babylonjs/Particles/EmitterTypes/index";
  70686. export * from "babylonjs/Particles/gpuParticleSystem";
  70687. export * from "babylonjs/Particles/IParticleSystem";
  70688. export * from "babylonjs/Particles/particle";
  70689. export * from "babylonjs/Particles/particleHelper";
  70690. export * from "babylonjs/Particles/particleSystem";
  70691. import "babylonjs/Particles/particleSystemComponent";
  70692. export * from "babylonjs/Particles/particleSystemComponent";
  70693. export * from "babylonjs/Particles/particleSystemSet";
  70694. export * from "babylonjs/Particles/solidParticle";
  70695. export * from "babylonjs/Particles/solidParticleSystem";
  70696. export * from "babylonjs/Particles/cloudPoint";
  70697. export * from "babylonjs/Particles/pointsCloudSystem";
  70698. export * from "babylonjs/Particles/subEmitter";
  70699. }
  70700. declare module "babylonjs/Physics/physicsEngineComponent" {
  70701. import { Nullable } from "babylonjs/types";
  70702. import { Observable, Observer } from "babylonjs/Misc/observable";
  70703. import { Vector3 } from "babylonjs/Maths/math.vector";
  70704. import { Mesh } from "babylonjs/Meshes/mesh";
  70705. import { ISceneComponent } from "babylonjs/sceneComponent";
  70706. import { Scene } from "babylonjs/scene";
  70707. import { Node } from "babylonjs/node";
  70708. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  70709. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70710. module "babylonjs/scene" {
  70711. interface Scene {
  70712. /** @hidden (Backing field) */
  70713. _physicsEngine: Nullable<IPhysicsEngine>;
  70714. /** @hidden */
  70715. _physicsTimeAccumulator: number;
  70716. /**
  70717. * Gets the current physics engine
  70718. * @returns a IPhysicsEngine or null if none attached
  70719. */
  70720. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  70721. /**
  70722. * Enables physics to the current scene
  70723. * @param gravity defines the scene's gravity for the physics engine
  70724. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  70725. * @return a boolean indicating if the physics engine was initialized
  70726. */
  70727. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  70728. /**
  70729. * Disables and disposes the physics engine associated with the scene
  70730. */
  70731. disablePhysicsEngine(): void;
  70732. /**
  70733. * Gets a boolean indicating if there is an active physics engine
  70734. * @returns a boolean indicating if there is an active physics engine
  70735. */
  70736. isPhysicsEnabled(): boolean;
  70737. /**
  70738. * Deletes a physics compound impostor
  70739. * @param compound defines the compound to delete
  70740. */
  70741. deleteCompoundImpostor(compound: any): void;
  70742. /**
  70743. * An event triggered when physic simulation is about to be run
  70744. */
  70745. onBeforePhysicsObservable: Observable<Scene>;
  70746. /**
  70747. * An event triggered when physic simulation has been done
  70748. */
  70749. onAfterPhysicsObservable: Observable<Scene>;
  70750. }
  70751. }
  70752. module "babylonjs/Meshes/abstractMesh" {
  70753. interface AbstractMesh {
  70754. /** @hidden */
  70755. _physicsImpostor: Nullable<PhysicsImpostor>;
  70756. /**
  70757. * Gets or sets impostor used for physic simulation
  70758. * @see http://doc.babylonjs.com/features/physics_engine
  70759. */
  70760. physicsImpostor: Nullable<PhysicsImpostor>;
  70761. /**
  70762. * Gets the current physics impostor
  70763. * @see http://doc.babylonjs.com/features/physics_engine
  70764. * @returns a physics impostor or null
  70765. */
  70766. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70767. /** Apply a physic impulse to the mesh
  70768. * @param force defines the force to apply
  70769. * @param contactPoint defines where to apply the force
  70770. * @returns the current mesh
  70771. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  70772. */
  70773. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70774. /**
  70775. * Creates a physic joint between two meshes
  70776. * @param otherMesh defines the other mesh to use
  70777. * @param pivot1 defines the pivot to use on this mesh
  70778. * @param pivot2 defines the pivot to use on the other mesh
  70779. * @param options defines additional options (can be plugin dependent)
  70780. * @returns the current mesh
  70781. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70782. */
  70783. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70784. /** @hidden */
  70785. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70786. }
  70787. }
  70788. /**
  70789. * Defines the physics engine scene component responsible to manage a physics engine
  70790. */
  70791. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70792. /**
  70793. * The component name helpful to identify the component in the list of scene components.
  70794. */
  70795. readonly name: string;
  70796. /**
  70797. * The scene the component belongs to.
  70798. */
  70799. scene: Scene;
  70800. /**
  70801. * Creates a new instance of the component for the given scene
  70802. * @param scene Defines the scene to register the component in
  70803. */
  70804. constructor(scene: Scene);
  70805. /**
  70806. * Registers the component in a given scene
  70807. */
  70808. register(): void;
  70809. /**
  70810. * Rebuilds the elements related to this component in case of
  70811. * context lost for instance.
  70812. */
  70813. rebuild(): void;
  70814. /**
  70815. * Disposes the component and the associated ressources
  70816. */
  70817. dispose(): void;
  70818. }
  70819. }
  70820. declare module "babylonjs/Physics/physicsHelper" {
  70821. import { Nullable } from "babylonjs/types";
  70822. import { Vector3 } from "babylonjs/Maths/math.vector";
  70823. import { Mesh } from "babylonjs/Meshes/mesh";
  70824. import { Scene } from "babylonjs/scene";
  70825. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  70826. /**
  70827. * A helper for physics simulations
  70828. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70829. */
  70830. export class PhysicsHelper {
  70831. private _scene;
  70832. private _physicsEngine;
  70833. /**
  70834. * Initializes the Physics helper
  70835. * @param scene Babylon.js scene
  70836. */
  70837. constructor(scene: Scene);
  70838. /**
  70839. * Applies a radial explosion impulse
  70840. * @param origin the origin of the explosion
  70841. * @param radiusOrEventOptions the radius or the options of radial explosion
  70842. * @param strength the explosion strength
  70843. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70844. * @returns A physics radial explosion event, or null
  70845. */
  70846. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70847. /**
  70848. * Applies a radial explosion force
  70849. * @param origin the origin of the explosion
  70850. * @param radiusOrEventOptions the radius or the options of radial explosion
  70851. * @param strength the explosion strength
  70852. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70853. * @returns A physics radial explosion event, or null
  70854. */
  70855. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70856. /**
  70857. * Creates a gravitational field
  70858. * @param origin the origin of the explosion
  70859. * @param radiusOrEventOptions the radius or the options of radial explosion
  70860. * @param strength the explosion strength
  70861. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70862. * @returns A physics gravitational field event, or null
  70863. */
  70864. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70865. /**
  70866. * Creates a physics updraft event
  70867. * @param origin the origin of the updraft
  70868. * @param radiusOrEventOptions the radius or the options of the updraft
  70869. * @param strength the strength of the updraft
  70870. * @param height the height of the updraft
  70871. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70872. * @returns A physics updraft event, or null
  70873. */
  70874. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70875. /**
  70876. * Creates a physics vortex event
  70877. * @param origin the of the vortex
  70878. * @param radiusOrEventOptions the radius or the options of the vortex
  70879. * @param strength the strength of the vortex
  70880. * @param height the height of the vortex
  70881. * @returns a Physics vortex event, or null
  70882. * A physics vortex event or null
  70883. */
  70884. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70885. }
  70886. /**
  70887. * Represents a physics radial explosion event
  70888. */
  70889. class PhysicsRadialExplosionEvent {
  70890. private _scene;
  70891. private _options;
  70892. private _sphere;
  70893. private _dataFetched;
  70894. /**
  70895. * Initializes a radial explosioin event
  70896. * @param _scene BabylonJS scene
  70897. * @param _options The options for the vortex event
  70898. */
  70899. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70900. /**
  70901. * Returns the data related to the radial explosion event (sphere).
  70902. * @returns The radial explosion event data
  70903. */
  70904. getData(): PhysicsRadialExplosionEventData;
  70905. /**
  70906. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70907. * @param impostor A physics imposter
  70908. * @param origin the origin of the explosion
  70909. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70910. */
  70911. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70912. /**
  70913. * Triggers affecterd impostors callbacks
  70914. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70915. */
  70916. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70917. /**
  70918. * Disposes the sphere.
  70919. * @param force Specifies if the sphere should be disposed by force
  70920. */
  70921. dispose(force?: boolean): void;
  70922. /*** Helpers ***/
  70923. private _prepareSphere;
  70924. private _intersectsWithSphere;
  70925. }
  70926. /**
  70927. * Represents a gravitational field event
  70928. */
  70929. class PhysicsGravitationalFieldEvent {
  70930. private _physicsHelper;
  70931. private _scene;
  70932. private _origin;
  70933. private _options;
  70934. private _tickCallback;
  70935. private _sphere;
  70936. private _dataFetched;
  70937. /**
  70938. * Initializes the physics gravitational field event
  70939. * @param _physicsHelper A physics helper
  70940. * @param _scene BabylonJS scene
  70941. * @param _origin The origin position of the gravitational field event
  70942. * @param _options The options for the vortex event
  70943. */
  70944. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70945. /**
  70946. * Returns the data related to the gravitational field event (sphere).
  70947. * @returns A gravitational field event
  70948. */
  70949. getData(): PhysicsGravitationalFieldEventData;
  70950. /**
  70951. * Enables the gravitational field.
  70952. */
  70953. enable(): void;
  70954. /**
  70955. * Disables the gravitational field.
  70956. */
  70957. disable(): void;
  70958. /**
  70959. * Disposes the sphere.
  70960. * @param force The force to dispose from the gravitational field event
  70961. */
  70962. dispose(force?: boolean): void;
  70963. private _tick;
  70964. }
  70965. /**
  70966. * Represents a physics updraft event
  70967. */
  70968. class PhysicsUpdraftEvent {
  70969. private _scene;
  70970. private _origin;
  70971. private _options;
  70972. private _physicsEngine;
  70973. private _originTop;
  70974. private _originDirection;
  70975. private _tickCallback;
  70976. private _cylinder;
  70977. private _cylinderPosition;
  70978. private _dataFetched;
  70979. /**
  70980. * Initializes the physics updraft event
  70981. * @param _scene BabylonJS scene
  70982. * @param _origin The origin position of the updraft
  70983. * @param _options The options for the updraft event
  70984. */
  70985. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70986. /**
  70987. * Returns the data related to the updraft event (cylinder).
  70988. * @returns A physics updraft event
  70989. */
  70990. getData(): PhysicsUpdraftEventData;
  70991. /**
  70992. * Enables the updraft.
  70993. */
  70994. enable(): void;
  70995. /**
  70996. * Disables the updraft.
  70997. */
  70998. disable(): void;
  70999. /**
  71000. * Disposes the cylinder.
  71001. * @param force Specifies if the updraft should be disposed by force
  71002. */
  71003. dispose(force?: boolean): void;
  71004. private getImpostorHitData;
  71005. private _tick;
  71006. /*** Helpers ***/
  71007. private _prepareCylinder;
  71008. private _intersectsWithCylinder;
  71009. }
  71010. /**
  71011. * Represents a physics vortex event
  71012. */
  71013. class PhysicsVortexEvent {
  71014. private _scene;
  71015. private _origin;
  71016. private _options;
  71017. private _physicsEngine;
  71018. private _originTop;
  71019. private _tickCallback;
  71020. private _cylinder;
  71021. private _cylinderPosition;
  71022. private _dataFetched;
  71023. /**
  71024. * Initializes the physics vortex event
  71025. * @param _scene The BabylonJS scene
  71026. * @param _origin The origin position of the vortex
  71027. * @param _options The options for the vortex event
  71028. */
  71029. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71030. /**
  71031. * Returns the data related to the vortex event (cylinder).
  71032. * @returns The physics vortex event data
  71033. */
  71034. getData(): PhysicsVortexEventData;
  71035. /**
  71036. * Enables the vortex.
  71037. */
  71038. enable(): void;
  71039. /**
  71040. * Disables the cortex.
  71041. */
  71042. disable(): void;
  71043. /**
  71044. * Disposes the sphere.
  71045. * @param force
  71046. */
  71047. dispose(force?: boolean): void;
  71048. private getImpostorHitData;
  71049. private _tick;
  71050. /*** Helpers ***/
  71051. private _prepareCylinder;
  71052. private _intersectsWithCylinder;
  71053. }
  71054. /**
  71055. * Options fot the radial explosion event
  71056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71057. */
  71058. export class PhysicsRadialExplosionEventOptions {
  71059. /**
  71060. * The radius of the sphere for the radial explosion.
  71061. */
  71062. radius: number;
  71063. /**
  71064. * The strenth of the explosion.
  71065. */
  71066. strength: number;
  71067. /**
  71068. * The strenght of the force in correspondence to the distance of the affected object
  71069. */
  71070. falloff: PhysicsRadialImpulseFalloff;
  71071. /**
  71072. * Sphere options for the radial explosion.
  71073. */
  71074. sphere: {
  71075. segments: number;
  71076. diameter: number;
  71077. };
  71078. /**
  71079. * Sphere options for the radial explosion.
  71080. */
  71081. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71082. }
  71083. /**
  71084. * Options fot the updraft event
  71085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71086. */
  71087. export class PhysicsUpdraftEventOptions {
  71088. /**
  71089. * The radius of the cylinder for the vortex
  71090. */
  71091. radius: number;
  71092. /**
  71093. * The strenth of the updraft.
  71094. */
  71095. strength: number;
  71096. /**
  71097. * The height of the cylinder for the updraft.
  71098. */
  71099. height: number;
  71100. /**
  71101. * The mode for the the updraft.
  71102. */
  71103. updraftMode: PhysicsUpdraftMode;
  71104. }
  71105. /**
  71106. * Options fot the vortex event
  71107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71108. */
  71109. export class PhysicsVortexEventOptions {
  71110. /**
  71111. * The radius of the cylinder for the vortex
  71112. */
  71113. radius: number;
  71114. /**
  71115. * The strenth of the vortex.
  71116. */
  71117. strength: number;
  71118. /**
  71119. * The height of the cylinder for the vortex.
  71120. */
  71121. height: number;
  71122. /**
  71123. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71124. */
  71125. centripetalForceThreshold: number;
  71126. /**
  71127. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71128. */
  71129. centripetalForceMultiplier: number;
  71130. /**
  71131. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71132. */
  71133. centrifugalForceMultiplier: number;
  71134. /**
  71135. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71136. */
  71137. updraftForceMultiplier: number;
  71138. }
  71139. /**
  71140. * The strenght of the force in correspondence to the distance of the affected object
  71141. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71142. */
  71143. export enum PhysicsRadialImpulseFalloff {
  71144. /** Defines that impulse is constant in strength across it's whole radius */
  71145. Constant = 0,
  71146. /** Defines that impulse gets weaker if it's further from the origin */
  71147. Linear = 1
  71148. }
  71149. /**
  71150. * The strength of the force in correspondence to the distance of the affected object
  71151. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71152. */
  71153. export enum PhysicsUpdraftMode {
  71154. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71155. Center = 0,
  71156. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71157. Perpendicular = 1
  71158. }
  71159. /**
  71160. * Interface for a physics hit data
  71161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71162. */
  71163. export interface PhysicsHitData {
  71164. /**
  71165. * The force applied at the contact point
  71166. */
  71167. force: Vector3;
  71168. /**
  71169. * The contact point
  71170. */
  71171. contactPoint: Vector3;
  71172. /**
  71173. * The distance from the origin to the contact point
  71174. */
  71175. distanceFromOrigin: number;
  71176. }
  71177. /**
  71178. * Interface for radial explosion event data
  71179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71180. */
  71181. export interface PhysicsRadialExplosionEventData {
  71182. /**
  71183. * A sphere used for the radial explosion event
  71184. */
  71185. sphere: Mesh;
  71186. }
  71187. /**
  71188. * Interface for gravitational field event data
  71189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71190. */
  71191. export interface PhysicsGravitationalFieldEventData {
  71192. /**
  71193. * A sphere mesh used for the gravitational field event
  71194. */
  71195. sphere: Mesh;
  71196. }
  71197. /**
  71198. * Interface for updraft event data
  71199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71200. */
  71201. export interface PhysicsUpdraftEventData {
  71202. /**
  71203. * A cylinder used for the updraft event
  71204. */
  71205. cylinder: Mesh;
  71206. }
  71207. /**
  71208. * Interface for vortex event data
  71209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71210. */
  71211. export interface PhysicsVortexEventData {
  71212. /**
  71213. * A cylinder used for the vortex event
  71214. */
  71215. cylinder: Mesh;
  71216. }
  71217. /**
  71218. * Interface for an affected physics impostor
  71219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71220. */
  71221. export interface PhysicsAffectedImpostorWithData {
  71222. /**
  71223. * The impostor affected by the effect
  71224. */
  71225. impostor: PhysicsImpostor;
  71226. /**
  71227. * The data about the hit/horce from the explosion
  71228. */
  71229. hitData: PhysicsHitData;
  71230. }
  71231. }
  71232. declare module "babylonjs/Physics/Plugins/index" {
  71233. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71234. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71235. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71236. }
  71237. declare module "babylonjs/Physics/index" {
  71238. export * from "babylonjs/Physics/IPhysicsEngine";
  71239. export * from "babylonjs/Physics/physicsEngine";
  71240. export * from "babylonjs/Physics/physicsEngineComponent";
  71241. export * from "babylonjs/Physics/physicsHelper";
  71242. export * from "babylonjs/Physics/physicsImpostor";
  71243. export * from "babylonjs/Physics/physicsJoint";
  71244. export * from "babylonjs/Physics/Plugins/index";
  71245. }
  71246. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71247. /** @hidden */
  71248. export var blackAndWhitePixelShader: {
  71249. name: string;
  71250. shader: string;
  71251. };
  71252. }
  71253. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71254. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71255. import { Camera } from "babylonjs/Cameras/camera";
  71256. import { Engine } from "babylonjs/Engines/engine";
  71257. import "babylonjs/Shaders/blackAndWhite.fragment";
  71258. /**
  71259. * Post process used to render in black and white
  71260. */
  71261. export class BlackAndWhitePostProcess extends PostProcess {
  71262. /**
  71263. * Linear about to convert he result to black and white (default: 1)
  71264. */
  71265. degree: number;
  71266. /**
  71267. * Creates a black and white post process
  71268. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71269. * @param name The name of the effect.
  71270. * @param options The required width/height ratio to downsize to before computing the render pass.
  71271. * @param camera The camera to apply the render pass to.
  71272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71273. * @param engine The engine which the post process will be applied. (default: current engine)
  71274. * @param reusable If the post process can be reused on the same frame. (default: false)
  71275. */
  71276. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71277. }
  71278. }
  71279. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71280. import { Nullable } from "babylonjs/types";
  71281. import { Camera } from "babylonjs/Cameras/camera";
  71282. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71283. import { Engine } from "babylonjs/Engines/engine";
  71284. /**
  71285. * This represents a set of one or more post processes in Babylon.
  71286. * A post process can be used to apply a shader to a texture after it is rendered.
  71287. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71288. */
  71289. export class PostProcessRenderEffect {
  71290. private _postProcesses;
  71291. private _getPostProcesses;
  71292. private _singleInstance;
  71293. private _cameras;
  71294. private _indicesForCamera;
  71295. /**
  71296. * Name of the effect
  71297. * @hidden
  71298. */
  71299. _name: string;
  71300. /**
  71301. * Instantiates a post process render effect.
  71302. * A post process can be used to apply a shader to a texture after it is rendered.
  71303. * @param engine The engine the effect is tied to
  71304. * @param name The name of the effect
  71305. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71306. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71307. */
  71308. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71309. /**
  71310. * Checks if all the post processes in the effect are supported.
  71311. */
  71312. get isSupported(): boolean;
  71313. /**
  71314. * Updates the current state of the effect
  71315. * @hidden
  71316. */
  71317. _update(): void;
  71318. /**
  71319. * Attaches the effect on cameras
  71320. * @param cameras The camera to attach to.
  71321. * @hidden
  71322. */
  71323. _attachCameras(cameras: Camera): void;
  71324. /**
  71325. * Attaches the effect on cameras
  71326. * @param cameras The camera to attach to.
  71327. * @hidden
  71328. */
  71329. _attachCameras(cameras: Camera[]): void;
  71330. /**
  71331. * Detaches the effect on cameras
  71332. * @param cameras The camera to detatch from.
  71333. * @hidden
  71334. */
  71335. _detachCameras(cameras: Camera): void;
  71336. /**
  71337. * Detatches the effect on cameras
  71338. * @param cameras The camera to detatch from.
  71339. * @hidden
  71340. */
  71341. _detachCameras(cameras: Camera[]): void;
  71342. /**
  71343. * Enables the effect on given cameras
  71344. * @param cameras The camera to enable.
  71345. * @hidden
  71346. */
  71347. _enable(cameras: Camera): void;
  71348. /**
  71349. * Enables the effect on given cameras
  71350. * @param cameras The camera to enable.
  71351. * @hidden
  71352. */
  71353. _enable(cameras: Nullable<Camera[]>): void;
  71354. /**
  71355. * Disables the effect on the given cameras
  71356. * @param cameras The camera to disable.
  71357. * @hidden
  71358. */
  71359. _disable(cameras: Camera): void;
  71360. /**
  71361. * Disables the effect on the given cameras
  71362. * @param cameras The camera to disable.
  71363. * @hidden
  71364. */
  71365. _disable(cameras: Nullable<Camera[]>): void;
  71366. /**
  71367. * Gets a list of the post processes contained in the effect.
  71368. * @param camera The camera to get the post processes on.
  71369. * @returns The list of the post processes in the effect.
  71370. */
  71371. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71372. }
  71373. }
  71374. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71375. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71376. /** @hidden */
  71377. export var extractHighlightsPixelShader: {
  71378. name: string;
  71379. shader: string;
  71380. };
  71381. }
  71382. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71383. import { Nullable } from "babylonjs/types";
  71384. import { Camera } from "babylonjs/Cameras/camera";
  71385. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71386. import { Engine } from "babylonjs/Engines/engine";
  71387. import "babylonjs/Shaders/extractHighlights.fragment";
  71388. /**
  71389. * 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.
  71390. */
  71391. export class ExtractHighlightsPostProcess extends PostProcess {
  71392. /**
  71393. * The luminance threshold, pixels below this value will be set to black.
  71394. */
  71395. threshold: number;
  71396. /** @hidden */
  71397. _exposure: number;
  71398. /**
  71399. * Post process which has the input texture to be used when performing highlight extraction
  71400. * @hidden
  71401. */
  71402. _inputPostProcess: Nullable<PostProcess>;
  71403. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71404. }
  71405. }
  71406. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71407. /** @hidden */
  71408. export var bloomMergePixelShader: {
  71409. name: string;
  71410. shader: string;
  71411. };
  71412. }
  71413. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71415. import { Nullable } from "babylonjs/types";
  71416. import { Engine } from "babylonjs/Engines/engine";
  71417. import { Camera } from "babylonjs/Cameras/camera";
  71418. import "babylonjs/Shaders/bloomMerge.fragment";
  71419. /**
  71420. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71421. */
  71422. export class BloomMergePostProcess extends PostProcess {
  71423. /** Weight of the bloom to be added to the original input. */
  71424. weight: number;
  71425. /**
  71426. * Creates a new instance of @see BloomMergePostProcess
  71427. * @param name The name of the effect.
  71428. * @param originalFromInput Post process which's input will be used for the merge.
  71429. * @param blurred Blurred highlights post process which's output will be used.
  71430. * @param weight Weight of the bloom to be added to the original input.
  71431. * @param options The required width/height ratio to downsize to before computing the render pass.
  71432. * @param camera The camera to apply the render pass to.
  71433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71434. * @param engine The engine which the post process will be applied. (default: current engine)
  71435. * @param reusable If the post process can be reused on the same frame. (default: false)
  71436. * @param textureType Type of textures used when performing the post process. (default: 0)
  71437. * @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)
  71438. */
  71439. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71440. /** Weight of the bloom to be added to the original input. */
  71441. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71442. }
  71443. }
  71444. declare module "babylonjs/PostProcesses/bloomEffect" {
  71445. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71446. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71447. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71448. import { Camera } from "babylonjs/Cameras/camera";
  71449. import { Scene } from "babylonjs/scene";
  71450. /**
  71451. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71452. */
  71453. export class BloomEffect extends PostProcessRenderEffect {
  71454. private bloomScale;
  71455. /**
  71456. * @hidden Internal
  71457. */
  71458. _effects: Array<PostProcess>;
  71459. /**
  71460. * @hidden Internal
  71461. */
  71462. _downscale: ExtractHighlightsPostProcess;
  71463. private _blurX;
  71464. private _blurY;
  71465. private _merge;
  71466. /**
  71467. * The luminance threshold to find bright areas of the image to bloom.
  71468. */
  71469. get threshold(): number;
  71470. set threshold(value: number);
  71471. /**
  71472. * The strength of the bloom.
  71473. */
  71474. get weight(): number;
  71475. set weight(value: number);
  71476. /**
  71477. * Specifies the size of the bloom blur kernel, relative to the final output size
  71478. */
  71479. get kernel(): number;
  71480. set kernel(value: number);
  71481. /**
  71482. * Creates a new instance of @see BloomEffect
  71483. * @param scene The scene the effect belongs to.
  71484. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71485. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71486. * @param bloomWeight The the strength of bloom.
  71487. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71488. * @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)
  71489. */
  71490. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71491. /**
  71492. * Disposes each of the internal effects for a given camera.
  71493. * @param camera The camera to dispose the effect on.
  71494. */
  71495. disposeEffects(camera: Camera): void;
  71496. /**
  71497. * @hidden Internal
  71498. */
  71499. _updateEffects(): void;
  71500. /**
  71501. * Internal
  71502. * @returns if all the contained post processes are ready.
  71503. * @hidden
  71504. */
  71505. _isReady(): boolean;
  71506. }
  71507. }
  71508. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71509. /** @hidden */
  71510. export var chromaticAberrationPixelShader: {
  71511. name: string;
  71512. shader: string;
  71513. };
  71514. }
  71515. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71516. import { Vector2 } from "babylonjs/Maths/math.vector";
  71517. import { Nullable } from "babylonjs/types";
  71518. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71519. import { Camera } from "babylonjs/Cameras/camera";
  71520. import { Engine } from "babylonjs/Engines/engine";
  71521. import "babylonjs/Shaders/chromaticAberration.fragment";
  71522. /**
  71523. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71524. */
  71525. export class ChromaticAberrationPostProcess extends PostProcess {
  71526. /**
  71527. * The amount of seperation of rgb channels (default: 30)
  71528. */
  71529. aberrationAmount: number;
  71530. /**
  71531. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71532. */
  71533. radialIntensity: number;
  71534. /**
  71535. * 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))
  71536. */
  71537. direction: Vector2;
  71538. /**
  71539. * 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))
  71540. */
  71541. centerPosition: Vector2;
  71542. /**
  71543. * Creates a new instance ChromaticAberrationPostProcess
  71544. * @param name The name of the effect.
  71545. * @param screenWidth The width of the screen to apply the effect on.
  71546. * @param screenHeight The height of the screen to apply the effect on.
  71547. * @param options The required width/height ratio to downsize to before computing the render pass.
  71548. * @param camera The camera to apply the render pass to.
  71549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71550. * @param engine The engine which the post process will be applied. (default: current engine)
  71551. * @param reusable If the post process can be reused on the same frame. (default: false)
  71552. * @param textureType Type of textures used when performing the post process. (default: 0)
  71553. * @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)
  71554. */
  71555. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71556. }
  71557. }
  71558. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71559. /** @hidden */
  71560. export var circleOfConfusionPixelShader: {
  71561. name: string;
  71562. shader: string;
  71563. };
  71564. }
  71565. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71566. import { Nullable } from "babylonjs/types";
  71567. import { Engine } from "babylonjs/Engines/engine";
  71568. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71569. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71570. import { Camera } from "babylonjs/Cameras/camera";
  71571. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71572. /**
  71573. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71574. */
  71575. export class CircleOfConfusionPostProcess extends PostProcess {
  71576. /**
  71577. * 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.
  71578. */
  71579. lensSize: number;
  71580. /**
  71581. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71582. */
  71583. fStop: number;
  71584. /**
  71585. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71586. */
  71587. focusDistance: number;
  71588. /**
  71589. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71590. */
  71591. focalLength: number;
  71592. private _depthTexture;
  71593. /**
  71594. * Creates a new instance CircleOfConfusionPostProcess
  71595. * @param name The name of the effect.
  71596. * @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.
  71597. * @param options The required width/height ratio to downsize to before computing the render pass.
  71598. * @param camera The camera to apply the render pass to.
  71599. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71600. * @param engine The engine which the post process will be applied. (default: current engine)
  71601. * @param reusable If the post process can be reused on the same frame. (default: false)
  71602. * @param textureType Type of textures used when performing the post process. (default: 0)
  71603. * @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)
  71604. */
  71605. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71606. /**
  71607. * 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.
  71608. */
  71609. set depthTexture(value: RenderTargetTexture);
  71610. }
  71611. }
  71612. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71613. /** @hidden */
  71614. export var colorCorrectionPixelShader: {
  71615. name: string;
  71616. shader: string;
  71617. };
  71618. }
  71619. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71620. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71621. import { Engine } from "babylonjs/Engines/engine";
  71622. import { Camera } from "babylonjs/Cameras/camera";
  71623. import "babylonjs/Shaders/colorCorrection.fragment";
  71624. /**
  71625. *
  71626. * This post-process allows the modification of rendered colors by using
  71627. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71628. *
  71629. * The object needs to be provided an url to a texture containing the color
  71630. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71631. * Use an image editing software to tweak the LUT to match your needs.
  71632. *
  71633. * For an example of a color LUT, see here:
  71634. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71635. * For explanations on color grading, see here:
  71636. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71637. *
  71638. */
  71639. export class ColorCorrectionPostProcess extends PostProcess {
  71640. private _colorTableTexture;
  71641. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71642. }
  71643. }
  71644. declare module "babylonjs/Shaders/convolution.fragment" {
  71645. /** @hidden */
  71646. export var convolutionPixelShader: {
  71647. name: string;
  71648. shader: string;
  71649. };
  71650. }
  71651. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71652. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71653. import { Nullable } from "babylonjs/types";
  71654. import { Camera } from "babylonjs/Cameras/camera";
  71655. import { Engine } from "babylonjs/Engines/engine";
  71656. import "babylonjs/Shaders/convolution.fragment";
  71657. /**
  71658. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71659. * input texture to perform effects such as edge detection or sharpening
  71660. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71661. */
  71662. export class ConvolutionPostProcess extends PostProcess {
  71663. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71664. kernel: number[];
  71665. /**
  71666. * Creates a new instance ConvolutionPostProcess
  71667. * @param name The name of the effect.
  71668. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71669. * @param options The required width/height ratio to downsize to before computing the render pass.
  71670. * @param camera The camera to apply the render pass to.
  71671. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71672. * @param engine The engine which the post process will be applied. (default: current engine)
  71673. * @param reusable If the post process can be reused on the same frame. (default: false)
  71674. * @param textureType Type of textures used when performing the post process. (default: 0)
  71675. */
  71676. constructor(name: string,
  71677. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71678. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71679. /**
  71680. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71681. */
  71682. static EdgeDetect0Kernel: number[];
  71683. /**
  71684. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71685. */
  71686. static EdgeDetect1Kernel: number[];
  71687. /**
  71688. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71689. */
  71690. static EdgeDetect2Kernel: number[];
  71691. /**
  71692. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71693. */
  71694. static SharpenKernel: number[];
  71695. /**
  71696. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71697. */
  71698. static EmbossKernel: number[];
  71699. /**
  71700. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71701. */
  71702. static GaussianKernel: number[];
  71703. }
  71704. }
  71705. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  71706. import { Nullable } from "babylonjs/types";
  71707. import { Vector2 } from "babylonjs/Maths/math.vector";
  71708. import { Camera } from "babylonjs/Cameras/camera";
  71709. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71710. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  71711. import { Engine } from "babylonjs/Engines/engine";
  71712. import { Scene } from "babylonjs/scene";
  71713. /**
  71714. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  71715. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  71716. * based on samples that have a large difference in distance than the center pixel.
  71717. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  71718. */
  71719. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  71720. direction: Vector2;
  71721. /**
  71722. * Creates a new instance CircleOfConfusionPostProcess
  71723. * @param name The name of the effect.
  71724. * @param scene The scene the effect belongs to.
  71725. * @param direction The direction the blur should be applied.
  71726. * @param kernel The size of the kernel used to blur.
  71727. * @param options The required width/height ratio to downsize to before computing the render pass.
  71728. * @param camera The camera to apply the render pass to.
  71729. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  71730. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  71731. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71732. * @param engine The engine which the post process will be applied. (default: current engine)
  71733. * @param reusable If the post process can be reused on the same frame. (default: false)
  71734. * @param textureType Type of textures used when performing the post process. (default: 0)
  71735. * @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)
  71736. */
  71737. 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);
  71738. }
  71739. }
  71740. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  71741. /** @hidden */
  71742. export var depthOfFieldMergePixelShader: {
  71743. name: string;
  71744. shader: string;
  71745. };
  71746. }
  71747. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  71748. import { Nullable } from "babylonjs/types";
  71749. import { Camera } from "babylonjs/Cameras/camera";
  71750. import { Effect } from "babylonjs/Materials/effect";
  71751. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71752. import { Engine } from "babylonjs/Engines/engine";
  71753. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  71754. /**
  71755. * Options to be set when merging outputs from the default pipeline.
  71756. */
  71757. export class DepthOfFieldMergePostProcessOptions {
  71758. /**
  71759. * The original image to merge on top of
  71760. */
  71761. originalFromInput: PostProcess;
  71762. /**
  71763. * Parameters to perform the merge of the depth of field effect
  71764. */
  71765. depthOfField?: {
  71766. circleOfConfusion: PostProcess;
  71767. blurSteps: Array<PostProcess>;
  71768. };
  71769. /**
  71770. * Parameters to perform the merge of bloom effect
  71771. */
  71772. bloom?: {
  71773. blurred: PostProcess;
  71774. weight: number;
  71775. };
  71776. }
  71777. /**
  71778. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71779. */
  71780. export class DepthOfFieldMergePostProcess extends PostProcess {
  71781. private blurSteps;
  71782. /**
  71783. * Creates a new instance of DepthOfFieldMergePostProcess
  71784. * @param name The name of the effect.
  71785. * @param originalFromInput Post process which's input will be used for the merge.
  71786. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71787. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71788. * @param options The required width/height ratio to downsize to before computing the render pass.
  71789. * @param camera The camera to apply the render pass to.
  71790. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71791. * @param engine The engine which the post process will be applied. (default: current engine)
  71792. * @param reusable If the post process can be reused on the same frame. (default: false)
  71793. * @param textureType Type of textures used when performing the post process. (default: 0)
  71794. * @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)
  71795. */
  71796. 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);
  71797. /**
  71798. * Updates the effect with the current post process compile time values and recompiles the shader.
  71799. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71800. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71801. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71802. * @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
  71803. * @param onCompiled Called when the shader has been compiled.
  71804. * @param onError Called if there is an error when compiling a shader.
  71805. */
  71806. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71807. }
  71808. }
  71809. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  71810. import { Nullable } from "babylonjs/types";
  71811. import { Camera } from "babylonjs/Cameras/camera";
  71812. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71813. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71814. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71815. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  71816. import { Scene } from "babylonjs/scene";
  71817. /**
  71818. * Specifies the level of max blur that should be applied when using the depth of field effect
  71819. */
  71820. export enum DepthOfFieldEffectBlurLevel {
  71821. /**
  71822. * Subtle blur
  71823. */
  71824. Low = 0,
  71825. /**
  71826. * Medium blur
  71827. */
  71828. Medium = 1,
  71829. /**
  71830. * Large blur
  71831. */
  71832. High = 2
  71833. }
  71834. /**
  71835. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71836. */
  71837. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71838. private _circleOfConfusion;
  71839. /**
  71840. * @hidden Internal, blurs from high to low
  71841. */
  71842. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71843. private _depthOfFieldBlurY;
  71844. private _dofMerge;
  71845. /**
  71846. * @hidden Internal post processes in depth of field effect
  71847. */
  71848. _effects: Array<PostProcess>;
  71849. /**
  71850. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71851. */
  71852. set focalLength(value: number);
  71853. get focalLength(): number;
  71854. /**
  71855. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71856. */
  71857. set fStop(value: number);
  71858. get fStop(): number;
  71859. /**
  71860. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71861. */
  71862. set focusDistance(value: number);
  71863. get focusDistance(): number;
  71864. /**
  71865. * 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.
  71866. */
  71867. set lensSize(value: number);
  71868. get lensSize(): number;
  71869. /**
  71870. * Creates a new instance DepthOfFieldEffect
  71871. * @param scene The scene the effect belongs to.
  71872. * @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.
  71873. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71874. * @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)
  71875. */
  71876. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71877. /**
  71878. * Get the current class name of the current effet
  71879. * @returns "DepthOfFieldEffect"
  71880. */
  71881. getClassName(): string;
  71882. /**
  71883. * 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.
  71884. */
  71885. set depthTexture(value: RenderTargetTexture);
  71886. /**
  71887. * Disposes each of the internal effects for a given camera.
  71888. * @param camera The camera to dispose the effect on.
  71889. */
  71890. disposeEffects(camera: Camera): void;
  71891. /**
  71892. * @hidden Internal
  71893. */
  71894. _updateEffects(): void;
  71895. /**
  71896. * Internal
  71897. * @returns if all the contained post processes are ready.
  71898. * @hidden
  71899. */
  71900. _isReady(): boolean;
  71901. }
  71902. }
  71903. declare module "babylonjs/Shaders/displayPass.fragment" {
  71904. /** @hidden */
  71905. export var displayPassPixelShader: {
  71906. name: string;
  71907. shader: string;
  71908. };
  71909. }
  71910. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  71911. import { Nullable } from "babylonjs/types";
  71912. import { Camera } from "babylonjs/Cameras/camera";
  71913. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71914. import { Engine } from "babylonjs/Engines/engine";
  71915. import "babylonjs/Shaders/displayPass.fragment";
  71916. /**
  71917. * DisplayPassPostProcess which produces an output the same as it's input
  71918. */
  71919. export class DisplayPassPostProcess extends PostProcess {
  71920. /**
  71921. * Creates the DisplayPassPostProcess
  71922. * @param name The name of the effect.
  71923. * @param options The required width/height ratio to downsize to before computing the render pass.
  71924. * @param camera The camera to apply the render pass to.
  71925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71926. * @param engine The engine which the post process will be applied. (default: current engine)
  71927. * @param reusable If the post process can be reused on the same frame. (default: false)
  71928. */
  71929. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71930. }
  71931. }
  71932. declare module "babylonjs/Shaders/filter.fragment" {
  71933. /** @hidden */
  71934. export var filterPixelShader: {
  71935. name: string;
  71936. shader: string;
  71937. };
  71938. }
  71939. declare module "babylonjs/PostProcesses/filterPostProcess" {
  71940. import { Nullable } from "babylonjs/types";
  71941. import { Matrix } from "babylonjs/Maths/math.vector";
  71942. import { Camera } from "babylonjs/Cameras/camera";
  71943. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71944. import { Engine } from "babylonjs/Engines/engine";
  71945. import "babylonjs/Shaders/filter.fragment";
  71946. /**
  71947. * Applies a kernel filter to the image
  71948. */
  71949. export class FilterPostProcess extends PostProcess {
  71950. /** The matrix to be applied to the image */
  71951. kernelMatrix: Matrix;
  71952. /**
  71953. *
  71954. * @param name The name of the effect.
  71955. * @param kernelMatrix The matrix to be applied to the image
  71956. * @param options The required width/height ratio to downsize to before computing the render pass.
  71957. * @param camera The camera to apply the render pass to.
  71958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71959. * @param engine The engine which the post process will be applied. (default: current engine)
  71960. * @param reusable If the post process can be reused on the same frame. (default: false)
  71961. */
  71962. constructor(name: string,
  71963. /** The matrix to be applied to the image */
  71964. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71965. }
  71966. }
  71967. declare module "babylonjs/Shaders/fxaa.fragment" {
  71968. /** @hidden */
  71969. export var fxaaPixelShader: {
  71970. name: string;
  71971. shader: string;
  71972. };
  71973. }
  71974. declare module "babylonjs/Shaders/fxaa.vertex" {
  71975. /** @hidden */
  71976. export var fxaaVertexShader: {
  71977. name: string;
  71978. shader: string;
  71979. };
  71980. }
  71981. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  71982. import { Nullable } from "babylonjs/types";
  71983. import { Camera } from "babylonjs/Cameras/camera";
  71984. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71985. import { Engine } from "babylonjs/Engines/engine";
  71986. import "babylonjs/Shaders/fxaa.fragment";
  71987. import "babylonjs/Shaders/fxaa.vertex";
  71988. /**
  71989. * Fxaa post process
  71990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71991. */
  71992. export class FxaaPostProcess extends PostProcess {
  71993. /** @hidden */
  71994. texelWidth: number;
  71995. /** @hidden */
  71996. texelHeight: number;
  71997. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71998. private _getDefines;
  71999. }
  72000. }
  72001. declare module "babylonjs/Shaders/grain.fragment" {
  72002. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72003. /** @hidden */
  72004. export var grainPixelShader: {
  72005. name: string;
  72006. shader: string;
  72007. };
  72008. }
  72009. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72010. import { Nullable } from "babylonjs/types";
  72011. import { Camera } from "babylonjs/Cameras/camera";
  72012. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72013. import { Engine } from "babylonjs/Engines/engine";
  72014. import "babylonjs/Shaders/grain.fragment";
  72015. /**
  72016. * The GrainPostProcess adds noise to the image at mid luminance levels
  72017. */
  72018. export class GrainPostProcess extends PostProcess {
  72019. /**
  72020. * The intensity of the grain added (default: 30)
  72021. */
  72022. intensity: number;
  72023. /**
  72024. * If the grain should be randomized on every frame
  72025. */
  72026. animated: boolean;
  72027. /**
  72028. * Creates a new instance of @see GrainPostProcess
  72029. * @param name The name of the effect.
  72030. * @param options The required width/height ratio to downsize to before computing the render pass.
  72031. * @param camera The camera to apply the render pass to.
  72032. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72033. * @param engine The engine which the post process will be applied. (default: current engine)
  72034. * @param reusable If the post process can be reused on the same frame. (default: false)
  72035. * @param textureType Type of textures used when performing the post process. (default: 0)
  72036. * @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)
  72037. */
  72038. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72039. }
  72040. }
  72041. declare module "babylonjs/Shaders/highlights.fragment" {
  72042. /** @hidden */
  72043. export var highlightsPixelShader: {
  72044. name: string;
  72045. shader: string;
  72046. };
  72047. }
  72048. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72049. import { Nullable } from "babylonjs/types";
  72050. import { Camera } from "babylonjs/Cameras/camera";
  72051. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72052. import { Engine } from "babylonjs/Engines/engine";
  72053. import "babylonjs/Shaders/highlights.fragment";
  72054. /**
  72055. * Extracts highlights from the image
  72056. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72057. */
  72058. export class HighlightsPostProcess extends PostProcess {
  72059. /**
  72060. * Extracts highlights from the image
  72061. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72062. * @param name The name of the effect.
  72063. * @param options The required width/height ratio to downsize to before computing the render pass.
  72064. * @param camera The camera to apply the render pass to.
  72065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72066. * @param engine The engine which the post process will be applied. (default: current engine)
  72067. * @param reusable If the post process can be reused on the same frame. (default: false)
  72068. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72069. */
  72070. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72071. }
  72072. }
  72073. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72074. /** @hidden */
  72075. export var mrtFragmentDeclaration: {
  72076. name: string;
  72077. shader: string;
  72078. };
  72079. }
  72080. declare module "babylonjs/Shaders/geometry.fragment" {
  72081. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72082. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72083. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72084. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72085. /** @hidden */
  72086. export var geometryPixelShader: {
  72087. name: string;
  72088. shader: string;
  72089. };
  72090. }
  72091. declare module "babylonjs/Shaders/geometry.vertex" {
  72092. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72093. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72094. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72095. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72096. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72097. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72098. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72099. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72100. /** @hidden */
  72101. export var geometryVertexShader: {
  72102. name: string;
  72103. shader: string;
  72104. };
  72105. }
  72106. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72107. import { Matrix } from "babylonjs/Maths/math.vector";
  72108. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72109. import { Mesh } from "babylonjs/Meshes/mesh";
  72110. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72111. import { Effect } from "babylonjs/Materials/effect";
  72112. import { Scene } from "babylonjs/scene";
  72113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72114. import "babylonjs/Shaders/geometry.fragment";
  72115. import "babylonjs/Shaders/geometry.vertex";
  72116. /** @hidden */
  72117. interface ISavedTransformationMatrix {
  72118. world: Matrix;
  72119. viewProjection: Matrix;
  72120. }
  72121. /**
  72122. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72123. */
  72124. export class GeometryBufferRenderer {
  72125. /**
  72126. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72127. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72128. */
  72129. static readonly POSITION_TEXTURE_TYPE: number;
  72130. /**
  72131. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72132. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72133. */
  72134. static readonly VELOCITY_TEXTURE_TYPE: number;
  72135. /**
  72136. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72137. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72138. */
  72139. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72140. /**
  72141. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72142. * in order to compute objects velocities when enableVelocity is set to "true"
  72143. * @hidden
  72144. */
  72145. _previousTransformationMatrices: {
  72146. [index: number]: ISavedTransformationMatrix;
  72147. };
  72148. /**
  72149. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72150. * in order to compute objects velocities when enableVelocity is set to "true"
  72151. * @hidden
  72152. */
  72153. _previousBonesTransformationMatrices: {
  72154. [index: number]: Float32Array;
  72155. };
  72156. /**
  72157. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72158. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72159. */
  72160. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72161. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72162. renderTransparentMeshes: boolean;
  72163. private _scene;
  72164. private _multiRenderTarget;
  72165. private _ratio;
  72166. private _enablePosition;
  72167. private _enableVelocity;
  72168. private _enableReflectivity;
  72169. private _positionIndex;
  72170. private _velocityIndex;
  72171. private _reflectivityIndex;
  72172. protected _effect: Effect;
  72173. protected _cachedDefines: string;
  72174. /**
  72175. * Set the render list (meshes to be rendered) used in the G buffer.
  72176. */
  72177. set renderList(meshes: Mesh[]);
  72178. /**
  72179. * Gets wether or not G buffer are supported by the running hardware.
  72180. * This requires draw buffer supports
  72181. */
  72182. get isSupported(): boolean;
  72183. /**
  72184. * Returns the index of the given texture type in the G-Buffer textures array
  72185. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72186. * @returns the index of the given texture type in the G-Buffer textures array
  72187. */
  72188. getTextureIndex(textureType: number): number;
  72189. /**
  72190. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72191. */
  72192. get enablePosition(): boolean;
  72193. /**
  72194. * Sets whether or not objects positions are enabled for the G buffer.
  72195. */
  72196. set enablePosition(enable: boolean);
  72197. /**
  72198. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72199. */
  72200. get enableVelocity(): boolean;
  72201. /**
  72202. * Sets wether or not objects velocities are enabled for the G buffer.
  72203. */
  72204. set enableVelocity(enable: boolean);
  72205. /**
  72206. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72207. */
  72208. get enableReflectivity(): boolean;
  72209. /**
  72210. * Sets wether or not objects roughness are enabled for the G buffer.
  72211. */
  72212. set enableReflectivity(enable: boolean);
  72213. /**
  72214. * Gets the scene associated with the buffer.
  72215. */
  72216. get scene(): Scene;
  72217. /**
  72218. * Gets the ratio used by the buffer during its creation.
  72219. * How big is the buffer related to the main canvas.
  72220. */
  72221. get ratio(): number;
  72222. /** @hidden */
  72223. static _SceneComponentInitialization: (scene: Scene) => void;
  72224. /**
  72225. * Creates a new G Buffer for the scene
  72226. * @param scene The scene the buffer belongs to
  72227. * @param ratio How big is the buffer related to the main canvas.
  72228. */
  72229. constructor(scene: Scene, ratio?: number);
  72230. /**
  72231. * Checks wether everything is ready to render a submesh to the G buffer.
  72232. * @param subMesh the submesh to check readiness for
  72233. * @param useInstances is the mesh drawn using instance or not
  72234. * @returns true if ready otherwise false
  72235. */
  72236. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72237. /**
  72238. * Gets the current underlying G Buffer.
  72239. * @returns the buffer
  72240. */
  72241. getGBuffer(): MultiRenderTarget;
  72242. /**
  72243. * Gets the number of samples used to render the buffer (anti aliasing).
  72244. */
  72245. get samples(): number;
  72246. /**
  72247. * Sets the number of samples used to render the buffer (anti aliasing).
  72248. */
  72249. set samples(value: number);
  72250. /**
  72251. * Disposes the renderer and frees up associated resources.
  72252. */
  72253. dispose(): void;
  72254. protected _createRenderTargets(): void;
  72255. private _copyBonesTransformationMatrices;
  72256. }
  72257. }
  72258. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72259. import { Nullable } from "babylonjs/types";
  72260. import { Scene } from "babylonjs/scene";
  72261. import { ISceneComponent } from "babylonjs/sceneComponent";
  72262. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72263. module "babylonjs/scene" {
  72264. interface Scene {
  72265. /** @hidden (Backing field) */
  72266. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72267. /**
  72268. * Gets or Sets the current geometry buffer associated to the scene.
  72269. */
  72270. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72271. /**
  72272. * Enables a GeometryBufferRender and associates it with the scene
  72273. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72274. * @returns the GeometryBufferRenderer
  72275. */
  72276. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72277. /**
  72278. * Disables the GeometryBufferRender associated with the scene
  72279. */
  72280. disableGeometryBufferRenderer(): void;
  72281. }
  72282. }
  72283. /**
  72284. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72285. * in several rendering techniques.
  72286. */
  72287. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72288. /**
  72289. * The component name helpful to identify the component in the list of scene components.
  72290. */
  72291. readonly name: string;
  72292. /**
  72293. * The scene the component belongs to.
  72294. */
  72295. scene: Scene;
  72296. /**
  72297. * Creates a new instance of the component for the given scene
  72298. * @param scene Defines the scene to register the component in
  72299. */
  72300. constructor(scene: Scene);
  72301. /**
  72302. * Registers the component in a given scene
  72303. */
  72304. register(): void;
  72305. /**
  72306. * Rebuilds the elements related to this component in case of
  72307. * context lost for instance.
  72308. */
  72309. rebuild(): void;
  72310. /**
  72311. * Disposes the component and the associated ressources
  72312. */
  72313. dispose(): void;
  72314. private _gatherRenderTargets;
  72315. }
  72316. }
  72317. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72318. /** @hidden */
  72319. export var motionBlurPixelShader: {
  72320. name: string;
  72321. shader: string;
  72322. };
  72323. }
  72324. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72325. import { Nullable } from "babylonjs/types";
  72326. import { Camera } from "babylonjs/Cameras/camera";
  72327. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72328. import { Scene } from "babylonjs/scene";
  72329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72330. import "babylonjs/Animations/animatable";
  72331. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72332. import "babylonjs/Shaders/motionBlur.fragment";
  72333. import { Engine } from "babylonjs/Engines/engine";
  72334. /**
  72335. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72336. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72337. * As an example, all you have to do is to create the post-process:
  72338. * var mb = new BABYLON.MotionBlurPostProcess(
  72339. * 'mb', // The name of the effect.
  72340. * scene, // The scene containing the objects to blur according to their velocity.
  72341. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72342. * camera // The camera to apply the render pass to.
  72343. * );
  72344. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72345. */
  72346. export class MotionBlurPostProcess extends PostProcess {
  72347. /**
  72348. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72349. */
  72350. motionStrength: number;
  72351. /**
  72352. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72353. */
  72354. get motionBlurSamples(): number;
  72355. /**
  72356. * Sets the number of iterations to be used for motion blur quality
  72357. */
  72358. set motionBlurSamples(samples: number);
  72359. private _motionBlurSamples;
  72360. private _geometryBufferRenderer;
  72361. /**
  72362. * Creates a new instance MotionBlurPostProcess
  72363. * @param name The name of the effect.
  72364. * @param scene The scene containing the objects to blur according to their velocity.
  72365. * @param options The required width/height ratio to downsize to before computing the render pass.
  72366. * @param camera The camera to apply the render pass to.
  72367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72368. * @param engine The engine which the post process will be applied. (default: current engine)
  72369. * @param reusable If the post process can be reused on the same frame. (default: false)
  72370. * @param textureType Type of textures used when performing the post process. (default: 0)
  72371. * @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)
  72372. */
  72373. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72374. /**
  72375. * Excludes the given skinned mesh from computing bones velocities.
  72376. * 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.
  72377. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72378. */
  72379. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72380. /**
  72381. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72382. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72383. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72384. */
  72385. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72386. /**
  72387. * Disposes the post process.
  72388. * @param camera The camera to dispose the post process on.
  72389. */
  72390. dispose(camera?: Camera): void;
  72391. }
  72392. }
  72393. declare module "babylonjs/Shaders/refraction.fragment" {
  72394. /** @hidden */
  72395. export var refractionPixelShader: {
  72396. name: string;
  72397. shader: string;
  72398. };
  72399. }
  72400. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72401. import { Color3 } from "babylonjs/Maths/math.color";
  72402. import { Camera } from "babylonjs/Cameras/camera";
  72403. import { Texture } from "babylonjs/Materials/Textures/texture";
  72404. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72405. import { Engine } from "babylonjs/Engines/engine";
  72406. import "babylonjs/Shaders/refraction.fragment";
  72407. /**
  72408. * Post process which applies a refractin texture
  72409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72410. */
  72411. export class RefractionPostProcess extends PostProcess {
  72412. /** the base color of the refraction (used to taint the rendering) */
  72413. color: Color3;
  72414. /** simulated refraction depth */
  72415. depth: number;
  72416. /** the coefficient of the base color (0 to remove base color tainting) */
  72417. colorLevel: number;
  72418. private _refTexture;
  72419. private _ownRefractionTexture;
  72420. /**
  72421. * Gets or sets the refraction texture
  72422. * Please note that you are responsible for disposing the texture if you set it manually
  72423. */
  72424. get refractionTexture(): Texture;
  72425. set refractionTexture(value: Texture);
  72426. /**
  72427. * Initializes the RefractionPostProcess
  72428. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72429. * @param name The name of the effect.
  72430. * @param refractionTextureUrl Url of the refraction texture to use
  72431. * @param color the base color of the refraction (used to taint the rendering)
  72432. * @param depth simulated refraction depth
  72433. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72434. * @param camera The camera to apply the render pass to.
  72435. * @param options The required width/height ratio to downsize to before computing the render pass.
  72436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72437. * @param engine The engine which the post process will be applied. (default: current engine)
  72438. * @param reusable If the post process can be reused on the same frame. (default: false)
  72439. */
  72440. constructor(name: string, refractionTextureUrl: string,
  72441. /** the base color of the refraction (used to taint the rendering) */
  72442. color: Color3,
  72443. /** simulated refraction depth */
  72444. depth: number,
  72445. /** the coefficient of the base color (0 to remove base color tainting) */
  72446. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72447. /**
  72448. * Disposes of the post process
  72449. * @param camera Camera to dispose post process on
  72450. */
  72451. dispose(camera: Camera): void;
  72452. }
  72453. }
  72454. declare module "babylonjs/Shaders/sharpen.fragment" {
  72455. /** @hidden */
  72456. export var sharpenPixelShader: {
  72457. name: string;
  72458. shader: string;
  72459. };
  72460. }
  72461. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72462. import { Nullable } from "babylonjs/types";
  72463. import { Camera } from "babylonjs/Cameras/camera";
  72464. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72465. import "babylonjs/Shaders/sharpen.fragment";
  72466. import { Engine } from "babylonjs/Engines/engine";
  72467. /**
  72468. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72469. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72470. */
  72471. export class SharpenPostProcess extends PostProcess {
  72472. /**
  72473. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72474. */
  72475. colorAmount: number;
  72476. /**
  72477. * How much sharpness should be applied (default: 0.3)
  72478. */
  72479. edgeAmount: number;
  72480. /**
  72481. * Creates a new instance ConvolutionPostProcess
  72482. * @param name The name of the effect.
  72483. * @param options The required width/height ratio to downsize to before computing the render pass.
  72484. * @param camera The camera to apply the render pass to.
  72485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72486. * @param engine The engine which the post process will be applied. (default: current engine)
  72487. * @param reusable If the post process can be reused on the same frame. (default: false)
  72488. * @param textureType Type of textures used when performing the post process. (default: 0)
  72489. * @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)
  72490. */
  72491. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72492. }
  72493. }
  72494. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72495. import { Nullable } from "babylonjs/types";
  72496. import { Camera } from "babylonjs/Cameras/camera";
  72497. import { Engine } from "babylonjs/Engines/engine";
  72498. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72499. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72500. /**
  72501. * PostProcessRenderPipeline
  72502. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72503. */
  72504. export class PostProcessRenderPipeline {
  72505. private engine;
  72506. private _renderEffects;
  72507. private _renderEffectsForIsolatedPass;
  72508. /**
  72509. * List of inspectable custom properties (used by the Inspector)
  72510. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72511. */
  72512. inspectableCustomProperties: IInspectable[];
  72513. /**
  72514. * @hidden
  72515. */
  72516. protected _cameras: Camera[];
  72517. /** @hidden */
  72518. _name: string;
  72519. /**
  72520. * Gets pipeline name
  72521. */
  72522. get name(): string;
  72523. /** Gets the list of attached cameras */
  72524. get cameras(): Camera[];
  72525. /**
  72526. * Initializes a PostProcessRenderPipeline
  72527. * @param engine engine to add the pipeline to
  72528. * @param name name of the pipeline
  72529. */
  72530. constructor(engine: Engine, name: string);
  72531. /**
  72532. * Gets the class name
  72533. * @returns "PostProcessRenderPipeline"
  72534. */
  72535. getClassName(): string;
  72536. /**
  72537. * If all the render effects in the pipeline are supported
  72538. */
  72539. get isSupported(): boolean;
  72540. /**
  72541. * Adds an effect to the pipeline
  72542. * @param renderEffect the effect to add
  72543. */
  72544. addEffect(renderEffect: PostProcessRenderEffect): void;
  72545. /** @hidden */
  72546. _rebuild(): void;
  72547. /** @hidden */
  72548. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72549. /** @hidden */
  72550. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72551. /** @hidden */
  72552. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72553. /** @hidden */
  72554. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72555. /** @hidden */
  72556. _attachCameras(cameras: Camera, unique: boolean): void;
  72557. /** @hidden */
  72558. _attachCameras(cameras: Camera[], unique: boolean): void;
  72559. /** @hidden */
  72560. _detachCameras(cameras: Camera): void;
  72561. /** @hidden */
  72562. _detachCameras(cameras: Nullable<Camera[]>): void;
  72563. /** @hidden */
  72564. _update(): void;
  72565. /** @hidden */
  72566. _reset(): void;
  72567. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72568. /**
  72569. * Disposes of the pipeline
  72570. */
  72571. dispose(): void;
  72572. }
  72573. }
  72574. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72575. import { Camera } from "babylonjs/Cameras/camera";
  72576. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72577. /**
  72578. * PostProcessRenderPipelineManager class
  72579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72580. */
  72581. export class PostProcessRenderPipelineManager {
  72582. private _renderPipelines;
  72583. /**
  72584. * Initializes a PostProcessRenderPipelineManager
  72585. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72586. */
  72587. constructor();
  72588. /**
  72589. * Gets the list of supported render pipelines
  72590. */
  72591. get supportedPipelines(): PostProcessRenderPipeline[];
  72592. /**
  72593. * Adds a pipeline to the manager
  72594. * @param renderPipeline The pipeline to add
  72595. */
  72596. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72597. /**
  72598. * Attaches a camera to the pipeline
  72599. * @param renderPipelineName The name of the pipeline to attach to
  72600. * @param cameras the camera to attach
  72601. * @param unique if the camera can be attached multiple times to the pipeline
  72602. */
  72603. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72604. /**
  72605. * Detaches a camera from the pipeline
  72606. * @param renderPipelineName The name of the pipeline to detach from
  72607. * @param cameras the camera to detach
  72608. */
  72609. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72610. /**
  72611. * Enables an effect by name on a pipeline
  72612. * @param renderPipelineName the name of the pipeline to enable the effect in
  72613. * @param renderEffectName the name of the effect to enable
  72614. * @param cameras the cameras that the effect should be enabled on
  72615. */
  72616. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72617. /**
  72618. * Disables an effect by name on a pipeline
  72619. * @param renderPipelineName the name of the pipeline to disable the effect in
  72620. * @param renderEffectName the name of the effect to disable
  72621. * @param cameras the cameras that the effect should be disabled on
  72622. */
  72623. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72624. /**
  72625. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72626. */
  72627. update(): void;
  72628. /** @hidden */
  72629. _rebuild(): void;
  72630. /**
  72631. * Disposes of the manager and pipelines
  72632. */
  72633. dispose(): void;
  72634. }
  72635. }
  72636. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72637. import { ISceneComponent } from "babylonjs/sceneComponent";
  72638. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72639. import { Scene } from "babylonjs/scene";
  72640. module "babylonjs/scene" {
  72641. interface Scene {
  72642. /** @hidden (Backing field) */
  72643. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72644. /**
  72645. * Gets the postprocess render pipeline manager
  72646. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72647. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72648. */
  72649. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72650. }
  72651. }
  72652. /**
  72653. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72654. */
  72655. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72656. /**
  72657. * The component name helpfull to identify the component in the list of scene components.
  72658. */
  72659. readonly name: string;
  72660. /**
  72661. * The scene the component belongs to.
  72662. */
  72663. scene: Scene;
  72664. /**
  72665. * Creates a new instance of the component for the given scene
  72666. * @param scene Defines the scene to register the component in
  72667. */
  72668. constructor(scene: Scene);
  72669. /**
  72670. * Registers the component in a given scene
  72671. */
  72672. register(): void;
  72673. /**
  72674. * Rebuilds the elements related to this component in case of
  72675. * context lost for instance.
  72676. */
  72677. rebuild(): void;
  72678. /**
  72679. * Disposes the component and the associated ressources
  72680. */
  72681. dispose(): void;
  72682. private _gatherRenderTargets;
  72683. }
  72684. }
  72685. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72686. import { Nullable } from "babylonjs/types";
  72687. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72688. import { Camera } from "babylonjs/Cameras/camera";
  72689. import { IDisposable } from "babylonjs/scene";
  72690. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72691. import { Scene } from "babylonjs/scene";
  72692. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72693. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72694. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72695. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72696. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72697. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72698. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72699. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72700. import { Animation } from "babylonjs/Animations/animation";
  72701. /**
  72702. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  72703. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72704. */
  72705. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72706. private _scene;
  72707. private _camerasToBeAttached;
  72708. /**
  72709. * ID of the sharpen post process,
  72710. */
  72711. private readonly SharpenPostProcessId;
  72712. /**
  72713. * @ignore
  72714. * ID of the image processing post process;
  72715. */
  72716. readonly ImageProcessingPostProcessId: string;
  72717. /**
  72718. * @ignore
  72719. * ID of the Fast Approximate Anti-Aliasing post process;
  72720. */
  72721. readonly FxaaPostProcessId: string;
  72722. /**
  72723. * ID of the chromatic aberration post process,
  72724. */
  72725. private readonly ChromaticAberrationPostProcessId;
  72726. /**
  72727. * ID of the grain post process
  72728. */
  72729. private readonly GrainPostProcessId;
  72730. /**
  72731. * Sharpen post process which will apply a sharpen convolution to enhance edges
  72732. */
  72733. sharpen: SharpenPostProcess;
  72734. private _sharpenEffect;
  72735. private bloom;
  72736. /**
  72737. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  72738. */
  72739. depthOfField: DepthOfFieldEffect;
  72740. /**
  72741. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72742. */
  72743. fxaa: FxaaPostProcess;
  72744. /**
  72745. * Image post processing pass used to perform operations such as tone mapping or color grading.
  72746. */
  72747. imageProcessing: ImageProcessingPostProcess;
  72748. /**
  72749. * Chromatic aberration post process which will shift rgb colors in the image
  72750. */
  72751. chromaticAberration: ChromaticAberrationPostProcess;
  72752. private _chromaticAberrationEffect;
  72753. /**
  72754. * Grain post process which add noise to the image
  72755. */
  72756. grain: GrainPostProcess;
  72757. private _grainEffect;
  72758. /**
  72759. * Glow post process which adds a glow to emissive areas of the image
  72760. */
  72761. private _glowLayer;
  72762. /**
  72763. * Animations which can be used to tweak settings over a period of time
  72764. */
  72765. animations: Animation[];
  72766. private _imageProcessingConfigurationObserver;
  72767. private _sharpenEnabled;
  72768. private _bloomEnabled;
  72769. private _depthOfFieldEnabled;
  72770. private _depthOfFieldBlurLevel;
  72771. private _fxaaEnabled;
  72772. private _imageProcessingEnabled;
  72773. private _defaultPipelineTextureType;
  72774. private _bloomScale;
  72775. private _chromaticAberrationEnabled;
  72776. private _grainEnabled;
  72777. private _buildAllowed;
  72778. /**
  72779. * Gets active scene
  72780. */
  72781. get scene(): Scene;
  72782. /**
  72783. * Enable or disable the sharpen process from the pipeline
  72784. */
  72785. set sharpenEnabled(enabled: boolean);
  72786. get sharpenEnabled(): boolean;
  72787. private _resizeObserver;
  72788. private _hardwareScaleLevel;
  72789. private _bloomKernel;
  72790. /**
  72791. * Specifies the size of the bloom blur kernel, relative to the final output size
  72792. */
  72793. get bloomKernel(): number;
  72794. set bloomKernel(value: number);
  72795. /**
  72796. * Specifies the weight of the bloom in the final rendering
  72797. */
  72798. private _bloomWeight;
  72799. /**
  72800. * Specifies the luma threshold for the area that will be blurred by the bloom
  72801. */
  72802. private _bloomThreshold;
  72803. private _hdr;
  72804. /**
  72805. * The strength of the bloom.
  72806. */
  72807. set bloomWeight(value: number);
  72808. get bloomWeight(): number;
  72809. /**
  72810. * The strength of the bloom.
  72811. */
  72812. set bloomThreshold(value: number);
  72813. get bloomThreshold(): number;
  72814. /**
  72815. * The scale of the bloom, lower value will provide better performance.
  72816. */
  72817. set bloomScale(value: number);
  72818. get bloomScale(): number;
  72819. /**
  72820. * Enable or disable the bloom from the pipeline
  72821. */
  72822. set bloomEnabled(enabled: boolean);
  72823. get bloomEnabled(): boolean;
  72824. private _rebuildBloom;
  72825. /**
  72826. * If the depth of field is enabled.
  72827. */
  72828. get depthOfFieldEnabled(): boolean;
  72829. set depthOfFieldEnabled(enabled: boolean);
  72830. /**
  72831. * Blur level of the depth of field effect. (Higher blur will effect performance)
  72832. */
  72833. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  72834. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  72835. /**
  72836. * If the anti aliasing is enabled.
  72837. */
  72838. set fxaaEnabled(enabled: boolean);
  72839. get fxaaEnabled(): boolean;
  72840. private _samples;
  72841. /**
  72842. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72843. */
  72844. set samples(sampleCount: number);
  72845. get samples(): number;
  72846. /**
  72847. * If image processing is enabled.
  72848. */
  72849. set imageProcessingEnabled(enabled: boolean);
  72850. get imageProcessingEnabled(): boolean;
  72851. /**
  72852. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  72853. */
  72854. set glowLayerEnabled(enabled: boolean);
  72855. get glowLayerEnabled(): boolean;
  72856. /**
  72857. * Gets the glow layer (or null if not defined)
  72858. */
  72859. get glowLayer(): Nullable<GlowLayer>;
  72860. /**
  72861. * Enable or disable the chromaticAberration process from the pipeline
  72862. */
  72863. set chromaticAberrationEnabled(enabled: boolean);
  72864. get chromaticAberrationEnabled(): boolean;
  72865. /**
  72866. * Enable or disable the grain process from the pipeline
  72867. */
  72868. set grainEnabled(enabled: boolean);
  72869. get grainEnabled(): boolean;
  72870. /**
  72871. * @constructor
  72872. * @param name - The rendering pipeline name (default: "")
  72873. * @param hdr - If high dynamic range textures should be used (default: true)
  72874. * @param scene - The scene linked to this pipeline (default: the last created scene)
  72875. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  72876. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  72877. */
  72878. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  72879. /**
  72880. * Get the class name
  72881. * @returns "DefaultRenderingPipeline"
  72882. */
  72883. getClassName(): string;
  72884. /**
  72885. * Force the compilation of the entire pipeline.
  72886. */
  72887. prepare(): void;
  72888. private _hasCleared;
  72889. private _prevPostProcess;
  72890. private _prevPrevPostProcess;
  72891. private _setAutoClearAndTextureSharing;
  72892. private _depthOfFieldSceneObserver;
  72893. private _buildPipeline;
  72894. private _disposePostProcesses;
  72895. /**
  72896. * Adds a camera to the pipeline
  72897. * @param camera the camera to be added
  72898. */
  72899. addCamera(camera: Camera): void;
  72900. /**
  72901. * Removes a camera from the pipeline
  72902. * @param camera the camera to remove
  72903. */
  72904. removeCamera(camera: Camera): void;
  72905. /**
  72906. * Dispose of the pipeline and stop all post processes
  72907. */
  72908. dispose(): void;
  72909. /**
  72910. * Serialize the rendering pipeline (Used when exporting)
  72911. * @returns the serialized object
  72912. */
  72913. serialize(): any;
  72914. /**
  72915. * Parse the serialized pipeline
  72916. * @param source Source pipeline.
  72917. * @param scene The scene to load the pipeline to.
  72918. * @param rootUrl The URL of the serialized pipeline.
  72919. * @returns An instantiated pipeline from the serialized object.
  72920. */
  72921. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  72922. }
  72923. }
  72924. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  72925. /** @hidden */
  72926. export var lensHighlightsPixelShader: {
  72927. name: string;
  72928. shader: string;
  72929. };
  72930. }
  72931. declare module "babylonjs/Shaders/depthOfField.fragment" {
  72932. /** @hidden */
  72933. export var depthOfFieldPixelShader: {
  72934. name: string;
  72935. shader: string;
  72936. };
  72937. }
  72938. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  72939. import { Camera } from "babylonjs/Cameras/camera";
  72940. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72941. import { Scene } from "babylonjs/scene";
  72942. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72943. import "babylonjs/Shaders/chromaticAberration.fragment";
  72944. import "babylonjs/Shaders/lensHighlights.fragment";
  72945. import "babylonjs/Shaders/depthOfField.fragment";
  72946. /**
  72947. * BABYLON.JS Chromatic Aberration GLSL Shader
  72948. * Author: Olivier Guyot
  72949. * Separates very slightly R, G and B colors on the edges of the screen
  72950. * Inspired by Francois Tarlier & Martins Upitis
  72951. */
  72952. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72953. /**
  72954. * @ignore
  72955. * The chromatic aberration PostProcess id in the pipeline
  72956. */
  72957. LensChromaticAberrationEffect: string;
  72958. /**
  72959. * @ignore
  72960. * The highlights enhancing PostProcess id in the pipeline
  72961. */
  72962. HighlightsEnhancingEffect: string;
  72963. /**
  72964. * @ignore
  72965. * The depth-of-field PostProcess id in the pipeline
  72966. */
  72967. LensDepthOfFieldEffect: string;
  72968. private _scene;
  72969. private _depthTexture;
  72970. private _grainTexture;
  72971. private _chromaticAberrationPostProcess;
  72972. private _highlightsPostProcess;
  72973. private _depthOfFieldPostProcess;
  72974. private _edgeBlur;
  72975. private _grainAmount;
  72976. private _chromaticAberration;
  72977. private _distortion;
  72978. private _highlightsGain;
  72979. private _highlightsThreshold;
  72980. private _dofDistance;
  72981. private _dofAperture;
  72982. private _dofDarken;
  72983. private _dofPentagon;
  72984. private _blurNoise;
  72985. /**
  72986. * @constructor
  72987. *
  72988. * Effect parameters are as follow:
  72989. * {
  72990. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72991. * edge_blur: number; // from 0 to x (1 for realism)
  72992. * distortion: number; // from 0 to x (1 for realism)
  72993. * grain_amount: number; // from 0 to 1
  72994. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72995. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72996. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72997. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72998. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72999. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73000. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73001. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73002. * }
  73003. * Note: if an effect parameter is unset, effect is disabled
  73004. *
  73005. * @param name The rendering pipeline name
  73006. * @param parameters - An object containing all parameters (see above)
  73007. * @param scene The scene linked to this pipeline
  73008. * @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)
  73009. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73010. */
  73011. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73012. /**
  73013. * Get the class name
  73014. * @returns "LensRenderingPipeline"
  73015. */
  73016. getClassName(): string;
  73017. /**
  73018. * Gets associated scene
  73019. */
  73020. get scene(): Scene;
  73021. /**
  73022. * Gets or sets the edge blur
  73023. */
  73024. get edgeBlur(): number;
  73025. set edgeBlur(value: number);
  73026. /**
  73027. * Gets or sets the grain amount
  73028. */
  73029. get grainAmount(): number;
  73030. set grainAmount(value: number);
  73031. /**
  73032. * Gets or sets the chromatic aberration amount
  73033. */
  73034. get chromaticAberration(): number;
  73035. set chromaticAberration(value: number);
  73036. /**
  73037. * Gets or sets the depth of field aperture
  73038. */
  73039. get dofAperture(): number;
  73040. set dofAperture(value: number);
  73041. /**
  73042. * Gets or sets the edge distortion
  73043. */
  73044. get edgeDistortion(): number;
  73045. set edgeDistortion(value: number);
  73046. /**
  73047. * Gets or sets the depth of field distortion
  73048. */
  73049. get dofDistortion(): number;
  73050. set dofDistortion(value: number);
  73051. /**
  73052. * Gets or sets the darken out of focus amount
  73053. */
  73054. get darkenOutOfFocus(): number;
  73055. set darkenOutOfFocus(value: number);
  73056. /**
  73057. * Gets or sets a boolean indicating if blur noise is enabled
  73058. */
  73059. get blurNoise(): boolean;
  73060. set blurNoise(value: boolean);
  73061. /**
  73062. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73063. */
  73064. get pentagonBokeh(): boolean;
  73065. set pentagonBokeh(value: boolean);
  73066. /**
  73067. * Gets or sets the highlight grain amount
  73068. */
  73069. get highlightsGain(): number;
  73070. set highlightsGain(value: number);
  73071. /**
  73072. * Gets or sets the highlight threshold
  73073. */
  73074. get highlightsThreshold(): number;
  73075. set highlightsThreshold(value: number);
  73076. /**
  73077. * Sets the amount of blur at the edges
  73078. * @param amount blur amount
  73079. */
  73080. setEdgeBlur(amount: number): void;
  73081. /**
  73082. * Sets edge blur to 0
  73083. */
  73084. disableEdgeBlur(): void;
  73085. /**
  73086. * Sets the amout of grain
  73087. * @param amount Amount of grain
  73088. */
  73089. setGrainAmount(amount: number): void;
  73090. /**
  73091. * Set grain amount to 0
  73092. */
  73093. disableGrain(): void;
  73094. /**
  73095. * Sets the chromatic aberration amount
  73096. * @param amount amount of chromatic aberration
  73097. */
  73098. setChromaticAberration(amount: number): void;
  73099. /**
  73100. * Sets chromatic aberration amount to 0
  73101. */
  73102. disableChromaticAberration(): void;
  73103. /**
  73104. * Sets the EdgeDistortion amount
  73105. * @param amount amount of EdgeDistortion
  73106. */
  73107. setEdgeDistortion(amount: number): void;
  73108. /**
  73109. * Sets edge distortion to 0
  73110. */
  73111. disableEdgeDistortion(): void;
  73112. /**
  73113. * Sets the FocusDistance amount
  73114. * @param amount amount of FocusDistance
  73115. */
  73116. setFocusDistance(amount: number): void;
  73117. /**
  73118. * Disables depth of field
  73119. */
  73120. disableDepthOfField(): void;
  73121. /**
  73122. * Sets the Aperture amount
  73123. * @param amount amount of Aperture
  73124. */
  73125. setAperture(amount: number): void;
  73126. /**
  73127. * Sets the DarkenOutOfFocus amount
  73128. * @param amount amount of DarkenOutOfFocus
  73129. */
  73130. setDarkenOutOfFocus(amount: number): void;
  73131. private _pentagonBokehIsEnabled;
  73132. /**
  73133. * Creates a pentagon bokeh effect
  73134. */
  73135. enablePentagonBokeh(): void;
  73136. /**
  73137. * Disables the pentagon bokeh effect
  73138. */
  73139. disablePentagonBokeh(): void;
  73140. /**
  73141. * Enables noise blur
  73142. */
  73143. enableNoiseBlur(): void;
  73144. /**
  73145. * Disables noise blur
  73146. */
  73147. disableNoiseBlur(): void;
  73148. /**
  73149. * Sets the HighlightsGain amount
  73150. * @param amount amount of HighlightsGain
  73151. */
  73152. setHighlightsGain(amount: number): void;
  73153. /**
  73154. * Sets the HighlightsThreshold amount
  73155. * @param amount amount of HighlightsThreshold
  73156. */
  73157. setHighlightsThreshold(amount: number): void;
  73158. /**
  73159. * Disables highlights
  73160. */
  73161. disableHighlights(): void;
  73162. /**
  73163. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73164. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73165. */
  73166. dispose(disableDepthRender?: boolean): void;
  73167. private _createChromaticAberrationPostProcess;
  73168. private _createHighlightsPostProcess;
  73169. private _createDepthOfFieldPostProcess;
  73170. private _createGrainTexture;
  73171. }
  73172. }
  73173. declare module "babylonjs/Shaders/ssao2.fragment" {
  73174. /** @hidden */
  73175. export var ssao2PixelShader: {
  73176. name: string;
  73177. shader: string;
  73178. };
  73179. }
  73180. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73181. /** @hidden */
  73182. export var ssaoCombinePixelShader: {
  73183. name: string;
  73184. shader: string;
  73185. };
  73186. }
  73187. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73188. import { Camera } from "babylonjs/Cameras/camera";
  73189. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73190. import { Scene } from "babylonjs/scene";
  73191. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73192. import "babylonjs/Shaders/ssao2.fragment";
  73193. import "babylonjs/Shaders/ssaoCombine.fragment";
  73194. /**
  73195. * Render pipeline to produce ssao effect
  73196. */
  73197. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73198. /**
  73199. * @ignore
  73200. * The PassPostProcess id in the pipeline that contains the original scene color
  73201. */
  73202. SSAOOriginalSceneColorEffect: string;
  73203. /**
  73204. * @ignore
  73205. * The SSAO PostProcess id in the pipeline
  73206. */
  73207. SSAORenderEffect: string;
  73208. /**
  73209. * @ignore
  73210. * The horizontal blur PostProcess id in the pipeline
  73211. */
  73212. SSAOBlurHRenderEffect: string;
  73213. /**
  73214. * @ignore
  73215. * The vertical blur PostProcess id in the pipeline
  73216. */
  73217. SSAOBlurVRenderEffect: string;
  73218. /**
  73219. * @ignore
  73220. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73221. */
  73222. SSAOCombineRenderEffect: string;
  73223. /**
  73224. * The output strength of the SSAO post-process. Default value is 1.0.
  73225. */
  73226. totalStrength: number;
  73227. /**
  73228. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73229. */
  73230. maxZ: number;
  73231. /**
  73232. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73233. */
  73234. minZAspect: number;
  73235. private _samples;
  73236. /**
  73237. * Number of samples used for the SSAO calculations. Default value is 8
  73238. */
  73239. set samples(n: number);
  73240. get samples(): number;
  73241. private _textureSamples;
  73242. /**
  73243. * Number of samples to use for antialiasing
  73244. */
  73245. set textureSamples(n: number);
  73246. get textureSamples(): number;
  73247. /**
  73248. * Ratio object used for SSAO ratio and blur ratio
  73249. */
  73250. private _ratio;
  73251. /**
  73252. * Dynamically generated sphere sampler.
  73253. */
  73254. private _sampleSphere;
  73255. /**
  73256. * Blur filter offsets
  73257. */
  73258. private _samplerOffsets;
  73259. private _expensiveBlur;
  73260. /**
  73261. * If bilateral blur should be used
  73262. */
  73263. set expensiveBlur(b: boolean);
  73264. get expensiveBlur(): boolean;
  73265. /**
  73266. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73267. */
  73268. radius: number;
  73269. /**
  73270. * The base color of the SSAO post-process
  73271. * The final result is "base + ssao" between [0, 1]
  73272. */
  73273. base: number;
  73274. /**
  73275. * Support test.
  73276. */
  73277. static get IsSupported(): boolean;
  73278. private _scene;
  73279. private _depthTexture;
  73280. private _normalTexture;
  73281. private _randomTexture;
  73282. private _originalColorPostProcess;
  73283. private _ssaoPostProcess;
  73284. private _blurHPostProcess;
  73285. private _blurVPostProcess;
  73286. private _ssaoCombinePostProcess;
  73287. /**
  73288. * Gets active scene
  73289. */
  73290. get scene(): Scene;
  73291. /**
  73292. * @constructor
  73293. * @param name The rendering pipeline name
  73294. * @param scene The scene linked to this pipeline
  73295. * @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 }
  73296. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73297. */
  73298. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73299. /**
  73300. * Get the class name
  73301. * @returns "SSAO2RenderingPipeline"
  73302. */
  73303. getClassName(): string;
  73304. /**
  73305. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73306. */
  73307. dispose(disableGeometryBufferRenderer?: boolean): void;
  73308. private _createBlurPostProcess;
  73309. /** @hidden */
  73310. _rebuild(): void;
  73311. private _bits;
  73312. private _radicalInverse_VdC;
  73313. private _hammersley;
  73314. private _hemisphereSample_uniform;
  73315. private _generateHemisphere;
  73316. private _createSSAOPostProcess;
  73317. private _createSSAOCombinePostProcess;
  73318. private _createRandomTexture;
  73319. /**
  73320. * Serialize the rendering pipeline (Used when exporting)
  73321. * @returns the serialized object
  73322. */
  73323. serialize(): any;
  73324. /**
  73325. * Parse the serialized pipeline
  73326. * @param source Source pipeline.
  73327. * @param scene The scene to load the pipeline to.
  73328. * @param rootUrl The URL of the serialized pipeline.
  73329. * @returns An instantiated pipeline from the serialized object.
  73330. */
  73331. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73332. }
  73333. }
  73334. declare module "babylonjs/Shaders/ssao.fragment" {
  73335. /** @hidden */
  73336. export var ssaoPixelShader: {
  73337. name: string;
  73338. shader: string;
  73339. };
  73340. }
  73341. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73342. import { Camera } from "babylonjs/Cameras/camera";
  73343. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73344. import { Scene } from "babylonjs/scene";
  73345. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73346. import "babylonjs/Shaders/ssao.fragment";
  73347. import "babylonjs/Shaders/ssaoCombine.fragment";
  73348. /**
  73349. * Render pipeline to produce ssao effect
  73350. */
  73351. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73352. /**
  73353. * @ignore
  73354. * The PassPostProcess id in the pipeline that contains the original scene color
  73355. */
  73356. SSAOOriginalSceneColorEffect: string;
  73357. /**
  73358. * @ignore
  73359. * The SSAO PostProcess id in the pipeline
  73360. */
  73361. SSAORenderEffect: string;
  73362. /**
  73363. * @ignore
  73364. * The horizontal blur PostProcess id in the pipeline
  73365. */
  73366. SSAOBlurHRenderEffect: string;
  73367. /**
  73368. * @ignore
  73369. * The vertical blur PostProcess id in the pipeline
  73370. */
  73371. SSAOBlurVRenderEffect: string;
  73372. /**
  73373. * @ignore
  73374. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73375. */
  73376. SSAOCombineRenderEffect: string;
  73377. /**
  73378. * The output strength of the SSAO post-process. Default value is 1.0.
  73379. */
  73380. totalStrength: number;
  73381. /**
  73382. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73383. */
  73384. radius: number;
  73385. /**
  73386. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73387. * Must not be equal to fallOff and superior to fallOff.
  73388. * Default value is 0.0075
  73389. */
  73390. area: number;
  73391. /**
  73392. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73393. * Must not be equal to area and inferior to area.
  73394. * Default value is 0.000001
  73395. */
  73396. fallOff: number;
  73397. /**
  73398. * The base color of the SSAO post-process
  73399. * The final result is "base + ssao" between [0, 1]
  73400. */
  73401. base: number;
  73402. private _scene;
  73403. private _depthTexture;
  73404. private _randomTexture;
  73405. private _originalColorPostProcess;
  73406. private _ssaoPostProcess;
  73407. private _blurHPostProcess;
  73408. private _blurVPostProcess;
  73409. private _ssaoCombinePostProcess;
  73410. private _firstUpdate;
  73411. /**
  73412. * Gets active scene
  73413. */
  73414. get scene(): Scene;
  73415. /**
  73416. * @constructor
  73417. * @param name - The rendering pipeline name
  73418. * @param scene - The scene linked to this pipeline
  73419. * @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 }
  73420. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73421. */
  73422. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73423. /**
  73424. * Get the class name
  73425. * @returns "SSAORenderingPipeline"
  73426. */
  73427. getClassName(): string;
  73428. /**
  73429. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73430. */
  73431. dispose(disableDepthRender?: boolean): void;
  73432. private _createBlurPostProcess;
  73433. /** @hidden */
  73434. _rebuild(): void;
  73435. private _createSSAOPostProcess;
  73436. private _createSSAOCombinePostProcess;
  73437. private _createRandomTexture;
  73438. }
  73439. }
  73440. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  73441. /** @hidden */
  73442. export var screenSpaceReflectionPixelShader: {
  73443. name: string;
  73444. shader: string;
  73445. };
  73446. }
  73447. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  73448. import { Nullable } from "babylonjs/types";
  73449. import { Camera } from "babylonjs/Cameras/camera";
  73450. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73451. import { Scene } from "babylonjs/scene";
  73452. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  73453. import { Engine } from "babylonjs/Engines/engine";
  73454. /**
  73455. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  73456. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  73457. */
  73458. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  73459. /**
  73460. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  73461. */
  73462. threshold: number;
  73463. /**
  73464. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  73465. */
  73466. strength: number;
  73467. /**
  73468. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  73469. */
  73470. reflectionSpecularFalloffExponent: number;
  73471. /**
  73472. * 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]
  73473. */
  73474. step: number;
  73475. /**
  73476. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  73477. */
  73478. roughnessFactor: number;
  73479. private _geometryBufferRenderer;
  73480. private _enableSmoothReflections;
  73481. private _reflectionSamples;
  73482. private _smoothSteps;
  73483. /**
  73484. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  73485. * @param name The name of the effect.
  73486. * @param scene The scene containing the objects to calculate reflections.
  73487. * @param options The required width/height ratio to downsize to before computing the render pass.
  73488. * @param camera The camera to apply the render pass to.
  73489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73490. * @param engine The engine which the post process will be applied. (default: current engine)
  73491. * @param reusable If the post process can be reused on the same frame. (default: false)
  73492. * @param textureType Type of textures used when performing the post process. (default: 0)
  73493. * @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)
  73494. */
  73495. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73496. /**
  73497. * Gets wether or not smoothing reflections is enabled.
  73498. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73499. */
  73500. get enableSmoothReflections(): boolean;
  73501. /**
  73502. * Sets wether or not smoothing reflections is enabled.
  73503. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  73504. */
  73505. set enableSmoothReflections(enabled: boolean);
  73506. /**
  73507. * Gets the number of samples taken while computing reflections. More samples count is high,
  73508. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73509. */
  73510. get reflectionSamples(): number;
  73511. /**
  73512. * Sets the number of samples taken while computing reflections. More samples count is high,
  73513. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  73514. */
  73515. set reflectionSamples(samples: number);
  73516. /**
  73517. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  73518. * more the post-process will require GPU power and can generate a drop in FPS.
  73519. * Default value (5.0) work pretty well in all cases but can be adjusted.
  73520. */
  73521. get smoothSteps(): number;
  73522. set smoothSteps(steps: number);
  73523. private _updateEffectDefines;
  73524. }
  73525. }
  73526. declare module "babylonjs/Shaders/standard.fragment" {
  73527. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  73528. /** @hidden */
  73529. export var standardPixelShader: {
  73530. name: string;
  73531. shader: string;
  73532. };
  73533. }
  73534. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  73535. import { Nullable } from "babylonjs/types";
  73536. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  73537. import { Camera } from "babylonjs/Cameras/camera";
  73538. import { Texture } from "babylonjs/Materials/Textures/texture";
  73539. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73540. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73541. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73542. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  73543. import { IDisposable } from "babylonjs/scene";
  73544. import { SpotLight } from "babylonjs/Lights/spotLight";
  73545. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  73546. import { Scene } from "babylonjs/scene";
  73547. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  73548. import { Animation } from "babylonjs/Animations/animation";
  73549. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73550. import "babylonjs/Shaders/standard.fragment";
  73551. /**
  73552. * Standard rendering pipeline
  73553. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73554. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  73555. */
  73556. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73557. /**
  73558. * Public members
  73559. */
  73560. /**
  73561. * Post-process which contains the original scene color before the pipeline applies all the effects
  73562. */
  73563. originalPostProcess: Nullable<PostProcess>;
  73564. /**
  73565. * Post-process used to down scale an image x4
  73566. */
  73567. downSampleX4PostProcess: Nullable<PostProcess>;
  73568. /**
  73569. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  73570. */
  73571. brightPassPostProcess: Nullable<PostProcess>;
  73572. /**
  73573. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  73574. */
  73575. blurHPostProcesses: PostProcess[];
  73576. /**
  73577. * Post-process array storing all the vertical blur post-processes used by the pipeline
  73578. */
  73579. blurVPostProcesses: PostProcess[];
  73580. /**
  73581. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  73582. */
  73583. textureAdderPostProcess: Nullable<PostProcess>;
  73584. /**
  73585. * Post-process used to create volumetric lighting effect
  73586. */
  73587. volumetricLightPostProcess: Nullable<PostProcess>;
  73588. /**
  73589. * Post-process used to smooth the previous volumetric light post-process on the X axis
  73590. */
  73591. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  73592. /**
  73593. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  73594. */
  73595. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  73596. /**
  73597. * Post-process used to merge the volumetric light effect and the real scene color
  73598. */
  73599. volumetricLightMergePostProces: Nullable<PostProcess>;
  73600. /**
  73601. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  73602. */
  73603. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  73604. /**
  73605. * Base post-process used to calculate the average luminance of the final image for HDR
  73606. */
  73607. luminancePostProcess: Nullable<PostProcess>;
  73608. /**
  73609. * Post-processes used to create down sample post-processes in order to get
  73610. * the average luminance of the final image for HDR
  73611. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  73612. */
  73613. luminanceDownSamplePostProcesses: PostProcess[];
  73614. /**
  73615. * Post-process used to create a HDR effect (light adaptation)
  73616. */
  73617. hdrPostProcess: Nullable<PostProcess>;
  73618. /**
  73619. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  73620. */
  73621. textureAdderFinalPostProcess: Nullable<PostProcess>;
  73622. /**
  73623. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  73624. */
  73625. lensFlareFinalPostProcess: Nullable<PostProcess>;
  73626. /**
  73627. * Post-process used to merge the final HDR post-process and the real scene color
  73628. */
  73629. hdrFinalPostProcess: Nullable<PostProcess>;
  73630. /**
  73631. * Post-process used to create a lens flare effect
  73632. */
  73633. lensFlarePostProcess: Nullable<PostProcess>;
  73634. /**
  73635. * Post-process that merges the result of the lens flare post-process and the real scene color
  73636. */
  73637. lensFlareComposePostProcess: Nullable<PostProcess>;
  73638. /**
  73639. * Post-process used to create a motion blur effect
  73640. */
  73641. motionBlurPostProcess: Nullable<PostProcess>;
  73642. /**
  73643. * Post-process used to create a depth of field effect
  73644. */
  73645. depthOfFieldPostProcess: Nullable<PostProcess>;
  73646. /**
  73647. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73648. */
  73649. fxaaPostProcess: Nullable<FxaaPostProcess>;
  73650. /**
  73651. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  73652. */
  73653. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  73654. /**
  73655. * Represents the brightness threshold in order to configure the illuminated surfaces
  73656. */
  73657. brightThreshold: number;
  73658. /**
  73659. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  73660. */
  73661. blurWidth: number;
  73662. /**
  73663. * Sets if the blur for highlighted surfaces must be only horizontal
  73664. */
  73665. horizontalBlur: boolean;
  73666. /**
  73667. * Gets the overall exposure used by the pipeline
  73668. */
  73669. get exposure(): number;
  73670. /**
  73671. * Sets the overall exposure used by the pipeline
  73672. */
  73673. set exposure(value: number);
  73674. /**
  73675. * Texture used typically to simulate "dirty" on camera lens
  73676. */
  73677. lensTexture: Nullable<Texture>;
  73678. /**
  73679. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  73680. */
  73681. volumetricLightCoefficient: number;
  73682. /**
  73683. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  73684. */
  73685. volumetricLightPower: number;
  73686. /**
  73687. * Used the set the blur intensity to smooth the volumetric lights
  73688. */
  73689. volumetricLightBlurScale: number;
  73690. /**
  73691. * Light (spot or directional) used to generate the volumetric lights rays
  73692. * The source light must have a shadow generate so the pipeline can get its
  73693. * depth map
  73694. */
  73695. sourceLight: Nullable<SpotLight | DirectionalLight>;
  73696. /**
  73697. * For eye adaptation, represents the minimum luminance the eye can see
  73698. */
  73699. hdrMinimumLuminance: number;
  73700. /**
  73701. * For eye adaptation, represents the decrease luminance speed
  73702. */
  73703. hdrDecreaseRate: number;
  73704. /**
  73705. * For eye adaptation, represents the increase luminance speed
  73706. */
  73707. hdrIncreaseRate: number;
  73708. /**
  73709. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73710. */
  73711. get hdrAutoExposure(): boolean;
  73712. /**
  73713. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  73714. */
  73715. set hdrAutoExposure(value: boolean);
  73716. /**
  73717. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  73718. */
  73719. lensColorTexture: Nullable<Texture>;
  73720. /**
  73721. * The overall strengh for the lens flare effect
  73722. */
  73723. lensFlareStrength: number;
  73724. /**
  73725. * Dispersion coefficient for lens flare ghosts
  73726. */
  73727. lensFlareGhostDispersal: number;
  73728. /**
  73729. * Main lens flare halo width
  73730. */
  73731. lensFlareHaloWidth: number;
  73732. /**
  73733. * Based on the lens distortion effect, defines how much the lens flare result
  73734. * is distorted
  73735. */
  73736. lensFlareDistortionStrength: number;
  73737. /**
  73738. * Configures the blur intensity used for for lens flare (halo)
  73739. */
  73740. lensFlareBlurWidth: number;
  73741. /**
  73742. * Lens star texture must be used to simulate rays on the flares and is available
  73743. * in the documentation
  73744. */
  73745. lensStarTexture: Nullable<Texture>;
  73746. /**
  73747. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  73748. * flare effect by taking account of the dirt texture
  73749. */
  73750. lensFlareDirtTexture: Nullable<Texture>;
  73751. /**
  73752. * Represents the focal length for the depth of field effect
  73753. */
  73754. depthOfFieldDistance: number;
  73755. /**
  73756. * Represents the blur intensity for the blurred part of the depth of field effect
  73757. */
  73758. depthOfFieldBlurWidth: number;
  73759. /**
  73760. * Gets how much the image is blurred by the movement while using the motion blur post-process
  73761. */
  73762. get motionStrength(): number;
  73763. /**
  73764. * Sets how much the image is blurred by the movement while using the motion blur post-process
  73765. */
  73766. set motionStrength(strength: number);
  73767. /**
  73768. * Gets wether or not the motion blur post-process is object based or screen based.
  73769. */
  73770. get objectBasedMotionBlur(): boolean;
  73771. /**
  73772. * Sets wether or not the motion blur post-process should be object based or screen based
  73773. */
  73774. set objectBasedMotionBlur(value: boolean);
  73775. /**
  73776. * List of animations for the pipeline (IAnimatable implementation)
  73777. */
  73778. animations: Animation[];
  73779. /**
  73780. * Private members
  73781. */
  73782. private _scene;
  73783. private _currentDepthOfFieldSource;
  73784. private _basePostProcess;
  73785. private _fixedExposure;
  73786. private _currentExposure;
  73787. private _hdrAutoExposure;
  73788. private _hdrCurrentLuminance;
  73789. private _motionStrength;
  73790. private _isObjectBasedMotionBlur;
  73791. private _floatTextureType;
  73792. private _camerasToBeAttached;
  73793. private _ratio;
  73794. private _bloomEnabled;
  73795. private _depthOfFieldEnabled;
  73796. private _vlsEnabled;
  73797. private _lensFlareEnabled;
  73798. private _hdrEnabled;
  73799. private _motionBlurEnabled;
  73800. private _fxaaEnabled;
  73801. private _screenSpaceReflectionsEnabled;
  73802. private _motionBlurSamples;
  73803. private _volumetricLightStepsCount;
  73804. private _samples;
  73805. /**
  73806. * @ignore
  73807. * Specifies if the bloom pipeline is enabled
  73808. */
  73809. get BloomEnabled(): boolean;
  73810. set BloomEnabled(enabled: boolean);
  73811. /**
  73812. * @ignore
  73813. * Specifies if the depth of field pipeline is enabed
  73814. */
  73815. get DepthOfFieldEnabled(): boolean;
  73816. set DepthOfFieldEnabled(enabled: boolean);
  73817. /**
  73818. * @ignore
  73819. * Specifies if the lens flare pipeline is enabed
  73820. */
  73821. get LensFlareEnabled(): boolean;
  73822. set LensFlareEnabled(enabled: boolean);
  73823. /**
  73824. * @ignore
  73825. * Specifies if the HDR pipeline is enabled
  73826. */
  73827. get HDREnabled(): boolean;
  73828. set HDREnabled(enabled: boolean);
  73829. /**
  73830. * @ignore
  73831. * Specifies if the volumetric lights scattering effect is enabled
  73832. */
  73833. get VLSEnabled(): boolean;
  73834. set VLSEnabled(enabled: boolean);
  73835. /**
  73836. * @ignore
  73837. * Specifies if the motion blur effect is enabled
  73838. */
  73839. get MotionBlurEnabled(): boolean;
  73840. set MotionBlurEnabled(enabled: boolean);
  73841. /**
  73842. * Specifies if anti-aliasing is enabled
  73843. */
  73844. get fxaaEnabled(): boolean;
  73845. set fxaaEnabled(enabled: boolean);
  73846. /**
  73847. * Specifies if screen space reflections are enabled.
  73848. */
  73849. get screenSpaceReflectionsEnabled(): boolean;
  73850. set screenSpaceReflectionsEnabled(enabled: boolean);
  73851. /**
  73852. * Specifies the number of steps used to calculate the volumetric lights
  73853. * Typically in interval [50, 200]
  73854. */
  73855. get volumetricLightStepsCount(): number;
  73856. set volumetricLightStepsCount(count: number);
  73857. /**
  73858. * Specifies the number of samples used for the motion blur effect
  73859. * Typically in interval [16, 64]
  73860. */
  73861. get motionBlurSamples(): number;
  73862. set motionBlurSamples(samples: number);
  73863. /**
  73864. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73865. */
  73866. get samples(): number;
  73867. set samples(sampleCount: number);
  73868. /**
  73869. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  73870. * @constructor
  73871. * @param name The rendering pipeline name
  73872. * @param scene The scene linked to this pipeline
  73873. * @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)
  73874. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  73875. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73876. */
  73877. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  73878. private _buildPipeline;
  73879. private _createDownSampleX4PostProcess;
  73880. private _createBrightPassPostProcess;
  73881. private _createBlurPostProcesses;
  73882. private _createTextureAdderPostProcess;
  73883. private _createVolumetricLightPostProcess;
  73884. private _createLuminancePostProcesses;
  73885. private _createHdrPostProcess;
  73886. private _createLensFlarePostProcess;
  73887. private _createDepthOfFieldPostProcess;
  73888. private _createMotionBlurPostProcess;
  73889. private _getDepthTexture;
  73890. private _disposePostProcesses;
  73891. /**
  73892. * Dispose of the pipeline and stop all post processes
  73893. */
  73894. dispose(): void;
  73895. /**
  73896. * Serialize the rendering pipeline (Used when exporting)
  73897. * @returns the serialized object
  73898. */
  73899. serialize(): any;
  73900. /**
  73901. * Parse the serialized pipeline
  73902. * @param source Source pipeline.
  73903. * @param scene The scene to load the pipeline to.
  73904. * @param rootUrl The URL of the serialized pipeline.
  73905. * @returns An instantiated pipeline from the serialized object.
  73906. */
  73907. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  73908. /**
  73909. * Luminance steps
  73910. */
  73911. static LuminanceSteps: number;
  73912. }
  73913. }
  73914. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  73915. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  73916. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  73917. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  73918. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  73919. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  73920. }
  73921. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  73922. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  73923. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73924. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73925. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  73926. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73927. }
  73928. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  73929. /** @hidden */
  73930. export var stereoscopicInterlacePixelShader: {
  73931. name: string;
  73932. shader: string;
  73933. };
  73934. }
  73935. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  73936. import { Camera } from "babylonjs/Cameras/camera";
  73937. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73938. import { Engine } from "babylonjs/Engines/engine";
  73939. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  73940. /**
  73941. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73942. */
  73943. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73944. private _stepSize;
  73945. private _passedProcess;
  73946. /**
  73947. * Initializes a StereoscopicInterlacePostProcessI
  73948. * @param name The name of the effect.
  73949. * @param rigCameras The rig cameras to be appled to the post process
  73950. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73951. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73953. * @param engine The engine which the post process will be applied. (default: current engine)
  73954. * @param reusable If the post process can be reused on the same frame. (default: false)
  73955. */
  73956. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73957. }
  73958. /**
  73959. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73960. */
  73961. export class StereoscopicInterlacePostProcess extends PostProcess {
  73962. private _stepSize;
  73963. private _passedProcess;
  73964. /**
  73965. * Initializes a StereoscopicInterlacePostProcess
  73966. * @param name The name of the effect.
  73967. * @param rigCameras The rig cameras to be appled to the post process
  73968. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73970. * @param engine The engine which the post process will be applied. (default: current engine)
  73971. * @param reusable If the post process can be reused on the same frame. (default: false)
  73972. */
  73973. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73974. }
  73975. }
  73976. declare module "babylonjs/Shaders/tonemap.fragment" {
  73977. /** @hidden */
  73978. export var tonemapPixelShader: {
  73979. name: string;
  73980. shader: string;
  73981. };
  73982. }
  73983. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  73984. import { Camera } from "babylonjs/Cameras/camera";
  73985. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73986. import "babylonjs/Shaders/tonemap.fragment";
  73987. import { Engine } from "babylonjs/Engines/engine";
  73988. /** Defines operator used for tonemapping */
  73989. export enum TonemappingOperator {
  73990. /** Hable */
  73991. Hable = 0,
  73992. /** Reinhard */
  73993. Reinhard = 1,
  73994. /** HejiDawson */
  73995. HejiDawson = 2,
  73996. /** Photographic */
  73997. Photographic = 3
  73998. }
  73999. /**
  74000. * Defines a post process to apply tone mapping
  74001. */
  74002. export class TonemapPostProcess extends PostProcess {
  74003. private _operator;
  74004. /** Defines the required exposure adjustement */
  74005. exposureAdjustment: number;
  74006. /**
  74007. * Creates a new TonemapPostProcess
  74008. * @param name defines the name of the postprocess
  74009. * @param _operator defines the operator to use
  74010. * @param exposureAdjustment defines the required exposure adjustement
  74011. * @param camera defines the camera to use (can be null)
  74012. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74013. * @param engine defines the hosting engine (can be ignore if camera is set)
  74014. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74015. */
  74016. constructor(name: string, _operator: TonemappingOperator,
  74017. /** Defines the required exposure adjustement */
  74018. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74019. }
  74020. }
  74021. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74022. /** @hidden */
  74023. export var volumetricLightScatteringPixelShader: {
  74024. name: string;
  74025. shader: string;
  74026. };
  74027. }
  74028. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74029. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74030. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74031. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74032. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74033. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74034. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74035. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74036. /** @hidden */
  74037. export var volumetricLightScatteringPassVertexShader: {
  74038. name: string;
  74039. shader: string;
  74040. };
  74041. }
  74042. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74043. /** @hidden */
  74044. export var volumetricLightScatteringPassPixelShader: {
  74045. name: string;
  74046. shader: string;
  74047. };
  74048. }
  74049. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74050. import { Vector3 } from "babylonjs/Maths/math.vector";
  74051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74052. import { Mesh } from "babylonjs/Meshes/mesh";
  74053. import { Camera } from "babylonjs/Cameras/camera";
  74054. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74055. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74056. import { Scene } from "babylonjs/scene";
  74057. import "babylonjs/Meshes/Builders/planeBuilder";
  74058. import "babylonjs/Shaders/depth.vertex";
  74059. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74060. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74061. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74062. import { Engine } from "babylonjs/Engines/engine";
  74063. /**
  74064. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74065. */
  74066. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74067. private _volumetricLightScatteringPass;
  74068. private _volumetricLightScatteringRTT;
  74069. private _viewPort;
  74070. private _screenCoordinates;
  74071. private _cachedDefines;
  74072. /**
  74073. * If not undefined, the mesh position is computed from the attached node position
  74074. */
  74075. attachedNode: {
  74076. position: Vector3;
  74077. };
  74078. /**
  74079. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74080. */
  74081. customMeshPosition: Vector3;
  74082. /**
  74083. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74084. */
  74085. useCustomMeshPosition: boolean;
  74086. /**
  74087. * If the post-process should inverse the light scattering direction
  74088. */
  74089. invert: boolean;
  74090. /**
  74091. * The internal mesh used by the post-process
  74092. */
  74093. mesh: Mesh;
  74094. /**
  74095. * @hidden
  74096. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74097. */
  74098. get useDiffuseColor(): boolean;
  74099. set useDiffuseColor(useDiffuseColor: boolean);
  74100. /**
  74101. * Array containing the excluded meshes not rendered in the internal pass
  74102. */
  74103. excludedMeshes: AbstractMesh[];
  74104. /**
  74105. * Controls the overall intensity of the post-process
  74106. */
  74107. exposure: number;
  74108. /**
  74109. * Dissipates each sample's contribution in range [0, 1]
  74110. */
  74111. decay: number;
  74112. /**
  74113. * Controls the overall intensity of each sample
  74114. */
  74115. weight: number;
  74116. /**
  74117. * Controls the density of each sample
  74118. */
  74119. density: number;
  74120. /**
  74121. * @constructor
  74122. * @param name The post-process name
  74123. * @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)
  74124. * @param camera The camera that the post-process will be attached to
  74125. * @param mesh The mesh used to create the light scattering
  74126. * @param samples The post-process quality, default 100
  74127. * @param samplingModeThe post-process filtering mode
  74128. * @param engine The babylon engine
  74129. * @param reusable If the post-process is reusable
  74130. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74131. */
  74132. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74133. /**
  74134. * Returns the string "VolumetricLightScatteringPostProcess"
  74135. * @returns "VolumetricLightScatteringPostProcess"
  74136. */
  74137. getClassName(): string;
  74138. private _isReady;
  74139. /**
  74140. * Sets the new light position for light scattering effect
  74141. * @param position The new custom light position
  74142. */
  74143. setCustomMeshPosition(position: Vector3): void;
  74144. /**
  74145. * Returns the light position for light scattering effect
  74146. * @return Vector3 The custom light position
  74147. */
  74148. getCustomMeshPosition(): Vector3;
  74149. /**
  74150. * Disposes the internal assets and detaches the post-process from the camera
  74151. */
  74152. dispose(camera: Camera): void;
  74153. /**
  74154. * Returns the render target texture used by the post-process
  74155. * @return the render target texture used by the post-process
  74156. */
  74157. getPass(): RenderTargetTexture;
  74158. private _meshExcluded;
  74159. private _createPass;
  74160. private _updateMeshScreenCoordinates;
  74161. /**
  74162. * Creates a default mesh for the Volumeric Light Scattering post-process
  74163. * @param name The mesh name
  74164. * @param scene The scene where to create the mesh
  74165. * @return the default mesh
  74166. */
  74167. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74168. }
  74169. }
  74170. declare module "babylonjs/PostProcesses/index" {
  74171. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74172. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74173. export * from "babylonjs/PostProcesses/bloomEffect";
  74174. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74175. export * from "babylonjs/PostProcesses/blurPostProcess";
  74176. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74177. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74178. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74179. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74180. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74181. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74182. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74183. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74184. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74185. export * from "babylonjs/PostProcesses/filterPostProcess";
  74186. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74187. export * from "babylonjs/PostProcesses/grainPostProcess";
  74188. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74189. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74190. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74191. export * from "babylonjs/PostProcesses/passPostProcess";
  74192. export * from "babylonjs/PostProcesses/postProcess";
  74193. export * from "babylonjs/PostProcesses/postProcessManager";
  74194. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74195. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74196. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74197. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74198. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74199. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74200. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74201. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74202. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74203. }
  74204. declare module "babylonjs/Probes/index" {
  74205. export * from "babylonjs/Probes/reflectionProbe";
  74206. }
  74207. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74208. import { Scene } from "babylonjs/scene";
  74209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74210. import { SmartArray } from "babylonjs/Misc/smartArray";
  74211. import { ISceneComponent } from "babylonjs/sceneComponent";
  74212. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74213. import "babylonjs/Meshes/Builders/boxBuilder";
  74214. import "babylonjs/Shaders/color.fragment";
  74215. import "babylonjs/Shaders/color.vertex";
  74216. import { Color3 } from "babylonjs/Maths/math.color";
  74217. import { Observable } from "babylonjs/Misc/observable";
  74218. module "babylonjs/scene" {
  74219. interface Scene {
  74220. /** @hidden (Backing field) */
  74221. _boundingBoxRenderer: BoundingBoxRenderer;
  74222. /** @hidden (Backing field) */
  74223. _forceShowBoundingBoxes: boolean;
  74224. /**
  74225. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74226. */
  74227. forceShowBoundingBoxes: boolean;
  74228. /**
  74229. * Gets the bounding box renderer associated with the scene
  74230. * @returns a BoundingBoxRenderer
  74231. */
  74232. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74233. }
  74234. }
  74235. module "babylonjs/Meshes/abstractMesh" {
  74236. interface AbstractMesh {
  74237. /** @hidden (Backing field) */
  74238. _showBoundingBox: boolean;
  74239. /**
  74240. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74241. */
  74242. showBoundingBox: boolean;
  74243. }
  74244. }
  74245. /**
  74246. * Component responsible of rendering the bounding box of the meshes in a scene.
  74247. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74248. */
  74249. export class BoundingBoxRenderer implements ISceneComponent {
  74250. /**
  74251. * The component name helpfull to identify the component in the list of scene components.
  74252. */
  74253. readonly name: string;
  74254. /**
  74255. * The scene the component belongs to.
  74256. */
  74257. scene: Scene;
  74258. /**
  74259. * Color of the bounding box lines placed in front of an object
  74260. */
  74261. frontColor: Color3;
  74262. /**
  74263. * Color of the bounding box lines placed behind an object
  74264. */
  74265. backColor: Color3;
  74266. /**
  74267. * Defines if the renderer should show the back lines or not
  74268. */
  74269. showBackLines: boolean;
  74270. /**
  74271. * Observable raised before rendering a bounding box
  74272. */
  74273. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74274. /**
  74275. * Observable raised after rendering a bounding box
  74276. */
  74277. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74278. /**
  74279. * @hidden
  74280. */
  74281. renderList: SmartArray<BoundingBox>;
  74282. private _colorShader;
  74283. private _vertexBuffers;
  74284. private _indexBuffer;
  74285. private _fillIndexBuffer;
  74286. private _fillIndexData;
  74287. /**
  74288. * Instantiates a new bounding box renderer in a scene.
  74289. * @param scene the scene the renderer renders in
  74290. */
  74291. constructor(scene: Scene);
  74292. /**
  74293. * Registers the component in a given scene
  74294. */
  74295. register(): void;
  74296. private _evaluateSubMesh;
  74297. private _activeMesh;
  74298. private _prepareRessources;
  74299. private _createIndexBuffer;
  74300. /**
  74301. * Rebuilds the elements related to this component in case of
  74302. * context lost for instance.
  74303. */
  74304. rebuild(): void;
  74305. /**
  74306. * @hidden
  74307. */
  74308. reset(): void;
  74309. /**
  74310. * Render the bounding boxes of a specific rendering group
  74311. * @param renderingGroupId defines the rendering group to render
  74312. */
  74313. render(renderingGroupId: number): void;
  74314. /**
  74315. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74316. * @param mesh Define the mesh to render the occlusion bounding box for
  74317. */
  74318. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74319. /**
  74320. * Dispose and release the resources attached to this renderer.
  74321. */
  74322. dispose(): void;
  74323. }
  74324. }
  74325. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74326. import { Nullable } from "babylonjs/types";
  74327. import { Scene } from "babylonjs/scene";
  74328. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74329. import { Camera } from "babylonjs/Cameras/camera";
  74330. import { ISceneComponent } from "babylonjs/sceneComponent";
  74331. module "babylonjs/scene" {
  74332. interface Scene {
  74333. /** @hidden (Backing field) */
  74334. _depthRenderer: {
  74335. [id: string]: DepthRenderer;
  74336. };
  74337. /**
  74338. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74339. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74340. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74341. * @returns the created depth renderer
  74342. */
  74343. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74344. /**
  74345. * Disables a depth renderer for a given camera
  74346. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74347. */
  74348. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74349. }
  74350. }
  74351. /**
  74352. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74353. * in several rendering techniques.
  74354. */
  74355. export class DepthRendererSceneComponent implements ISceneComponent {
  74356. /**
  74357. * The component name helpfull to identify the component in the list of scene components.
  74358. */
  74359. readonly name: string;
  74360. /**
  74361. * The scene the component belongs to.
  74362. */
  74363. scene: Scene;
  74364. /**
  74365. * Creates a new instance of the component for the given scene
  74366. * @param scene Defines the scene to register the component in
  74367. */
  74368. constructor(scene: Scene);
  74369. /**
  74370. * Registers the component in a given scene
  74371. */
  74372. register(): void;
  74373. /**
  74374. * Rebuilds the elements related to this component in case of
  74375. * context lost for instance.
  74376. */
  74377. rebuild(): void;
  74378. /**
  74379. * Disposes the component and the associated ressources
  74380. */
  74381. dispose(): void;
  74382. private _gatherRenderTargets;
  74383. private _gatherActiveCameraRenderTargets;
  74384. }
  74385. }
  74386. declare module "babylonjs/Shaders/outline.fragment" {
  74387. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74388. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  74389. /** @hidden */
  74390. export var outlinePixelShader: {
  74391. name: string;
  74392. shader: string;
  74393. };
  74394. }
  74395. declare module "babylonjs/Shaders/outline.vertex" {
  74396. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74398. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74399. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74400. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  74401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74402. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74403. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74404. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  74405. /** @hidden */
  74406. export var outlineVertexShader: {
  74407. name: string;
  74408. shader: string;
  74409. };
  74410. }
  74411. declare module "babylonjs/Rendering/outlineRenderer" {
  74412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  74413. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  74414. import { Scene } from "babylonjs/scene";
  74415. import { ISceneComponent } from "babylonjs/sceneComponent";
  74416. import "babylonjs/Shaders/outline.fragment";
  74417. import "babylonjs/Shaders/outline.vertex";
  74418. module "babylonjs/scene" {
  74419. interface Scene {
  74420. /** @hidden */
  74421. _outlineRenderer: OutlineRenderer;
  74422. /**
  74423. * Gets the outline renderer associated with the scene
  74424. * @returns a OutlineRenderer
  74425. */
  74426. getOutlineRenderer(): OutlineRenderer;
  74427. }
  74428. }
  74429. module "babylonjs/Meshes/abstractMesh" {
  74430. interface AbstractMesh {
  74431. /** @hidden (Backing field) */
  74432. _renderOutline: boolean;
  74433. /**
  74434. * Gets or sets a boolean indicating if the outline must be rendered as well
  74435. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  74436. */
  74437. renderOutline: boolean;
  74438. /** @hidden (Backing field) */
  74439. _renderOverlay: boolean;
  74440. /**
  74441. * Gets or sets a boolean indicating if the overlay must be rendered as well
  74442. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  74443. */
  74444. renderOverlay: boolean;
  74445. }
  74446. }
  74447. /**
  74448. * This class is responsible to draw bothe outline/overlay of meshes.
  74449. * It should not be used directly but through the available method on mesh.
  74450. */
  74451. export class OutlineRenderer implements ISceneComponent {
  74452. /**
  74453. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  74454. */
  74455. private static _StencilReference;
  74456. /**
  74457. * The name of the component. Each component must have a unique name.
  74458. */
  74459. name: string;
  74460. /**
  74461. * The scene the component belongs to.
  74462. */
  74463. scene: Scene;
  74464. /**
  74465. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  74466. */
  74467. zOffset: number;
  74468. private _engine;
  74469. private _effect;
  74470. private _cachedDefines;
  74471. private _savedDepthWrite;
  74472. /**
  74473. * Instantiates a new outline renderer. (There could be only one per scene).
  74474. * @param scene Defines the scene it belongs to
  74475. */
  74476. constructor(scene: Scene);
  74477. /**
  74478. * Register the component to one instance of a scene.
  74479. */
  74480. register(): void;
  74481. /**
  74482. * Rebuilds the elements related to this component in case of
  74483. * context lost for instance.
  74484. */
  74485. rebuild(): void;
  74486. /**
  74487. * Disposes the component and the associated ressources.
  74488. */
  74489. dispose(): void;
  74490. /**
  74491. * Renders the outline in the canvas.
  74492. * @param subMesh Defines the sumesh to render
  74493. * @param batch Defines the batch of meshes in case of instances
  74494. * @param useOverlay Defines if the rendering is for the overlay or the outline
  74495. */
  74496. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  74497. /**
  74498. * Returns whether or not the outline renderer is ready for a given submesh.
  74499. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  74500. * @param subMesh Defines the submesh to check readyness for
  74501. * @param useInstances Defines wheter wee are trying to render instances or not
  74502. * @returns true if ready otherwise false
  74503. */
  74504. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74505. private _beforeRenderingMesh;
  74506. private _afterRenderingMesh;
  74507. }
  74508. }
  74509. declare module "babylonjs/Rendering/index" {
  74510. export * from "babylonjs/Rendering/boundingBoxRenderer";
  74511. export * from "babylonjs/Rendering/depthRenderer";
  74512. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  74513. export * from "babylonjs/Rendering/edgesRenderer";
  74514. export * from "babylonjs/Rendering/geometryBufferRenderer";
  74515. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74516. export * from "babylonjs/Rendering/outlineRenderer";
  74517. export * from "babylonjs/Rendering/renderingGroup";
  74518. export * from "babylonjs/Rendering/renderingManager";
  74519. export * from "babylonjs/Rendering/utilityLayerRenderer";
  74520. }
  74521. declare module "babylonjs/Sprites/ISprites" {
  74522. /**
  74523. * Defines the basic options interface of a Sprite Frame Source Size.
  74524. */
  74525. export interface ISpriteJSONSpriteSourceSize {
  74526. /**
  74527. * number of the original width of the Frame
  74528. */
  74529. w: number;
  74530. /**
  74531. * number of the original height of the Frame
  74532. */
  74533. h: number;
  74534. }
  74535. /**
  74536. * Defines the basic options interface of a Sprite Frame Data.
  74537. */
  74538. export interface ISpriteJSONSpriteFrameData {
  74539. /**
  74540. * number of the x offset of the Frame
  74541. */
  74542. x: number;
  74543. /**
  74544. * number of the y offset of the Frame
  74545. */
  74546. y: number;
  74547. /**
  74548. * number of the width of the Frame
  74549. */
  74550. w: number;
  74551. /**
  74552. * number of the height of the Frame
  74553. */
  74554. h: number;
  74555. }
  74556. /**
  74557. * Defines the basic options interface of a JSON Sprite.
  74558. */
  74559. export interface ISpriteJSONSprite {
  74560. /**
  74561. * string name of the Frame
  74562. */
  74563. filename: string;
  74564. /**
  74565. * ISpriteJSONSpriteFrame basic object of the frame data
  74566. */
  74567. frame: ISpriteJSONSpriteFrameData;
  74568. /**
  74569. * boolean to flag is the frame was rotated.
  74570. */
  74571. rotated: boolean;
  74572. /**
  74573. * boolean to flag is the frame was trimmed.
  74574. */
  74575. trimmed: boolean;
  74576. /**
  74577. * ISpriteJSONSpriteFrame basic object of the source data
  74578. */
  74579. spriteSourceSize: ISpriteJSONSpriteFrameData;
  74580. /**
  74581. * ISpriteJSONSpriteFrame basic object of the source data
  74582. */
  74583. sourceSize: ISpriteJSONSpriteSourceSize;
  74584. }
  74585. /**
  74586. * Defines the basic options interface of a JSON atlas.
  74587. */
  74588. export interface ISpriteJSONAtlas {
  74589. /**
  74590. * Array of objects that contain the frame data.
  74591. */
  74592. frames: Array<ISpriteJSONSprite>;
  74593. /**
  74594. * object basic object containing the sprite meta data.
  74595. */
  74596. meta?: object;
  74597. }
  74598. }
  74599. declare module "babylonjs/Shaders/spriteMap.fragment" {
  74600. /** @hidden */
  74601. export var spriteMapPixelShader: {
  74602. name: string;
  74603. shader: string;
  74604. };
  74605. }
  74606. declare module "babylonjs/Shaders/spriteMap.vertex" {
  74607. /** @hidden */
  74608. export var spriteMapVertexShader: {
  74609. name: string;
  74610. shader: string;
  74611. };
  74612. }
  74613. declare module "babylonjs/Sprites/spriteMap" {
  74614. import { IDisposable, Scene } from "babylonjs/scene";
  74615. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  74616. import { Texture } from "babylonjs/Materials/Textures/texture";
  74617. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  74618. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  74619. import "babylonjs/Meshes/Builders/planeBuilder";
  74620. import "babylonjs/Shaders/spriteMap.fragment";
  74621. import "babylonjs/Shaders/spriteMap.vertex";
  74622. /**
  74623. * Defines the basic options interface of a SpriteMap
  74624. */
  74625. export interface ISpriteMapOptions {
  74626. /**
  74627. * Vector2 of the number of cells in the grid.
  74628. */
  74629. stageSize?: Vector2;
  74630. /**
  74631. * Vector2 of the size of the output plane in World Units.
  74632. */
  74633. outputSize?: Vector2;
  74634. /**
  74635. * Vector3 of the position of the output plane in World Units.
  74636. */
  74637. outputPosition?: Vector3;
  74638. /**
  74639. * Vector3 of the rotation of the output plane.
  74640. */
  74641. outputRotation?: Vector3;
  74642. /**
  74643. * number of layers that the system will reserve in resources.
  74644. */
  74645. layerCount?: number;
  74646. /**
  74647. * number of max animation frames a single cell will reserve in resources.
  74648. */
  74649. maxAnimationFrames?: number;
  74650. /**
  74651. * number cell index of the base tile when the system compiles.
  74652. */
  74653. baseTile?: number;
  74654. /**
  74655. * boolean flip the sprite after its been repositioned by the framing data.
  74656. */
  74657. flipU?: boolean;
  74658. /**
  74659. * Vector3 scalar of the global RGB values of the SpriteMap.
  74660. */
  74661. colorMultiply?: Vector3;
  74662. }
  74663. /**
  74664. * Defines the IDisposable interface in order to be cleanable from resources.
  74665. */
  74666. export interface ISpriteMap extends IDisposable {
  74667. /**
  74668. * String name of the SpriteMap.
  74669. */
  74670. name: string;
  74671. /**
  74672. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  74673. */
  74674. atlasJSON: ISpriteJSONAtlas;
  74675. /**
  74676. * Texture of the SpriteMap.
  74677. */
  74678. spriteSheet: Texture;
  74679. /**
  74680. * The parameters to initialize the SpriteMap with.
  74681. */
  74682. options: ISpriteMapOptions;
  74683. }
  74684. /**
  74685. * Class used to manage a grid restricted sprite deployment on an Output plane.
  74686. */
  74687. export class SpriteMap implements ISpriteMap {
  74688. /** The Name of the spriteMap */
  74689. name: string;
  74690. /** The JSON file with the frame and meta data */
  74691. atlasJSON: ISpriteJSONAtlas;
  74692. /** The systems Sprite Sheet Texture */
  74693. spriteSheet: Texture;
  74694. /** Arguments passed with the Constructor */
  74695. options: ISpriteMapOptions;
  74696. /** Public Sprite Storage array, parsed from atlasJSON */
  74697. sprites: Array<ISpriteJSONSprite>;
  74698. /** Returns the Number of Sprites in the System */
  74699. get spriteCount(): number;
  74700. /** Returns the Position of Output Plane*/
  74701. get position(): Vector3;
  74702. /** Returns the Position of Output Plane*/
  74703. set position(v: Vector3);
  74704. /** Returns the Rotation of Output Plane*/
  74705. get rotation(): Vector3;
  74706. /** Returns the Rotation of Output Plane*/
  74707. set rotation(v: Vector3);
  74708. /** Sets the AnimationMap*/
  74709. get animationMap(): RawTexture;
  74710. /** Sets the AnimationMap*/
  74711. set animationMap(v: RawTexture);
  74712. /** Scene that the SpriteMap was created in */
  74713. private _scene;
  74714. /** Texture Buffer of Float32 that holds tile frame data*/
  74715. private _frameMap;
  74716. /** Texture Buffers of Float32 that holds tileMap data*/
  74717. private _tileMaps;
  74718. /** Texture Buffer of Float32 that holds Animation Data*/
  74719. private _animationMap;
  74720. /** Custom ShaderMaterial Central to the System*/
  74721. private _material;
  74722. /** Custom ShaderMaterial Central to the System*/
  74723. private _output;
  74724. /** Systems Time Ticker*/
  74725. private _time;
  74726. /**
  74727. * Creates a new SpriteMap
  74728. * @param name defines the SpriteMaps Name
  74729. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  74730. * @param spriteSheet is the Texture that the Sprites are on.
  74731. * @param options a basic deployment configuration
  74732. * @param scene The Scene that the map is deployed on
  74733. */
  74734. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74735. /**
  74736. * Returns tileID location
  74737. * @returns Vector2 the cell position ID
  74738. */
  74739. getTileID(): Vector2;
  74740. /**
  74741. * Gets the UV location of the mouse over the SpriteMap.
  74742. * @returns Vector2 the UV position of the mouse interaction
  74743. */
  74744. getMousePosition(): Vector2;
  74745. /**
  74746. * Creates the "frame" texture Buffer
  74747. * -------------------------------------
  74748. * Structure of frames
  74749. * "filename": "Falling-Water-2.png",
  74750. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74751. * "rotated": true,
  74752. * "trimmed": true,
  74753. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74754. * "sourceSize": {"w":32,"h":32}
  74755. * @returns RawTexture of the frameMap
  74756. */
  74757. private _createFrameBuffer;
  74758. /**
  74759. * Creates the tileMap texture Buffer
  74760. * @param buffer normally and array of numbers, or a false to generate from scratch
  74761. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74762. * @returns RawTexture of the tileMap
  74763. */
  74764. private _createTileBuffer;
  74765. /**
  74766. * Modifies the data of the tileMaps
  74767. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74768. * @param pos is the iVector2 Coordinates of the Tile
  74769. * @param tile The SpriteIndex of the new Tile
  74770. */
  74771. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74772. /**
  74773. * Creates the animationMap texture Buffer
  74774. * @param buffer normally and array of numbers, or a false to generate from scratch
  74775. * @returns RawTexture of the animationMap
  74776. */
  74777. private _createTileAnimationBuffer;
  74778. /**
  74779. * Modifies the data of the animationMap
  74780. * @param cellID is the Index of the Sprite
  74781. * @param _frame is the target Animation frame
  74782. * @param toCell is the Target Index of the next frame of the animation
  74783. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74784. * @param speed is a global scalar of the time variable on the map.
  74785. */
  74786. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74787. /**
  74788. * Exports the .tilemaps file
  74789. */
  74790. saveTileMaps(): void;
  74791. /**
  74792. * Imports the .tilemaps file
  74793. * @param url of the .tilemaps file
  74794. */
  74795. loadTileMaps(url: string): void;
  74796. /**
  74797. * Release associated resources
  74798. */
  74799. dispose(): void;
  74800. }
  74801. }
  74802. declare module "babylonjs/Sprites/spritePackedManager" {
  74803. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  74804. import { Scene } from "babylonjs/scene";
  74805. /**
  74806. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74807. * @see http://doc.babylonjs.com/babylon101/sprites
  74808. */
  74809. export class SpritePackedManager extends SpriteManager {
  74810. /** defines the packed manager's name */
  74811. name: string;
  74812. /**
  74813. * Creates a new sprite manager from a packed sprite sheet
  74814. * @param name defines the manager's name
  74815. * @param imgUrl defines the sprite sheet url
  74816. * @param capacity defines the maximum allowed number of sprites
  74817. * @param scene defines the hosting scene
  74818. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74819. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74820. * @param samplingMode defines the smapling mode to use with spritesheet
  74821. * @param fromPacked set to true; do not alter
  74822. */
  74823. constructor(
  74824. /** defines the packed manager's name */
  74825. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74826. }
  74827. }
  74828. declare module "babylonjs/Sprites/index" {
  74829. export * from "babylonjs/Sprites/sprite";
  74830. export * from "babylonjs/Sprites/ISprites";
  74831. export * from "babylonjs/Sprites/spriteManager";
  74832. export * from "babylonjs/Sprites/spriteMap";
  74833. export * from "babylonjs/Sprites/spritePackedManager";
  74834. export * from "babylonjs/Sprites/spriteSceneComponent";
  74835. }
  74836. declare module "babylonjs/States/index" {
  74837. export * from "babylonjs/States/alphaCullingState";
  74838. export * from "babylonjs/States/depthCullingState";
  74839. export * from "babylonjs/States/stencilState";
  74840. }
  74841. declare module "babylonjs/Misc/assetsManager" {
  74842. import { Scene } from "babylonjs/scene";
  74843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74844. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  74845. import { Skeleton } from "babylonjs/Bones/skeleton";
  74846. import { Observable } from "babylonjs/Misc/observable";
  74847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  74848. import { Texture } from "babylonjs/Materials/Textures/texture";
  74849. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  74850. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  74851. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  74852. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  74853. /**
  74854. * Defines the list of states available for a task inside a AssetsManager
  74855. */
  74856. export enum AssetTaskState {
  74857. /**
  74858. * Initialization
  74859. */
  74860. INIT = 0,
  74861. /**
  74862. * Running
  74863. */
  74864. RUNNING = 1,
  74865. /**
  74866. * Done
  74867. */
  74868. DONE = 2,
  74869. /**
  74870. * Error
  74871. */
  74872. ERROR = 3
  74873. }
  74874. /**
  74875. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74876. */
  74877. export abstract class AbstractAssetTask {
  74878. /**
  74879. * Task name
  74880. */ name: string;
  74881. /**
  74882. * Callback called when the task is successful
  74883. */
  74884. onSuccess: (task: any) => void;
  74885. /**
  74886. * Callback called when the task is not successful
  74887. */
  74888. onError: (task: any, message?: string, exception?: any) => void;
  74889. /**
  74890. * Creates a new AssetsManager
  74891. * @param name defines the name of the task
  74892. */
  74893. constructor(
  74894. /**
  74895. * Task name
  74896. */ name: string);
  74897. private _isCompleted;
  74898. private _taskState;
  74899. private _errorObject;
  74900. /**
  74901. * Get if the task is completed
  74902. */
  74903. get isCompleted(): boolean;
  74904. /**
  74905. * Gets the current state of the task
  74906. */
  74907. get taskState(): AssetTaskState;
  74908. /**
  74909. * Gets the current error object (if task is in error)
  74910. */
  74911. get errorObject(): {
  74912. message?: string;
  74913. exception?: any;
  74914. };
  74915. /**
  74916. * Internal only
  74917. * @hidden
  74918. */
  74919. _setErrorObject(message?: string, exception?: any): void;
  74920. /**
  74921. * Execute the current task
  74922. * @param scene defines the scene where you want your assets to be loaded
  74923. * @param onSuccess is a callback called when the task is successfully executed
  74924. * @param onError is a callback called if an error occurs
  74925. */
  74926. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74927. /**
  74928. * Execute the current task
  74929. * @param scene defines the scene where you want your assets to be loaded
  74930. * @param onSuccess is a callback called when the task is successfully executed
  74931. * @param onError is a callback called if an error occurs
  74932. */
  74933. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74934. /**
  74935. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74936. * This can be used with failed tasks that have the reason for failure fixed.
  74937. */
  74938. reset(): void;
  74939. private onErrorCallback;
  74940. private onDoneCallback;
  74941. }
  74942. /**
  74943. * Define the interface used by progress events raised during assets loading
  74944. */
  74945. export interface IAssetsProgressEvent {
  74946. /**
  74947. * Defines the number of remaining tasks to process
  74948. */
  74949. remainingCount: number;
  74950. /**
  74951. * Defines the total number of tasks
  74952. */
  74953. totalCount: number;
  74954. /**
  74955. * Defines the task that was just processed
  74956. */
  74957. task: AbstractAssetTask;
  74958. }
  74959. /**
  74960. * Class used to share progress information about assets loading
  74961. */
  74962. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74963. /**
  74964. * Defines the number of remaining tasks to process
  74965. */
  74966. remainingCount: number;
  74967. /**
  74968. * Defines the total number of tasks
  74969. */
  74970. totalCount: number;
  74971. /**
  74972. * Defines the task that was just processed
  74973. */
  74974. task: AbstractAssetTask;
  74975. /**
  74976. * Creates a AssetsProgressEvent
  74977. * @param remainingCount defines the number of remaining tasks to process
  74978. * @param totalCount defines the total number of tasks
  74979. * @param task defines the task that was just processed
  74980. */
  74981. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74982. }
  74983. /**
  74984. * Define a task used by AssetsManager to load meshes
  74985. */
  74986. export class MeshAssetTask extends AbstractAssetTask {
  74987. /**
  74988. * Defines the name of the task
  74989. */
  74990. name: string;
  74991. /**
  74992. * Defines the list of mesh's names you want to load
  74993. */
  74994. meshesNames: any;
  74995. /**
  74996. * Defines the root url to use as a base to load your meshes and associated resources
  74997. */
  74998. rootUrl: string;
  74999. /**
  75000. * Defines the filename or File of the scene to load from
  75001. */
  75002. sceneFilename: string | File;
  75003. /**
  75004. * Gets the list of loaded meshes
  75005. */
  75006. loadedMeshes: Array<AbstractMesh>;
  75007. /**
  75008. * Gets the list of loaded particle systems
  75009. */
  75010. loadedParticleSystems: Array<IParticleSystem>;
  75011. /**
  75012. * Gets the list of loaded skeletons
  75013. */
  75014. loadedSkeletons: Array<Skeleton>;
  75015. /**
  75016. * Gets the list of loaded animation groups
  75017. */
  75018. loadedAnimationGroups: Array<AnimationGroup>;
  75019. /**
  75020. * Callback called when the task is successful
  75021. */
  75022. onSuccess: (task: MeshAssetTask) => void;
  75023. /**
  75024. * Callback called when the task is successful
  75025. */
  75026. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75027. /**
  75028. * Creates a new MeshAssetTask
  75029. * @param name defines the name of the task
  75030. * @param meshesNames defines the list of mesh's names you want to load
  75031. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75032. * @param sceneFilename defines the filename or File of the scene to load from
  75033. */
  75034. constructor(
  75035. /**
  75036. * Defines the name of the task
  75037. */
  75038. name: string,
  75039. /**
  75040. * Defines the list of mesh's names you want to load
  75041. */
  75042. meshesNames: any,
  75043. /**
  75044. * Defines the root url to use as a base to load your meshes and associated resources
  75045. */
  75046. rootUrl: string,
  75047. /**
  75048. * Defines the filename or File of the scene to load from
  75049. */
  75050. sceneFilename: string | File);
  75051. /**
  75052. * Execute the current task
  75053. * @param scene defines the scene where you want your assets to be loaded
  75054. * @param onSuccess is a callback called when the task is successfully executed
  75055. * @param onError is a callback called if an error occurs
  75056. */
  75057. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75058. }
  75059. /**
  75060. * Define a task used by AssetsManager to load text content
  75061. */
  75062. export class TextFileAssetTask extends AbstractAssetTask {
  75063. /**
  75064. * Defines the name of the task
  75065. */
  75066. name: string;
  75067. /**
  75068. * Defines the location of the file to load
  75069. */
  75070. url: string;
  75071. /**
  75072. * Gets the loaded text string
  75073. */
  75074. text: string;
  75075. /**
  75076. * Callback called when the task is successful
  75077. */
  75078. onSuccess: (task: TextFileAssetTask) => void;
  75079. /**
  75080. * Callback called when the task is successful
  75081. */
  75082. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75083. /**
  75084. * Creates a new TextFileAssetTask object
  75085. * @param name defines the name of the task
  75086. * @param url defines the location of the file to load
  75087. */
  75088. constructor(
  75089. /**
  75090. * Defines the name of the task
  75091. */
  75092. name: string,
  75093. /**
  75094. * Defines the location of the file to load
  75095. */
  75096. url: string);
  75097. /**
  75098. * Execute the current task
  75099. * @param scene defines the scene where you want your assets to be loaded
  75100. * @param onSuccess is a callback called when the task is successfully executed
  75101. * @param onError is a callback called if an error occurs
  75102. */
  75103. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75104. }
  75105. /**
  75106. * Define a task used by AssetsManager to load binary data
  75107. */
  75108. export class BinaryFileAssetTask extends AbstractAssetTask {
  75109. /**
  75110. * Defines the name of the task
  75111. */
  75112. name: string;
  75113. /**
  75114. * Defines the location of the file to load
  75115. */
  75116. url: string;
  75117. /**
  75118. * Gets the lodaded data (as an array buffer)
  75119. */
  75120. data: ArrayBuffer;
  75121. /**
  75122. * Callback called when the task is successful
  75123. */
  75124. onSuccess: (task: BinaryFileAssetTask) => void;
  75125. /**
  75126. * Callback called when the task is successful
  75127. */
  75128. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75129. /**
  75130. * Creates a new BinaryFileAssetTask object
  75131. * @param name defines the name of the new task
  75132. * @param url defines the location of the file to load
  75133. */
  75134. constructor(
  75135. /**
  75136. * Defines the name of the task
  75137. */
  75138. name: string,
  75139. /**
  75140. * Defines the location of the file to load
  75141. */
  75142. url: string);
  75143. /**
  75144. * Execute the current task
  75145. * @param scene defines the scene where you want your assets to be loaded
  75146. * @param onSuccess is a callback called when the task is successfully executed
  75147. * @param onError is a callback called if an error occurs
  75148. */
  75149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75150. }
  75151. /**
  75152. * Define a task used by AssetsManager to load images
  75153. */
  75154. export class ImageAssetTask extends AbstractAssetTask {
  75155. /**
  75156. * Defines the name of the task
  75157. */
  75158. name: string;
  75159. /**
  75160. * Defines the location of the image to load
  75161. */
  75162. url: string;
  75163. /**
  75164. * Gets the loaded images
  75165. */
  75166. image: HTMLImageElement;
  75167. /**
  75168. * Callback called when the task is successful
  75169. */
  75170. onSuccess: (task: ImageAssetTask) => void;
  75171. /**
  75172. * Callback called when the task is successful
  75173. */
  75174. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75175. /**
  75176. * Creates a new ImageAssetTask
  75177. * @param name defines the name of the task
  75178. * @param url defines the location of the image to load
  75179. */
  75180. constructor(
  75181. /**
  75182. * Defines the name of the task
  75183. */
  75184. name: string,
  75185. /**
  75186. * Defines the location of the image to load
  75187. */
  75188. url: string);
  75189. /**
  75190. * Execute the current task
  75191. * @param scene defines the scene where you want your assets to be loaded
  75192. * @param onSuccess is a callback called when the task is successfully executed
  75193. * @param onError is a callback called if an error occurs
  75194. */
  75195. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75196. }
  75197. /**
  75198. * Defines the interface used by texture loading tasks
  75199. */
  75200. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75201. /**
  75202. * Gets the loaded texture
  75203. */
  75204. texture: TEX;
  75205. }
  75206. /**
  75207. * Define a task used by AssetsManager to load 2D textures
  75208. */
  75209. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75210. /**
  75211. * Defines the name of the task
  75212. */
  75213. name: string;
  75214. /**
  75215. * Defines the location of the file to load
  75216. */
  75217. url: string;
  75218. /**
  75219. * Defines if mipmap should not be generated (default is false)
  75220. */
  75221. noMipmap?: boolean | undefined;
  75222. /**
  75223. * Defines if texture must be inverted on Y axis (default is true)
  75224. */
  75225. invertY: boolean;
  75226. /**
  75227. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75228. */
  75229. samplingMode: number;
  75230. /**
  75231. * Gets the loaded texture
  75232. */
  75233. texture: Texture;
  75234. /**
  75235. * Callback called when the task is successful
  75236. */
  75237. onSuccess: (task: TextureAssetTask) => void;
  75238. /**
  75239. * Callback called when the task is successful
  75240. */
  75241. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75242. /**
  75243. * Creates a new TextureAssetTask object
  75244. * @param name defines the name of the task
  75245. * @param url defines the location of the file to load
  75246. * @param noMipmap defines if mipmap should not be generated (default is false)
  75247. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75248. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75249. */
  75250. constructor(
  75251. /**
  75252. * Defines the name of the task
  75253. */
  75254. name: string,
  75255. /**
  75256. * Defines the location of the file to load
  75257. */
  75258. url: string,
  75259. /**
  75260. * Defines if mipmap should not be generated (default is false)
  75261. */
  75262. noMipmap?: boolean | undefined,
  75263. /**
  75264. * Defines if texture must be inverted on Y axis (default is true)
  75265. */
  75266. invertY?: boolean,
  75267. /**
  75268. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75269. */
  75270. samplingMode?: number);
  75271. /**
  75272. * Execute the current task
  75273. * @param scene defines the scene where you want your assets to be loaded
  75274. * @param onSuccess is a callback called when the task is successfully executed
  75275. * @param onError is a callback called if an error occurs
  75276. */
  75277. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75278. }
  75279. /**
  75280. * Define a task used by AssetsManager to load cube textures
  75281. */
  75282. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75283. /**
  75284. * Defines the name of the task
  75285. */
  75286. name: string;
  75287. /**
  75288. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75289. */
  75290. url: string;
  75291. /**
  75292. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75293. */
  75294. extensions?: string[] | undefined;
  75295. /**
  75296. * Defines if mipmaps should not be generated (default is false)
  75297. */
  75298. noMipmap?: boolean | undefined;
  75299. /**
  75300. * Defines the explicit list of files (undefined by default)
  75301. */
  75302. files?: string[] | undefined;
  75303. /**
  75304. * Gets the loaded texture
  75305. */
  75306. texture: CubeTexture;
  75307. /**
  75308. * Callback called when the task is successful
  75309. */
  75310. onSuccess: (task: CubeTextureAssetTask) => void;
  75311. /**
  75312. * Callback called when the task is successful
  75313. */
  75314. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75315. /**
  75316. * Creates a new CubeTextureAssetTask
  75317. * @param name defines the name of the task
  75318. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75319. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75320. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75321. * @param files defines the explicit list of files (undefined by default)
  75322. */
  75323. constructor(
  75324. /**
  75325. * Defines the name of the task
  75326. */
  75327. name: string,
  75328. /**
  75329. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75330. */
  75331. url: string,
  75332. /**
  75333. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75334. */
  75335. extensions?: string[] | undefined,
  75336. /**
  75337. * Defines if mipmaps should not be generated (default is false)
  75338. */
  75339. noMipmap?: boolean | undefined,
  75340. /**
  75341. * Defines the explicit list of files (undefined by default)
  75342. */
  75343. files?: string[] | undefined);
  75344. /**
  75345. * Execute the current task
  75346. * @param scene defines the scene where you want your assets to be loaded
  75347. * @param onSuccess is a callback called when the task is successfully executed
  75348. * @param onError is a callback called if an error occurs
  75349. */
  75350. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75351. }
  75352. /**
  75353. * Define a task used by AssetsManager to load HDR cube textures
  75354. */
  75355. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  75356. /**
  75357. * Defines the name of the task
  75358. */
  75359. name: string;
  75360. /**
  75361. * Defines the location of the file to load
  75362. */
  75363. url: string;
  75364. /**
  75365. * Defines the desired size (the more it increases the longer the generation will be)
  75366. */
  75367. size: number;
  75368. /**
  75369. * Defines if mipmaps should not be generated (default is false)
  75370. */
  75371. noMipmap: boolean;
  75372. /**
  75373. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75374. */
  75375. generateHarmonics: boolean;
  75376. /**
  75377. * 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)
  75378. */
  75379. gammaSpace: boolean;
  75380. /**
  75381. * Internal Use Only
  75382. */
  75383. reserved: boolean;
  75384. /**
  75385. * Gets the loaded texture
  75386. */
  75387. texture: HDRCubeTexture;
  75388. /**
  75389. * Callback called when the task is successful
  75390. */
  75391. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  75392. /**
  75393. * Callback called when the task is successful
  75394. */
  75395. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  75396. /**
  75397. * Creates a new HDRCubeTextureAssetTask object
  75398. * @param name defines the name of the task
  75399. * @param url defines the location of the file to load
  75400. * @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.
  75401. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75402. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75403. * @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)
  75404. * @param reserved Internal use only
  75405. */
  75406. constructor(
  75407. /**
  75408. * Defines the name of the task
  75409. */
  75410. name: string,
  75411. /**
  75412. * Defines the location of the file to load
  75413. */
  75414. url: string,
  75415. /**
  75416. * Defines the desired size (the more it increases the longer the generation will be)
  75417. */
  75418. size: number,
  75419. /**
  75420. * Defines if mipmaps should not be generated (default is false)
  75421. */
  75422. noMipmap?: boolean,
  75423. /**
  75424. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  75425. */
  75426. generateHarmonics?: boolean,
  75427. /**
  75428. * 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)
  75429. */
  75430. gammaSpace?: boolean,
  75431. /**
  75432. * Internal Use Only
  75433. */
  75434. reserved?: boolean);
  75435. /**
  75436. * Execute the current task
  75437. * @param scene defines the scene where you want your assets to be loaded
  75438. * @param onSuccess is a callback called when the task is successfully executed
  75439. * @param onError is a callback called if an error occurs
  75440. */
  75441. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75442. }
  75443. /**
  75444. * Define a task used by AssetsManager to load Equirectangular cube textures
  75445. */
  75446. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  75447. /**
  75448. * Defines the name of the task
  75449. */
  75450. name: string;
  75451. /**
  75452. * Defines the location of the file to load
  75453. */
  75454. url: string;
  75455. /**
  75456. * Defines the desired size (the more it increases the longer the generation will be)
  75457. */
  75458. size: number;
  75459. /**
  75460. * Defines if mipmaps should not be generated (default is false)
  75461. */
  75462. noMipmap: boolean;
  75463. /**
  75464. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75465. * but the standard material would require them in Gamma space) (default is true)
  75466. */
  75467. gammaSpace: boolean;
  75468. /**
  75469. * Gets the loaded texture
  75470. */
  75471. texture: EquiRectangularCubeTexture;
  75472. /**
  75473. * Callback called when the task is successful
  75474. */
  75475. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  75476. /**
  75477. * Callback called when the task is successful
  75478. */
  75479. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  75480. /**
  75481. * Creates a new EquiRectangularCubeTextureAssetTask object
  75482. * @param name defines the name of the task
  75483. * @param url defines the location of the file to load
  75484. * @param size defines the desired size (the more it increases the longer the generation will be)
  75485. * If the size is omitted this implies you are using a preprocessed cubemap.
  75486. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75487. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  75488. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  75489. * (default is true)
  75490. */
  75491. constructor(
  75492. /**
  75493. * Defines the name of the task
  75494. */
  75495. name: string,
  75496. /**
  75497. * Defines the location of the file to load
  75498. */
  75499. url: string,
  75500. /**
  75501. * Defines the desired size (the more it increases the longer the generation will be)
  75502. */
  75503. size: number,
  75504. /**
  75505. * Defines if mipmaps should not be generated (default is false)
  75506. */
  75507. noMipmap?: boolean,
  75508. /**
  75509. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  75510. * but the standard material would require them in Gamma space) (default is true)
  75511. */
  75512. gammaSpace?: boolean);
  75513. /**
  75514. * Execute the current task
  75515. * @param scene defines the scene where you want your assets to be loaded
  75516. * @param onSuccess is a callback called when the task is successfully executed
  75517. * @param onError is a callback called if an error occurs
  75518. */
  75519. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75520. }
  75521. /**
  75522. * This class can be used to easily import assets into a scene
  75523. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  75524. */
  75525. export class AssetsManager {
  75526. private _scene;
  75527. private _isLoading;
  75528. protected _tasks: AbstractAssetTask[];
  75529. protected _waitingTasksCount: number;
  75530. protected _totalTasksCount: number;
  75531. /**
  75532. * Callback called when all tasks are processed
  75533. */
  75534. onFinish: (tasks: AbstractAssetTask[]) => void;
  75535. /**
  75536. * Callback called when a task is successful
  75537. */
  75538. onTaskSuccess: (task: AbstractAssetTask) => void;
  75539. /**
  75540. * Callback called when a task had an error
  75541. */
  75542. onTaskError: (task: AbstractAssetTask) => void;
  75543. /**
  75544. * Callback called when a task is done (whatever the result is)
  75545. */
  75546. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  75547. /**
  75548. * Observable called when all tasks are processed
  75549. */
  75550. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  75551. /**
  75552. * Observable called when a task had an error
  75553. */
  75554. onTaskErrorObservable: Observable<AbstractAssetTask>;
  75555. /**
  75556. * Observable called when all tasks were executed
  75557. */
  75558. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  75559. /**
  75560. * Observable called when a task is done (whatever the result is)
  75561. */
  75562. onProgressObservable: Observable<IAssetsProgressEvent>;
  75563. /**
  75564. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  75565. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  75566. */
  75567. useDefaultLoadingScreen: boolean;
  75568. /**
  75569. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  75570. * when all assets have been downloaded.
  75571. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  75572. */
  75573. autoHideLoadingUI: boolean;
  75574. /**
  75575. * Creates a new AssetsManager
  75576. * @param scene defines the scene to work on
  75577. */
  75578. constructor(scene: Scene);
  75579. /**
  75580. * Add a MeshAssetTask to the list of active tasks
  75581. * @param taskName defines the name of the new task
  75582. * @param meshesNames defines the name of meshes to load
  75583. * @param rootUrl defines the root url to use to locate files
  75584. * @param sceneFilename defines the filename of the scene file
  75585. * @returns a new MeshAssetTask object
  75586. */
  75587. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  75588. /**
  75589. * Add a TextFileAssetTask to the list of active tasks
  75590. * @param taskName defines the name of the new task
  75591. * @param url defines the url of the file to load
  75592. * @returns a new TextFileAssetTask object
  75593. */
  75594. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  75595. /**
  75596. * Add a BinaryFileAssetTask to the list of active tasks
  75597. * @param taskName defines the name of the new task
  75598. * @param url defines the url of the file to load
  75599. * @returns a new BinaryFileAssetTask object
  75600. */
  75601. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  75602. /**
  75603. * Add a ImageAssetTask to the list of active tasks
  75604. * @param taskName defines the name of the new task
  75605. * @param url defines the url of the file to load
  75606. * @returns a new ImageAssetTask object
  75607. */
  75608. addImageTask(taskName: string, url: string): ImageAssetTask;
  75609. /**
  75610. * Add a TextureAssetTask to the list of active tasks
  75611. * @param taskName defines the name of the new task
  75612. * @param url defines the url of the file to load
  75613. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75614. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  75615. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  75616. * @returns a new TextureAssetTask object
  75617. */
  75618. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  75619. /**
  75620. * Add a CubeTextureAssetTask to the list of active tasks
  75621. * @param taskName defines the name of the new task
  75622. * @param url defines the url of the file to load
  75623. * @param extensions defines the extension to use to load the cube map (can be null)
  75624. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75625. * @param files defines the list of files to load (can be null)
  75626. * @returns a new CubeTextureAssetTask object
  75627. */
  75628. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  75629. /**
  75630. *
  75631. * Add a HDRCubeTextureAssetTask to the list of active tasks
  75632. * @param taskName defines the name of the new task
  75633. * @param url defines the url of the file to load
  75634. * @param size defines the size you want for the cubemap (can be null)
  75635. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75636. * @param generateHarmonics defines if you want to automatically generate (true by default)
  75637. * @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)
  75638. * @param reserved Internal use only
  75639. * @returns a new HDRCubeTextureAssetTask object
  75640. */
  75641. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  75642. /**
  75643. *
  75644. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  75645. * @param taskName defines the name of the new task
  75646. * @param url defines the url of the file to load
  75647. * @param size defines the size you want for the cubemap (can be null)
  75648. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  75649. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  75650. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  75651. * @returns a new EquiRectangularCubeTextureAssetTask object
  75652. */
  75653. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  75654. /**
  75655. * Remove a task from the assets manager.
  75656. * @param task the task to remove
  75657. */
  75658. removeTask(task: AbstractAssetTask): void;
  75659. private _decreaseWaitingTasksCount;
  75660. private _runTask;
  75661. /**
  75662. * Reset the AssetsManager and remove all tasks
  75663. * @return the current instance of the AssetsManager
  75664. */
  75665. reset(): AssetsManager;
  75666. /**
  75667. * Start the loading process
  75668. * @return the current instance of the AssetsManager
  75669. */
  75670. load(): AssetsManager;
  75671. /**
  75672. * Start the loading process as an async operation
  75673. * @return a promise returning the list of failed tasks
  75674. */
  75675. loadAsync(): Promise<void>;
  75676. }
  75677. }
  75678. declare module "babylonjs/Misc/deferred" {
  75679. /**
  75680. * Wrapper class for promise with external resolve and reject.
  75681. */
  75682. export class Deferred<T> {
  75683. /**
  75684. * The promise associated with this deferred object.
  75685. */
  75686. readonly promise: Promise<T>;
  75687. private _resolve;
  75688. private _reject;
  75689. /**
  75690. * The resolve method of the promise associated with this deferred object.
  75691. */
  75692. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  75693. /**
  75694. * The reject method of the promise associated with this deferred object.
  75695. */
  75696. get reject(): (reason?: any) => void;
  75697. /**
  75698. * Constructor for this deferred object.
  75699. */
  75700. constructor();
  75701. }
  75702. }
  75703. declare module "babylonjs/Misc/meshExploder" {
  75704. import { Mesh } from "babylonjs/Meshes/mesh";
  75705. /**
  75706. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75707. */
  75708. export class MeshExploder {
  75709. private _centerMesh;
  75710. private _meshes;
  75711. private _meshesOrigins;
  75712. private _toCenterVectors;
  75713. private _scaledDirection;
  75714. private _newPosition;
  75715. private _centerPosition;
  75716. /**
  75717. * Explodes meshes from a center mesh.
  75718. * @param meshes The meshes to explode.
  75719. * @param centerMesh The mesh to be center of explosion.
  75720. */
  75721. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75722. private _setCenterMesh;
  75723. /**
  75724. * Get class name
  75725. * @returns "MeshExploder"
  75726. */
  75727. getClassName(): string;
  75728. /**
  75729. * "Exploded meshes"
  75730. * @returns Array of meshes with the centerMesh at index 0.
  75731. */
  75732. getMeshes(): Array<Mesh>;
  75733. /**
  75734. * Explodes meshes giving a specific direction
  75735. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75736. */
  75737. explode(direction?: number): void;
  75738. }
  75739. }
  75740. declare module "babylonjs/Misc/filesInput" {
  75741. import { Engine } from "babylonjs/Engines/engine";
  75742. import { Scene } from "babylonjs/scene";
  75743. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  75744. /**
  75745. * Class used to help managing file picking and drag'n'drop
  75746. */
  75747. export class FilesInput {
  75748. /**
  75749. * List of files ready to be loaded
  75750. */
  75751. static get FilesToLoad(): {
  75752. [key: string]: File;
  75753. };
  75754. /**
  75755. * Callback called when a file is processed
  75756. */
  75757. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  75758. private _engine;
  75759. private _currentScene;
  75760. private _sceneLoadedCallback;
  75761. private _progressCallback;
  75762. private _additionalRenderLoopLogicCallback;
  75763. private _textureLoadingCallback;
  75764. private _startingProcessingFilesCallback;
  75765. private _onReloadCallback;
  75766. private _errorCallback;
  75767. private _elementToMonitor;
  75768. private _sceneFileToLoad;
  75769. private _filesToLoad;
  75770. /**
  75771. * Creates a new FilesInput
  75772. * @param engine defines the rendering engine
  75773. * @param scene defines the hosting scene
  75774. * @param sceneLoadedCallback callback called when scene is loaded
  75775. * @param progressCallback callback called to track progress
  75776. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75777. * @param textureLoadingCallback callback called when a texture is loading
  75778. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75779. * @param onReloadCallback callback called when a reload is requested
  75780. * @param errorCallback callback call if an error occurs
  75781. */
  75782. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: ISceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  75783. private _dragEnterHandler;
  75784. private _dragOverHandler;
  75785. private _dropHandler;
  75786. /**
  75787. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75788. * @param elementToMonitor defines the DOM element to track
  75789. */
  75790. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75791. /**
  75792. * Release all associated resources
  75793. */
  75794. dispose(): void;
  75795. private renderFunction;
  75796. private drag;
  75797. private drop;
  75798. private _traverseFolder;
  75799. private _processFiles;
  75800. /**
  75801. * Load files from a drop event
  75802. * @param event defines the drop event to use as source
  75803. */
  75804. loadFiles(event: any): void;
  75805. private _processReload;
  75806. /**
  75807. * Reload the current scene from the loaded files
  75808. */
  75809. reload(): void;
  75810. }
  75811. }
  75812. declare module "babylonjs/Misc/HighDynamicRange/index" {
  75813. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  75814. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  75815. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  75816. }
  75817. declare module "babylonjs/Misc/sceneOptimizer" {
  75818. import { Scene, IDisposable } from "babylonjs/scene";
  75819. import { Observable } from "babylonjs/Misc/observable";
  75820. /**
  75821. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75822. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75823. */
  75824. export class SceneOptimization {
  75825. /**
  75826. * Defines the priority of this optimization (0 by default which means first in the list)
  75827. */
  75828. priority: number;
  75829. /**
  75830. * Gets a string describing the action executed by the current optimization
  75831. * @returns description string
  75832. */
  75833. getDescription(): string;
  75834. /**
  75835. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75836. * @param scene defines the current scene where to apply this optimization
  75837. * @param optimizer defines the current optimizer
  75838. * @returns true if everything that can be done was applied
  75839. */
  75840. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75841. /**
  75842. * Creates the SceneOptimization object
  75843. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75844. * @param desc defines the description associated with the optimization
  75845. */
  75846. constructor(
  75847. /**
  75848. * Defines the priority of this optimization (0 by default which means first in the list)
  75849. */
  75850. priority?: number);
  75851. }
  75852. /**
  75853. * Defines an optimization used to reduce the size of render target textures
  75854. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75855. */
  75856. export class TextureOptimization extends SceneOptimization {
  75857. /**
  75858. * Defines the priority of this optimization (0 by default which means first in the list)
  75859. */
  75860. priority: number;
  75861. /**
  75862. * 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
  75863. */
  75864. maximumSize: number;
  75865. /**
  75866. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75867. */
  75868. step: number;
  75869. /**
  75870. * Gets a string describing the action executed by the current optimization
  75871. * @returns description string
  75872. */
  75873. getDescription(): string;
  75874. /**
  75875. * Creates the TextureOptimization object
  75876. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75877. * @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
  75878. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75879. */
  75880. constructor(
  75881. /**
  75882. * Defines the priority of this optimization (0 by default which means first in the list)
  75883. */
  75884. priority?: number,
  75885. /**
  75886. * 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
  75887. */
  75888. maximumSize?: number,
  75889. /**
  75890. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75891. */
  75892. step?: number);
  75893. /**
  75894. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75895. * @param scene defines the current scene where to apply this optimization
  75896. * @param optimizer defines the current optimizer
  75897. * @returns true if everything that can be done was applied
  75898. */
  75899. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75900. }
  75901. /**
  75902. * Defines an optimization used to increase or decrease the rendering resolution
  75903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75904. */
  75905. export class HardwareScalingOptimization extends SceneOptimization {
  75906. /**
  75907. * Defines the priority of this optimization (0 by default which means first in the list)
  75908. */
  75909. priority: number;
  75910. /**
  75911. * Defines the maximum scale to use (2 by default)
  75912. */
  75913. maximumScale: number;
  75914. /**
  75915. * Defines the step to use between two passes (0.5 by default)
  75916. */
  75917. step: number;
  75918. private _currentScale;
  75919. private _directionOffset;
  75920. /**
  75921. * Gets a string describing the action executed by the current optimization
  75922. * @return description string
  75923. */
  75924. getDescription(): string;
  75925. /**
  75926. * Creates the HardwareScalingOptimization object
  75927. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75928. * @param maximumScale defines the maximum scale to use (2 by default)
  75929. * @param step defines the step to use between two passes (0.5 by default)
  75930. */
  75931. constructor(
  75932. /**
  75933. * Defines the priority of this optimization (0 by default which means first in the list)
  75934. */
  75935. priority?: number,
  75936. /**
  75937. * Defines the maximum scale to use (2 by default)
  75938. */
  75939. maximumScale?: number,
  75940. /**
  75941. * Defines the step to use between two passes (0.5 by default)
  75942. */
  75943. step?: number);
  75944. /**
  75945. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75946. * @param scene defines the current scene where to apply this optimization
  75947. * @param optimizer defines the current optimizer
  75948. * @returns true if everything that can be done was applied
  75949. */
  75950. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75951. }
  75952. /**
  75953. * Defines an optimization used to remove shadows
  75954. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75955. */
  75956. export class ShadowsOptimization extends SceneOptimization {
  75957. /**
  75958. * Gets a string describing the action executed by the current optimization
  75959. * @return description string
  75960. */
  75961. getDescription(): string;
  75962. /**
  75963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75964. * @param scene defines the current scene where to apply this optimization
  75965. * @param optimizer defines the current optimizer
  75966. * @returns true if everything that can be done was applied
  75967. */
  75968. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75969. }
  75970. /**
  75971. * Defines an optimization used to turn post-processes off
  75972. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75973. */
  75974. export class PostProcessesOptimization extends SceneOptimization {
  75975. /**
  75976. * Gets a string describing the action executed by the current optimization
  75977. * @return description string
  75978. */
  75979. getDescription(): string;
  75980. /**
  75981. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75982. * @param scene defines the current scene where to apply this optimization
  75983. * @param optimizer defines the current optimizer
  75984. * @returns true if everything that can be done was applied
  75985. */
  75986. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75987. }
  75988. /**
  75989. * Defines an optimization used to turn lens flares off
  75990. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75991. */
  75992. export class LensFlaresOptimization extends SceneOptimization {
  75993. /**
  75994. * Gets a string describing the action executed by the current optimization
  75995. * @return description string
  75996. */
  75997. getDescription(): string;
  75998. /**
  75999. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76000. * @param scene defines the current scene where to apply this optimization
  76001. * @param optimizer defines the current optimizer
  76002. * @returns true if everything that can be done was applied
  76003. */
  76004. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76005. }
  76006. /**
  76007. * Defines an optimization based on user defined callback.
  76008. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76009. */
  76010. export class CustomOptimization extends SceneOptimization {
  76011. /**
  76012. * Callback called to apply the custom optimization.
  76013. */
  76014. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76015. /**
  76016. * Callback called to get custom description
  76017. */
  76018. onGetDescription: () => string;
  76019. /**
  76020. * Gets a string describing the action executed by the current optimization
  76021. * @returns description string
  76022. */
  76023. getDescription(): string;
  76024. /**
  76025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76026. * @param scene defines the current scene where to apply this optimization
  76027. * @param optimizer defines the current optimizer
  76028. * @returns true if everything that can be done was applied
  76029. */
  76030. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76031. }
  76032. /**
  76033. * Defines an optimization used to turn particles off
  76034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76035. */
  76036. export class ParticlesOptimization extends SceneOptimization {
  76037. /**
  76038. * Gets a string describing the action executed by the current optimization
  76039. * @return description string
  76040. */
  76041. getDescription(): string;
  76042. /**
  76043. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76044. * @param scene defines the current scene where to apply this optimization
  76045. * @param optimizer defines the current optimizer
  76046. * @returns true if everything that can be done was applied
  76047. */
  76048. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76049. }
  76050. /**
  76051. * Defines an optimization used to turn render targets off
  76052. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76053. */
  76054. export class RenderTargetsOptimization extends SceneOptimization {
  76055. /**
  76056. * Gets a string describing the action executed by the current optimization
  76057. * @return description string
  76058. */
  76059. getDescription(): string;
  76060. /**
  76061. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76062. * @param scene defines the current scene where to apply this optimization
  76063. * @param optimizer defines the current optimizer
  76064. * @returns true if everything that can be done was applied
  76065. */
  76066. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76067. }
  76068. /**
  76069. * Defines an optimization used to merge meshes with compatible materials
  76070. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76071. */
  76072. export class MergeMeshesOptimization extends SceneOptimization {
  76073. private static _UpdateSelectionTree;
  76074. /**
  76075. * Gets or sets a boolean which defines if optimization octree has to be updated
  76076. */
  76077. static get UpdateSelectionTree(): boolean;
  76078. /**
  76079. * Gets or sets a boolean which defines if optimization octree has to be updated
  76080. */
  76081. static set UpdateSelectionTree(value: boolean);
  76082. /**
  76083. * Gets a string describing the action executed by the current optimization
  76084. * @return description string
  76085. */
  76086. getDescription(): string;
  76087. private _canBeMerged;
  76088. /**
  76089. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76090. * @param scene defines the current scene where to apply this optimization
  76091. * @param optimizer defines the current optimizer
  76092. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76093. * @returns true if everything that can be done was applied
  76094. */
  76095. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76096. }
  76097. /**
  76098. * Defines a list of options used by SceneOptimizer
  76099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76100. */
  76101. export class SceneOptimizerOptions {
  76102. /**
  76103. * Defines the target frame rate to reach (60 by default)
  76104. */
  76105. targetFrameRate: number;
  76106. /**
  76107. * Defines the interval between two checkes (2000ms by default)
  76108. */
  76109. trackerDuration: number;
  76110. /**
  76111. * Gets the list of optimizations to apply
  76112. */
  76113. optimizations: SceneOptimization[];
  76114. /**
  76115. * Creates a new list of options used by SceneOptimizer
  76116. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76117. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76118. */
  76119. constructor(
  76120. /**
  76121. * Defines the target frame rate to reach (60 by default)
  76122. */
  76123. targetFrameRate?: number,
  76124. /**
  76125. * Defines the interval between two checkes (2000ms by default)
  76126. */
  76127. trackerDuration?: number);
  76128. /**
  76129. * Add a new optimization
  76130. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76131. * @returns the current SceneOptimizerOptions
  76132. */
  76133. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76134. /**
  76135. * Add a new custom optimization
  76136. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76137. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76138. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76139. * @returns the current SceneOptimizerOptions
  76140. */
  76141. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76142. /**
  76143. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76144. * @param targetFrameRate defines the target frame rate (60 by default)
  76145. * @returns a SceneOptimizerOptions object
  76146. */
  76147. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76148. /**
  76149. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76150. * @param targetFrameRate defines the target frame rate (60 by default)
  76151. * @returns a SceneOptimizerOptions object
  76152. */
  76153. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76154. /**
  76155. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76156. * @param targetFrameRate defines the target frame rate (60 by default)
  76157. * @returns a SceneOptimizerOptions object
  76158. */
  76159. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76160. }
  76161. /**
  76162. * Class used to run optimizations in order to reach a target frame rate
  76163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76164. */
  76165. export class SceneOptimizer implements IDisposable {
  76166. private _isRunning;
  76167. private _options;
  76168. private _scene;
  76169. private _currentPriorityLevel;
  76170. private _targetFrameRate;
  76171. private _trackerDuration;
  76172. private _currentFrameRate;
  76173. private _sceneDisposeObserver;
  76174. private _improvementMode;
  76175. /**
  76176. * Defines an observable called when the optimizer reaches the target frame rate
  76177. */
  76178. onSuccessObservable: Observable<SceneOptimizer>;
  76179. /**
  76180. * Defines an observable called when the optimizer enables an optimization
  76181. */
  76182. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76183. /**
  76184. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76185. */
  76186. onFailureObservable: Observable<SceneOptimizer>;
  76187. /**
  76188. * Gets a boolean indicating if the optimizer is in improvement mode
  76189. */
  76190. get isInImprovementMode(): boolean;
  76191. /**
  76192. * Gets the current priority level (0 at start)
  76193. */
  76194. get currentPriorityLevel(): number;
  76195. /**
  76196. * Gets the current frame rate checked by the SceneOptimizer
  76197. */
  76198. get currentFrameRate(): number;
  76199. /**
  76200. * Gets or sets the current target frame rate (60 by default)
  76201. */
  76202. get targetFrameRate(): number;
  76203. /**
  76204. * Gets or sets the current target frame rate (60 by default)
  76205. */
  76206. set targetFrameRate(value: number);
  76207. /**
  76208. * Gets or sets the current interval between two checks (every 2000ms by default)
  76209. */
  76210. get trackerDuration(): number;
  76211. /**
  76212. * Gets or sets the current interval between two checks (every 2000ms by default)
  76213. */
  76214. set trackerDuration(value: number);
  76215. /**
  76216. * Gets the list of active optimizations
  76217. */
  76218. get optimizations(): SceneOptimization[];
  76219. /**
  76220. * Creates a new SceneOptimizer
  76221. * @param scene defines the scene to work on
  76222. * @param options defines the options to use with the SceneOptimizer
  76223. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76224. * @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)
  76225. */
  76226. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76227. /**
  76228. * Stops the current optimizer
  76229. */
  76230. stop(): void;
  76231. /**
  76232. * Reset the optimizer to initial step (current priority level = 0)
  76233. */
  76234. reset(): void;
  76235. /**
  76236. * Start the optimizer. By default it will try to reach a specific framerate
  76237. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76238. */
  76239. start(): void;
  76240. private _checkCurrentState;
  76241. /**
  76242. * Release all resources
  76243. */
  76244. dispose(): void;
  76245. /**
  76246. * Helper function to create a SceneOptimizer with one single line of code
  76247. * @param scene defines the scene to work on
  76248. * @param options defines the options to use with the SceneOptimizer
  76249. * @param onSuccess defines a callback to call on success
  76250. * @param onFailure defines a callback to call on failure
  76251. * @returns the new SceneOptimizer object
  76252. */
  76253. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76254. }
  76255. }
  76256. declare module "babylonjs/Misc/sceneSerializer" {
  76257. import { Scene } from "babylonjs/scene";
  76258. /**
  76259. * Class used to serialize a scene into a string
  76260. */
  76261. export class SceneSerializer {
  76262. /**
  76263. * Clear cache used by a previous serialization
  76264. */
  76265. static ClearCache(): void;
  76266. /**
  76267. * Serialize a scene into a JSON compatible object
  76268. * @param scene defines the scene to serialize
  76269. * @returns a JSON compatible object
  76270. */
  76271. static Serialize(scene: Scene): any;
  76272. /**
  76273. * Serialize a mesh into a JSON compatible object
  76274. * @param toSerialize defines the mesh to serialize
  76275. * @param withParents defines if parents must be serialized as well
  76276. * @param withChildren defines if children must be serialized as well
  76277. * @returns a JSON compatible object
  76278. */
  76279. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76280. }
  76281. }
  76282. declare module "babylonjs/Misc/textureTools" {
  76283. import { Texture } from "babylonjs/Materials/Textures/texture";
  76284. /**
  76285. * Class used to host texture specific utilities
  76286. */
  76287. export class TextureTools {
  76288. /**
  76289. * Uses the GPU to create a copy texture rescaled at a given size
  76290. * @param texture Texture to copy from
  76291. * @param width defines the desired width
  76292. * @param height defines the desired height
  76293. * @param useBilinearMode defines if bilinear mode has to be used
  76294. * @return the generated texture
  76295. */
  76296. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76297. }
  76298. }
  76299. declare module "babylonjs/Misc/videoRecorder" {
  76300. import { Nullable } from "babylonjs/types";
  76301. import { Engine } from "babylonjs/Engines/engine";
  76302. /**
  76303. * This represents the different options available for the video capture.
  76304. */
  76305. export interface VideoRecorderOptions {
  76306. /** Defines the mime type of the video. */
  76307. mimeType: string;
  76308. /** Defines the FPS the video should be recorded at. */
  76309. fps: number;
  76310. /** Defines the chunk size for the recording data. */
  76311. recordChunckSize: number;
  76312. /** The audio tracks to attach to the recording. */
  76313. audioTracks?: MediaStreamTrack[];
  76314. }
  76315. /**
  76316. * This can help with recording videos from BabylonJS.
  76317. * This is based on the available WebRTC functionalities of the browser.
  76318. *
  76319. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  76320. */
  76321. export class VideoRecorder {
  76322. private static readonly _defaultOptions;
  76323. /**
  76324. * Returns whether or not the VideoRecorder is available in your browser.
  76325. * @param engine Defines the Babylon Engine.
  76326. * @returns true if supported otherwise false.
  76327. */
  76328. static IsSupported(engine: Engine): boolean;
  76329. private readonly _options;
  76330. private _canvas;
  76331. private _mediaRecorder;
  76332. private _recordedChunks;
  76333. private _fileName;
  76334. private _resolve;
  76335. private _reject;
  76336. /**
  76337. * True when a recording is already in progress.
  76338. */
  76339. get isRecording(): boolean;
  76340. /**
  76341. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76342. * @param engine Defines the BabylonJS Engine you wish to record.
  76343. * @param options Defines options that can be used to customize the capture.
  76344. */
  76345. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76346. /**
  76347. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76348. */
  76349. stopRecording(): void;
  76350. /**
  76351. * Starts recording the canvas for a max duration specified in parameters.
  76352. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  76353. * If null no automatic download will start and you can rely on the promise to get the data back.
  76354. * @param maxDuration Defines the maximum recording time in seconds.
  76355. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  76356. * @return A promise callback at the end of the recording with the video data in Blob.
  76357. */
  76358. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  76359. /**
  76360. * Releases internal resources used during the recording.
  76361. */
  76362. dispose(): void;
  76363. private _handleDataAvailable;
  76364. private _handleError;
  76365. private _handleStop;
  76366. }
  76367. }
  76368. declare module "babylonjs/Misc/screenshotTools" {
  76369. import { Camera } from "babylonjs/Cameras/camera";
  76370. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  76371. import { Engine } from "babylonjs/Engines/engine";
  76372. /**
  76373. * Class containing a set of static utilities functions for screenshots
  76374. */
  76375. export class ScreenshotTools {
  76376. /**
  76377. * Captures a screenshot of the current rendering
  76378. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76379. * @param engine defines the rendering engine
  76380. * @param camera defines the source camera
  76381. * @param size This parameter can be set to a single number or to an object with the
  76382. * following (optional) properties: precision, width, height. If a single number is passed,
  76383. * it will be used for both width and height. If an object is passed, the screenshot size
  76384. * will be derived from the parameters. The precision property is a multiplier allowing
  76385. * rendering at a higher or lower resolution
  76386. * @param successCallback defines the callback receives a single parameter which contains the
  76387. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76388. * src parameter of an <img> to display it
  76389. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76390. * Check your browser for supported MIME types
  76391. */
  76392. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  76393. /**
  76394. * Captures a screenshot of the current rendering
  76395. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76396. * @param engine defines the rendering engine
  76397. * @param camera defines the source camera
  76398. * @param size This parameter can be set to a single number or to an object with the
  76399. * following (optional) properties: precision, width, height. If a single number is passed,
  76400. * it will be used for both width and height. If an object is passed, the screenshot size
  76401. * will be derived from the parameters. The precision property is a multiplier allowing
  76402. * rendering at a higher or lower resolution
  76403. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  76404. * Check your browser for supported MIME types
  76405. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76406. * to the src parameter of an <img> to display it
  76407. */
  76408. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  76409. /**
  76410. * Generates an image screenshot from the specified camera.
  76411. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76412. * @param engine The engine to use for rendering
  76413. * @param camera The camera to use for rendering
  76414. * @param size This parameter can be set to a single number or to an object with the
  76415. * following (optional) properties: precision, width, height. If a single number is passed,
  76416. * it will be used for both width and height. If an object is passed, the screenshot size
  76417. * will be derived from the parameters. The precision property is a multiplier allowing
  76418. * rendering at a higher or lower resolution
  76419. * @param successCallback The callback receives a single parameter which contains the
  76420. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  76421. * src parameter of an <img> to display it
  76422. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76423. * Check your browser for supported MIME types
  76424. * @param samples Texture samples (default: 1)
  76425. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76426. * @param fileName A name for for the downloaded file.
  76427. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76428. */
  76429. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  76430. /**
  76431. * Generates an image screenshot from the specified camera.
  76432. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  76433. * @param engine The engine to use for rendering
  76434. * @param camera The camera to use for rendering
  76435. * @param size This parameter can be set to a single number or to an object with the
  76436. * following (optional) properties: precision, width, height. If a single number is passed,
  76437. * it will be used for both width and height. If an object is passed, the screenshot size
  76438. * will be derived from the parameters. The precision property is a multiplier allowing
  76439. * rendering at a higher or lower resolution
  76440. * @param mimeType The MIME type of the screenshot image (default: image/png).
  76441. * Check your browser for supported MIME types
  76442. * @param samples Texture samples (default: 1)
  76443. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  76444. * @param fileName A name for for the downloaded file.
  76445. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  76446. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  76447. * to the src parameter of an <img> to display it
  76448. */
  76449. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  76450. /**
  76451. * Gets height and width for screenshot size
  76452. * @private
  76453. */
  76454. private static _getScreenshotSize;
  76455. }
  76456. }
  76457. declare module "babylonjs/Misc/dataReader" {
  76458. /**
  76459. * Interface for a data buffer
  76460. */
  76461. export interface IDataBuffer {
  76462. /**
  76463. * Reads bytes from the data buffer.
  76464. * @param byteOffset The byte offset to read
  76465. * @param byteLength The byte length to read
  76466. * @returns A promise that resolves when the bytes are read
  76467. */
  76468. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  76469. /**
  76470. * The byte length of the buffer.
  76471. */
  76472. readonly byteLength: number;
  76473. }
  76474. /**
  76475. * Utility class for reading from a data buffer
  76476. */
  76477. export class DataReader {
  76478. /**
  76479. * The data buffer associated with this data reader.
  76480. */
  76481. readonly buffer: IDataBuffer;
  76482. /**
  76483. * The current byte offset from the beginning of the data buffer.
  76484. */
  76485. byteOffset: number;
  76486. private _dataView;
  76487. private _dataByteOffset;
  76488. /**
  76489. * Constructor
  76490. * @param buffer The buffer to read
  76491. */
  76492. constructor(buffer: IDataBuffer);
  76493. /**
  76494. * Loads the given byte length.
  76495. * @param byteLength The byte length to load
  76496. * @returns A promise that resolves when the load is complete
  76497. */
  76498. loadAsync(byteLength: number): Promise<void>;
  76499. /**
  76500. * Read a unsigned 32-bit integer from the currently loaded data range.
  76501. * @returns The 32-bit integer read
  76502. */
  76503. readUint32(): number;
  76504. /**
  76505. * Read a byte array from the currently loaded data range.
  76506. * @param byteLength The byte length to read
  76507. * @returns The byte array read
  76508. */
  76509. readUint8Array(byteLength: number): Uint8Array;
  76510. /**
  76511. * Read a string from the currently loaded data range.
  76512. * @param byteLength The byte length to read
  76513. * @returns The string read
  76514. */
  76515. readString(byteLength: number): string;
  76516. /**
  76517. * Skips the given byte length the currently loaded data range.
  76518. * @param byteLength The byte length to skip
  76519. */
  76520. skipBytes(byteLength: number): void;
  76521. }
  76522. }
  76523. declare module "babylonjs/Misc/dataStorage" {
  76524. /**
  76525. * Class for storing data to local storage if available or in-memory storage otherwise
  76526. */
  76527. export class DataStorage {
  76528. private static _Storage;
  76529. private static _GetStorage;
  76530. /**
  76531. * Reads a string from the data storage
  76532. * @param key The key to read
  76533. * @param defaultValue The value if the key doesn't exist
  76534. * @returns The string value
  76535. */
  76536. static ReadString(key: string, defaultValue: string): string;
  76537. /**
  76538. * Writes a string to the data storage
  76539. * @param key The key to write
  76540. * @param value The value to write
  76541. */
  76542. static WriteString(key: string, value: string): void;
  76543. /**
  76544. * Reads a boolean from the data storage
  76545. * @param key The key to read
  76546. * @param defaultValue The value if the key doesn't exist
  76547. * @returns The boolean value
  76548. */
  76549. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  76550. /**
  76551. * Writes a boolean to the data storage
  76552. * @param key The key to write
  76553. * @param value The value to write
  76554. */
  76555. static WriteBoolean(key: string, value: boolean): void;
  76556. /**
  76557. * Reads a number from the data storage
  76558. * @param key The key to read
  76559. * @param defaultValue The value if the key doesn't exist
  76560. * @returns The number value
  76561. */
  76562. static ReadNumber(key: string, defaultValue: number): number;
  76563. /**
  76564. * Writes a number to the data storage
  76565. * @param key The key to write
  76566. * @param value The value to write
  76567. */
  76568. static WriteNumber(key: string, value: number): void;
  76569. }
  76570. }
  76571. declare module "babylonjs/Misc/index" {
  76572. export * from "babylonjs/Misc/andOrNotEvaluator";
  76573. export * from "babylonjs/Misc/assetsManager";
  76574. export * from "babylonjs/Misc/basis";
  76575. export * from "babylonjs/Misc/dds";
  76576. export * from "babylonjs/Misc/decorators";
  76577. export * from "babylonjs/Misc/deferred";
  76578. export * from "babylonjs/Misc/environmentTextureTools";
  76579. export * from "babylonjs/Misc/meshExploder";
  76580. export * from "babylonjs/Misc/filesInput";
  76581. export * from "babylonjs/Misc/HighDynamicRange/index";
  76582. export * from "babylonjs/Misc/khronosTextureContainer";
  76583. export * from "babylonjs/Misc/observable";
  76584. export * from "babylonjs/Misc/performanceMonitor";
  76585. export * from "babylonjs/Misc/promise";
  76586. export * from "babylonjs/Misc/sceneOptimizer";
  76587. export * from "babylonjs/Misc/sceneSerializer";
  76588. export * from "babylonjs/Misc/smartArray";
  76589. export * from "babylonjs/Misc/stringDictionary";
  76590. export * from "babylonjs/Misc/tags";
  76591. export * from "babylonjs/Misc/textureTools";
  76592. export * from "babylonjs/Misc/tga";
  76593. export * from "babylonjs/Misc/tools";
  76594. export * from "babylonjs/Misc/videoRecorder";
  76595. export * from "babylonjs/Misc/virtualJoystick";
  76596. export * from "babylonjs/Misc/workerPool";
  76597. export * from "babylonjs/Misc/logger";
  76598. export * from "babylonjs/Misc/typeStore";
  76599. export * from "babylonjs/Misc/filesInputStore";
  76600. export * from "babylonjs/Misc/deepCopier";
  76601. export * from "babylonjs/Misc/pivotTools";
  76602. export * from "babylonjs/Misc/precisionDate";
  76603. export * from "babylonjs/Misc/screenshotTools";
  76604. export * from "babylonjs/Misc/typeStore";
  76605. export * from "babylonjs/Misc/webRequest";
  76606. export * from "babylonjs/Misc/iInspectable";
  76607. export * from "babylonjs/Misc/brdfTextureTools";
  76608. export * from "babylonjs/Misc/rgbdTextureTools";
  76609. export * from "babylonjs/Misc/gradients";
  76610. export * from "babylonjs/Misc/perfCounter";
  76611. export * from "babylonjs/Misc/fileRequest";
  76612. export * from "babylonjs/Misc/customAnimationFrameRequester";
  76613. export * from "babylonjs/Misc/retryStrategy";
  76614. export * from "babylonjs/Misc/interfaces/screenshotSize";
  76615. export * from "babylonjs/Misc/canvasGenerator";
  76616. export * from "babylonjs/Misc/fileTools";
  76617. export * from "babylonjs/Misc/stringTools";
  76618. export * from "babylonjs/Misc/dataReader";
  76619. export * from "babylonjs/Misc/minMaxReducer";
  76620. export * from "babylonjs/Misc/depthReducer";
  76621. export * from "babylonjs/Misc/dataStorage";
  76622. }
  76623. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  76624. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  76625. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76626. import { Observable } from "babylonjs/Misc/observable";
  76627. import { Matrix } from "babylonjs/Maths/math.vector";
  76628. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76629. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76630. /**
  76631. * An interface for all Hit test features
  76632. */
  76633. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76634. /**
  76635. * Triggered when new babylon (transformed) hit test results are available
  76636. */
  76637. onHitTestResultObservable: Observable<T[]>;
  76638. }
  76639. /**
  76640. * Options used for hit testing
  76641. */
  76642. export interface IWebXRLegacyHitTestOptions {
  76643. /**
  76644. * Only test when user interacted with the scene. Default - hit test every frame
  76645. */
  76646. testOnPointerDownOnly?: boolean;
  76647. /**
  76648. * The node to use to transform the local results to world coordinates
  76649. */
  76650. worldParentNode?: TransformNode;
  76651. }
  76652. /**
  76653. * Interface defining the babylon result of raycasting/hit-test
  76654. */
  76655. export interface IWebXRLegacyHitResult {
  76656. /**
  76657. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76658. */
  76659. transformationMatrix: Matrix;
  76660. /**
  76661. * The native hit test result
  76662. */
  76663. xrHitResult: XRHitResult | XRHitTestResult;
  76664. }
  76665. /**
  76666. * The currently-working hit-test module.
  76667. * Hit test (or Ray-casting) is used to interact with the real world.
  76668. * For further information read here - https://github.com/immersive-web/hit-test
  76669. */
  76670. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76671. /**
  76672. * options to use when constructing this feature
  76673. */
  76674. readonly options: IWebXRLegacyHitTestOptions;
  76675. private _direction;
  76676. private _mat;
  76677. private _onSelectEnabled;
  76678. private _origin;
  76679. /**
  76680. * The module's name
  76681. */
  76682. static readonly Name: string;
  76683. /**
  76684. * The (Babylon) version of this module.
  76685. * This is an integer representing the implementation version.
  76686. * This number does not correspond to the WebXR specs version
  76687. */
  76688. static readonly Version: number;
  76689. /**
  76690. * Populated with the last native XR Hit Results
  76691. */
  76692. lastNativeXRHitResults: XRHitResult[];
  76693. /**
  76694. * Triggered when new babylon (transformed) hit test results are available
  76695. */
  76696. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76697. /**
  76698. * Creates a new instance of the (legacy version) hit test feature
  76699. * @param _xrSessionManager an instance of WebXRSessionManager
  76700. * @param options options to use when constructing this feature
  76701. */
  76702. constructor(_xrSessionManager: WebXRSessionManager,
  76703. /**
  76704. * options to use when constructing this feature
  76705. */
  76706. options?: IWebXRLegacyHitTestOptions);
  76707. /**
  76708. * execute a hit test with an XR Ray
  76709. *
  76710. * @param xrSession a native xrSession that will execute this hit test
  76711. * @param xrRay the ray (position and direction) to use for ray-casting
  76712. * @param referenceSpace native XR reference space to use for the hit-test
  76713. * @param filter filter function that will filter the results
  76714. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76715. */
  76716. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76717. /**
  76718. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76719. * @param event the (select) event to use to select with
  76720. * @param referenceSpace the reference space to use for this hit test
  76721. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76722. */
  76723. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76724. /**
  76725. * attach this feature
  76726. * Will usually be called by the features manager
  76727. *
  76728. * @returns true if successful.
  76729. */
  76730. attach(): boolean;
  76731. /**
  76732. * detach this feature.
  76733. * Will usually be called by the features manager
  76734. *
  76735. * @returns true if successful.
  76736. */
  76737. detach(): boolean;
  76738. /**
  76739. * Dispose this feature and all of the resources attached
  76740. */
  76741. dispose(): void;
  76742. protected _onXRFrame(frame: XRFrame): void;
  76743. private _onHitTestResults;
  76744. private _onSelect;
  76745. }
  76746. }
  76747. declare module "babylonjs/XR/features/WebXRHitTest" {
  76748. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76749. import { Observable } from "babylonjs/Misc/observable";
  76750. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76751. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76752. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  76753. /**
  76754. * Options used for hit testing (version 2)
  76755. */
  76756. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76757. /**
  76758. * Do not create a permanent hit test. Will usually be used when only
  76759. * transient inputs are needed.
  76760. */
  76761. disablePermanentHitTest?: boolean;
  76762. /**
  76763. * Enable transient (for example touch-based) hit test inspections
  76764. */
  76765. enableTransientHitTest?: boolean;
  76766. /**
  76767. * Offset ray for the permanent hit test
  76768. */
  76769. offsetRay?: Vector3;
  76770. /**
  76771. * Offset ray for the transient hit test
  76772. */
  76773. transientOffsetRay?: Vector3;
  76774. /**
  76775. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76776. */
  76777. useReferenceSpace?: boolean;
  76778. }
  76779. /**
  76780. * Interface defining the babylon result of hit-test
  76781. */
  76782. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76783. /**
  76784. * The input source that generated this hit test (if transient)
  76785. */
  76786. inputSource?: XRInputSource;
  76787. /**
  76788. * Is this a transient hit test
  76789. */
  76790. isTransient?: boolean;
  76791. /**
  76792. * Position of the hit test result
  76793. */
  76794. position: Vector3;
  76795. /**
  76796. * Rotation of the hit test result
  76797. */
  76798. rotationQuaternion: Quaternion;
  76799. /**
  76800. * The native hit test result
  76801. */
  76802. xrHitResult: XRHitTestResult;
  76803. }
  76804. /**
  76805. * The currently-working hit-test module.
  76806. * Hit test (or Ray-casting) is used to interact with the real world.
  76807. * For further information read here - https://github.com/immersive-web/hit-test
  76808. *
  76809. * Tested on chrome (mobile) 80.
  76810. */
  76811. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76812. /**
  76813. * options to use when constructing this feature
  76814. */
  76815. readonly options: IWebXRHitTestOptions;
  76816. private _tmpMat;
  76817. private _tmpPos;
  76818. private _tmpQuat;
  76819. private _transientXrHitTestSource;
  76820. private _xrHitTestSource;
  76821. private initHitTestSource;
  76822. /**
  76823. * The module's name
  76824. */
  76825. static readonly Name: string;
  76826. /**
  76827. * The (Babylon) version of this module.
  76828. * This is an integer representing the implementation version.
  76829. * This number does not correspond to the WebXR specs version
  76830. */
  76831. static readonly Version: number;
  76832. /**
  76833. * When set to true, each hit test will have its own position/rotation objects
  76834. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76835. * the developers will clone them or copy them as they see fit.
  76836. */
  76837. autoCloneTransformation: boolean;
  76838. /**
  76839. * Triggered when new babylon (transformed) hit test results are available
  76840. */
  76841. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76842. /**
  76843. * Use this to temporarily pause hit test checks.
  76844. */
  76845. paused: boolean;
  76846. /**
  76847. * Creates a new instance of the hit test feature
  76848. * @param _xrSessionManager an instance of WebXRSessionManager
  76849. * @param options options to use when constructing this feature
  76850. */
  76851. constructor(_xrSessionManager: WebXRSessionManager,
  76852. /**
  76853. * options to use when constructing this feature
  76854. */
  76855. options?: IWebXRHitTestOptions);
  76856. /**
  76857. * attach this feature
  76858. * Will usually be called by the features manager
  76859. *
  76860. * @returns true if successful.
  76861. */
  76862. attach(): boolean;
  76863. /**
  76864. * detach this feature.
  76865. * Will usually be called by the features manager
  76866. *
  76867. * @returns true if successful.
  76868. */
  76869. detach(): boolean;
  76870. /**
  76871. * Dispose this feature and all of the resources attached
  76872. */
  76873. dispose(): void;
  76874. protected _onXRFrame(frame: XRFrame): void;
  76875. private _processWebXRHitTestResult;
  76876. }
  76877. }
  76878. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  76879. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  76880. import { Observable } from "babylonjs/Misc/observable";
  76881. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  76882. import { TransformNode } from "babylonjs/Meshes/transformNode";
  76883. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  76884. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  76885. /**
  76886. * Configuration options of the anchor system
  76887. */
  76888. export interface IWebXRAnchorSystemOptions {
  76889. /**
  76890. * a node that will be used to convert local to world coordinates
  76891. */
  76892. worldParentNode?: TransformNode;
  76893. /**
  76894. * If set to true a reference of the created anchors will be kept until the next session starts
  76895. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76896. */
  76897. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76898. }
  76899. /**
  76900. * A babylon container for an XR Anchor
  76901. */
  76902. export interface IWebXRAnchor {
  76903. /**
  76904. * A babylon-assigned ID for this anchor
  76905. */
  76906. id: number;
  76907. /**
  76908. * Transformation matrix to apply to an object attached to this anchor
  76909. */
  76910. transformationMatrix: Matrix;
  76911. /**
  76912. * The native anchor object
  76913. */
  76914. xrAnchor: XRAnchor;
  76915. /**
  76916. * if defined, this object will be constantly updated by the anchor's position and rotation
  76917. */
  76918. attachedNode?: TransformNode;
  76919. }
  76920. /**
  76921. * An implementation of the anchor system for WebXR.
  76922. * For further information see https://github.com/immersive-web/anchors/
  76923. */
  76924. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76925. private _options;
  76926. private _lastFrameDetected;
  76927. private _trackedAnchors;
  76928. private _referenceSpaceForFrameAnchors;
  76929. private _futureAnchors;
  76930. /**
  76931. * The module's name
  76932. */
  76933. static readonly Name: string;
  76934. /**
  76935. * The (Babylon) version of this module.
  76936. * This is an integer representing the implementation version.
  76937. * This number does not correspond to the WebXR specs version
  76938. */
  76939. static readonly Version: number;
  76940. /**
  76941. * Observers registered here will be executed when a new anchor was added to the session
  76942. */
  76943. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76944. /**
  76945. * Observers registered here will be executed when an anchor was removed from the session
  76946. */
  76947. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76948. /**
  76949. * Observers registered here will be executed when an existing anchor updates
  76950. * This can execute N times every frame
  76951. */
  76952. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76953. /**
  76954. * Set the reference space to use for anchor creation, when not using a hit test.
  76955. * Will default to the session's reference space if not defined
  76956. */
  76957. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76958. /**
  76959. * constructs a new anchor system
  76960. * @param _xrSessionManager an instance of WebXRSessionManager
  76961. * @param _options configuration object for this feature
  76962. */
  76963. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76964. private _tmpVector;
  76965. private _tmpQuaternion;
  76966. private _populateTmpTransformation;
  76967. /**
  76968. * Create a new anchor point using a hit test result at a specific point in the scene
  76969. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76970. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76971. *
  76972. * @param hitTestResult The hit test result to use for this anchor creation
  76973. * @param position an optional position offset for this anchor
  76974. * @param rotationQuaternion an optional rotation offset for this anchor
  76975. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76976. */
  76977. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76978. /**
  76979. * Add a new anchor at a specific position and rotation
  76980. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76981. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76982. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76983. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76984. *
  76985. * @param position the position in which to add an anchor
  76986. * @param rotationQuaternion an optional rotation for the anchor transformation
  76987. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76988. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76989. */
  76990. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76991. /**
  76992. * detach this feature.
  76993. * Will usually be called by the features manager
  76994. *
  76995. * @returns true if successful.
  76996. */
  76997. detach(): boolean;
  76998. /**
  76999. * Dispose this feature and all of the resources attached
  77000. */
  77001. dispose(): void;
  77002. protected _onXRFrame(frame: XRFrame): void;
  77003. /**
  77004. * avoiding using Array.find for global support.
  77005. * @param xrAnchor the plane to find in the array
  77006. */
  77007. private _findIndexInAnchorArray;
  77008. private _updateAnchorWithXRFrame;
  77009. private _createAnchorAtTransformation;
  77010. }
  77011. }
  77012. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77013. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77014. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77015. import { Observable } from "babylonjs/Misc/observable";
  77016. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77017. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77018. /**
  77019. * Options used in the plane detector module
  77020. */
  77021. export interface IWebXRPlaneDetectorOptions {
  77022. /**
  77023. * The node to use to transform the local results to world coordinates
  77024. */
  77025. worldParentNode?: TransformNode;
  77026. /**
  77027. * If set to true a reference of the created planes will be kept until the next session starts
  77028. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77029. */
  77030. doNotRemovePlanesOnSessionEnded?: boolean;
  77031. }
  77032. /**
  77033. * A babylon interface for a WebXR plane.
  77034. * A Plane is actually a polygon, built from N points in space
  77035. *
  77036. * Supported in chrome 79, not supported in canary 81 ATM
  77037. */
  77038. export interface IWebXRPlane {
  77039. /**
  77040. * a babylon-assigned ID for this polygon
  77041. */
  77042. id: number;
  77043. /**
  77044. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77045. */
  77046. polygonDefinition: Array<Vector3>;
  77047. /**
  77048. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77049. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77050. */
  77051. transformationMatrix: Matrix;
  77052. /**
  77053. * the native xr-plane object
  77054. */
  77055. xrPlane: XRPlane;
  77056. }
  77057. /**
  77058. * The plane detector is used to detect planes in the real world when in AR
  77059. * For more information see https://github.com/immersive-web/real-world-geometry/
  77060. */
  77061. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77062. private _options;
  77063. private _detectedPlanes;
  77064. private _enabled;
  77065. private _lastFrameDetected;
  77066. /**
  77067. * The module's name
  77068. */
  77069. static readonly Name: string;
  77070. /**
  77071. * The (Babylon) version of this module.
  77072. * This is an integer representing the implementation version.
  77073. * This number does not correspond to the WebXR specs version
  77074. */
  77075. static readonly Version: number;
  77076. /**
  77077. * Observers registered here will be executed when a new plane was added to the session
  77078. */
  77079. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77080. /**
  77081. * Observers registered here will be executed when a plane is no longer detected in the session
  77082. */
  77083. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77084. /**
  77085. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77086. * This can execute N times every frame
  77087. */
  77088. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77089. /**
  77090. * construct a new Plane Detector
  77091. * @param _xrSessionManager an instance of xr Session manager
  77092. * @param _options configuration to use when constructing this feature
  77093. */
  77094. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77095. /**
  77096. * detach this feature.
  77097. * Will usually be called by the features manager
  77098. *
  77099. * @returns true if successful.
  77100. */
  77101. detach(): boolean;
  77102. /**
  77103. * Dispose this feature and all of the resources attached
  77104. */
  77105. dispose(): void;
  77106. protected _onXRFrame(frame: XRFrame): void;
  77107. private _init;
  77108. private _updatePlaneWithXRPlane;
  77109. /**
  77110. * avoiding using Array.find for global support.
  77111. * @param xrPlane the plane to find in the array
  77112. */
  77113. private findIndexInPlaneArray;
  77114. }
  77115. }
  77116. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77117. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77118. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77119. import { Observable } from "babylonjs/Misc/observable";
  77120. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77121. /**
  77122. * Options interface for the background remover plugin
  77123. */
  77124. export interface IWebXRBackgroundRemoverOptions {
  77125. /**
  77126. * Further background meshes to disable when entering AR
  77127. */
  77128. backgroundMeshes?: AbstractMesh[];
  77129. /**
  77130. * flags to configure the removal of the environment helper.
  77131. * If not set, the entire background will be removed. If set, flags should be set as well.
  77132. */
  77133. environmentHelperRemovalFlags?: {
  77134. /**
  77135. * Should the skybox be removed (default false)
  77136. */
  77137. skyBox?: boolean;
  77138. /**
  77139. * Should the ground be removed (default false)
  77140. */
  77141. ground?: boolean;
  77142. };
  77143. /**
  77144. * don't disable the environment helper
  77145. */
  77146. ignoreEnvironmentHelper?: boolean;
  77147. }
  77148. /**
  77149. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77150. */
  77151. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77152. /**
  77153. * read-only options to be used in this module
  77154. */
  77155. readonly options: IWebXRBackgroundRemoverOptions;
  77156. /**
  77157. * The module's name
  77158. */
  77159. static readonly Name: string;
  77160. /**
  77161. * The (Babylon) version of this module.
  77162. * This is an integer representing the implementation version.
  77163. * This number does not correspond to the WebXR specs version
  77164. */
  77165. static readonly Version: number;
  77166. /**
  77167. * registered observers will be triggered when the background state changes
  77168. */
  77169. onBackgroundStateChangedObservable: Observable<boolean>;
  77170. /**
  77171. * constructs a new background remover module
  77172. * @param _xrSessionManager the session manager for this module
  77173. * @param options read-only options to be used in this module
  77174. */
  77175. constructor(_xrSessionManager: WebXRSessionManager,
  77176. /**
  77177. * read-only options to be used in this module
  77178. */
  77179. options?: IWebXRBackgroundRemoverOptions);
  77180. /**
  77181. * attach this feature
  77182. * Will usually be called by the features manager
  77183. *
  77184. * @returns true if successful.
  77185. */
  77186. attach(): boolean;
  77187. /**
  77188. * detach this feature.
  77189. * Will usually be called by the features manager
  77190. *
  77191. * @returns true if successful.
  77192. */
  77193. detach(): boolean;
  77194. /**
  77195. * Dispose this feature and all of the resources attached
  77196. */
  77197. dispose(): void;
  77198. protected _onXRFrame(_xrFrame: XRFrame): void;
  77199. private _setBackgroundState;
  77200. }
  77201. }
  77202. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77203. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77204. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77205. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77206. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77207. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77208. import { Nullable } from "babylonjs/types";
  77209. /**
  77210. * Options for the controller physics feature
  77211. */
  77212. export class IWebXRControllerPhysicsOptions {
  77213. /**
  77214. * Should the headset get its own impostor
  77215. */
  77216. enableHeadsetImpostor?: boolean;
  77217. /**
  77218. * Optional parameters for the headset impostor
  77219. */
  77220. headsetImpostorParams?: {
  77221. /**
  77222. * The type of impostor to create. Default is sphere
  77223. */
  77224. impostorType: number;
  77225. /**
  77226. * the size of the impostor. Defaults to 10cm
  77227. */
  77228. impostorSize?: number | {
  77229. width: number;
  77230. height: number;
  77231. depth: number;
  77232. };
  77233. /**
  77234. * Friction definitions
  77235. */
  77236. friction?: number;
  77237. /**
  77238. * Restitution
  77239. */
  77240. restitution?: number;
  77241. };
  77242. /**
  77243. * The physics properties of the future impostors
  77244. */
  77245. physicsProperties?: {
  77246. /**
  77247. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77248. * Note that this requires a physics engine that supports mesh impostors!
  77249. */
  77250. useControllerMesh?: boolean;
  77251. /**
  77252. * The type of impostor to create. Default is sphere
  77253. */
  77254. impostorType?: number;
  77255. /**
  77256. * the size of the impostor. Defaults to 10cm
  77257. */
  77258. impostorSize?: number | {
  77259. width: number;
  77260. height: number;
  77261. depth: number;
  77262. };
  77263. /**
  77264. * Friction definitions
  77265. */
  77266. friction?: number;
  77267. /**
  77268. * Restitution
  77269. */
  77270. restitution?: number;
  77271. };
  77272. /**
  77273. * the xr input to use with this pointer selection
  77274. */
  77275. xrInput: WebXRInput;
  77276. }
  77277. /**
  77278. * Add physics impostor to your webxr controllers,
  77279. * including naive calculation of their linear and angular velocity
  77280. */
  77281. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77282. private readonly _options;
  77283. private _attachController;
  77284. private _controllers;
  77285. private _debugMode;
  77286. private _delta;
  77287. private _headsetImpostor?;
  77288. private _headsetMesh?;
  77289. private _lastTimestamp;
  77290. private _tmpQuaternion;
  77291. private _tmpVector;
  77292. /**
  77293. * The module's name
  77294. */
  77295. static readonly Name: string;
  77296. /**
  77297. * The (Babylon) version of this module.
  77298. * This is an integer representing the implementation version.
  77299. * This number does not correspond to the webxr specs version
  77300. */
  77301. static readonly Version: number;
  77302. /**
  77303. * Construct a new Controller Physics Feature
  77304. * @param _xrSessionManager the corresponding xr session manager
  77305. * @param _options options to create this feature with
  77306. */
  77307. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77308. /**
  77309. * @hidden
  77310. * enable debugging - will show console outputs and the impostor mesh
  77311. */
  77312. _enablePhysicsDebug(): void;
  77313. /**
  77314. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77315. * @param xrController the controller to add
  77316. */
  77317. addController(xrController: WebXRInputSource): void;
  77318. /**
  77319. * attach this feature
  77320. * Will usually be called by the features manager
  77321. *
  77322. * @returns true if successful.
  77323. */
  77324. attach(): boolean;
  77325. /**
  77326. * detach this feature.
  77327. * Will usually be called by the features manager
  77328. *
  77329. * @returns true if successful.
  77330. */
  77331. detach(): boolean;
  77332. /**
  77333. * Get the headset impostor, if enabled
  77334. * @returns the impostor
  77335. */
  77336. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77337. /**
  77338. * Get the physics impostor of a specific controller.
  77339. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77340. * @param controller the controller or the controller id of which to get the impostor
  77341. * @returns the impostor or null
  77342. */
  77343. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77344. /**
  77345. * Update the physics properties provided in the constructor
  77346. * @param newProperties the new properties object
  77347. */
  77348. setPhysicsProperties(newProperties: {
  77349. impostorType?: number;
  77350. impostorSize?: number | {
  77351. width: number;
  77352. height: number;
  77353. depth: number;
  77354. };
  77355. friction?: number;
  77356. restitution?: number;
  77357. }): void;
  77358. protected _onXRFrame(_xrFrame: any): void;
  77359. private _detachController;
  77360. }
  77361. }
  77362. declare module "babylonjs/XR/features/index" {
  77363. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  77364. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  77365. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  77366. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  77367. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  77368. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  77369. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  77370. export * from "babylonjs/XR/features/WebXRHitTest";
  77371. }
  77372. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  77373. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77375. import { Scene } from "babylonjs/scene";
  77376. /**
  77377. * The motion controller class for all microsoft mixed reality controllers
  77378. */
  77379. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77380. protected readonly _mapping: {
  77381. defaultButton: {
  77382. valueNodeName: string;
  77383. unpressedNodeName: string;
  77384. pressedNodeName: string;
  77385. };
  77386. defaultAxis: {
  77387. valueNodeName: string;
  77388. minNodeName: string;
  77389. maxNodeName: string;
  77390. };
  77391. buttons: {
  77392. "xr-standard-trigger": {
  77393. rootNodeName: string;
  77394. componentProperty: string;
  77395. states: string[];
  77396. };
  77397. "xr-standard-squeeze": {
  77398. rootNodeName: string;
  77399. componentProperty: string;
  77400. states: string[];
  77401. };
  77402. "xr-standard-touchpad": {
  77403. rootNodeName: string;
  77404. labelAnchorNodeName: string;
  77405. touchPointNodeName: string;
  77406. };
  77407. "xr-standard-thumbstick": {
  77408. rootNodeName: string;
  77409. componentProperty: string;
  77410. states: string[];
  77411. };
  77412. };
  77413. axes: {
  77414. "xr-standard-touchpad": {
  77415. "x-axis": {
  77416. rootNodeName: string;
  77417. };
  77418. "y-axis": {
  77419. rootNodeName: string;
  77420. };
  77421. };
  77422. "xr-standard-thumbstick": {
  77423. "x-axis": {
  77424. rootNodeName: string;
  77425. };
  77426. "y-axis": {
  77427. rootNodeName: string;
  77428. };
  77429. };
  77430. };
  77431. };
  77432. /**
  77433. * The base url used to load the left and right controller models
  77434. */
  77435. static MODEL_BASE_URL: string;
  77436. /**
  77437. * The name of the left controller model file
  77438. */
  77439. static MODEL_LEFT_FILENAME: string;
  77440. /**
  77441. * The name of the right controller model file
  77442. */
  77443. static MODEL_RIGHT_FILENAME: string;
  77444. profileId: string;
  77445. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77446. protected _getFilenameAndPath(): {
  77447. filename: string;
  77448. path: string;
  77449. };
  77450. protected _getModelLoadingConstraints(): boolean;
  77451. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77452. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77453. protected _updateModel(): void;
  77454. }
  77455. }
  77456. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  77457. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77459. import { Scene } from "babylonjs/scene";
  77460. /**
  77461. * The motion controller class for oculus touch (quest, rift).
  77462. * This class supports legacy mapping as well the standard xr mapping
  77463. */
  77464. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77465. private _forceLegacyControllers;
  77466. private _modelRootNode;
  77467. /**
  77468. * The base url used to load the left and right controller models
  77469. */
  77470. static MODEL_BASE_URL: string;
  77471. /**
  77472. * The name of the left controller model file
  77473. */
  77474. static MODEL_LEFT_FILENAME: string;
  77475. /**
  77476. * The name of the right controller model file
  77477. */
  77478. static MODEL_RIGHT_FILENAME: string;
  77479. /**
  77480. * Base Url for the Quest controller model.
  77481. */
  77482. static QUEST_MODEL_BASE_URL: string;
  77483. profileId: string;
  77484. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77485. protected _getFilenameAndPath(): {
  77486. filename: string;
  77487. path: string;
  77488. };
  77489. protected _getModelLoadingConstraints(): boolean;
  77490. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77491. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77492. protected _updateModel(): void;
  77493. /**
  77494. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77495. * between the touch and touch 2.
  77496. */
  77497. private _isQuest;
  77498. }
  77499. }
  77500. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  77501. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77502. import { Scene } from "babylonjs/scene";
  77503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77504. /**
  77505. * The motion controller class for the standard HTC-Vive controllers
  77506. */
  77507. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77508. private _modelRootNode;
  77509. /**
  77510. * The base url used to load the left and right controller models
  77511. */
  77512. static MODEL_BASE_URL: string;
  77513. /**
  77514. * File name for the controller model.
  77515. */
  77516. static MODEL_FILENAME: string;
  77517. profileId: string;
  77518. /**
  77519. * Create a new Vive motion controller object
  77520. * @param scene the scene to use to create this controller
  77521. * @param gamepadObject the corresponding gamepad object
  77522. * @param handedness the handedness of the controller
  77523. */
  77524. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77525. protected _getFilenameAndPath(): {
  77526. filename: string;
  77527. path: string;
  77528. };
  77529. protected _getModelLoadingConstraints(): boolean;
  77530. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77531. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77532. protected _updateModel(): void;
  77533. }
  77534. }
  77535. declare module "babylonjs/XR/motionController/index" {
  77536. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  77537. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  77538. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  77539. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  77540. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  77541. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  77542. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  77543. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  77544. }
  77545. declare module "babylonjs/XR/index" {
  77546. export * from "babylonjs/XR/webXRCamera";
  77547. export * from "babylonjs/XR/webXREnterExitUI";
  77548. export * from "babylonjs/XR/webXRExperienceHelper";
  77549. export * from "babylonjs/XR/webXRInput";
  77550. export * from "babylonjs/XR/webXRInputSource";
  77551. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  77552. export * from "babylonjs/XR/webXRTypes";
  77553. export * from "babylonjs/XR/webXRSessionManager";
  77554. export * from "babylonjs/XR/webXRDefaultExperience";
  77555. export * from "babylonjs/XR/webXRFeaturesManager";
  77556. export * from "babylonjs/XR/features/index";
  77557. export * from "babylonjs/XR/motionController/index";
  77558. }
  77559. declare module "babylonjs/index" {
  77560. export * from "babylonjs/abstractScene";
  77561. export * from "babylonjs/Actions/index";
  77562. export * from "babylonjs/Animations/index";
  77563. export * from "babylonjs/assetContainer";
  77564. export * from "babylonjs/Audio/index";
  77565. export * from "babylonjs/Behaviors/index";
  77566. export * from "babylonjs/Bones/index";
  77567. export * from "babylonjs/Cameras/index";
  77568. export * from "babylonjs/Collisions/index";
  77569. export * from "babylonjs/Culling/index";
  77570. export * from "babylonjs/Debug/index";
  77571. export * from "babylonjs/DeviceInput/index";
  77572. export * from "babylonjs/Engines/index";
  77573. export * from "babylonjs/Events/index";
  77574. export * from "babylonjs/Gamepads/index";
  77575. export * from "babylonjs/Gizmos/index";
  77576. export * from "babylonjs/Helpers/index";
  77577. export * from "babylonjs/Instrumentation/index";
  77578. export * from "babylonjs/Layers/index";
  77579. export * from "babylonjs/LensFlares/index";
  77580. export * from "babylonjs/Lights/index";
  77581. export * from "babylonjs/Loading/index";
  77582. export * from "babylonjs/Materials/index";
  77583. export * from "babylonjs/Maths/index";
  77584. export * from "babylonjs/Meshes/index";
  77585. export * from "babylonjs/Morph/index";
  77586. export * from "babylonjs/Navigation/index";
  77587. export * from "babylonjs/node";
  77588. export * from "babylonjs/Offline/index";
  77589. export * from "babylonjs/Particles/index";
  77590. export * from "babylonjs/Physics/index";
  77591. export * from "babylonjs/PostProcesses/index";
  77592. export * from "babylonjs/Probes/index";
  77593. export * from "babylonjs/Rendering/index";
  77594. export * from "babylonjs/scene";
  77595. export * from "babylonjs/sceneComponent";
  77596. export * from "babylonjs/Sprites/index";
  77597. export * from "babylonjs/States/index";
  77598. export * from "babylonjs/Misc/index";
  77599. export * from "babylonjs/XR/index";
  77600. export * from "babylonjs/types";
  77601. }
  77602. declare module "babylonjs/Animations/pathCursor" {
  77603. import { Vector3 } from "babylonjs/Maths/math.vector";
  77604. import { Path2 } from "babylonjs/Maths/math.path";
  77605. /**
  77606. * A cursor which tracks a point on a path
  77607. */
  77608. export class PathCursor {
  77609. private path;
  77610. /**
  77611. * Stores path cursor callbacks for when an onchange event is triggered
  77612. */
  77613. private _onchange;
  77614. /**
  77615. * The value of the path cursor
  77616. */
  77617. value: number;
  77618. /**
  77619. * The animation array of the path cursor
  77620. */
  77621. animations: Animation[];
  77622. /**
  77623. * Initializes the path cursor
  77624. * @param path The path to track
  77625. */
  77626. constructor(path: Path2);
  77627. /**
  77628. * Gets the cursor point on the path
  77629. * @returns A point on the path cursor at the cursor location
  77630. */
  77631. getPoint(): Vector3;
  77632. /**
  77633. * Moves the cursor ahead by the step amount
  77634. * @param step The amount to move the cursor forward
  77635. * @returns This path cursor
  77636. */
  77637. moveAhead(step?: number): PathCursor;
  77638. /**
  77639. * Moves the cursor behind by the step amount
  77640. * @param step The amount to move the cursor back
  77641. * @returns This path cursor
  77642. */
  77643. moveBack(step?: number): PathCursor;
  77644. /**
  77645. * Moves the cursor by the step amount
  77646. * If the step amount is greater than one, an exception is thrown
  77647. * @param step The amount to move the cursor
  77648. * @returns This path cursor
  77649. */
  77650. move(step: number): PathCursor;
  77651. /**
  77652. * Ensures that the value is limited between zero and one
  77653. * @returns This path cursor
  77654. */
  77655. private ensureLimits;
  77656. /**
  77657. * Runs onchange callbacks on change (used by the animation engine)
  77658. * @returns This path cursor
  77659. */
  77660. private raiseOnChange;
  77661. /**
  77662. * Executes a function on change
  77663. * @param f A path cursor onchange callback
  77664. * @returns This path cursor
  77665. */
  77666. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77667. }
  77668. }
  77669. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  77670. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  77671. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  77672. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  77673. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  77674. }
  77675. declare module "babylonjs/Engines/Processors/Expressions/index" {
  77676. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  77677. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  77678. }
  77679. declare module "babylonjs/Engines/Processors/index" {
  77680. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  77681. export * from "babylonjs/Engines/Processors/Expressions/index";
  77682. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  77683. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  77684. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  77685. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  77686. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  77687. export * from "babylonjs/Engines/Processors/shaderProcessor";
  77688. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  77689. }
  77690. declare module "babylonjs/Legacy/legacy" {
  77691. import * as Babylon from "babylonjs/index";
  77692. export * from "babylonjs/index";
  77693. }
  77694. declare module "babylonjs/Shaders/blur.fragment" {
  77695. /** @hidden */
  77696. export var blurPixelShader: {
  77697. name: string;
  77698. shader: string;
  77699. };
  77700. }
  77701. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  77702. /** @hidden */
  77703. export var pointCloudVertexDeclaration: {
  77704. name: string;
  77705. shader: string;
  77706. };
  77707. }
  77708. declare module "babylonjs" {
  77709. export * from "babylonjs/Legacy/legacy";
  77710. }
  77711. declare module BABYLON {
  77712. /** Alias type for value that can be null */
  77713. export type Nullable<T> = T | null;
  77714. /**
  77715. * Alias type for number that are floats
  77716. * @ignorenaming
  77717. */
  77718. export type float = number;
  77719. /**
  77720. * Alias type for number that are doubles.
  77721. * @ignorenaming
  77722. */
  77723. export type double = number;
  77724. /**
  77725. * Alias type for number that are integer
  77726. * @ignorenaming
  77727. */
  77728. export type int = number;
  77729. /** Alias type for number array or Float32Array */
  77730. export type FloatArray = number[] | Float32Array;
  77731. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  77732. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  77733. /**
  77734. * Alias for types that can be used by a Buffer or VertexBuffer.
  77735. */
  77736. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  77737. /**
  77738. * Alias type for primitive types
  77739. * @ignorenaming
  77740. */
  77741. type Primitive = undefined | null | boolean | string | number | Function;
  77742. /**
  77743. * Type modifier to make all the properties of an object Readonly
  77744. */
  77745. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  77746. /**
  77747. * Type modifier to make all the properties of an object Readonly recursively
  77748. */
  77749. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  77750. /**
  77751. * Type modifier to make object properties readonly.
  77752. */
  77753. export type DeepImmutableObject<T> = {
  77754. readonly [K in keyof T]: DeepImmutable<T[K]>;
  77755. };
  77756. /** @hidden */
  77757. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  77758. }
  77759. }
  77760. declare module BABYLON {
  77761. /**
  77762. * A class serves as a medium between the observable and its observers
  77763. */
  77764. export class EventState {
  77765. /**
  77766. * Create a new EventState
  77767. * @param mask defines the mask associated with this state
  77768. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77769. * @param target defines the original target of the state
  77770. * @param currentTarget defines the current target of the state
  77771. */
  77772. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  77773. /**
  77774. * Initialize the current event state
  77775. * @param mask defines the mask associated with this state
  77776. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  77777. * @param target defines the original target of the state
  77778. * @param currentTarget defines the current target of the state
  77779. * @returns the current event state
  77780. */
  77781. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  77782. /**
  77783. * An Observer can set this property to true to prevent subsequent observers of being notified
  77784. */
  77785. skipNextObservers: boolean;
  77786. /**
  77787. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77788. */
  77789. mask: number;
  77790. /**
  77791. * The object that originally notified the event
  77792. */
  77793. target?: any;
  77794. /**
  77795. * The current object in the bubbling phase
  77796. */
  77797. currentTarget?: any;
  77798. /**
  77799. * This will be populated with the return value of the last function that was executed.
  77800. * If it is the first function in the callback chain it will be the event data.
  77801. */
  77802. lastReturnValue?: any;
  77803. }
  77804. /**
  77805. * Represent an Observer registered to a given Observable object.
  77806. */
  77807. export class Observer<T> {
  77808. /**
  77809. * Defines the callback to call when the observer is notified
  77810. */
  77811. callback: (eventData: T, eventState: EventState) => void;
  77812. /**
  77813. * Defines the mask of the observer (used to filter notifications)
  77814. */
  77815. mask: number;
  77816. /**
  77817. * Defines the current scope used to restore the JS context
  77818. */
  77819. scope: any;
  77820. /** @hidden */
  77821. _willBeUnregistered: boolean;
  77822. /**
  77823. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  77824. */
  77825. unregisterOnNextCall: boolean;
  77826. /**
  77827. * Creates a new observer
  77828. * @param callback defines the callback to call when the observer is notified
  77829. * @param mask defines the mask of the observer (used to filter notifications)
  77830. * @param scope defines the current scope used to restore the JS context
  77831. */
  77832. constructor(
  77833. /**
  77834. * Defines the callback to call when the observer is notified
  77835. */
  77836. callback: (eventData: T, eventState: EventState) => void,
  77837. /**
  77838. * Defines the mask of the observer (used to filter notifications)
  77839. */
  77840. mask: number,
  77841. /**
  77842. * Defines the current scope used to restore the JS context
  77843. */
  77844. scope?: any);
  77845. }
  77846. /**
  77847. * Represent a list of observers registered to multiple Observables object.
  77848. */
  77849. export class MultiObserver<T> {
  77850. private _observers;
  77851. private _observables;
  77852. /**
  77853. * Release associated resources
  77854. */
  77855. dispose(): void;
  77856. /**
  77857. * Raise a callback when one of the observable will notify
  77858. * @param observables defines a list of observables to watch
  77859. * @param callback defines the callback to call on notification
  77860. * @param mask defines the mask used to filter notifications
  77861. * @param scope defines the current scope used to restore the JS context
  77862. * @returns the new MultiObserver
  77863. */
  77864. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  77865. }
  77866. /**
  77867. * The Observable class is a simple implementation of the Observable pattern.
  77868. *
  77869. * 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.
  77870. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  77871. * 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).
  77872. * 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.
  77873. */
  77874. export class Observable<T> {
  77875. private _observers;
  77876. private _eventState;
  77877. private _onObserverAdded;
  77878. /**
  77879. * Gets the list of observers
  77880. */
  77881. get observers(): Array<Observer<T>>;
  77882. /**
  77883. * Creates a new observable
  77884. * @param onObserverAdded defines a callback to call when a new observer is added
  77885. */
  77886. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  77887. /**
  77888. * Create a new Observer with the specified callback
  77889. * @param callback the callback that will be executed for that Observer
  77890. * @param mask the mask used to filter observers
  77891. * @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.
  77892. * @param scope optional scope for the callback to be called from
  77893. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  77894. * @returns the new observer created for the callback
  77895. */
  77896. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  77897. /**
  77898. * Create a new Observer with the specified callback and unregisters after the next notification
  77899. * @param callback the callback that will be executed for that Observer
  77900. * @returns the new observer created for the callback
  77901. */
  77902. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  77903. /**
  77904. * Remove an Observer from the Observable object
  77905. * @param observer the instance of the Observer to remove
  77906. * @returns false if it doesn't belong to this Observable
  77907. */
  77908. remove(observer: Nullable<Observer<T>>): boolean;
  77909. /**
  77910. * Remove a callback from the Observable object
  77911. * @param callback the callback to remove
  77912. * @param scope optional scope. If used only the callbacks with this scope will be removed
  77913. * @returns false if it doesn't belong to this Observable
  77914. */
  77915. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  77916. private _deferUnregister;
  77917. private _remove;
  77918. /**
  77919. * Moves the observable to the top of the observer list making it get called first when notified
  77920. * @param observer the observer to move
  77921. */
  77922. makeObserverTopPriority(observer: Observer<T>): void;
  77923. /**
  77924. * Moves the observable to the bottom of the observer list making it get called last when notified
  77925. * @param observer the observer to move
  77926. */
  77927. makeObserverBottomPriority(observer: Observer<T>): void;
  77928. /**
  77929. * Notify all Observers by calling their respective callback with the given data
  77930. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  77931. * @param eventData defines the data to send to all observers
  77932. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  77933. * @param target defines the original target of the state
  77934. * @param currentTarget defines the current target of the state
  77935. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  77936. */
  77937. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  77938. /**
  77939. * Calling this will execute each callback, expecting it to be a promise or return a value.
  77940. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  77941. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  77942. * and it is crucial that all callbacks will be executed.
  77943. * The order of the callbacks is kept, callbacks are not executed parallel.
  77944. *
  77945. * @param eventData The data to be sent to each callback
  77946. * @param mask is used to filter observers defaults to -1
  77947. * @param target defines the callback target (see EventState)
  77948. * @param currentTarget defines he current object in the bubbling phase
  77949. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  77950. */
  77951. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  77952. /**
  77953. * Notify a specific observer
  77954. * @param observer defines the observer to notify
  77955. * @param eventData defines the data to be sent to each callback
  77956. * @param mask is used to filter observers defaults to -1
  77957. */
  77958. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  77959. /**
  77960. * Gets a boolean indicating if the observable has at least one observer
  77961. * @returns true is the Observable has at least one Observer registered
  77962. */
  77963. hasObservers(): boolean;
  77964. /**
  77965. * Clear the list of observers
  77966. */
  77967. clear(): void;
  77968. /**
  77969. * Clone the current observable
  77970. * @returns a new observable
  77971. */
  77972. clone(): Observable<T>;
  77973. /**
  77974. * Does this observable handles observer registered with a given mask
  77975. * @param mask defines the mask to be tested
  77976. * @return whether or not one observer registered with the given mask is handeled
  77977. **/
  77978. hasSpecificMask(mask?: number): boolean;
  77979. }
  77980. }
  77981. declare module BABYLON {
  77982. /**
  77983. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  77984. * Babylon.js
  77985. */
  77986. export class DomManagement {
  77987. /**
  77988. * Checks if the window object exists
  77989. * @returns true if the window object exists
  77990. */
  77991. static IsWindowObjectExist(): boolean;
  77992. /**
  77993. * Checks if the navigator object exists
  77994. * @returns true if the navigator object exists
  77995. */
  77996. static IsNavigatorAvailable(): boolean;
  77997. /**
  77998. * Check if the document object exists
  77999. * @returns true if the document object exists
  78000. */
  78001. static IsDocumentAvailable(): boolean;
  78002. /**
  78003. * Extracts text content from a DOM element hierarchy
  78004. * @param element defines the root element
  78005. * @returns a string
  78006. */
  78007. static GetDOMTextContent(element: HTMLElement): string;
  78008. }
  78009. }
  78010. declare module BABYLON {
  78011. /**
  78012. * Logger used througouht the application to allow configuration of
  78013. * the log level required for the messages.
  78014. */
  78015. export class Logger {
  78016. /**
  78017. * No log
  78018. */
  78019. static readonly NoneLogLevel: number;
  78020. /**
  78021. * Only message logs
  78022. */
  78023. static readonly MessageLogLevel: number;
  78024. /**
  78025. * Only warning logs
  78026. */
  78027. static readonly WarningLogLevel: number;
  78028. /**
  78029. * Only error logs
  78030. */
  78031. static readonly ErrorLogLevel: number;
  78032. /**
  78033. * All logs
  78034. */
  78035. static readonly AllLogLevel: number;
  78036. private static _LogCache;
  78037. /**
  78038. * Gets a value indicating the number of loading errors
  78039. * @ignorenaming
  78040. */
  78041. static errorsCount: number;
  78042. /**
  78043. * Callback called when a new log is added
  78044. */
  78045. static OnNewCacheEntry: (entry: string) => void;
  78046. private static _AddLogEntry;
  78047. private static _FormatMessage;
  78048. private static _LogDisabled;
  78049. private static _LogEnabled;
  78050. private static _WarnDisabled;
  78051. private static _WarnEnabled;
  78052. private static _ErrorDisabled;
  78053. private static _ErrorEnabled;
  78054. /**
  78055. * Log a message to the console
  78056. */
  78057. static Log: (message: string) => void;
  78058. /**
  78059. * Write a warning message to the console
  78060. */
  78061. static Warn: (message: string) => void;
  78062. /**
  78063. * Write an error message to the console
  78064. */
  78065. static Error: (message: string) => void;
  78066. /**
  78067. * Gets current log cache (list of logs)
  78068. */
  78069. static get LogCache(): string;
  78070. /**
  78071. * Clears the log cache
  78072. */
  78073. static ClearLogCache(): void;
  78074. /**
  78075. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78076. */
  78077. static set LogLevels(level: number);
  78078. }
  78079. }
  78080. declare module BABYLON {
  78081. /** @hidden */
  78082. export class _TypeStore {
  78083. /** @hidden */
  78084. static RegisteredTypes: {
  78085. [key: string]: Object;
  78086. };
  78087. /** @hidden */
  78088. static GetClass(fqdn: string): any;
  78089. }
  78090. }
  78091. declare module BABYLON {
  78092. /**
  78093. * Helper to manipulate strings
  78094. */
  78095. export class StringTools {
  78096. /**
  78097. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78098. * @param str Source string
  78099. * @param suffix Suffix to search for in the source string
  78100. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78101. */
  78102. static EndsWith(str: string, suffix: string): boolean;
  78103. /**
  78104. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78105. * @param str Source string
  78106. * @param suffix Suffix to search for in the source string
  78107. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78108. */
  78109. static StartsWith(str: string, suffix: string): boolean;
  78110. /**
  78111. * Decodes a buffer into a string
  78112. * @param buffer The buffer to decode
  78113. * @returns The decoded string
  78114. */
  78115. static Decode(buffer: Uint8Array | Uint16Array): string;
  78116. /**
  78117. * Encode a buffer to a base64 string
  78118. * @param buffer defines the buffer to encode
  78119. * @returns the encoded string
  78120. */
  78121. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78122. /**
  78123. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78124. * @param num the number to convert and pad
  78125. * @param length the expected length of the string
  78126. * @returns the padded string
  78127. */
  78128. static PadNumber(num: number, length: number): string;
  78129. }
  78130. }
  78131. declare module BABYLON {
  78132. /**
  78133. * Class containing a set of static utilities functions for deep copy.
  78134. */
  78135. export class DeepCopier {
  78136. /**
  78137. * Tries to copy an object by duplicating every property
  78138. * @param source defines the source object
  78139. * @param destination defines the target object
  78140. * @param doNotCopyList defines a list of properties to avoid
  78141. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78142. */
  78143. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78144. }
  78145. }
  78146. declare module BABYLON {
  78147. /**
  78148. * Class containing a set of static utilities functions for precision date
  78149. */
  78150. export class PrecisionDate {
  78151. /**
  78152. * Gets either window.performance.now() if supported or Date.now() else
  78153. */
  78154. static get Now(): number;
  78155. }
  78156. }
  78157. declare module BABYLON {
  78158. /** @hidden */
  78159. export class _DevTools {
  78160. static WarnImport(name: string): string;
  78161. }
  78162. }
  78163. declare module BABYLON {
  78164. /**
  78165. * Interface used to define the mechanism to get data from the network
  78166. */
  78167. export interface IWebRequest {
  78168. /**
  78169. * Returns client's response url
  78170. */
  78171. responseURL: string;
  78172. /**
  78173. * Returns client's status
  78174. */
  78175. status: number;
  78176. /**
  78177. * Returns client's status as a text
  78178. */
  78179. statusText: string;
  78180. }
  78181. }
  78182. declare module BABYLON {
  78183. /**
  78184. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78185. */
  78186. export class WebRequest implements IWebRequest {
  78187. private _xhr;
  78188. /**
  78189. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78190. * i.e. when loading files, where the server/service expects an Authorization header
  78191. */
  78192. static CustomRequestHeaders: {
  78193. [key: string]: string;
  78194. };
  78195. /**
  78196. * Add callback functions in this array to update all the requests before they get sent to the network
  78197. */
  78198. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78199. private _injectCustomRequestHeaders;
  78200. /**
  78201. * Gets or sets a function to be called when loading progress changes
  78202. */
  78203. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78204. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78205. /**
  78206. * Returns client's state
  78207. */
  78208. get readyState(): number;
  78209. /**
  78210. * Returns client's status
  78211. */
  78212. get status(): number;
  78213. /**
  78214. * Returns client's status as a text
  78215. */
  78216. get statusText(): string;
  78217. /**
  78218. * Returns client's response
  78219. */
  78220. get response(): any;
  78221. /**
  78222. * Returns client's response url
  78223. */
  78224. get responseURL(): string;
  78225. /**
  78226. * Returns client's response as text
  78227. */
  78228. get responseText(): string;
  78229. /**
  78230. * Gets or sets the expected response type
  78231. */
  78232. get responseType(): XMLHttpRequestResponseType;
  78233. set responseType(value: XMLHttpRequestResponseType);
  78234. /** @hidden */
  78235. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78236. /** @hidden */
  78237. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78238. /**
  78239. * Cancels any network activity
  78240. */
  78241. abort(): void;
  78242. /**
  78243. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78244. * @param body defines an optional request body
  78245. */
  78246. send(body?: Document | BodyInit | null): void;
  78247. /**
  78248. * Sets the request method, request URL
  78249. * @param method defines the method to use (GET, POST, etc..)
  78250. * @param url defines the url to connect with
  78251. */
  78252. open(method: string, url: string): void;
  78253. /**
  78254. * Sets the value of a request header.
  78255. * @param name The name of the header whose value is to be set
  78256. * @param value The value to set as the body of the header
  78257. */
  78258. setRequestHeader(name: string, value: string): void;
  78259. /**
  78260. * Get the string containing the text of a particular header's value.
  78261. * @param name The name of the header
  78262. * @returns The string containing the text of the given header name
  78263. */
  78264. getResponseHeader(name: string): Nullable<string>;
  78265. }
  78266. }
  78267. declare module BABYLON {
  78268. /**
  78269. * File request interface
  78270. */
  78271. export interface IFileRequest {
  78272. /**
  78273. * Raised when the request is complete (success or error).
  78274. */
  78275. onCompleteObservable: Observable<IFileRequest>;
  78276. /**
  78277. * Aborts the request for a file.
  78278. */
  78279. abort: () => void;
  78280. }
  78281. }
  78282. declare module BABYLON {
  78283. /**
  78284. * Define options used to create a render target texture
  78285. */
  78286. export class RenderTargetCreationOptions {
  78287. /**
  78288. * Specifies is mipmaps must be generated
  78289. */
  78290. generateMipMaps?: boolean;
  78291. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78292. generateDepthBuffer?: boolean;
  78293. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78294. generateStencilBuffer?: boolean;
  78295. /** Defines texture type (int by default) */
  78296. type?: number;
  78297. /** Defines sampling mode (trilinear by default) */
  78298. samplingMode?: number;
  78299. /** Defines format (RGBA by default) */
  78300. format?: number;
  78301. }
  78302. }
  78303. declare module BABYLON {
  78304. /** Defines the cross module used constants to avoid circular dependncies */
  78305. export class Constants {
  78306. /** Defines that alpha blending is disabled */
  78307. static readonly ALPHA_DISABLE: number;
  78308. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78309. static readonly ALPHA_ADD: number;
  78310. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78311. static readonly ALPHA_COMBINE: number;
  78312. /** Defines that alpha blending is DEST - SRC * DEST */
  78313. static readonly ALPHA_SUBTRACT: number;
  78314. /** Defines that alpha blending is SRC * DEST */
  78315. static readonly ALPHA_MULTIPLY: number;
  78316. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78317. static readonly ALPHA_MAXIMIZED: number;
  78318. /** Defines that alpha blending is SRC + DEST */
  78319. static readonly ALPHA_ONEONE: number;
  78320. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78321. static readonly ALPHA_PREMULTIPLIED: number;
  78322. /**
  78323. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78324. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78325. */
  78326. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78327. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78328. static readonly ALPHA_INTERPOLATE: number;
  78329. /**
  78330. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78331. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78332. */
  78333. static readonly ALPHA_SCREENMODE: number;
  78334. /**
  78335. * Defines that alpha blending is SRC + DST
  78336. * Alpha will be set to SRC ALPHA + DST ALPHA
  78337. */
  78338. static readonly ALPHA_ONEONE_ONEONE: number;
  78339. /**
  78340. * Defines that alpha blending is SRC * DST ALPHA + DST
  78341. * Alpha will be set to 0
  78342. */
  78343. static readonly ALPHA_ALPHATOCOLOR: number;
  78344. /**
  78345. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78346. */
  78347. static readonly ALPHA_REVERSEONEMINUS: number;
  78348. /**
  78349. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  78350. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  78351. */
  78352. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  78353. /**
  78354. * Defines that alpha blending is SRC + DST
  78355. * Alpha will be set to SRC ALPHA
  78356. */
  78357. static readonly ALPHA_ONEONE_ONEZERO: number;
  78358. /**
  78359. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78360. * Alpha will be set to DST ALPHA
  78361. */
  78362. static readonly ALPHA_EXCLUSION: number;
  78363. /** Defines that alpha blending equation a SUM */
  78364. static readonly ALPHA_EQUATION_ADD: number;
  78365. /** Defines that alpha blending equation a SUBSTRACTION */
  78366. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  78367. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  78368. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  78369. /** Defines that alpha blending equation a MAX operation */
  78370. static readonly ALPHA_EQUATION_MAX: number;
  78371. /** Defines that alpha blending equation a MIN operation */
  78372. static readonly ALPHA_EQUATION_MIN: number;
  78373. /**
  78374. * Defines that alpha blending equation a DARKEN operation:
  78375. * It takes the min of the src and sums the alpha channels.
  78376. */
  78377. static readonly ALPHA_EQUATION_DARKEN: number;
  78378. /** Defines that the ressource is not delayed*/
  78379. static readonly DELAYLOADSTATE_NONE: number;
  78380. /** Defines that the ressource was successfully delay loaded */
  78381. static readonly DELAYLOADSTATE_LOADED: number;
  78382. /** Defines that the ressource is currently delay loading */
  78383. static readonly DELAYLOADSTATE_LOADING: number;
  78384. /** Defines that the ressource is delayed and has not started loading */
  78385. static readonly DELAYLOADSTATE_NOTLOADED: number;
  78386. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  78387. static readonly NEVER: number;
  78388. /** 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 */
  78389. static readonly ALWAYS: number;
  78390. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  78391. static readonly LESS: number;
  78392. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  78393. static readonly EQUAL: number;
  78394. /** 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 */
  78395. static readonly LEQUAL: number;
  78396. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  78397. static readonly GREATER: number;
  78398. /** 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 */
  78399. static readonly GEQUAL: number;
  78400. /** 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 */
  78401. static readonly NOTEQUAL: number;
  78402. /** Passed to stencilOperation to specify that stencil value must be kept */
  78403. static readonly KEEP: number;
  78404. /** Passed to stencilOperation to specify that stencil value must be replaced */
  78405. static readonly REPLACE: number;
  78406. /** Passed to stencilOperation to specify that stencil value must be incremented */
  78407. static readonly INCR: number;
  78408. /** Passed to stencilOperation to specify that stencil value must be decremented */
  78409. static readonly DECR: number;
  78410. /** Passed to stencilOperation to specify that stencil value must be inverted */
  78411. static readonly INVERT: number;
  78412. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  78413. static readonly INCR_WRAP: number;
  78414. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  78415. static readonly DECR_WRAP: number;
  78416. /** Texture is not repeating outside of 0..1 UVs */
  78417. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  78418. /** Texture is repeating outside of 0..1 UVs */
  78419. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  78420. /** Texture is repeating and mirrored */
  78421. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  78422. /** ALPHA */
  78423. static readonly TEXTUREFORMAT_ALPHA: number;
  78424. /** LUMINANCE */
  78425. static readonly TEXTUREFORMAT_LUMINANCE: number;
  78426. /** LUMINANCE_ALPHA */
  78427. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78428. /** RGB */
  78429. static readonly TEXTUREFORMAT_RGB: number;
  78430. /** RGBA */
  78431. static readonly TEXTUREFORMAT_RGBA: number;
  78432. /** RED */
  78433. static readonly TEXTUREFORMAT_RED: number;
  78434. /** RED (2nd reference) */
  78435. static readonly TEXTUREFORMAT_R: number;
  78436. /** RG */
  78437. static readonly TEXTUREFORMAT_RG: number;
  78438. /** RED_INTEGER */
  78439. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  78440. /** RED_INTEGER (2nd reference) */
  78441. static readonly TEXTUREFORMAT_R_INTEGER: number;
  78442. /** RG_INTEGER */
  78443. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  78444. /** RGB_INTEGER */
  78445. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  78446. /** RGBA_INTEGER */
  78447. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  78448. /** UNSIGNED_BYTE */
  78449. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  78450. /** UNSIGNED_BYTE (2nd reference) */
  78451. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  78452. /** FLOAT */
  78453. static readonly TEXTURETYPE_FLOAT: number;
  78454. /** HALF_FLOAT */
  78455. static readonly TEXTURETYPE_HALF_FLOAT: number;
  78456. /** BYTE */
  78457. static readonly TEXTURETYPE_BYTE: number;
  78458. /** SHORT */
  78459. static readonly TEXTURETYPE_SHORT: number;
  78460. /** UNSIGNED_SHORT */
  78461. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  78462. /** INT */
  78463. static readonly TEXTURETYPE_INT: number;
  78464. /** UNSIGNED_INT */
  78465. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  78466. /** UNSIGNED_SHORT_4_4_4_4 */
  78467. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  78468. /** UNSIGNED_SHORT_5_5_5_1 */
  78469. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  78470. /** UNSIGNED_SHORT_5_6_5 */
  78471. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  78472. /** UNSIGNED_INT_2_10_10_10_REV */
  78473. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  78474. /** UNSIGNED_INT_24_8 */
  78475. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  78476. /** UNSIGNED_INT_10F_11F_11F_REV */
  78477. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  78478. /** UNSIGNED_INT_5_9_9_9_REV */
  78479. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  78480. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  78481. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  78482. /** nearest is mag = nearest and min = nearest and no mip */
  78483. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  78484. /** mag = nearest and min = nearest and mip = none */
  78485. static readonly TEXTURE_NEAREST_NEAREST: number;
  78486. /** Bilinear is mag = linear and min = linear and no mip */
  78487. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  78488. /** mag = linear and min = linear and mip = none */
  78489. static readonly TEXTURE_LINEAR_LINEAR: number;
  78490. /** Trilinear is mag = linear and min = linear and mip = linear */
  78491. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  78492. /** Trilinear is mag = linear and min = linear and mip = linear */
  78493. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  78494. /** mag = nearest and min = nearest and mip = nearest */
  78495. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  78496. /** mag = nearest and min = linear and mip = nearest */
  78497. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  78498. /** mag = nearest and min = linear and mip = linear */
  78499. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  78500. /** mag = nearest and min = linear and mip = none */
  78501. static readonly TEXTURE_NEAREST_LINEAR: number;
  78502. /** nearest is mag = nearest and min = nearest and mip = linear */
  78503. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  78504. /** mag = linear and min = nearest and mip = nearest */
  78505. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  78506. /** mag = linear and min = nearest and mip = linear */
  78507. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  78508. /** Bilinear is mag = linear and min = linear and mip = nearest */
  78509. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  78510. /** mag = linear and min = nearest and mip = none */
  78511. static readonly TEXTURE_LINEAR_NEAREST: number;
  78512. /** Explicit coordinates mode */
  78513. static readonly TEXTURE_EXPLICIT_MODE: number;
  78514. /** Spherical coordinates mode */
  78515. static readonly TEXTURE_SPHERICAL_MODE: number;
  78516. /** Planar coordinates mode */
  78517. static readonly TEXTURE_PLANAR_MODE: number;
  78518. /** Cubic coordinates mode */
  78519. static readonly TEXTURE_CUBIC_MODE: number;
  78520. /** Projection coordinates mode */
  78521. static readonly TEXTURE_PROJECTION_MODE: number;
  78522. /** Skybox coordinates mode */
  78523. static readonly TEXTURE_SKYBOX_MODE: number;
  78524. /** Inverse Cubic coordinates mode */
  78525. static readonly TEXTURE_INVCUBIC_MODE: number;
  78526. /** Equirectangular coordinates mode */
  78527. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  78528. /** Equirectangular Fixed coordinates mode */
  78529. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  78530. /** Equirectangular Fixed Mirrored coordinates mode */
  78531. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  78532. /** Offline (baking) quality for texture filtering */
  78533. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  78534. /** High quality for texture filtering */
  78535. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  78536. /** Medium quality for texture filtering */
  78537. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  78538. /** Low quality for texture filtering */
  78539. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  78540. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  78541. static readonly SCALEMODE_FLOOR: number;
  78542. /** Defines that texture rescaling will look for the nearest power of 2 size */
  78543. static readonly SCALEMODE_NEAREST: number;
  78544. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  78545. static readonly SCALEMODE_CEILING: number;
  78546. /**
  78547. * The dirty texture flag value
  78548. */
  78549. static readonly MATERIAL_TextureDirtyFlag: number;
  78550. /**
  78551. * The dirty light flag value
  78552. */
  78553. static readonly MATERIAL_LightDirtyFlag: number;
  78554. /**
  78555. * The dirty fresnel flag value
  78556. */
  78557. static readonly MATERIAL_FresnelDirtyFlag: number;
  78558. /**
  78559. * The dirty attribute flag value
  78560. */
  78561. static readonly MATERIAL_AttributesDirtyFlag: number;
  78562. /**
  78563. * The dirty misc flag value
  78564. */
  78565. static readonly MATERIAL_MiscDirtyFlag: number;
  78566. /**
  78567. * The all dirty flag value
  78568. */
  78569. static readonly MATERIAL_AllDirtyFlag: number;
  78570. /**
  78571. * Returns the triangle fill mode
  78572. */
  78573. static readonly MATERIAL_TriangleFillMode: number;
  78574. /**
  78575. * Returns the wireframe mode
  78576. */
  78577. static readonly MATERIAL_WireFrameFillMode: number;
  78578. /**
  78579. * Returns the point fill mode
  78580. */
  78581. static readonly MATERIAL_PointFillMode: number;
  78582. /**
  78583. * Returns the point list draw mode
  78584. */
  78585. static readonly MATERIAL_PointListDrawMode: number;
  78586. /**
  78587. * Returns the line list draw mode
  78588. */
  78589. static readonly MATERIAL_LineListDrawMode: number;
  78590. /**
  78591. * Returns the line loop draw mode
  78592. */
  78593. static readonly MATERIAL_LineLoopDrawMode: number;
  78594. /**
  78595. * Returns the line strip draw mode
  78596. */
  78597. static readonly MATERIAL_LineStripDrawMode: number;
  78598. /**
  78599. * Returns the triangle strip draw mode
  78600. */
  78601. static readonly MATERIAL_TriangleStripDrawMode: number;
  78602. /**
  78603. * Returns the triangle fan draw mode
  78604. */
  78605. static readonly MATERIAL_TriangleFanDrawMode: number;
  78606. /**
  78607. * Stores the clock-wise side orientation
  78608. */
  78609. static readonly MATERIAL_ClockWiseSideOrientation: number;
  78610. /**
  78611. * Stores the counter clock-wise side orientation
  78612. */
  78613. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  78614. /**
  78615. * Nothing
  78616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78617. */
  78618. static readonly ACTION_NothingTrigger: number;
  78619. /**
  78620. * On pick
  78621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78622. */
  78623. static readonly ACTION_OnPickTrigger: number;
  78624. /**
  78625. * On left pick
  78626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78627. */
  78628. static readonly ACTION_OnLeftPickTrigger: number;
  78629. /**
  78630. * On right pick
  78631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78632. */
  78633. static readonly ACTION_OnRightPickTrigger: number;
  78634. /**
  78635. * On center pick
  78636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78637. */
  78638. static readonly ACTION_OnCenterPickTrigger: number;
  78639. /**
  78640. * On pick down
  78641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78642. */
  78643. static readonly ACTION_OnPickDownTrigger: number;
  78644. /**
  78645. * On double pick
  78646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78647. */
  78648. static readonly ACTION_OnDoublePickTrigger: number;
  78649. /**
  78650. * On pick up
  78651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78652. */
  78653. static readonly ACTION_OnPickUpTrigger: number;
  78654. /**
  78655. * On pick out.
  78656. * This trigger will only be raised if you also declared a OnPickDown
  78657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78658. */
  78659. static readonly ACTION_OnPickOutTrigger: number;
  78660. /**
  78661. * On long press
  78662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78663. */
  78664. static readonly ACTION_OnLongPressTrigger: number;
  78665. /**
  78666. * On pointer over
  78667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78668. */
  78669. static readonly ACTION_OnPointerOverTrigger: number;
  78670. /**
  78671. * On pointer out
  78672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78673. */
  78674. static readonly ACTION_OnPointerOutTrigger: number;
  78675. /**
  78676. * On every frame
  78677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78678. */
  78679. static readonly ACTION_OnEveryFrameTrigger: number;
  78680. /**
  78681. * On intersection enter
  78682. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78683. */
  78684. static readonly ACTION_OnIntersectionEnterTrigger: number;
  78685. /**
  78686. * On intersection exit
  78687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78688. */
  78689. static readonly ACTION_OnIntersectionExitTrigger: number;
  78690. /**
  78691. * On key down
  78692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78693. */
  78694. static readonly ACTION_OnKeyDownTrigger: number;
  78695. /**
  78696. * On key up
  78697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78698. */
  78699. static readonly ACTION_OnKeyUpTrigger: number;
  78700. /**
  78701. * Billboard mode will only apply to Y axis
  78702. */
  78703. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  78704. /**
  78705. * Billboard mode will apply to all axes
  78706. */
  78707. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  78708. /**
  78709. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  78710. */
  78711. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  78712. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78713. * Test order :
  78714. * Is the bounding sphere outside the frustum ?
  78715. * If not, are the bounding box vertices outside the frustum ?
  78716. * It not, then the cullable object is in the frustum.
  78717. */
  78718. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  78719. /** Culling strategy : Bounding Sphere Only.
  78720. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78721. * It's also less accurate than the standard because some not visible objects can still be selected.
  78722. * Test : is the bounding sphere outside the frustum ?
  78723. * If not, then the cullable object is in the frustum.
  78724. */
  78725. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78726. /** Culling strategy : Optimistic Inclusion.
  78727. * This in an inclusion test first, then the standard exclusion test.
  78728. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78729. * 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.
  78730. * Anyway, it's as accurate as the standard strategy.
  78731. * Test :
  78732. * Is the cullable object bounding sphere center in the frustum ?
  78733. * If not, apply the default culling strategy.
  78734. */
  78735. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78736. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78737. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78738. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78739. * 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.
  78740. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78741. * Test :
  78742. * Is the cullable object bounding sphere center in the frustum ?
  78743. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78744. */
  78745. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78746. /**
  78747. * No logging while loading
  78748. */
  78749. static readonly SCENELOADER_NO_LOGGING: number;
  78750. /**
  78751. * Minimal logging while loading
  78752. */
  78753. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  78754. /**
  78755. * Summary logging while loading
  78756. */
  78757. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  78758. /**
  78759. * Detailled logging while loading
  78760. */
  78761. static readonly SCENELOADER_DETAILED_LOGGING: number;
  78762. }
  78763. }
  78764. declare module BABYLON {
  78765. /**
  78766. * This represents the required contract to create a new type of texture loader.
  78767. */
  78768. export interface IInternalTextureLoader {
  78769. /**
  78770. * Defines wether the loader supports cascade loading the different faces.
  78771. */
  78772. supportCascades: boolean;
  78773. /**
  78774. * This returns if the loader support the current file information.
  78775. * @param extension defines the file extension of the file being loaded
  78776. * @returns true if the loader can load the specified file
  78777. */
  78778. canLoad(extension: string): boolean;
  78779. /**
  78780. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  78781. * @param data contains the texture data
  78782. * @param texture defines the BabylonJS internal texture
  78783. * @param createPolynomials will be true if polynomials have been requested
  78784. * @param onLoad defines the callback to trigger once the texture is ready
  78785. * @param onError defines the callback to trigger in case of error
  78786. */
  78787. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  78788. /**
  78789. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  78790. * @param data contains the texture data
  78791. * @param texture defines the BabylonJS internal texture
  78792. * @param callback defines the method to call once ready to upload
  78793. */
  78794. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  78795. }
  78796. }
  78797. declare module BABYLON {
  78798. /**
  78799. * Class used to store and describe the pipeline context associated with an effect
  78800. */
  78801. export interface IPipelineContext {
  78802. /**
  78803. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  78804. */
  78805. isAsync: boolean;
  78806. /**
  78807. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  78808. */
  78809. isReady: boolean;
  78810. /** @hidden */
  78811. _getVertexShaderCode(): string | null;
  78812. /** @hidden */
  78813. _getFragmentShaderCode(): string | null;
  78814. /** @hidden */
  78815. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  78816. }
  78817. }
  78818. declare module BABYLON {
  78819. /**
  78820. * Class used to store gfx data (like WebGLBuffer)
  78821. */
  78822. export class DataBuffer {
  78823. /**
  78824. * Gets or sets the number of objects referencing this buffer
  78825. */
  78826. references: number;
  78827. /** Gets or sets the size of the underlying buffer */
  78828. capacity: number;
  78829. /**
  78830. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  78831. */
  78832. is32Bits: boolean;
  78833. /**
  78834. * Gets the underlying buffer
  78835. */
  78836. get underlyingResource(): any;
  78837. }
  78838. }
  78839. declare module BABYLON {
  78840. /** @hidden */
  78841. export interface IShaderProcessor {
  78842. attributeProcessor?: (attribute: string) => string;
  78843. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  78844. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  78845. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  78846. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  78847. lineProcessor?: (line: string, isFragment: boolean) => string;
  78848. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78849. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  78850. }
  78851. }
  78852. declare module BABYLON {
  78853. /** @hidden */
  78854. export interface ProcessingOptions {
  78855. defines: string[];
  78856. indexParameters: any;
  78857. isFragment: boolean;
  78858. shouldUseHighPrecisionShader: boolean;
  78859. supportsUniformBuffers: boolean;
  78860. shadersRepository: string;
  78861. includesShadersStore: {
  78862. [key: string]: string;
  78863. };
  78864. processor?: IShaderProcessor;
  78865. version: string;
  78866. platformName: string;
  78867. lookForClosingBracketForUniformBuffer?: boolean;
  78868. }
  78869. }
  78870. declare module BABYLON {
  78871. /** @hidden */
  78872. export class ShaderCodeNode {
  78873. line: string;
  78874. children: ShaderCodeNode[];
  78875. additionalDefineKey?: string;
  78876. additionalDefineValue?: string;
  78877. isValid(preprocessors: {
  78878. [key: string]: string;
  78879. }): boolean;
  78880. process(preprocessors: {
  78881. [key: string]: string;
  78882. }, options: ProcessingOptions): string;
  78883. }
  78884. }
  78885. declare module BABYLON {
  78886. /** @hidden */
  78887. export class ShaderCodeCursor {
  78888. private _lines;
  78889. lineIndex: number;
  78890. get currentLine(): string;
  78891. get canRead(): boolean;
  78892. set lines(value: string[]);
  78893. }
  78894. }
  78895. declare module BABYLON {
  78896. /** @hidden */
  78897. export class ShaderCodeConditionNode extends ShaderCodeNode {
  78898. process(preprocessors: {
  78899. [key: string]: string;
  78900. }, options: ProcessingOptions): string;
  78901. }
  78902. }
  78903. declare module BABYLON {
  78904. /** @hidden */
  78905. export class ShaderDefineExpression {
  78906. isTrue(preprocessors: {
  78907. [key: string]: string;
  78908. }): boolean;
  78909. private static _OperatorPriority;
  78910. private static _Stack;
  78911. static postfixToInfix(postfix: string[]): string;
  78912. static infixToPostfix(infix: string): string[];
  78913. }
  78914. }
  78915. declare module BABYLON {
  78916. /** @hidden */
  78917. export class ShaderCodeTestNode extends ShaderCodeNode {
  78918. testExpression: ShaderDefineExpression;
  78919. isValid(preprocessors: {
  78920. [key: string]: string;
  78921. }): boolean;
  78922. }
  78923. }
  78924. declare module BABYLON {
  78925. /** @hidden */
  78926. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  78927. define: string;
  78928. not: boolean;
  78929. constructor(define: string, not?: boolean);
  78930. isTrue(preprocessors: {
  78931. [key: string]: string;
  78932. }): boolean;
  78933. }
  78934. }
  78935. declare module BABYLON {
  78936. /** @hidden */
  78937. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  78938. leftOperand: ShaderDefineExpression;
  78939. rightOperand: ShaderDefineExpression;
  78940. isTrue(preprocessors: {
  78941. [key: string]: string;
  78942. }): boolean;
  78943. }
  78944. }
  78945. declare module BABYLON {
  78946. /** @hidden */
  78947. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  78948. leftOperand: ShaderDefineExpression;
  78949. rightOperand: ShaderDefineExpression;
  78950. isTrue(preprocessors: {
  78951. [key: string]: string;
  78952. }): boolean;
  78953. }
  78954. }
  78955. declare module BABYLON {
  78956. /** @hidden */
  78957. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  78958. define: string;
  78959. operand: string;
  78960. testValue: string;
  78961. constructor(define: string, operand: string, testValue: string);
  78962. isTrue(preprocessors: {
  78963. [key: string]: string;
  78964. }): boolean;
  78965. }
  78966. }
  78967. declare module BABYLON {
  78968. /**
  78969. * Class used to enable access to offline support
  78970. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  78971. */
  78972. export interface IOfflineProvider {
  78973. /**
  78974. * Gets a boolean indicating if scene must be saved in the database
  78975. */
  78976. enableSceneOffline: boolean;
  78977. /**
  78978. * Gets a boolean indicating if textures must be saved in the database
  78979. */
  78980. enableTexturesOffline: boolean;
  78981. /**
  78982. * Open the offline support and make it available
  78983. * @param successCallback defines the callback to call on success
  78984. * @param errorCallback defines the callback to call on error
  78985. */
  78986. open(successCallback: () => void, errorCallback: () => void): void;
  78987. /**
  78988. * Loads an image from the offline support
  78989. * @param url defines the url to load from
  78990. * @param image defines the target DOM image
  78991. */
  78992. loadImage(url: string, image: HTMLImageElement): void;
  78993. /**
  78994. * Loads a file from offline support
  78995. * @param url defines the URL to load from
  78996. * @param sceneLoaded defines a callback to call on success
  78997. * @param progressCallBack defines a callback to call when progress changed
  78998. * @param errorCallback defines a callback to call on error
  78999. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79000. */
  79001. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79002. }
  79003. }
  79004. declare module BABYLON {
  79005. /**
  79006. * Class used to help managing file picking and drag'n'drop
  79007. * File Storage
  79008. */
  79009. export class FilesInputStore {
  79010. /**
  79011. * List of files ready to be loaded
  79012. */
  79013. static FilesToLoad: {
  79014. [key: string]: File;
  79015. };
  79016. }
  79017. }
  79018. declare module BABYLON {
  79019. /**
  79020. * Class used to define a retry strategy when error happens while loading assets
  79021. */
  79022. export class RetryStrategy {
  79023. /**
  79024. * Function used to defines an exponential back off strategy
  79025. * @param maxRetries defines the maximum number of retries (3 by default)
  79026. * @param baseInterval defines the interval between retries
  79027. * @returns the strategy function to use
  79028. */
  79029. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79030. }
  79031. }
  79032. declare module BABYLON {
  79033. /**
  79034. * @ignore
  79035. * Application error to support additional information when loading a file
  79036. */
  79037. export abstract class BaseError extends Error {
  79038. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79039. }
  79040. }
  79041. declare module BABYLON {
  79042. /** @ignore */
  79043. export class LoadFileError extends BaseError {
  79044. request?: WebRequest;
  79045. file?: File;
  79046. /**
  79047. * Creates a new LoadFileError
  79048. * @param message defines the message of the error
  79049. * @param request defines the optional web request
  79050. * @param file defines the optional file
  79051. */
  79052. constructor(message: string, object?: WebRequest | File);
  79053. }
  79054. /** @ignore */
  79055. export class RequestFileError extends BaseError {
  79056. request: WebRequest;
  79057. /**
  79058. * Creates a new LoadFileError
  79059. * @param message defines the message of the error
  79060. * @param request defines the optional web request
  79061. */
  79062. constructor(message: string, request: WebRequest);
  79063. }
  79064. /** @ignore */
  79065. export class ReadFileError extends BaseError {
  79066. file: File;
  79067. /**
  79068. * Creates a new ReadFileError
  79069. * @param message defines the message of the error
  79070. * @param file defines the optional file
  79071. */
  79072. constructor(message: string, file: File);
  79073. }
  79074. /**
  79075. * @hidden
  79076. */
  79077. export class FileTools {
  79078. /**
  79079. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79080. */
  79081. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79082. /**
  79083. * Gets or sets the base URL to use to load assets
  79084. */
  79085. static BaseUrl: string;
  79086. /**
  79087. * Default behaviour for cors in the application.
  79088. * It can be a string if the expected behavior is identical in the entire app.
  79089. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79090. */
  79091. static CorsBehavior: string | ((url: string | string[]) => string);
  79092. /**
  79093. * Gets or sets a function used to pre-process url before using them to load assets
  79094. */
  79095. static PreprocessUrl: (url: string) => string;
  79096. /**
  79097. * Removes unwanted characters from an url
  79098. * @param url defines the url to clean
  79099. * @returns the cleaned url
  79100. */
  79101. private static _CleanUrl;
  79102. /**
  79103. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79104. * @param url define the url we are trying
  79105. * @param element define the dom element where to configure the cors policy
  79106. */
  79107. static SetCorsBehavior(url: string | string[], element: {
  79108. crossOrigin: string | null;
  79109. }): void;
  79110. /**
  79111. * Loads an image as an HTMLImageElement.
  79112. * @param input url string, ArrayBuffer, or Blob to load
  79113. * @param onLoad callback called when the image successfully loads
  79114. * @param onError callback called when the image fails to load
  79115. * @param offlineProvider offline provider for caching
  79116. * @param mimeType optional mime type
  79117. * @returns the HTMLImageElement of the loaded image
  79118. */
  79119. 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>;
  79120. /**
  79121. * Reads a file from a File object
  79122. * @param file defines the file to load
  79123. * @param onSuccess defines the callback to call when data is loaded
  79124. * @param onProgress defines the callback to call during loading process
  79125. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79126. * @param onError defines the callback to call when an error occurs
  79127. * @returns a file request object
  79128. */
  79129. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79130. /**
  79131. * Loads a file from a url
  79132. * @param url url to load
  79133. * @param onSuccess callback called when the file successfully loads
  79134. * @param onProgress callback called while file is loading (if the server supports this mode)
  79135. * @param offlineProvider defines the offline provider for caching
  79136. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79137. * @param onError callback called when the file fails to load
  79138. * @returns a file request object
  79139. */
  79140. 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;
  79141. /**
  79142. * Loads a file
  79143. * @param url url to load
  79144. * @param onSuccess callback called when the file successfully loads
  79145. * @param onProgress callback called while file is loading (if the server supports this mode)
  79146. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79147. * @param onError callback called when the file fails to load
  79148. * @param onOpened callback called when the web request is opened
  79149. * @returns a file request object
  79150. */
  79151. 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;
  79152. /**
  79153. * Checks if the loaded document was accessed via `file:`-Protocol.
  79154. * @returns boolean
  79155. */
  79156. static IsFileURL(): boolean;
  79157. }
  79158. }
  79159. declare module BABYLON {
  79160. /** @hidden */
  79161. export class ShaderProcessor {
  79162. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79163. private static _ProcessPrecision;
  79164. private static _ExtractOperation;
  79165. private static _BuildSubExpression;
  79166. private static _BuildExpression;
  79167. private static _MoveCursorWithinIf;
  79168. private static _MoveCursor;
  79169. private static _EvaluatePreProcessors;
  79170. private static _PreparePreProcessors;
  79171. private static _ProcessShaderConversion;
  79172. private static _ProcessIncludes;
  79173. /**
  79174. * Loads a file from a url
  79175. * @param url url to load
  79176. * @param onSuccess callback called when the file successfully loads
  79177. * @param onProgress callback called while file is loading (if the server supports this mode)
  79178. * @param offlineProvider defines the offline provider for caching
  79179. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79180. * @param onError callback called when the file fails to load
  79181. * @returns a file request object
  79182. * @hidden
  79183. */
  79184. 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;
  79185. }
  79186. }
  79187. declare module BABYLON {
  79188. /**
  79189. * @hidden
  79190. */
  79191. export interface IColor4Like {
  79192. r: float;
  79193. g: float;
  79194. b: float;
  79195. a: float;
  79196. }
  79197. /**
  79198. * @hidden
  79199. */
  79200. export interface IColor3Like {
  79201. r: float;
  79202. g: float;
  79203. b: float;
  79204. }
  79205. /**
  79206. * @hidden
  79207. */
  79208. export interface IVector4Like {
  79209. x: float;
  79210. y: float;
  79211. z: float;
  79212. w: float;
  79213. }
  79214. /**
  79215. * @hidden
  79216. */
  79217. export interface IVector3Like {
  79218. x: float;
  79219. y: float;
  79220. z: float;
  79221. }
  79222. /**
  79223. * @hidden
  79224. */
  79225. export interface IVector2Like {
  79226. x: float;
  79227. y: float;
  79228. }
  79229. /**
  79230. * @hidden
  79231. */
  79232. export interface IMatrixLike {
  79233. toArray(): DeepImmutable<Float32Array>;
  79234. updateFlag: int;
  79235. }
  79236. /**
  79237. * @hidden
  79238. */
  79239. export interface IViewportLike {
  79240. x: float;
  79241. y: float;
  79242. width: float;
  79243. height: float;
  79244. }
  79245. /**
  79246. * @hidden
  79247. */
  79248. export interface IPlaneLike {
  79249. normal: IVector3Like;
  79250. d: float;
  79251. normalize(): void;
  79252. }
  79253. }
  79254. declare module BABYLON {
  79255. /**
  79256. * Interface used to define common properties for effect fallbacks
  79257. */
  79258. export interface IEffectFallbacks {
  79259. /**
  79260. * Removes the defines that should be removed when falling back.
  79261. * @param currentDefines defines the current define statements for the shader.
  79262. * @param effect defines the current effect we try to compile
  79263. * @returns The resulting defines with defines of the current rank removed.
  79264. */
  79265. reduce(currentDefines: string, effect: Effect): string;
  79266. /**
  79267. * Removes the fallback from the bound mesh.
  79268. */
  79269. unBindMesh(): void;
  79270. /**
  79271. * Checks to see if more fallbacks are still availible.
  79272. */
  79273. hasMoreFallbacks: boolean;
  79274. }
  79275. }
  79276. declare module BABYLON {
  79277. /**
  79278. * Class used to evalaute queries containing `and` and `or` operators
  79279. */
  79280. export class AndOrNotEvaluator {
  79281. /**
  79282. * Evaluate a query
  79283. * @param query defines the query to evaluate
  79284. * @param evaluateCallback defines the callback used to filter result
  79285. * @returns true if the query matches
  79286. */
  79287. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79288. private static _HandleParenthesisContent;
  79289. private static _SimplifyNegation;
  79290. }
  79291. }
  79292. declare module BABYLON {
  79293. /**
  79294. * Class used to store custom tags
  79295. */
  79296. export class Tags {
  79297. /**
  79298. * Adds support for tags on the given object
  79299. * @param obj defines the object to use
  79300. */
  79301. static EnableFor(obj: any): void;
  79302. /**
  79303. * Removes tags support
  79304. * @param obj defines the object to use
  79305. */
  79306. static DisableFor(obj: any): void;
  79307. /**
  79308. * Gets a boolean indicating if the given object has tags
  79309. * @param obj defines the object to use
  79310. * @returns a boolean
  79311. */
  79312. static HasTags(obj: any): boolean;
  79313. /**
  79314. * Gets the tags available on a given object
  79315. * @param obj defines the object to use
  79316. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79317. * @returns the tags
  79318. */
  79319. static GetTags(obj: any, asString?: boolean): any;
  79320. /**
  79321. * Adds tags to an object
  79322. * @param obj defines the object to use
  79323. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79324. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79325. */
  79326. static AddTagsTo(obj: any, tagsString: string): void;
  79327. /**
  79328. * @hidden
  79329. */
  79330. static _AddTagTo(obj: any, tag: string): void;
  79331. /**
  79332. * Removes specific tags from a specific object
  79333. * @param obj defines the object to use
  79334. * @param tagsString defines the tags to remove
  79335. */
  79336. static RemoveTagsFrom(obj: any, tagsString: string): void;
  79337. /**
  79338. * @hidden
  79339. */
  79340. static _RemoveTagFrom(obj: any, tag: string): void;
  79341. /**
  79342. * Defines if tags hosted on an object match a given query
  79343. * @param obj defines the object to use
  79344. * @param tagsQuery defines the tag query
  79345. * @returns a boolean
  79346. */
  79347. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  79348. }
  79349. }
  79350. declare module BABYLON {
  79351. /**
  79352. * Scalar computation library
  79353. */
  79354. export class Scalar {
  79355. /**
  79356. * Two pi constants convenient for computation.
  79357. */
  79358. static TwoPi: number;
  79359. /**
  79360. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79361. * @param a number
  79362. * @param b number
  79363. * @param epsilon (default = 1.401298E-45)
  79364. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  79365. */
  79366. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  79367. /**
  79368. * Returns a string : the upper case translation of the number i to hexadecimal.
  79369. * @param i number
  79370. * @returns the upper case translation of the number i to hexadecimal.
  79371. */
  79372. static ToHex(i: number): string;
  79373. /**
  79374. * Returns -1 if value is negative and +1 is value is positive.
  79375. * @param value the value
  79376. * @returns the value itself if it's equal to zero.
  79377. */
  79378. static Sign(value: number): number;
  79379. /**
  79380. * Returns the value itself if it's between min and max.
  79381. * Returns min if the value is lower than min.
  79382. * Returns max if the value is greater than max.
  79383. * @param value the value to clmap
  79384. * @param min the min value to clamp to (default: 0)
  79385. * @param max the max value to clamp to (default: 1)
  79386. * @returns the clamped value
  79387. */
  79388. static Clamp(value: number, min?: number, max?: number): number;
  79389. /**
  79390. * the log2 of value.
  79391. * @param value the value to compute log2 of
  79392. * @returns the log2 of value.
  79393. */
  79394. static Log2(value: number): number;
  79395. /**
  79396. * Loops the value, so that it is never larger than length and never smaller than 0.
  79397. *
  79398. * This is similar to the modulo operator but it works with floating point numbers.
  79399. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  79400. * With t = 5 and length = 2.5, the result would be 0.0.
  79401. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  79402. * @param value the value
  79403. * @param length the length
  79404. * @returns the looped value
  79405. */
  79406. static Repeat(value: number, length: number): number;
  79407. /**
  79408. * Normalize the value between 0.0 and 1.0 using min and max values
  79409. * @param value value to normalize
  79410. * @param min max to normalize between
  79411. * @param max min to normalize between
  79412. * @returns the normalized value
  79413. */
  79414. static Normalize(value: number, min: number, max: number): number;
  79415. /**
  79416. * Denormalize the value from 0.0 and 1.0 using min and max values
  79417. * @param normalized value to denormalize
  79418. * @param min max to denormalize between
  79419. * @param max min to denormalize between
  79420. * @returns the denormalized value
  79421. */
  79422. static Denormalize(normalized: number, min: number, max: number): number;
  79423. /**
  79424. * Calculates the shortest difference between two given angles given in degrees.
  79425. * @param current current angle in degrees
  79426. * @param target target angle in degrees
  79427. * @returns the delta
  79428. */
  79429. static DeltaAngle(current: number, target: number): number;
  79430. /**
  79431. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  79432. * @param tx value
  79433. * @param length length
  79434. * @returns The returned value will move back and forth between 0 and length
  79435. */
  79436. static PingPong(tx: number, length: number): number;
  79437. /**
  79438. * Interpolates between min and max with smoothing at the limits.
  79439. *
  79440. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  79441. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  79442. * @param from from
  79443. * @param to to
  79444. * @param tx value
  79445. * @returns the smooth stepped value
  79446. */
  79447. static SmoothStep(from: number, to: number, tx: number): number;
  79448. /**
  79449. * Moves a value current towards target.
  79450. *
  79451. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  79452. * Negative values of maxDelta pushes the value away from target.
  79453. * @param current current value
  79454. * @param target target value
  79455. * @param maxDelta max distance to move
  79456. * @returns resulting value
  79457. */
  79458. static MoveTowards(current: number, target: number, maxDelta: number): number;
  79459. /**
  79460. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79461. *
  79462. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  79463. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  79464. * @param current current value
  79465. * @param target target value
  79466. * @param maxDelta max distance to move
  79467. * @returns resulting angle
  79468. */
  79469. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  79470. /**
  79471. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  79472. * @param start start value
  79473. * @param end target value
  79474. * @param amount amount to lerp between
  79475. * @returns the lerped value
  79476. */
  79477. static Lerp(start: number, end: number, amount: number): number;
  79478. /**
  79479. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  79480. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  79481. * @param start start value
  79482. * @param end target value
  79483. * @param amount amount to lerp between
  79484. * @returns the lerped value
  79485. */
  79486. static LerpAngle(start: number, end: number, amount: number): number;
  79487. /**
  79488. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  79489. * @param a start value
  79490. * @param b target value
  79491. * @param value value between a and b
  79492. * @returns the inverseLerp value
  79493. */
  79494. static InverseLerp(a: number, b: number, value: number): number;
  79495. /**
  79496. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  79497. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  79498. * @param value1 spline value
  79499. * @param tangent1 spline value
  79500. * @param value2 spline value
  79501. * @param tangent2 spline value
  79502. * @param amount input value
  79503. * @returns hermite result
  79504. */
  79505. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  79506. /**
  79507. * Returns a random float number between and min and max values
  79508. * @param min min value of random
  79509. * @param max max value of random
  79510. * @returns random value
  79511. */
  79512. static RandomRange(min: number, max: number): number;
  79513. /**
  79514. * This function returns percentage of a number in a given range.
  79515. *
  79516. * RangeToPercent(40,20,60) will return 0.5 (50%)
  79517. * RangeToPercent(34,0,100) will return 0.34 (34%)
  79518. * @param number to convert to percentage
  79519. * @param min min range
  79520. * @param max max range
  79521. * @returns the percentage
  79522. */
  79523. static RangeToPercent(number: number, min: number, max: number): number;
  79524. /**
  79525. * This function returns number that corresponds to the percentage in a given range.
  79526. *
  79527. * PercentToRange(0.34,0,100) will return 34.
  79528. * @param percent to convert to number
  79529. * @param min min range
  79530. * @param max max range
  79531. * @returns the number
  79532. */
  79533. static PercentToRange(percent: number, min: number, max: number): number;
  79534. /**
  79535. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  79536. * @param angle The angle to normalize in radian.
  79537. * @return The converted angle.
  79538. */
  79539. static NormalizeRadians(angle: number): number;
  79540. }
  79541. }
  79542. declare module BABYLON {
  79543. /**
  79544. * Constant used to convert a value to gamma space
  79545. * @ignorenaming
  79546. */
  79547. export const ToGammaSpace: number;
  79548. /**
  79549. * Constant used to convert a value to linear space
  79550. * @ignorenaming
  79551. */
  79552. export const ToLinearSpace = 2.2;
  79553. /**
  79554. * Constant used to define the minimal number value in Babylon.js
  79555. * @ignorenaming
  79556. */
  79557. let Epsilon: number;
  79558. }
  79559. declare module BABYLON {
  79560. /**
  79561. * Class used to represent a viewport on screen
  79562. */
  79563. export class Viewport {
  79564. /** viewport left coordinate */
  79565. x: number;
  79566. /** viewport top coordinate */
  79567. y: number;
  79568. /**viewport width */
  79569. width: number;
  79570. /** viewport height */
  79571. height: number;
  79572. /**
  79573. * Creates a Viewport object located at (x, y) and sized (width, height)
  79574. * @param x defines viewport left coordinate
  79575. * @param y defines viewport top coordinate
  79576. * @param width defines the viewport width
  79577. * @param height defines the viewport height
  79578. */
  79579. constructor(
  79580. /** viewport left coordinate */
  79581. x: number,
  79582. /** viewport top coordinate */
  79583. y: number,
  79584. /**viewport width */
  79585. width: number,
  79586. /** viewport height */
  79587. height: number);
  79588. /**
  79589. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  79590. * @param renderWidth defines the rendering width
  79591. * @param renderHeight defines the rendering height
  79592. * @returns a new Viewport
  79593. */
  79594. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  79595. /**
  79596. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  79597. * @param renderWidth defines the rendering width
  79598. * @param renderHeight defines the rendering height
  79599. * @param ref defines the target viewport
  79600. * @returns the current viewport
  79601. */
  79602. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  79603. /**
  79604. * Returns a new Viewport copied from the current one
  79605. * @returns a new Viewport
  79606. */
  79607. clone(): Viewport;
  79608. }
  79609. }
  79610. declare module BABYLON {
  79611. /**
  79612. * Class containing a set of static utilities functions for arrays.
  79613. */
  79614. export class ArrayTools {
  79615. /**
  79616. * Returns an array of the given size filled with element built from the given constructor and the paramters
  79617. * @param size the number of element to construct and put in the array
  79618. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  79619. * @returns a new array filled with new objects
  79620. */
  79621. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  79622. }
  79623. }
  79624. declare module BABYLON {
  79625. /**
  79626. * Represents a plane by the equation ax + by + cz + d = 0
  79627. */
  79628. export class Plane {
  79629. private static _TmpMatrix;
  79630. /**
  79631. * Normal of the plane (a,b,c)
  79632. */
  79633. normal: Vector3;
  79634. /**
  79635. * d component of the plane
  79636. */
  79637. d: number;
  79638. /**
  79639. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79640. * @param a a component of the plane
  79641. * @param b b component of the plane
  79642. * @param c c component of the plane
  79643. * @param d d component of the plane
  79644. */
  79645. constructor(a: number, b: number, c: number, d: number);
  79646. /**
  79647. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79648. */
  79649. asArray(): number[];
  79650. /**
  79651. * @returns a new plane copied from the current Plane.
  79652. */
  79653. clone(): Plane;
  79654. /**
  79655. * @returns the string "Plane".
  79656. */
  79657. getClassName(): string;
  79658. /**
  79659. * @returns the Plane hash code.
  79660. */
  79661. getHashCode(): number;
  79662. /**
  79663. * Normalize the current Plane in place.
  79664. * @returns the updated Plane.
  79665. */
  79666. normalize(): Plane;
  79667. /**
  79668. * Applies a transformation the plane and returns the result
  79669. * @param transformation the transformation matrix to be applied to the plane
  79670. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79671. */
  79672. transform(transformation: DeepImmutable<Matrix>): Plane;
  79673. /**
  79674. * Compute the dot product between the point and the plane normal
  79675. * @param point point to calculate the dot product with
  79676. * @returns the dot product (float) of the point coordinates and the plane normal.
  79677. */
  79678. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79679. /**
  79680. * Updates the current Plane from the plane defined by the three given points.
  79681. * @param point1 one of the points used to contruct the plane
  79682. * @param point2 one of the points used to contruct the plane
  79683. * @param point3 one of the points used to contruct the plane
  79684. * @returns the updated Plane.
  79685. */
  79686. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79687. /**
  79688. * Checks if the plane is facing a given direction
  79689. * @param direction the direction to check if the plane is facing
  79690. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79691. * @returns True is the vector "direction" is the same side than the plane normal.
  79692. */
  79693. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79694. /**
  79695. * Calculates the distance to a point
  79696. * @param point point to calculate distance to
  79697. * @returns the signed distance (float) from the given point to the Plane.
  79698. */
  79699. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79700. /**
  79701. * Creates a plane from an array
  79702. * @param array the array to create a plane from
  79703. * @returns a new Plane from the given array.
  79704. */
  79705. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79706. /**
  79707. * Creates a plane from three points
  79708. * @param point1 point used to create the plane
  79709. * @param point2 point used to create the plane
  79710. * @param point3 point used to create the plane
  79711. * @returns a new Plane defined by the three given points.
  79712. */
  79713. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79714. /**
  79715. * Creates a plane from an origin point and a normal
  79716. * @param origin origin of the plane to be constructed
  79717. * @param normal normal of the plane to be constructed
  79718. * @returns a new Plane the normal vector to this plane at the given origin point.
  79719. * Note : the vector "normal" is updated because normalized.
  79720. */
  79721. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  79722. /**
  79723. * Calculates the distance from a plane and a point
  79724. * @param origin origin of the plane to be constructed
  79725. * @param normal normal of the plane to be constructed
  79726. * @param point point to calculate distance to
  79727. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79728. */
  79729. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79730. }
  79731. }
  79732. declare module BABYLON {
  79733. /**
  79734. * Class representing a vector containing 2 coordinates
  79735. */
  79736. export class Vector2 {
  79737. /** defines the first coordinate */
  79738. x: number;
  79739. /** defines the second coordinate */
  79740. y: number;
  79741. /**
  79742. * Creates a new Vector2 from the given x and y coordinates
  79743. * @param x defines the first coordinate
  79744. * @param y defines the second coordinate
  79745. */
  79746. constructor(
  79747. /** defines the first coordinate */
  79748. x?: number,
  79749. /** defines the second coordinate */
  79750. y?: number);
  79751. /**
  79752. * Gets a string with the Vector2 coordinates
  79753. * @returns a string with the Vector2 coordinates
  79754. */
  79755. toString(): string;
  79756. /**
  79757. * Gets class name
  79758. * @returns the string "Vector2"
  79759. */
  79760. getClassName(): string;
  79761. /**
  79762. * Gets current vector hash code
  79763. * @returns the Vector2 hash code as a number
  79764. */
  79765. getHashCode(): number;
  79766. /**
  79767. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  79768. * @param array defines the source array
  79769. * @param index defines the offset in source array
  79770. * @returns the current Vector2
  79771. */
  79772. toArray(array: FloatArray, index?: number): Vector2;
  79773. /**
  79774. * Copy the current vector to an array
  79775. * @returns a new array with 2 elements: the Vector2 coordinates.
  79776. */
  79777. asArray(): number[];
  79778. /**
  79779. * Sets the Vector2 coordinates with the given Vector2 coordinates
  79780. * @param source defines the source Vector2
  79781. * @returns the current updated Vector2
  79782. */
  79783. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  79784. /**
  79785. * Sets the Vector2 coordinates with the given floats
  79786. * @param x defines the first coordinate
  79787. * @param y defines the second coordinate
  79788. * @returns the current updated Vector2
  79789. */
  79790. copyFromFloats(x: number, y: number): Vector2;
  79791. /**
  79792. * Sets the Vector2 coordinates with the given floats
  79793. * @param x defines the first coordinate
  79794. * @param y defines the second coordinate
  79795. * @returns the current updated Vector2
  79796. */
  79797. set(x: number, y: number): Vector2;
  79798. /**
  79799. * Add another vector with the current one
  79800. * @param otherVector defines the other vector
  79801. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  79802. */
  79803. add(otherVector: DeepImmutable<Vector2>): Vector2;
  79804. /**
  79805. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  79806. * @param otherVector defines the other vector
  79807. * @param result defines the target vector
  79808. * @returns the unmodified current Vector2
  79809. */
  79810. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79811. /**
  79812. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  79813. * @param otherVector defines the other vector
  79814. * @returns the current updated Vector2
  79815. */
  79816. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79817. /**
  79818. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  79819. * @param otherVector defines the other vector
  79820. * @returns a new Vector2
  79821. */
  79822. addVector3(otherVector: Vector3): Vector2;
  79823. /**
  79824. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  79825. * @param otherVector defines the other vector
  79826. * @returns a new Vector2
  79827. */
  79828. subtract(otherVector: Vector2): Vector2;
  79829. /**
  79830. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  79831. * @param otherVector defines the other vector
  79832. * @param result defines the target vector
  79833. * @returns the unmodified current Vector2
  79834. */
  79835. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79836. /**
  79837. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  79838. * @param otherVector defines the other vector
  79839. * @returns the current updated Vector2
  79840. */
  79841. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79842. /**
  79843. * Multiplies in place the current Vector2 coordinates by the given ones
  79844. * @param otherVector defines the other vector
  79845. * @returns the current updated Vector2
  79846. */
  79847. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79848. /**
  79849. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  79850. * @param otherVector defines the other vector
  79851. * @returns a new Vector2
  79852. */
  79853. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  79854. /**
  79855. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  79856. * @param otherVector defines the other vector
  79857. * @param result defines the target vector
  79858. * @returns the unmodified current Vector2
  79859. */
  79860. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79861. /**
  79862. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  79863. * @param x defines the first coordinate
  79864. * @param y defines the second coordinate
  79865. * @returns a new Vector2
  79866. */
  79867. multiplyByFloats(x: number, y: number): Vector2;
  79868. /**
  79869. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  79870. * @param otherVector defines the other vector
  79871. * @returns a new Vector2
  79872. */
  79873. divide(otherVector: Vector2): Vector2;
  79874. /**
  79875. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  79876. * @param otherVector defines the other vector
  79877. * @param result defines the target vector
  79878. * @returns the unmodified current Vector2
  79879. */
  79880. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  79881. /**
  79882. * Divides the current Vector2 coordinates by the given ones
  79883. * @param otherVector defines the other vector
  79884. * @returns the current updated Vector2
  79885. */
  79886. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  79887. /**
  79888. * Gets a new Vector2 with current Vector2 negated coordinates
  79889. * @returns a new Vector2
  79890. */
  79891. negate(): Vector2;
  79892. /**
  79893. * Negate this vector in place
  79894. * @returns this
  79895. */
  79896. negateInPlace(): Vector2;
  79897. /**
  79898. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  79899. * @param result defines the Vector3 object where to store the result
  79900. * @returns the current Vector2
  79901. */
  79902. negateToRef(result: Vector2): Vector2;
  79903. /**
  79904. * Multiply the Vector2 coordinates by scale
  79905. * @param scale defines the scaling factor
  79906. * @returns the current updated Vector2
  79907. */
  79908. scaleInPlace(scale: number): Vector2;
  79909. /**
  79910. * Returns a new Vector2 scaled by "scale" from the current Vector2
  79911. * @param scale defines the scaling factor
  79912. * @returns a new Vector2
  79913. */
  79914. scale(scale: number): Vector2;
  79915. /**
  79916. * Scale the current Vector2 values by a factor to a given Vector2
  79917. * @param scale defines the scale factor
  79918. * @param result defines the Vector2 object where to store the result
  79919. * @returns the unmodified current Vector2
  79920. */
  79921. scaleToRef(scale: number, result: Vector2): Vector2;
  79922. /**
  79923. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  79924. * @param scale defines the scale factor
  79925. * @param result defines the Vector2 object where to store the result
  79926. * @returns the unmodified current Vector2
  79927. */
  79928. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  79929. /**
  79930. * Gets a boolean if two vectors are equals
  79931. * @param otherVector defines the other vector
  79932. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  79933. */
  79934. equals(otherVector: DeepImmutable<Vector2>): boolean;
  79935. /**
  79936. * Gets a boolean if two vectors are equals (using an epsilon value)
  79937. * @param otherVector defines the other vector
  79938. * @param epsilon defines the minimal distance to consider equality
  79939. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  79940. */
  79941. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  79942. /**
  79943. * Gets a new Vector2 from current Vector2 floored values
  79944. * @returns a new Vector2
  79945. */
  79946. floor(): Vector2;
  79947. /**
  79948. * Gets a new Vector2 from current Vector2 floored values
  79949. * @returns a new Vector2
  79950. */
  79951. fract(): Vector2;
  79952. /**
  79953. * Gets the length of the vector
  79954. * @returns the vector length (float)
  79955. */
  79956. length(): number;
  79957. /**
  79958. * Gets the vector squared length
  79959. * @returns the vector squared length (float)
  79960. */
  79961. lengthSquared(): number;
  79962. /**
  79963. * Normalize the vector
  79964. * @returns the current updated Vector2
  79965. */
  79966. normalize(): Vector2;
  79967. /**
  79968. * Gets a new Vector2 copied from the Vector2
  79969. * @returns a new Vector2
  79970. */
  79971. clone(): Vector2;
  79972. /**
  79973. * Gets a new Vector2(0, 0)
  79974. * @returns a new Vector2
  79975. */
  79976. static Zero(): Vector2;
  79977. /**
  79978. * Gets a new Vector2(1, 1)
  79979. * @returns a new Vector2
  79980. */
  79981. static One(): Vector2;
  79982. /**
  79983. * Gets a new Vector2 set from the given index element of the given array
  79984. * @param array defines the data source
  79985. * @param offset defines the offset in the data source
  79986. * @returns a new Vector2
  79987. */
  79988. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  79989. /**
  79990. * Sets "result" from the given index element of the given array
  79991. * @param array defines the data source
  79992. * @param offset defines the offset in the data source
  79993. * @param result defines the target vector
  79994. */
  79995. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  79996. /**
  79997. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  79998. * @param value1 defines 1st point of control
  79999. * @param value2 defines 2nd point of control
  80000. * @param value3 defines 3rd point of control
  80001. * @param value4 defines 4th point of control
  80002. * @param amount defines the interpolation factor
  80003. * @returns a new Vector2
  80004. */
  80005. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80006. /**
  80007. * 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".
  80008. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80009. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80010. * @param value defines the value to clamp
  80011. * @param min defines the lower limit
  80012. * @param max defines the upper limit
  80013. * @returns a new Vector2
  80014. */
  80015. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80016. /**
  80017. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80018. * @param value1 defines the 1st control point
  80019. * @param tangent1 defines the outgoing tangent
  80020. * @param value2 defines the 2nd control point
  80021. * @param tangent2 defines the incoming tangent
  80022. * @param amount defines the interpolation factor
  80023. * @returns a new Vector2
  80024. */
  80025. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80026. /**
  80027. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80028. * @param start defines the start vector
  80029. * @param end defines the end vector
  80030. * @param amount defines the interpolation factor
  80031. * @returns a new Vector2
  80032. */
  80033. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80034. /**
  80035. * Gets the dot product of the vector "left" and the vector "right"
  80036. * @param left defines first vector
  80037. * @param right defines second vector
  80038. * @returns the dot product (float)
  80039. */
  80040. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80041. /**
  80042. * Returns a new Vector2 equal to the normalized given vector
  80043. * @param vector defines the vector to normalize
  80044. * @returns a new Vector2
  80045. */
  80046. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80047. /**
  80048. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80049. * @param left defines 1st vector
  80050. * @param right defines 2nd vector
  80051. * @returns a new Vector2
  80052. */
  80053. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80054. /**
  80055. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80056. * @param left defines 1st vector
  80057. * @param right defines 2nd vector
  80058. * @returns a new Vector2
  80059. */
  80060. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80061. /**
  80062. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80063. * @param vector defines the vector to transform
  80064. * @param transformation defines the matrix to apply
  80065. * @returns a new Vector2
  80066. */
  80067. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80068. /**
  80069. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80070. * @param vector defines the vector to transform
  80071. * @param transformation defines the matrix to apply
  80072. * @param result defines the target vector
  80073. */
  80074. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80075. /**
  80076. * Determines if a given vector is included in a triangle
  80077. * @param p defines the vector to test
  80078. * @param p0 defines 1st triangle point
  80079. * @param p1 defines 2nd triangle point
  80080. * @param p2 defines 3rd triangle point
  80081. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80082. */
  80083. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80084. /**
  80085. * Gets the distance between the vectors "value1" and "value2"
  80086. * @param value1 defines first vector
  80087. * @param value2 defines second vector
  80088. * @returns the distance between vectors
  80089. */
  80090. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80091. /**
  80092. * Returns the squared distance between the vectors "value1" and "value2"
  80093. * @param value1 defines first vector
  80094. * @param value2 defines second vector
  80095. * @returns the squared distance between vectors
  80096. */
  80097. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80098. /**
  80099. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80100. * @param value1 defines first vector
  80101. * @param value2 defines second vector
  80102. * @returns a new Vector2
  80103. */
  80104. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80105. /**
  80106. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80107. * @param p defines the middle point
  80108. * @param segA defines one point of the segment
  80109. * @param segB defines the other point of the segment
  80110. * @returns the shortest distance
  80111. */
  80112. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80113. }
  80114. /**
  80115. * Class used to store (x,y,z) vector representation
  80116. * A Vector3 is the main object used in 3D geometry
  80117. * It can represent etiher the coordinates of a point the space, either a direction
  80118. * Reminder: js uses a left handed forward facing system
  80119. */
  80120. export class Vector3 {
  80121. private static _UpReadOnly;
  80122. private static _ZeroReadOnly;
  80123. /** @hidden */
  80124. _x: number;
  80125. /** @hidden */
  80126. _y: number;
  80127. /** @hidden */
  80128. _z: number;
  80129. /** @hidden */
  80130. _isDirty: boolean;
  80131. /** Gets or sets the x coordinate */
  80132. get x(): number;
  80133. set x(value: number);
  80134. /** Gets or sets the y coordinate */
  80135. get y(): number;
  80136. set y(value: number);
  80137. /** Gets or sets the z coordinate */
  80138. get z(): number;
  80139. set z(value: number);
  80140. /**
  80141. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80142. * @param x defines the first coordinates (on X axis)
  80143. * @param y defines the second coordinates (on Y axis)
  80144. * @param z defines the third coordinates (on Z axis)
  80145. */
  80146. constructor(x?: number, y?: number, z?: number);
  80147. /**
  80148. * Creates a string representation of the Vector3
  80149. * @returns a string with the Vector3 coordinates.
  80150. */
  80151. toString(): string;
  80152. /**
  80153. * Gets the class name
  80154. * @returns the string "Vector3"
  80155. */
  80156. getClassName(): string;
  80157. /**
  80158. * Creates the Vector3 hash code
  80159. * @returns a number which tends to be unique between Vector3 instances
  80160. */
  80161. getHashCode(): number;
  80162. /**
  80163. * Creates an array containing three elements : the coordinates of the Vector3
  80164. * @returns a new array of numbers
  80165. */
  80166. asArray(): number[];
  80167. /**
  80168. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80169. * @param array defines the destination array
  80170. * @param index defines the offset in the destination array
  80171. * @returns the current Vector3
  80172. */
  80173. toArray(array: FloatArray, index?: number): Vector3;
  80174. /**
  80175. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80176. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80177. */
  80178. toQuaternion(): Quaternion;
  80179. /**
  80180. * Adds the given vector to the current Vector3
  80181. * @param otherVector defines the second operand
  80182. * @returns the current updated Vector3
  80183. */
  80184. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80185. /**
  80186. * Adds the given coordinates to the current Vector3
  80187. * @param x defines the x coordinate of the operand
  80188. * @param y defines the y coordinate of the operand
  80189. * @param z defines the z coordinate of the operand
  80190. * @returns the current updated Vector3
  80191. */
  80192. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80193. /**
  80194. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80195. * @param otherVector defines the second operand
  80196. * @returns the resulting Vector3
  80197. */
  80198. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80199. /**
  80200. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80201. * @param otherVector defines the second operand
  80202. * @param result defines the Vector3 object where to store the result
  80203. * @returns the current Vector3
  80204. */
  80205. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80206. /**
  80207. * Subtract the given vector from the current Vector3
  80208. * @param otherVector defines the second operand
  80209. * @returns the current updated Vector3
  80210. */
  80211. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80212. /**
  80213. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80214. * @param otherVector defines the second operand
  80215. * @returns the resulting Vector3
  80216. */
  80217. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80218. /**
  80219. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80220. * @param otherVector defines the second operand
  80221. * @param result defines the Vector3 object where to store the result
  80222. * @returns the current Vector3
  80223. */
  80224. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80225. /**
  80226. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80227. * @param x defines the x coordinate of the operand
  80228. * @param y defines the y coordinate of the operand
  80229. * @param z defines the z coordinate of the operand
  80230. * @returns the resulting Vector3
  80231. */
  80232. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80233. /**
  80234. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80235. * @param x defines the x coordinate of the operand
  80236. * @param y defines the y coordinate of the operand
  80237. * @param z defines the z coordinate of the operand
  80238. * @param result defines the Vector3 object where to store the result
  80239. * @returns the current Vector3
  80240. */
  80241. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80242. /**
  80243. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80244. * @returns a new Vector3
  80245. */
  80246. negate(): Vector3;
  80247. /**
  80248. * Negate this vector in place
  80249. * @returns this
  80250. */
  80251. negateInPlace(): Vector3;
  80252. /**
  80253. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80254. * @param result defines the Vector3 object where to store the result
  80255. * @returns the current Vector3
  80256. */
  80257. negateToRef(result: Vector3): Vector3;
  80258. /**
  80259. * Multiplies the Vector3 coordinates by the float "scale"
  80260. * @param scale defines the multiplier factor
  80261. * @returns the current updated Vector3
  80262. */
  80263. scaleInPlace(scale: number): Vector3;
  80264. /**
  80265. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80266. * @param scale defines the multiplier factor
  80267. * @returns a new Vector3
  80268. */
  80269. scale(scale: number): Vector3;
  80270. /**
  80271. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80272. * @param scale defines the multiplier factor
  80273. * @param result defines the Vector3 object where to store the result
  80274. * @returns the current Vector3
  80275. */
  80276. scaleToRef(scale: number, result: Vector3): Vector3;
  80277. /**
  80278. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80279. * @param scale defines the scale factor
  80280. * @param result defines the Vector3 object where to store the result
  80281. * @returns the unmodified current Vector3
  80282. */
  80283. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80284. /**
  80285. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80286. * @param origin defines the origin of the projection ray
  80287. * @param plane defines the plane to project to
  80288. * @returns the projected vector3
  80289. */
  80290. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80291. /**
  80292. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80293. * @param origin defines the origin of the projection ray
  80294. * @param plane defines the plane to project to
  80295. * @param result defines the Vector3 where to store the result
  80296. */
  80297. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80298. /**
  80299. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80300. * @param otherVector defines the second operand
  80301. * @returns true if both vectors are equals
  80302. */
  80303. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80304. /**
  80305. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80306. * @param otherVector defines the second operand
  80307. * @param epsilon defines the minimal distance to define values as equals
  80308. * @returns true if both vectors are distant less than epsilon
  80309. */
  80310. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80311. /**
  80312. * Returns true if the current Vector3 coordinates equals the given floats
  80313. * @param x defines the x coordinate of the operand
  80314. * @param y defines the y coordinate of the operand
  80315. * @param z defines the z coordinate of the operand
  80316. * @returns true if both vectors are equals
  80317. */
  80318. equalsToFloats(x: number, y: number, z: number): boolean;
  80319. /**
  80320. * Multiplies the current Vector3 coordinates by the given ones
  80321. * @param otherVector defines the second operand
  80322. * @returns the current updated Vector3
  80323. */
  80324. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80325. /**
  80326. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80327. * @param otherVector defines the second operand
  80328. * @returns the new Vector3
  80329. */
  80330. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80331. /**
  80332. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  80333. * @param otherVector defines the second operand
  80334. * @param result defines the Vector3 object where to store the result
  80335. * @returns the current Vector3
  80336. */
  80337. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80338. /**
  80339. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  80340. * @param x defines the x coordinate of the operand
  80341. * @param y defines the y coordinate of the operand
  80342. * @param z defines the z coordinate of the operand
  80343. * @returns the new Vector3
  80344. */
  80345. multiplyByFloats(x: number, y: number, z: number): Vector3;
  80346. /**
  80347. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  80348. * @param otherVector defines the second operand
  80349. * @returns the new Vector3
  80350. */
  80351. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  80352. /**
  80353. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  80354. * @param otherVector defines the second operand
  80355. * @param result defines the Vector3 object where to store the result
  80356. * @returns the current Vector3
  80357. */
  80358. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80359. /**
  80360. * Divides the current Vector3 coordinates by the given ones.
  80361. * @param otherVector defines the second operand
  80362. * @returns the current updated Vector3
  80363. */
  80364. divideInPlace(otherVector: Vector3): Vector3;
  80365. /**
  80366. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  80367. * @param other defines the second operand
  80368. * @returns the current updated Vector3
  80369. */
  80370. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80371. /**
  80372. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  80373. * @param other defines the second operand
  80374. * @returns the current updated Vector3
  80375. */
  80376. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  80377. /**
  80378. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  80379. * @param x defines the x coordinate of the operand
  80380. * @param y defines the y coordinate of the operand
  80381. * @param z defines the z coordinate of the operand
  80382. * @returns the current updated Vector3
  80383. */
  80384. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80385. /**
  80386. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  80387. * @param x defines the x coordinate of the operand
  80388. * @param y defines the y coordinate of the operand
  80389. * @param z defines the z coordinate of the operand
  80390. * @returns the current updated Vector3
  80391. */
  80392. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80393. /**
  80394. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  80395. * Check if is non uniform within a certain amount of decimal places to account for this
  80396. * @param epsilon the amount the values can differ
  80397. * @returns if the the vector is non uniform to a certain number of decimal places
  80398. */
  80399. isNonUniformWithinEpsilon(epsilon: number): boolean;
  80400. /**
  80401. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  80402. */
  80403. get isNonUniform(): boolean;
  80404. /**
  80405. * Gets a new Vector3 from current Vector3 floored values
  80406. * @returns a new Vector3
  80407. */
  80408. floor(): Vector3;
  80409. /**
  80410. * Gets a new Vector3 from current Vector3 floored values
  80411. * @returns a new Vector3
  80412. */
  80413. fract(): Vector3;
  80414. /**
  80415. * Gets the length of the Vector3
  80416. * @returns the length of the Vector3
  80417. */
  80418. length(): number;
  80419. /**
  80420. * Gets the squared length of the Vector3
  80421. * @returns squared length of the Vector3
  80422. */
  80423. lengthSquared(): number;
  80424. /**
  80425. * Normalize the current Vector3.
  80426. * Please note that this is an in place operation.
  80427. * @returns the current updated Vector3
  80428. */
  80429. normalize(): Vector3;
  80430. /**
  80431. * Reorders the x y z properties of the vector in place
  80432. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  80433. * @returns the current updated vector
  80434. */
  80435. reorderInPlace(order: string): this;
  80436. /**
  80437. * Rotates the vector around 0,0,0 by a quaternion
  80438. * @param quaternion the rotation quaternion
  80439. * @param result vector to store the result
  80440. * @returns the resulting vector
  80441. */
  80442. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  80443. /**
  80444. * Rotates a vector around a given point
  80445. * @param quaternion the rotation quaternion
  80446. * @param point the point to rotate around
  80447. * @param result vector to store the result
  80448. * @returns the resulting vector
  80449. */
  80450. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  80451. /**
  80452. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  80453. * The cross product is then orthogonal to both current and "other"
  80454. * @param other defines the right operand
  80455. * @returns the cross product
  80456. */
  80457. cross(other: Vector3): Vector3;
  80458. /**
  80459. * Normalize the current Vector3 with the given input length.
  80460. * Please note that this is an in place operation.
  80461. * @param len the length of the vector
  80462. * @returns the current updated Vector3
  80463. */
  80464. normalizeFromLength(len: number): Vector3;
  80465. /**
  80466. * Normalize the current Vector3 to a new vector
  80467. * @returns the new Vector3
  80468. */
  80469. normalizeToNew(): Vector3;
  80470. /**
  80471. * Normalize the current Vector3 to the reference
  80472. * @param reference define the Vector3 to update
  80473. * @returns the updated Vector3
  80474. */
  80475. normalizeToRef(reference: Vector3): Vector3;
  80476. /**
  80477. * Creates a new Vector3 copied from the current Vector3
  80478. * @returns the new Vector3
  80479. */
  80480. clone(): Vector3;
  80481. /**
  80482. * Copies the given vector coordinates to the current Vector3 ones
  80483. * @param source defines the source Vector3
  80484. * @returns the current updated Vector3
  80485. */
  80486. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  80487. /**
  80488. * Copies the given floats to the current Vector3 coordinates
  80489. * @param x defines the x coordinate of the operand
  80490. * @param y defines the y coordinate of the operand
  80491. * @param z defines the z coordinate of the operand
  80492. * @returns the current updated Vector3
  80493. */
  80494. copyFromFloats(x: number, y: number, z: number): Vector3;
  80495. /**
  80496. * Copies the given floats to the current Vector3 coordinates
  80497. * @param x defines the x coordinate of the operand
  80498. * @param y defines the y coordinate of the operand
  80499. * @param z defines the z coordinate of the operand
  80500. * @returns the current updated Vector3
  80501. */
  80502. set(x: number, y: number, z: number): Vector3;
  80503. /**
  80504. * Copies the given float to the current Vector3 coordinates
  80505. * @param v defines the x, y and z coordinates of the operand
  80506. * @returns the current updated Vector3
  80507. */
  80508. setAll(v: number): Vector3;
  80509. /**
  80510. * Get the clip factor between two vectors
  80511. * @param vector0 defines the first operand
  80512. * @param vector1 defines the second operand
  80513. * @param axis defines the axis to use
  80514. * @param size defines the size along the axis
  80515. * @returns the clip factor
  80516. */
  80517. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  80518. /**
  80519. * Get angle between two vectors
  80520. * @param vector0 angle between vector0 and vector1
  80521. * @param vector1 angle between vector0 and vector1
  80522. * @param normal direction of the normal
  80523. * @return the angle between vector0 and vector1
  80524. */
  80525. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  80526. /**
  80527. * Returns a new Vector3 set from the index "offset" of the given array
  80528. * @param array defines the source array
  80529. * @param offset defines the offset in the source array
  80530. * @returns the new Vector3
  80531. */
  80532. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  80533. /**
  80534. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  80535. * @param array defines the source array
  80536. * @param offset defines the offset in the source array
  80537. * @returns the new Vector3
  80538. * @deprecated Please use FromArray instead.
  80539. */
  80540. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  80541. /**
  80542. * Sets the given vector "result" with the element values from the index "offset" of the given array
  80543. * @param array defines the source array
  80544. * @param offset defines the offset in the source array
  80545. * @param result defines the Vector3 where to store the result
  80546. */
  80547. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  80548. /**
  80549. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  80550. * @param array defines the source array
  80551. * @param offset defines the offset in the source array
  80552. * @param result defines the Vector3 where to store the result
  80553. * @deprecated Please use FromArrayToRef instead.
  80554. */
  80555. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  80556. /**
  80557. * Sets the given vector "result" with the given floats.
  80558. * @param x defines the x coordinate of the source
  80559. * @param y defines the y coordinate of the source
  80560. * @param z defines the z coordinate of the source
  80561. * @param result defines the Vector3 where to store the result
  80562. */
  80563. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  80564. /**
  80565. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  80566. * @returns a new empty Vector3
  80567. */
  80568. static Zero(): Vector3;
  80569. /**
  80570. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  80571. * @returns a new unit Vector3
  80572. */
  80573. static One(): Vector3;
  80574. /**
  80575. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  80576. * @returns a new up Vector3
  80577. */
  80578. static Up(): Vector3;
  80579. /**
  80580. * Gets a up Vector3 that must not be updated
  80581. */
  80582. static get UpReadOnly(): DeepImmutable<Vector3>;
  80583. /**
  80584. * Gets a zero Vector3 that must not be updated
  80585. */
  80586. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  80587. /**
  80588. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  80589. * @returns a new down Vector3
  80590. */
  80591. static Down(): Vector3;
  80592. /**
  80593. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  80594. * @param rightHandedSystem is the scene right-handed (negative z)
  80595. * @returns a new forward Vector3
  80596. */
  80597. static Forward(rightHandedSystem?: boolean): Vector3;
  80598. /**
  80599. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  80600. * @param rightHandedSystem is the scene right-handed (negative-z)
  80601. * @returns a new forward Vector3
  80602. */
  80603. static Backward(rightHandedSystem?: boolean): Vector3;
  80604. /**
  80605. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  80606. * @returns a new right Vector3
  80607. */
  80608. static Right(): Vector3;
  80609. /**
  80610. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  80611. * @returns a new left Vector3
  80612. */
  80613. static Left(): Vector3;
  80614. /**
  80615. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  80616. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80617. * @param vector defines the Vector3 to transform
  80618. * @param transformation defines the transformation matrix
  80619. * @returns the transformed Vector3
  80620. */
  80621. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80622. /**
  80623. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  80624. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  80625. * @param vector defines the Vector3 to transform
  80626. * @param transformation defines the transformation matrix
  80627. * @param result defines the Vector3 where to store the result
  80628. */
  80629. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80630. /**
  80631. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  80632. * This method computes tranformed coordinates only, not transformed direction vectors
  80633. * @param x define the x coordinate of the source vector
  80634. * @param y define the y coordinate of the source vector
  80635. * @param z define the z coordinate of the source vector
  80636. * @param transformation defines the transformation matrix
  80637. * @param result defines the Vector3 where to store the result
  80638. */
  80639. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80640. /**
  80641. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  80642. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80643. * @param vector defines the Vector3 to transform
  80644. * @param transformation defines the transformation matrix
  80645. * @returns the new Vector3
  80646. */
  80647. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  80648. /**
  80649. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  80650. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80651. * @param vector defines the Vector3 to transform
  80652. * @param transformation defines the transformation matrix
  80653. * @param result defines the Vector3 where to store the result
  80654. */
  80655. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80656. /**
  80657. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  80658. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  80659. * @param x define the x coordinate of the source vector
  80660. * @param y define the y coordinate of the source vector
  80661. * @param z define the z coordinate of the source vector
  80662. * @param transformation defines the transformation matrix
  80663. * @param result defines the Vector3 where to store the result
  80664. */
  80665. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  80666. /**
  80667. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  80668. * @param value1 defines the first control point
  80669. * @param value2 defines the second control point
  80670. * @param value3 defines the third control point
  80671. * @param value4 defines the fourth control point
  80672. * @param amount defines the amount on the spline to use
  80673. * @returns the new Vector3
  80674. */
  80675. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  80676. /**
  80677. * 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"
  80678. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80679. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80680. * @param value defines the current value
  80681. * @param min defines the lower range value
  80682. * @param max defines the upper range value
  80683. * @returns the new Vector3
  80684. */
  80685. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  80686. /**
  80687. * 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"
  80688. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  80689. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  80690. * @param value defines the current value
  80691. * @param min defines the lower range value
  80692. * @param max defines the upper range value
  80693. * @param result defines the Vector3 where to store the result
  80694. */
  80695. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  80696. /**
  80697. * Checks if a given vector is inside a specific range
  80698. * @param v defines the vector to test
  80699. * @param min defines the minimum range
  80700. * @param max defines the maximum range
  80701. */
  80702. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  80703. /**
  80704. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  80705. * @param value1 defines the first control point
  80706. * @param tangent1 defines the first tangent vector
  80707. * @param value2 defines the second control point
  80708. * @param tangent2 defines the second tangent vector
  80709. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  80710. * @returns the new Vector3
  80711. */
  80712. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  80713. /**
  80714. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  80715. * @param start defines the start value
  80716. * @param end defines the end value
  80717. * @param amount max defines amount between both (between 0 and 1)
  80718. * @returns the new Vector3
  80719. */
  80720. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  80721. /**
  80722. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  80723. * @param start defines the start value
  80724. * @param end defines the end value
  80725. * @param amount max defines amount between both (between 0 and 1)
  80726. * @param result defines the Vector3 where to store the result
  80727. */
  80728. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  80729. /**
  80730. * Returns the dot product (float) between the vectors "left" and "right"
  80731. * @param left defines the left operand
  80732. * @param right defines the right operand
  80733. * @returns the dot product
  80734. */
  80735. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  80736. /**
  80737. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  80738. * The cross product is then orthogonal to both "left" and "right"
  80739. * @param left defines the left operand
  80740. * @param right defines the right operand
  80741. * @returns the cross product
  80742. */
  80743. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80744. /**
  80745. * Sets the given vector "result" with the cross product of "left" and "right"
  80746. * The cross product is then orthogonal to both "left" and "right"
  80747. * @param left defines the left operand
  80748. * @param right defines the right operand
  80749. * @param result defines the Vector3 where to store the result
  80750. */
  80751. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  80752. /**
  80753. * Returns a new Vector3 as the normalization of the given vector
  80754. * @param vector defines the Vector3 to normalize
  80755. * @returns the new Vector3
  80756. */
  80757. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  80758. /**
  80759. * Sets the given vector "result" with the normalization of the given first vector
  80760. * @param vector defines the Vector3 to normalize
  80761. * @param result defines the Vector3 where to store the result
  80762. */
  80763. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  80764. /**
  80765. * Project a Vector3 onto screen space
  80766. * @param vector defines the Vector3 to project
  80767. * @param world defines the world matrix to use
  80768. * @param transform defines the transform (view x projection) matrix to use
  80769. * @param viewport defines the screen viewport to use
  80770. * @returns the new Vector3
  80771. */
  80772. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  80773. /** @hidden */
  80774. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  80775. /**
  80776. * Unproject from screen space to object space
  80777. * @param source defines the screen space Vector3 to use
  80778. * @param viewportWidth defines the current width of the viewport
  80779. * @param viewportHeight defines the current height of the viewport
  80780. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80781. * @param transform defines the transform (view x projection) matrix to use
  80782. * @returns the new Vector3
  80783. */
  80784. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  80785. /**
  80786. * Unproject from screen space to object space
  80787. * @param source defines the screen space Vector3 to use
  80788. * @param viewportWidth defines the current width of the viewport
  80789. * @param viewportHeight defines the current height of the viewport
  80790. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80791. * @param view defines the view matrix to use
  80792. * @param projection defines the projection matrix to use
  80793. * @returns the new Vector3
  80794. */
  80795. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  80796. /**
  80797. * Unproject from screen space to object space
  80798. * @param source defines the screen space Vector3 to use
  80799. * @param viewportWidth defines the current width of the viewport
  80800. * @param viewportHeight defines the current height of the viewport
  80801. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80802. * @param view defines the view matrix to use
  80803. * @param projection defines the projection matrix to use
  80804. * @param result defines the Vector3 where to store the result
  80805. */
  80806. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80807. /**
  80808. * Unproject from screen space to object space
  80809. * @param sourceX defines the screen space x coordinate to use
  80810. * @param sourceY defines the screen space y coordinate to use
  80811. * @param sourceZ defines the screen space z coordinate to use
  80812. * @param viewportWidth defines the current width of the viewport
  80813. * @param viewportHeight defines the current height of the viewport
  80814. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  80815. * @param view defines the view matrix to use
  80816. * @param projection defines the projection matrix to use
  80817. * @param result defines the Vector3 where to store the result
  80818. */
  80819. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  80820. /**
  80821. * Gets the minimal coordinate values between two Vector3
  80822. * @param left defines the first operand
  80823. * @param right defines the second operand
  80824. * @returns the new Vector3
  80825. */
  80826. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80827. /**
  80828. * Gets the maximal coordinate values between two Vector3
  80829. * @param left defines the first operand
  80830. * @param right defines the second operand
  80831. * @returns the new Vector3
  80832. */
  80833. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  80834. /**
  80835. * Returns the distance between the vectors "value1" and "value2"
  80836. * @param value1 defines the first operand
  80837. * @param value2 defines the second operand
  80838. * @returns the distance
  80839. */
  80840. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80841. /**
  80842. * Returns the squared distance between the vectors "value1" and "value2"
  80843. * @param value1 defines the first operand
  80844. * @param value2 defines the second operand
  80845. * @returns the squared distance
  80846. */
  80847. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  80848. /**
  80849. * Returns a new Vector3 located at the center between "value1" and "value2"
  80850. * @param value1 defines the first operand
  80851. * @param value2 defines the second operand
  80852. * @returns the new Vector3
  80853. */
  80854. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  80855. /**
  80856. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  80857. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  80858. * to something in order to rotate it from its local system to the given target system
  80859. * Note: axis1, axis2 and axis3 are normalized during this operation
  80860. * @param axis1 defines the first axis
  80861. * @param axis2 defines the second axis
  80862. * @param axis3 defines the third axis
  80863. * @returns a new Vector3
  80864. */
  80865. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  80866. /**
  80867. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  80868. * @param axis1 defines the first axis
  80869. * @param axis2 defines the second axis
  80870. * @param axis3 defines the third axis
  80871. * @param ref defines the Vector3 where to store the result
  80872. */
  80873. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  80874. }
  80875. /**
  80876. * Vector4 class created for EulerAngle class conversion to Quaternion
  80877. */
  80878. export class Vector4 {
  80879. /** x value of the vector */
  80880. x: number;
  80881. /** y value of the vector */
  80882. y: number;
  80883. /** z value of the vector */
  80884. z: number;
  80885. /** w value of the vector */
  80886. w: number;
  80887. /**
  80888. * Creates a Vector4 object from the given floats.
  80889. * @param x x value of the vector
  80890. * @param y y value of the vector
  80891. * @param z z value of the vector
  80892. * @param w w value of the vector
  80893. */
  80894. constructor(
  80895. /** x value of the vector */
  80896. x: number,
  80897. /** y value of the vector */
  80898. y: number,
  80899. /** z value of the vector */
  80900. z: number,
  80901. /** w value of the vector */
  80902. w: number);
  80903. /**
  80904. * Returns the string with the Vector4 coordinates.
  80905. * @returns a string containing all the vector values
  80906. */
  80907. toString(): string;
  80908. /**
  80909. * Returns the string "Vector4".
  80910. * @returns "Vector4"
  80911. */
  80912. getClassName(): string;
  80913. /**
  80914. * Returns the Vector4 hash code.
  80915. * @returns a unique hash code
  80916. */
  80917. getHashCode(): number;
  80918. /**
  80919. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  80920. * @returns the resulting array
  80921. */
  80922. asArray(): number[];
  80923. /**
  80924. * Populates the given array from the given index with the Vector4 coordinates.
  80925. * @param array array to populate
  80926. * @param index index of the array to start at (default: 0)
  80927. * @returns the Vector4.
  80928. */
  80929. toArray(array: FloatArray, index?: number): Vector4;
  80930. /**
  80931. * Adds the given vector to the current Vector4.
  80932. * @param otherVector the vector to add
  80933. * @returns the updated Vector4.
  80934. */
  80935. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80936. /**
  80937. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  80938. * @param otherVector the vector to add
  80939. * @returns the resulting vector
  80940. */
  80941. add(otherVector: DeepImmutable<Vector4>): Vector4;
  80942. /**
  80943. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  80944. * @param otherVector the vector to add
  80945. * @param result the vector to store the result
  80946. * @returns the current Vector4.
  80947. */
  80948. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80949. /**
  80950. * Subtract in place the given vector from the current Vector4.
  80951. * @param otherVector the vector to subtract
  80952. * @returns the updated Vector4.
  80953. */
  80954. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  80955. /**
  80956. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  80957. * @param otherVector the vector to add
  80958. * @returns the new vector with the result
  80959. */
  80960. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  80961. /**
  80962. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  80963. * @param otherVector the vector to subtract
  80964. * @param result the vector to store the result
  80965. * @returns the current Vector4.
  80966. */
  80967. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  80968. /**
  80969. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80970. */
  80971. /**
  80972. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80973. * @param x value to subtract
  80974. * @param y value to subtract
  80975. * @param z value to subtract
  80976. * @param w value to subtract
  80977. * @returns new vector containing the result
  80978. */
  80979. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  80980. /**
  80981. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  80982. * @param x value to subtract
  80983. * @param y value to subtract
  80984. * @param z value to subtract
  80985. * @param w value to subtract
  80986. * @param result the vector to store the result in
  80987. * @returns the current Vector4.
  80988. */
  80989. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  80990. /**
  80991. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  80992. * @returns a new vector with the negated values
  80993. */
  80994. negate(): Vector4;
  80995. /**
  80996. * Negate this vector in place
  80997. * @returns this
  80998. */
  80999. negateInPlace(): Vector4;
  81000. /**
  81001. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81002. * @param result defines the Vector3 object where to store the result
  81003. * @returns the current Vector4
  81004. */
  81005. negateToRef(result: Vector4): Vector4;
  81006. /**
  81007. * Multiplies the current Vector4 coordinates by scale (float).
  81008. * @param scale the number to scale with
  81009. * @returns the updated Vector4.
  81010. */
  81011. scaleInPlace(scale: number): Vector4;
  81012. /**
  81013. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81014. * @param scale the number to scale with
  81015. * @returns a new vector with the result
  81016. */
  81017. scale(scale: number): Vector4;
  81018. /**
  81019. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81020. * @param scale the number to scale with
  81021. * @param result a vector to store the result in
  81022. * @returns the current Vector4.
  81023. */
  81024. scaleToRef(scale: number, result: Vector4): Vector4;
  81025. /**
  81026. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81027. * @param scale defines the scale factor
  81028. * @param result defines the Vector4 object where to store the result
  81029. * @returns the unmodified current Vector4
  81030. */
  81031. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81032. /**
  81033. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81034. * @param otherVector the vector to compare against
  81035. * @returns true if they are equal
  81036. */
  81037. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81038. /**
  81039. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81040. * @param otherVector vector to compare against
  81041. * @param epsilon (Default: very small number)
  81042. * @returns true if they are equal
  81043. */
  81044. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81045. /**
  81046. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81047. * @param x x value to compare against
  81048. * @param y y value to compare against
  81049. * @param z z value to compare against
  81050. * @param w w value to compare against
  81051. * @returns true if equal
  81052. */
  81053. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81054. /**
  81055. * Multiplies in place the current Vector4 by the given one.
  81056. * @param otherVector vector to multiple with
  81057. * @returns the updated Vector4.
  81058. */
  81059. multiplyInPlace(otherVector: Vector4): Vector4;
  81060. /**
  81061. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81062. * @param otherVector vector to multiple with
  81063. * @returns resulting new vector
  81064. */
  81065. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81066. /**
  81067. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81068. * @param otherVector vector to multiple with
  81069. * @param result vector to store the result
  81070. * @returns the current Vector4.
  81071. */
  81072. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81073. /**
  81074. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81075. * @param x x value multiply with
  81076. * @param y y value multiply with
  81077. * @param z z value multiply with
  81078. * @param w w value multiply with
  81079. * @returns resulting new vector
  81080. */
  81081. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81082. /**
  81083. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81084. * @param otherVector vector to devide with
  81085. * @returns resulting new vector
  81086. */
  81087. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81088. /**
  81089. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81090. * @param otherVector vector to devide with
  81091. * @param result vector to store the result
  81092. * @returns the current Vector4.
  81093. */
  81094. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81095. /**
  81096. * Divides the current Vector3 coordinates by the given ones.
  81097. * @param otherVector vector to devide with
  81098. * @returns the updated Vector3.
  81099. */
  81100. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81101. /**
  81102. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81103. * @param other defines the second operand
  81104. * @returns the current updated Vector4
  81105. */
  81106. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81107. /**
  81108. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81109. * @param other defines the second operand
  81110. * @returns the current updated Vector4
  81111. */
  81112. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81113. /**
  81114. * Gets a new Vector4 from current Vector4 floored values
  81115. * @returns a new Vector4
  81116. */
  81117. floor(): Vector4;
  81118. /**
  81119. * Gets a new Vector4 from current Vector3 floored values
  81120. * @returns a new Vector4
  81121. */
  81122. fract(): Vector4;
  81123. /**
  81124. * Returns the Vector4 length (float).
  81125. * @returns the length
  81126. */
  81127. length(): number;
  81128. /**
  81129. * Returns the Vector4 squared length (float).
  81130. * @returns the length squared
  81131. */
  81132. lengthSquared(): number;
  81133. /**
  81134. * Normalizes in place the Vector4.
  81135. * @returns the updated Vector4.
  81136. */
  81137. normalize(): Vector4;
  81138. /**
  81139. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81140. * @returns this converted to a new vector3
  81141. */
  81142. toVector3(): Vector3;
  81143. /**
  81144. * Returns a new Vector4 copied from the current one.
  81145. * @returns the new cloned vector
  81146. */
  81147. clone(): Vector4;
  81148. /**
  81149. * Updates the current Vector4 with the given one coordinates.
  81150. * @param source the source vector to copy from
  81151. * @returns the updated Vector4.
  81152. */
  81153. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81154. /**
  81155. * Updates the current Vector4 coordinates with the given floats.
  81156. * @param x float to copy from
  81157. * @param y float to copy from
  81158. * @param z float to copy from
  81159. * @param w float to copy from
  81160. * @returns the updated Vector4.
  81161. */
  81162. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81163. /**
  81164. * Updates the current Vector4 coordinates with the given floats.
  81165. * @param x float to set from
  81166. * @param y float to set from
  81167. * @param z float to set from
  81168. * @param w float to set from
  81169. * @returns the updated Vector4.
  81170. */
  81171. set(x: number, y: number, z: number, w: number): Vector4;
  81172. /**
  81173. * Copies the given float to the current Vector3 coordinates
  81174. * @param v defines the x, y, z and w coordinates of the operand
  81175. * @returns the current updated Vector3
  81176. */
  81177. setAll(v: number): Vector4;
  81178. /**
  81179. * Returns a new Vector4 set from the starting index of the given array.
  81180. * @param array the array to pull values from
  81181. * @param offset the offset into the array to start at
  81182. * @returns the new vector
  81183. */
  81184. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81185. /**
  81186. * Updates the given vector "result" from the starting index of the given array.
  81187. * @param array the array to pull values from
  81188. * @param offset the offset into the array to start at
  81189. * @param result the vector to store the result in
  81190. */
  81191. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81192. /**
  81193. * Updates the given vector "result" from the starting index of the given Float32Array.
  81194. * @param array the array to pull values from
  81195. * @param offset the offset into the array to start at
  81196. * @param result the vector to store the result in
  81197. */
  81198. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81199. /**
  81200. * Updates the given vector "result" coordinates from the given floats.
  81201. * @param x float to set from
  81202. * @param y float to set from
  81203. * @param z float to set from
  81204. * @param w float to set from
  81205. * @param result the vector to the floats in
  81206. */
  81207. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81208. /**
  81209. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81210. * @returns the new vector
  81211. */
  81212. static Zero(): Vector4;
  81213. /**
  81214. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81215. * @returns the new vector
  81216. */
  81217. static One(): Vector4;
  81218. /**
  81219. * Returns a new normalized Vector4 from the given one.
  81220. * @param vector the vector to normalize
  81221. * @returns the vector
  81222. */
  81223. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81224. /**
  81225. * Updates the given vector "result" from the normalization of the given one.
  81226. * @param vector the vector to normalize
  81227. * @param result the vector to store the result in
  81228. */
  81229. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81230. /**
  81231. * Returns a vector with the minimum values from the left and right vectors
  81232. * @param left left vector to minimize
  81233. * @param right right vector to minimize
  81234. * @returns a new vector with the minimum of the left and right vector values
  81235. */
  81236. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81237. /**
  81238. * Returns a vector with the maximum values from the left and right vectors
  81239. * @param left left vector to maximize
  81240. * @param right right vector to maximize
  81241. * @returns a new vector with the maximum of the left and right vector values
  81242. */
  81243. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81244. /**
  81245. * Returns the distance (float) between the vectors "value1" and "value2".
  81246. * @param value1 value to calulate the distance between
  81247. * @param value2 value to calulate the distance between
  81248. * @return the distance between the two vectors
  81249. */
  81250. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81251. /**
  81252. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81253. * @param value1 value to calulate the distance between
  81254. * @param value2 value to calulate the distance between
  81255. * @return the distance between the two vectors squared
  81256. */
  81257. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81258. /**
  81259. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81260. * @param value1 value to calulate the center between
  81261. * @param value2 value to calulate the center between
  81262. * @return the center between the two vectors
  81263. */
  81264. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81265. /**
  81266. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81267. * This methods computes transformed normalized direction vectors only.
  81268. * @param vector the vector to transform
  81269. * @param transformation the transformation matrix to apply
  81270. * @returns the new vector
  81271. */
  81272. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81273. /**
  81274. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81275. * This methods computes transformed normalized direction vectors only.
  81276. * @param vector the vector to transform
  81277. * @param transformation the transformation matrix to apply
  81278. * @param result the vector to store the result in
  81279. */
  81280. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81281. /**
  81282. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81283. * This methods computes transformed normalized direction vectors only.
  81284. * @param x value to transform
  81285. * @param y value to transform
  81286. * @param z value to transform
  81287. * @param w value to transform
  81288. * @param transformation the transformation matrix to apply
  81289. * @param result the vector to store the results in
  81290. */
  81291. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81292. /**
  81293. * Creates a new Vector4 from a Vector3
  81294. * @param source defines the source data
  81295. * @param w defines the 4th component (default is 0)
  81296. * @returns a new Vector4
  81297. */
  81298. static FromVector3(source: Vector3, w?: number): Vector4;
  81299. }
  81300. /**
  81301. * Class used to store quaternion data
  81302. * @see https://en.wikipedia.org/wiki/Quaternion
  81303. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  81304. */
  81305. export class Quaternion {
  81306. /** @hidden */
  81307. _x: number;
  81308. /** @hidden */
  81309. _y: number;
  81310. /** @hidden */
  81311. _z: number;
  81312. /** @hidden */
  81313. _w: number;
  81314. /** @hidden */
  81315. _isDirty: boolean;
  81316. /** Gets or sets the x coordinate */
  81317. get x(): number;
  81318. set x(value: number);
  81319. /** Gets or sets the y coordinate */
  81320. get y(): number;
  81321. set y(value: number);
  81322. /** Gets or sets the z coordinate */
  81323. get z(): number;
  81324. set z(value: number);
  81325. /** Gets or sets the w coordinate */
  81326. get w(): number;
  81327. set w(value: number);
  81328. /**
  81329. * Creates a new Quaternion from the given floats
  81330. * @param x defines the first component (0 by default)
  81331. * @param y defines the second component (0 by default)
  81332. * @param z defines the third component (0 by default)
  81333. * @param w defines the fourth component (1.0 by default)
  81334. */
  81335. constructor(x?: number, y?: number, z?: number, w?: number);
  81336. /**
  81337. * Gets a string representation for the current quaternion
  81338. * @returns a string with the Quaternion coordinates
  81339. */
  81340. toString(): string;
  81341. /**
  81342. * Gets the class name of the quaternion
  81343. * @returns the string "Quaternion"
  81344. */
  81345. getClassName(): string;
  81346. /**
  81347. * Gets a hash code for this quaternion
  81348. * @returns the quaternion hash code
  81349. */
  81350. getHashCode(): number;
  81351. /**
  81352. * Copy the quaternion to an array
  81353. * @returns a new array populated with 4 elements from the quaternion coordinates
  81354. */
  81355. asArray(): number[];
  81356. /**
  81357. * Check if two quaternions are equals
  81358. * @param otherQuaternion defines the second operand
  81359. * @return true if the current quaternion and the given one coordinates are strictly equals
  81360. */
  81361. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  81362. /**
  81363. * Gets a boolean if two quaternions are equals (using an epsilon value)
  81364. * @param otherQuaternion defines the other quaternion
  81365. * @param epsilon defines the minimal distance to consider equality
  81366. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  81367. */
  81368. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  81369. /**
  81370. * Clone the current quaternion
  81371. * @returns a new quaternion copied from the current one
  81372. */
  81373. clone(): Quaternion;
  81374. /**
  81375. * Copy a quaternion to the current one
  81376. * @param other defines the other quaternion
  81377. * @returns the updated current quaternion
  81378. */
  81379. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  81380. /**
  81381. * Updates the current quaternion with the given float coordinates
  81382. * @param x defines the x coordinate
  81383. * @param y defines the y coordinate
  81384. * @param z defines the z coordinate
  81385. * @param w defines the w coordinate
  81386. * @returns the updated current quaternion
  81387. */
  81388. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  81389. /**
  81390. * Updates the current quaternion from the given float coordinates
  81391. * @param x defines the x coordinate
  81392. * @param y defines the y coordinate
  81393. * @param z defines the z coordinate
  81394. * @param w defines the w coordinate
  81395. * @returns the updated current quaternion
  81396. */
  81397. set(x: number, y: number, z: number, w: number): Quaternion;
  81398. /**
  81399. * Adds two quaternions
  81400. * @param other defines the second operand
  81401. * @returns a new quaternion as the addition result of the given one and the current quaternion
  81402. */
  81403. add(other: DeepImmutable<Quaternion>): Quaternion;
  81404. /**
  81405. * Add a quaternion to the current one
  81406. * @param other defines the quaternion to add
  81407. * @returns the current quaternion
  81408. */
  81409. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  81410. /**
  81411. * Subtract two quaternions
  81412. * @param other defines the second operand
  81413. * @returns a new quaternion as the subtraction result of the given one from the current one
  81414. */
  81415. subtract(other: Quaternion): Quaternion;
  81416. /**
  81417. * Multiplies the current quaternion by a scale factor
  81418. * @param value defines the scale factor
  81419. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  81420. */
  81421. scale(value: number): Quaternion;
  81422. /**
  81423. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  81424. * @param scale defines the scale factor
  81425. * @param result defines the Quaternion object where to store the result
  81426. * @returns the unmodified current quaternion
  81427. */
  81428. scaleToRef(scale: number, result: Quaternion): Quaternion;
  81429. /**
  81430. * Multiplies in place the current quaternion by a scale factor
  81431. * @param value defines the scale factor
  81432. * @returns the current modified quaternion
  81433. */
  81434. scaleInPlace(value: number): Quaternion;
  81435. /**
  81436. * Scale the current quaternion values by a factor and add the result to a given quaternion
  81437. * @param scale defines the scale factor
  81438. * @param result defines the Quaternion object where to store the result
  81439. * @returns the unmodified current quaternion
  81440. */
  81441. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  81442. /**
  81443. * Multiplies two quaternions
  81444. * @param q1 defines the second operand
  81445. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  81446. */
  81447. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  81448. /**
  81449. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  81450. * @param q1 defines the second operand
  81451. * @param result defines the target quaternion
  81452. * @returns the current quaternion
  81453. */
  81454. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  81455. /**
  81456. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  81457. * @param q1 defines the second operand
  81458. * @returns the currentupdated quaternion
  81459. */
  81460. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  81461. /**
  81462. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  81463. * @param ref defines the target quaternion
  81464. * @returns the current quaternion
  81465. */
  81466. conjugateToRef(ref: Quaternion): Quaternion;
  81467. /**
  81468. * Conjugates in place (1-q) the current quaternion
  81469. * @returns the current updated quaternion
  81470. */
  81471. conjugateInPlace(): Quaternion;
  81472. /**
  81473. * Conjugates in place (1-q) the current quaternion
  81474. * @returns a new quaternion
  81475. */
  81476. conjugate(): Quaternion;
  81477. /**
  81478. * Gets length of current quaternion
  81479. * @returns the quaternion length (float)
  81480. */
  81481. length(): number;
  81482. /**
  81483. * Normalize in place the current quaternion
  81484. * @returns the current updated quaternion
  81485. */
  81486. normalize(): Quaternion;
  81487. /**
  81488. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  81489. * @param order is a reserved parameter and is ignore for now
  81490. * @returns a new Vector3 containing the Euler angles
  81491. */
  81492. toEulerAngles(order?: string): Vector3;
  81493. /**
  81494. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  81495. * @param result defines the vector which will be filled with the Euler angles
  81496. * @param order is a reserved parameter and is ignore for now
  81497. * @returns the current unchanged quaternion
  81498. */
  81499. toEulerAnglesToRef(result: Vector3): Quaternion;
  81500. /**
  81501. * Updates the given rotation matrix with the current quaternion values
  81502. * @param result defines the target matrix
  81503. * @returns the current unchanged quaternion
  81504. */
  81505. toRotationMatrix(result: Matrix): Quaternion;
  81506. /**
  81507. * Updates the current quaternion from the given rotation matrix values
  81508. * @param matrix defines the source matrix
  81509. * @returns the current updated quaternion
  81510. */
  81511. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81512. /**
  81513. * Creates a new quaternion from a rotation matrix
  81514. * @param matrix defines the source matrix
  81515. * @returns a new quaternion created from the given rotation matrix values
  81516. */
  81517. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  81518. /**
  81519. * Updates the given quaternion with the given rotation matrix values
  81520. * @param matrix defines the source matrix
  81521. * @param result defines the target quaternion
  81522. */
  81523. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  81524. /**
  81525. * Returns the dot product (float) between the quaternions "left" and "right"
  81526. * @param left defines the left operand
  81527. * @param right defines the right operand
  81528. * @returns the dot product
  81529. */
  81530. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  81531. /**
  81532. * Checks if the two quaternions are close to each other
  81533. * @param quat0 defines the first quaternion to check
  81534. * @param quat1 defines the second quaternion to check
  81535. * @returns true if the two quaternions are close to each other
  81536. */
  81537. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  81538. /**
  81539. * Creates an empty quaternion
  81540. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  81541. */
  81542. static Zero(): Quaternion;
  81543. /**
  81544. * Inverse a given quaternion
  81545. * @param q defines the source quaternion
  81546. * @returns a new quaternion as the inverted current quaternion
  81547. */
  81548. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  81549. /**
  81550. * Inverse a given quaternion
  81551. * @param q defines the source quaternion
  81552. * @param result the quaternion the result will be stored in
  81553. * @returns the result quaternion
  81554. */
  81555. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  81556. /**
  81557. * Creates an identity quaternion
  81558. * @returns the identity quaternion
  81559. */
  81560. static Identity(): Quaternion;
  81561. /**
  81562. * Gets a boolean indicating if the given quaternion is identity
  81563. * @param quaternion defines the quaternion to check
  81564. * @returns true if the quaternion is identity
  81565. */
  81566. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  81567. /**
  81568. * Creates a quaternion from a rotation around an axis
  81569. * @param axis defines the axis to use
  81570. * @param angle defines the angle to use
  81571. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  81572. */
  81573. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  81574. /**
  81575. * Creates a rotation around an axis and stores it into the given quaternion
  81576. * @param axis defines the axis to use
  81577. * @param angle defines the angle to use
  81578. * @param result defines the target quaternion
  81579. * @returns the target quaternion
  81580. */
  81581. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  81582. /**
  81583. * Creates a new quaternion from data stored into an array
  81584. * @param array defines the data source
  81585. * @param offset defines the offset in the source array where the data starts
  81586. * @returns a new quaternion
  81587. */
  81588. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  81589. /**
  81590. * Updates the given quaternion "result" from the starting index of the given array.
  81591. * @param array the array to pull values from
  81592. * @param offset the offset into the array to start at
  81593. * @param result the quaternion to store the result in
  81594. */
  81595. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  81596. /**
  81597. * Create a quaternion from Euler rotation angles
  81598. * @param x Pitch
  81599. * @param y Yaw
  81600. * @param z Roll
  81601. * @returns the new Quaternion
  81602. */
  81603. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  81604. /**
  81605. * Updates a quaternion from Euler rotation angles
  81606. * @param x Pitch
  81607. * @param y Yaw
  81608. * @param z Roll
  81609. * @param result the quaternion to store the result
  81610. * @returns the updated quaternion
  81611. */
  81612. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  81613. /**
  81614. * Create a quaternion from Euler rotation vector
  81615. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81616. * @returns the new Quaternion
  81617. */
  81618. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  81619. /**
  81620. * Updates a quaternion from Euler rotation vector
  81621. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  81622. * @param result the quaternion to store the result
  81623. * @returns the updated quaternion
  81624. */
  81625. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  81626. /**
  81627. * Creates a new quaternion from the given Euler float angles (y, x, z)
  81628. * @param yaw defines the rotation around Y axis
  81629. * @param pitch defines the rotation around X axis
  81630. * @param roll defines the rotation around Z axis
  81631. * @returns the new quaternion
  81632. */
  81633. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  81634. /**
  81635. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  81636. * @param yaw defines the rotation around Y axis
  81637. * @param pitch defines the rotation around X axis
  81638. * @param roll defines the rotation around Z axis
  81639. * @param result defines the target quaternion
  81640. */
  81641. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  81642. /**
  81643. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  81644. * @param alpha defines the rotation around first axis
  81645. * @param beta defines the rotation around second axis
  81646. * @param gamma defines the rotation around third axis
  81647. * @returns the new quaternion
  81648. */
  81649. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  81650. /**
  81651. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  81652. * @param alpha defines the rotation around first axis
  81653. * @param beta defines the rotation around second axis
  81654. * @param gamma defines the rotation around third axis
  81655. * @param result defines the target quaternion
  81656. */
  81657. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  81658. /**
  81659. * 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)
  81660. * @param axis1 defines the first axis
  81661. * @param axis2 defines the second axis
  81662. * @param axis3 defines the third axis
  81663. * @returns the new quaternion
  81664. */
  81665. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  81666. /**
  81667. * 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
  81668. * @param axis1 defines the first axis
  81669. * @param axis2 defines the second axis
  81670. * @param axis3 defines the third axis
  81671. * @param ref defines the target quaternion
  81672. */
  81673. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  81674. /**
  81675. * Interpolates between two quaternions
  81676. * @param left defines first quaternion
  81677. * @param right defines second quaternion
  81678. * @param amount defines the gradient to use
  81679. * @returns the new interpolated quaternion
  81680. */
  81681. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81682. /**
  81683. * Interpolates between two quaternions and stores it into a target quaternion
  81684. * @param left defines first quaternion
  81685. * @param right defines second quaternion
  81686. * @param amount defines the gradient to use
  81687. * @param result defines the target quaternion
  81688. */
  81689. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  81690. /**
  81691. * Interpolate between two quaternions using Hermite interpolation
  81692. * @param value1 defines first quaternion
  81693. * @param tangent1 defines the incoming tangent
  81694. * @param value2 defines second quaternion
  81695. * @param tangent2 defines the outgoing tangent
  81696. * @param amount defines the target quaternion
  81697. * @returns the new interpolated quaternion
  81698. */
  81699. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  81700. }
  81701. /**
  81702. * Class used to store matrix data (4x4)
  81703. */
  81704. export class Matrix {
  81705. private static _updateFlagSeed;
  81706. private static _identityReadOnly;
  81707. private _isIdentity;
  81708. private _isIdentityDirty;
  81709. private _isIdentity3x2;
  81710. private _isIdentity3x2Dirty;
  81711. /**
  81712. * Gets the update flag of the matrix which is an unique number for the matrix.
  81713. * It will be incremented every time the matrix data change.
  81714. * You can use it to speed the comparison between two versions of the same matrix.
  81715. */
  81716. updateFlag: number;
  81717. private readonly _m;
  81718. /**
  81719. * Gets the internal data of the matrix
  81720. */
  81721. get m(): DeepImmutable<Float32Array>;
  81722. /** @hidden */
  81723. _markAsUpdated(): void;
  81724. /** @hidden */
  81725. private _updateIdentityStatus;
  81726. /**
  81727. * Creates an empty matrix (filled with zeros)
  81728. */
  81729. constructor();
  81730. /**
  81731. * Check if the current matrix is identity
  81732. * @returns true is the matrix is the identity matrix
  81733. */
  81734. isIdentity(): boolean;
  81735. /**
  81736. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  81737. * @returns true is the matrix is the identity matrix
  81738. */
  81739. isIdentityAs3x2(): boolean;
  81740. /**
  81741. * Gets the determinant of the matrix
  81742. * @returns the matrix determinant
  81743. */
  81744. determinant(): number;
  81745. /**
  81746. * Returns the matrix as a Float32Array
  81747. * @returns the matrix underlying array
  81748. */
  81749. toArray(): DeepImmutable<Float32Array>;
  81750. /**
  81751. * Returns the matrix as a Float32Array
  81752. * @returns the matrix underlying array.
  81753. */
  81754. asArray(): DeepImmutable<Float32Array>;
  81755. /**
  81756. * Inverts the current matrix in place
  81757. * @returns the current inverted matrix
  81758. */
  81759. invert(): Matrix;
  81760. /**
  81761. * Sets all the matrix elements to zero
  81762. * @returns the current matrix
  81763. */
  81764. reset(): Matrix;
  81765. /**
  81766. * Adds the current matrix with a second one
  81767. * @param other defines the matrix to add
  81768. * @returns a new matrix as the addition of the current matrix and the given one
  81769. */
  81770. add(other: DeepImmutable<Matrix>): Matrix;
  81771. /**
  81772. * Sets the given matrix "result" to the addition of the current matrix and the given one
  81773. * @param other defines the matrix to add
  81774. * @param result defines the target matrix
  81775. * @returns the current matrix
  81776. */
  81777. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81778. /**
  81779. * Adds in place the given matrix to the current matrix
  81780. * @param other defines the second operand
  81781. * @returns the current updated matrix
  81782. */
  81783. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  81784. /**
  81785. * Sets the given matrix to the current inverted Matrix
  81786. * @param other defines the target matrix
  81787. * @returns the unmodified current matrix
  81788. */
  81789. invertToRef(other: Matrix): Matrix;
  81790. /**
  81791. * add a value at the specified position in the current Matrix
  81792. * @param index the index of the value within the matrix. between 0 and 15.
  81793. * @param value the value to be added
  81794. * @returns the current updated matrix
  81795. */
  81796. addAtIndex(index: number, value: number): Matrix;
  81797. /**
  81798. * mutiply the specified position in the current Matrix by a value
  81799. * @param index the index of the value within the matrix. between 0 and 15.
  81800. * @param value the value to be added
  81801. * @returns the current updated matrix
  81802. */
  81803. multiplyAtIndex(index: number, value: number): Matrix;
  81804. /**
  81805. * Inserts the translation vector (using 3 floats) in the current matrix
  81806. * @param x defines the 1st component of the translation
  81807. * @param y defines the 2nd component of the translation
  81808. * @param z defines the 3rd component of the translation
  81809. * @returns the current updated matrix
  81810. */
  81811. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81812. /**
  81813. * Adds the translation vector (using 3 floats) in the current matrix
  81814. * @param x defines the 1st component of the translation
  81815. * @param y defines the 2nd component of the translation
  81816. * @param z defines the 3rd component of the translation
  81817. * @returns the current updated matrix
  81818. */
  81819. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  81820. /**
  81821. * Inserts the translation vector in the current matrix
  81822. * @param vector3 defines the translation to insert
  81823. * @returns the current updated matrix
  81824. */
  81825. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  81826. /**
  81827. * Gets the translation value of the current matrix
  81828. * @returns a new Vector3 as the extracted translation from the matrix
  81829. */
  81830. getTranslation(): Vector3;
  81831. /**
  81832. * Fill a Vector3 with the extracted translation from the matrix
  81833. * @param result defines the Vector3 where to store the translation
  81834. * @returns the current matrix
  81835. */
  81836. getTranslationToRef(result: Vector3): Matrix;
  81837. /**
  81838. * Remove rotation and scaling part from the matrix
  81839. * @returns the updated matrix
  81840. */
  81841. removeRotationAndScaling(): Matrix;
  81842. /**
  81843. * Multiply two matrices
  81844. * @param other defines the second operand
  81845. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  81846. */
  81847. multiply(other: DeepImmutable<Matrix>): Matrix;
  81848. /**
  81849. * Copy the current matrix from the given one
  81850. * @param other defines the source matrix
  81851. * @returns the current updated matrix
  81852. */
  81853. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  81854. /**
  81855. * Populates the given array from the starting index with the current matrix values
  81856. * @param array defines the target array
  81857. * @param offset defines the offset in the target array where to start storing values
  81858. * @returns the current matrix
  81859. */
  81860. copyToArray(array: Float32Array, offset?: number): Matrix;
  81861. /**
  81862. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  81863. * @param other defines the second operand
  81864. * @param result defines the matrix where to store the multiplication
  81865. * @returns the current matrix
  81866. */
  81867. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  81868. /**
  81869. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  81870. * @param other defines the second operand
  81871. * @param result defines the array where to store the multiplication
  81872. * @param offset defines the offset in the target array where to start storing values
  81873. * @returns the current matrix
  81874. */
  81875. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  81876. /**
  81877. * Check equality between this matrix and a second one
  81878. * @param value defines the second matrix to compare
  81879. * @returns true is the current matrix and the given one values are strictly equal
  81880. */
  81881. equals(value: DeepImmutable<Matrix>): boolean;
  81882. /**
  81883. * Clone the current matrix
  81884. * @returns a new matrix from the current matrix
  81885. */
  81886. clone(): Matrix;
  81887. /**
  81888. * Returns the name of the current matrix class
  81889. * @returns the string "Matrix"
  81890. */
  81891. getClassName(): string;
  81892. /**
  81893. * Gets the hash code of the current matrix
  81894. * @returns the hash code
  81895. */
  81896. getHashCode(): number;
  81897. /**
  81898. * Decomposes the current Matrix into a translation, rotation and scaling components
  81899. * @param scale defines the scale vector3 given as a reference to update
  81900. * @param rotation defines the rotation quaternion given as a reference to update
  81901. * @param translation defines the translation vector3 given as a reference to update
  81902. * @returns true if operation was successful
  81903. */
  81904. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  81905. /**
  81906. * Gets specific row of the matrix
  81907. * @param index defines the number of the row to get
  81908. * @returns the index-th row of the current matrix as a new Vector4
  81909. */
  81910. getRow(index: number): Nullable<Vector4>;
  81911. /**
  81912. * Sets the index-th row of the current matrix to the vector4 values
  81913. * @param index defines the number of the row to set
  81914. * @param row defines the target vector4
  81915. * @returns the updated current matrix
  81916. */
  81917. setRow(index: number, row: Vector4): Matrix;
  81918. /**
  81919. * Compute the transpose of the matrix
  81920. * @returns the new transposed matrix
  81921. */
  81922. transpose(): Matrix;
  81923. /**
  81924. * Compute the transpose of the matrix and store it in a given matrix
  81925. * @param result defines the target matrix
  81926. * @returns the current matrix
  81927. */
  81928. transposeToRef(result: Matrix): Matrix;
  81929. /**
  81930. * Sets the index-th row of the current matrix with the given 4 x float values
  81931. * @param index defines the row index
  81932. * @param x defines the x component to set
  81933. * @param y defines the y component to set
  81934. * @param z defines the z component to set
  81935. * @param w defines the w component to set
  81936. * @returns the updated current matrix
  81937. */
  81938. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  81939. /**
  81940. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  81941. * @param scale defines the scale factor
  81942. * @returns a new matrix
  81943. */
  81944. scale(scale: number): Matrix;
  81945. /**
  81946. * Scale the current matrix values by a factor to a given result matrix
  81947. * @param scale defines the scale factor
  81948. * @param result defines the matrix to store the result
  81949. * @returns the current matrix
  81950. */
  81951. scaleToRef(scale: number, result: Matrix): Matrix;
  81952. /**
  81953. * Scale the current matrix values by a factor and add the result to a given matrix
  81954. * @param scale defines the scale factor
  81955. * @param result defines the Matrix to store the result
  81956. * @returns the current matrix
  81957. */
  81958. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  81959. /**
  81960. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  81961. * @param ref matrix to store the result
  81962. */
  81963. toNormalMatrix(ref: Matrix): void;
  81964. /**
  81965. * Gets only rotation part of the current matrix
  81966. * @returns a new matrix sets to the extracted rotation matrix from the current one
  81967. */
  81968. getRotationMatrix(): Matrix;
  81969. /**
  81970. * Extracts the rotation matrix from the current one and sets it as the given "result"
  81971. * @param result defines the target matrix to store data to
  81972. * @returns the current matrix
  81973. */
  81974. getRotationMatrixToRef(result: Matrix): Matrix;
  81975. /**
  81976. * Toggles model matrix from being right handed to left handed in place and vice versa
  81977. */
  81978. toggleModelMatrixHandInPlace(): void;
  81979. /**
  81980. * Toggles projection matrix from being right handed to left handed in place and vice versa
  81981. */
  81982. toggleProjectionMatrixHandInPlace(): void;
  81983. /**
  81984. * Creates a matrix from an array
  81985. * @param array defines the source array
  81986. * @param offset defines an offset in the source array
  81987. * @returns a new Matrix set from the starting index of the given array
  81988. */
  81989. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  81990. /**
  81991. * Copy the content of an array into a given matrix
  81992. * @param array defines the source array
  81993. * @param offset defines an offset in the source array
  81994. * @param result defines the target matrix
  81995. */
  81996. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  81997. /**
  81998. * Stores an array into a matrix after having multiplied each component by a given factor
  81999. * @param array defines the source array
  82000. * @param offset defines the offset in the source array
  82001. * @param scale defines the scaling factor
  82002. * @param result defines the target matrix
  82003. */
  82004. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82005. /**
  82006. * Gets an identity matrix that must not be updated
  82007. */
  82008. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82009. /**
  82010. * Stores a list of values (16) inside a given matrix
  82011. * @param initialM11 defines 1st value of 1st row
  82012. * @param initialM12 defines 2nd value of 1st row
  82013. * @param initialM13 defines 3rd value of 1st row
  82014. * @param initialM14 defines 4th value of 1st row
  82015. * @param initialM21 defines 1st value of 2nd row
  82016. * @param initialM22 defines 2nd value of 2nd row
  82017. * @param initialM23 defines 3rd value of 2nd row
  82018. * @param initialM24 defines 4th value of 2nd row
  82019. * @param initialM31 defines 1st value of 3rd row
  82020. * @param initialM32 defines 2nd value of 3rd row
  82021. * @param initialM33 defines 3rd value of 3rd row
  82022. * @param initialM34 defines 4th value of 3rd row
  82023. * @param initialM41 defines 1st value of 4th row
  82024. * @param initialM42 defines 2nd value of 4th row
  82025. * @param initialM43 defines 3rd value of 4th row
  82026. * @param initialM44 defines 4th value of 4th row
  82027. * @param result defines the target matrix
  82028. */
  82029. 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;
  82030. /**
  82031. * Creates new matrix from a list of values (16)
  82032. * @param initialM11 defines 1st value of 1st row
  82033. * @param initialM12 defines 2nd value of 1st row
  82034. * @param initialM13 defines 3rd value of 1st row
  82035. * @param initialM14 defines 4th value of 1st row
  82036. * @param initialM21 defines 1st value of 2nd row
  82037. * @param initialM22 defines 2nd value of 2nd row
  82038. * @param initialM23 defines 3rd value of 2nd row
  82039. * @param initialM24 defines 4th value of 2nd row
  82040. * @param initialM31 defines 1st value of 3rd row
  82041. * @param initialM32 defines 2nd value of 3rd row
  82042. * @param initialM33 defines 3rd value of 3rd row
  82043. * @param initialM34 defines 4th value of 3rd row
  82044. * @param initialM41 defines 1st value of 4th row
  82045. * @param initialM42 defines 2nd value of 4th row
  82046. * @param initialM43 defines 3rd value of 4th row
  82047. * @param initialM44 defines 4th value of 4th row
  82048. * @returns the new matrix
  82049. */
  82050. 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;
  82051. /**
  82052. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82053. * @param scale defines the scale vector3
  82054. * @param rotation defines the rotation quaternion
  82055. * @param translation defines the translation vector3
  82056. * @returns a new matrix
  82057. */
  82058. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82059. /**
  82060. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82061. * @param scale defines the scale vector3
  82062. * @param rotation defines the rotation quaternion
  82063. * @param translation defines the translation vector3
  82064. * @param result defines the target matrix
  82065. */
  82066. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82067. /**
  82068. * Creates a new identity matrix
  82069. * @returns a new identity matrix
  82070. */
  82071. static Identity(): Matrix;
  82072. /**
  82073. * Creates a new identity matrix and stores the result in a given matrix
  82074. * @param result defines the target matrix
  82075. */
  82076. static IdentityToRef(result: Matrix): void;
  82077. /**
  82078. * Creates a new zero matrix
  82079. * @returns a new zero matrix
  82080. */
  82081. static Zero(): Matrix;
  82082. /**
  82083. * Creates a new rotation matrix for "angle" radians around the X axis
  82084. * @param angle defines the angle (in radians) to use
  82085. * @return the new matrix
  82086. */
  82087. static RotationX(angle: number): Matrix;
  82088. /**
  82089. * Creates a new matrix as the invert of a given matrix
  82090. * @param source defines the source matrix
  82091. * @returns the new matrix
  82092. */
  82093. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82094. /**
  82095. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82096. * @param angle defines the angle (in radians) to use
  82097. * @param result defines the target matrix
  82098. */
  82099. static RotationXToRef(angle: number, result: Matrix): void;
  82100. /**
  82101. * Creates a new rotation matrix for "angle" radians around the Y axis
  82102. * @param angle defines the angle (in radians) to use
  82103. * @return the new matrix
  82104. */
  82105. static RotationY(angle: number): Matrix;
  82106. /**
  82107. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82108. * @param angle defines the angle (in radians) to use
  82109. * @param result defines the target matrix
  82110. */
  82111. static RotationYToRef(angle: number, result: Matrix): void;
  82112. /**
  82113. * Creates a new rotation matrix for "angle" radians around the Z axis
  82114. * @param angle defines the angle (in radians) to use
  82115. * @return the new matrix
  82116. */
  82117. static RotationZ(angle: number): Matrix;
  82118. /**
  82119. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82120. * @param angle defines the angle (in radians) to use
  82121. * @param result defines the target matrix
  82122. */
  82123. static RotationZToRef(angle: number, result: Matrix): void;
  82124. /**
  82125. * Creates a new rotation matrix for "angle" radians around the given axis
  82126. * @param axis defines the axis to use
  82127. * @param angle defines the angle (in radians) to use
  82128. * @return the new matrix
  82129. */
  82130. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82131. /**
  82132. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82133. * @param axis defines the axis to use
  82134. * @param angle defines the angle (in radians) to use
  82135. * @param result defines the target matrix
  82136. */
  82137. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82138. /**
  82139. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82140. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82141. * @param from defines the vector to align
  82142. * @param to defines the vector to align to
  82143. * @param result defines the target matrix
  82144. */
  82145. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82146. /**
  82147. * Creates a rotation matrix
  82148. * @param yaw defines the yaw angle in radians (Y axis)
  82149. * @param pitch defines the pitch angle in radians (X axis)
  82150. * @param roll defines the roll angle in radians (X axis)
  82151. * @returns the new rotation matrix
  82152. */
  82153. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82154. /**
  82155. * Creates a rotation matrix and stores it in a given matrix
  82156. * @param yaw defines the yaw angle in radians (Y axis)
  82157. * @param pitch defines the pitch angle in radians (X axis)
  82158. * @param roll defines the roll angle in radians (X axis)
  82159. * @param result defines the target matrix
  82160. */
  82161. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82162. /**
  82163. * Creates a scaling matrix
  82164. * @param x defines the scale factor on X axis
  82165. * @param y defines the scale factor on Y axis
  82166. * @param z defines the scale factor on Z axis
  82167. * @returns the new matrix
  82168. */
  82169. static Scaling(x: number, y: number, z: number): Matrix;
  82170. /**
  82171. * Creates a scaling matrix and stores it in a given matrix
  82172. * @param x defines the scale factor on X axis
  82173. * @param y defines the scale factor on Y axis
  82174. * @param z defines the scale factor on Z axis
  82175. * @param result defines the target matrix
  82176. */
  82177. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82178. /**
  82179. * Creates a translation matrix
  82180. * @param x defines the translation on X axis
  82181. * @param y defines the translation on Y axis
  82182. * @param z defines the translationon Z axis
  82183. * @returns the new matrix
  82184. */
  82185. static Translation(x: number, y: number, z: number): Matrix;
  82186. /**
  82187. * Creates a translation matrix and stores it in a given matrix
  82188. * @param x defines the translation on X axis
  82189. * @param y defines the translation on Y axis
  82190. * @param z defines the translationon Z axis
  82191. * @param result defines the target matrix
  82192. */
  82193. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82194. /**
  82195. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82196. * @param startValue defines the start value
  82197. * @param endValue defines the end value
  82198. * @param gradient defines the gradient factor
  82199. * @returns the new matrix
  82200. */
  82201. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82202. /**
  82203. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82204. * @param startValue defines the start value
  82205. * @param endValue defines the end value
  82206. * @param gradient defines the gradient factor
  82207. * @param result defines the Matrix object where to store data
  82208. */
  82209. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82210. /**
  82211. * Builds a new matrix whose values are computed by:
  82212. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82213. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82214. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82215. * @param startValue defines the first matrix
  82216. * @param endValue defines the second matrix
  82217. * @param gradient defines the gradient between the two matrices
  82218. * @returns the new matrix
  82219. */
  82220. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82221. /**
  82222. * Update a matrix to values which are computed by:
  82223. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82224. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82225. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82226. * @param startValue defines the first matrix
  82227. * @param endValue defines the second matrix
  82228. * @param gradient defines the gradient between the two matrices
  82229. * @param result defines the target matrix
  82230. */
  82231. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82232. /**
  82233. * 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"
  82234. * This function works in left handed mode
  82235. * @param eye defines the final position of the entity
  82236. * @param target defines where the entity should look at
  82237. * @param up defines the up vector for the entity
  82238. * @returns the new matrix
  82239. */
  82240. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82241. /**
  82242. * 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".
  82243. * This function works in left handed mode
  82244. * @param eye defines the final position of the entity
  82245. * @param target defines where the entity should look at
  82246. * @param up defines the up vector for the entity
  82247. * @param result defines the target matrix
  82248. */
  82249. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82250. /**
  82251. * 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"
  82252. * This function works in right handed mode
  82253. * @param eye defines the final position of the entity
  82254. * @param target defines where the entity should look at
  82255. * @param up defines the up vector for the entity
  82256. * @returns the new matrix
  82257. */
  82258. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82259. /**
  82260. * 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".
  82261. * This function works in right handed mode
  82262. * @param eye defines the final position of the entity
  82263. * @param target defines where the entity should look at
  82264. * @param up defines the up vector for the entity
  82265. * @param result defines the target matrix
  82266. */
  82267. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82268. /**
  82269. * Create a left-handed orthographic projection matrix
  82270. * @param width defines the viewport width
  82271. * @param height defines the viewport height
  82272. * @param znear defines the near clip plane
  82273. * @param zfar defines the far clip plane
  82274. * @returns a new matrix as a left-handed orthographic projection matrix
  82275. */
  82276. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82277. /**
  82278. * Store a left-handed orthographic projection to a given matrix
  82279. * @param width defines the viewport width
  82280. * @param height defines the viewport height
  82281. * @param znear defines the near clip plane
  82282. * @param zfar defines the far clip plane
  82283. * @param result defines the target matrix
  82284. */
  82285. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82286. /**
  82287. * Create a left-handed orthographic projection matrix
  82288. * @param left defines the viewport left coordinate
  82289. * @param right defines the viewport right coordinate
  82290. * @param bottom defines the viewport bottom coordinate
  82291. * @param top defines the viewport top coordinate
  82292. * @param znear defines the near clip plane
  82293. * @param zfar defines the far clip plane
  82294. * @returns a new matrix as a left-handed orthographic projection matrix
  82295. */
  82296. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82297. /**
  82298. * Stores a left-handed orthographic projection into a given matrix
  82299. * @param left defines the viewport left coordinate
  82300. * @param right defines the viewport right coordinate
  82301. * @param bottom defines the viewport bottom coordinate
  82302. * @param top defines the viewport top coordinate
  82303. * @param znear defines the near clip plane
  82304. * @param zfar defines the far clip plane
  82305. * @param result defines the target matrix
  82306. */
  82307. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82308. /**
  82309. * Creates a right-handed orthographic projection matrix
  82310. * @param left defines the viewport left coordinate
  82311. * @param right defines the viewport right coordinate
  82312. * @param bottom defines the viewport bottom coordinate
  82313. * @param top defines the viewport top coordinate
  82314. * @param znear defines the near clip plane
  82315. * @param zfar defines the far clip plane
  82316. * @returns a new matrix as a right-handed orthographic projection matrix
  82317. */
  82318. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82319. /**
  82320. * Stores a right-handed orthographic projection into a given matrix
  82321. * @param left defines the viewport left coordinate
  82322. * @param right defines the viewport right coordinate
  82323. * @param bottom defines the viewport bottom coordinate
  82324. * @param top defines the viewport top coordinate
  82325. * @param znear defines the near clip plane
  82326. * @param zfar defines the far clip plane
  82327. * @param result defines the target matrix
  82328. */
  82329. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82330. /**
  82331. * Creates a left-handed perspective projection matrix
  82332. * @param width defines the viewport width
  82333. * @param height defines the viewport height
  82334. * @param znear defines the near clip plane
  82335. * @param zfar defines the far clip plane
  82336. * @returns a new matrix as a left-handed perspective projection matrix
  82337. */
  82338. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82339. /**
  82340. * Creates a left-handed perspective projection matrix
  82341. * @param fov defines the horizontal field of view
  82342. * @param aspect defines the aspect ratio
  82343. * @param znear defines the near clip plane
  82344. * @param zfar defines the far clip plane
  82345. * @returns a new matrix as a left-handed perspective projection matrix
  82346. */
  82347. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82348. /**
  82349. * Stores a left-handed perspective projection into a given matrix
  82350. * @param fov defines the horizontal field of view
  82351. * @param aspect defines the aspect ratio
  82352. * @param znear defines the near clip plane
  82353. * @param zfar defines the far clip plane
  82354. * @param result defines the target matrix
  82355. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82356. */
  82357. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82358. /**
  82359. * Stores a left-handed perspective projection into a given matrix with depth reversed
  82360. * @param fov defines the horizontal field of view
  82361. * @param aspect defines the aspect ratio
  82362. * @param znear defines the near clip plane
  82363. * @param zfar not used as infinity is used as far clip
  82364. * @param result defines the target matrix
  82365. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82366. */
  82367. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82368. /**
  82369. * Creates a right-handed perspective projection matrix
  82370. * @param fov defines the horizontal field of view
  82371. * @param aspect defines the aspect ratio
  82372. * @param znear defines the near clip plane
  82373. * @param zfar defines the far clip plane
  82374. * @returns a new matrix as a right-handed perspective projection matrix
  82375. */
  82376. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  82377. /**
  82378. * Stores a right-handed perspective projection into a given matrix
  82379. * @param fov defines the horizontal field of view
  82380. * @param aspect defines the aspect ratio
  82381. * @param znear defines the near clip plane
  82382. * @param zfar defines the far clip plane
  82383. * @param result defines the target matrix
  82384. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82385. */
  82386. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82387. /**
  82388. * Stores a right-handed perspective projection into a given matrix
  82389. * @param fov defines the horizontal field of view
  82390. * @param aspect defines the aspect ratio
  82391. * @param znear defines the near clip plane
  82392. * @param zfar not used as infinity is used as far clip
  82393. * @param result defines the target matrix
  82394. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  82395. */
  82396. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  82397. /**
  82398. * Stores a perspective projection for WebVR info a given matrix
  82399. * @param fov defines the field of view
  82400. * @param znear defines the near clip plane
  82401. * @param zfar defines the far clip plane
  82402. * @param result defines the target matrix
  82403. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  82404. */
  82405. static PerspectiveFovWebVRToRef(fov: {
  82406. upDegrees: number;
  82407. downDegrees: number;
  82408. leftDegrees: number;
  82409. rightDegrees: number;
  82410. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  82411. /**
  82412. * Computes a complete transformation matrix
  82413. * @param viewport defines the viewport to use
  82414. * @param world defines the world matrix
  82415. * @param view defines the view matrix
  82416. * @param projection defines the projection matrix
  82417. * @param zmin defines the near clip plane
  82418. * @param zmax defines the far clip plane
  82419. * @returns the transformation matrix
  82420. */
  82421. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  82422. /**
  82423. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  82424. * @param matrix defines the matrix to use
  82425. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  82426. */
  82427. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  82428. /**
  82429. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  82430. * @param matrix defines the matrix to use
  82431. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  82432. */
  82433. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  82434. /**
  82435. * Compute the transpose of a given matrix
  82436. * @param matrix defines the matrix to transpose
  82437. * @returns the new matrix
  82438. */
  82439. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  82440. /**
  82441. * Compute the transpose of a matrix and store it in a target matrix
  82442. * @param matrix defines the matrix to transpose
  82443. * @param result defines the target matrix
  82444. */
  82445. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  82446. /**
  82447. * Computes a reflection matrix from a plane
  82448. * @param plane defines the reflection plane
  82449. * @returns a new matrix
  82450. */
  82451. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  82452. /**
  82453. * Computes a reflection matrix from a plane
  82454. * @param plane defines the reflection plane
  82455. * @param result defines the target matrix
  82456. */
  82457. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  82458. /**
  82459. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  82460. * @param xaxis defines the value of the 1st axis
  82461. * @param yaxis defines the value of the 2nd axis
  82462. * @param zaxis defines the value of the 3rd axis
  82463. * @param result defines the target matrix
  82464. */
  82465. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  82466. /**
  82467. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  82468. * @param quat defines the quaternion to use
  82469. * @param result defines the target matrix
  82470. */
  82471. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  82472. }
  82473. /**
  82474. * @hidden
  82475. */
  82476. export class TmpVectors {
  82477. static Vector2: Vector2[];
  82478. static Vector3: Vector3[];
  82479. static Vector4: Vector4[];
  82480. static Quaternion: Quaternion[];
  82481. static Matrix: Matrix[];
  82482. }
  82483. }
  82484. declare module BABYLON {
  82485. /**
  82486. * Defines potential orientation for back face culling
  82487. */
  82488. export enum Orientation {
  82489. /**
  82490. * Clockwise
  82491. */
  82492. CW = 0,
  82493. /** Counter clockwise */
  82494. CCW = 1
  82495. }
  82496. /** Class used to represent a Bezier curve */
  82497. export class BezierCurve {
  82498. /**
  82499. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  82500. * @param t defines the time
  82501. * @param x1 defines the left coordinate on X axis
  82502. * @param y1 defines the left coordinate on Y axis
  82503. * @param x2 defines the right coordinate on X axis
  82504. * @param y2 defines the right coordinate on Y axis
  82505. * @returns the interpolated value
  82506. */
  82507. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  82508. }
  82509. /**
  82510. * Defines angle representation
  82511. */
  82512. export class Angle {
  82513. private _radians;
  82514. /**
  82515. * Creates an Angle object of "radians" radians (float).
  82516. * @param radians the angle in radians
  82517. */
  82518. constructor(radians: number);
  82519. /**
  82520. * Get value in degrees
  82521. * @returns the Angle value in degrees (float)
  82522. */
  82523. degrees(): number;
  82524. /**
  82525. * Get value in radians
  82526. * @returns the Angle value in radians (float)
  82527. */
  82528. radians(): number;
  82529. /**
  82530. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  82531. * @param a defines first vector
  82532. * @param b defines second vector
  82533. * @returns a new Angle
  82534. */
  82535. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  82536. /**
  82537. * Gets a new Angle object from the given float in radians
  82538. * @param radians defines the angle value in radians
  82539. * @returns a new Angle
  82540. */
  82541. static FromRadians(radians: number): Angle;
  82542. /**
  82543. * Gets a new Angle object from the given float in degrees
  82544. * @param degrees defines the angle value in degrees
  82545. * @returns a new Angle
  82546. */
  82547. static FromDegrees(degrees: number): Angle;
  82548. }
  82549. /**
  82550. * This represents an arc in a 2d space.
  82551. */
  82552. export class Arc2 {
  82553. /** Defines the start point of the arc */
  82554. startPoint: Vector2;
  82555. /** Defines the mid point of the arc */
  82556. midPoint: Vector2;
  82557. /** Defines the end point of the arc */
  82558. endPoint: Vector2;
  82559. /**
  82560. * Defines the center point of the arc.
  82561. */
  82562. centerPoint: Vector2;
  82563. /**
  82564. * Defines the radius of the arc.
  82565. */
  82566. radius: number;
  82567. /**
  82568. * Defines the angle of the arc (from mid point to end point).
  82569. */
  82570. angle: Angle;
  82571. /**
  82572. * Defines the start angle of the arc (from start point to middle point).
  82573. */
  82574. startAngle: Angle;
  82575. /**
  82576. * Defines the orientation of the arc (clock wise/counter clock wise).
  82577. */
  82578. orientation: Orientation;
  82579. /**
  82580. * Creates an Arc object from the three given points : start, middle and end.
  82581. * @param startPoint Defines the start point of the arc
  82582. * @param midPoint Defines the midlle point of the arc
  82583. * @param endPoint Defines the end point of the arc
  82584. */
  82585. constructor(
  82586. /** Defines the start point of the arc */
  82587. startPoint: Vector2,
  82588. /** Defines the mid point of the arc */
  82589. midPoint: Vector2,
  82590. /** Defines the end point of the arc */
  82591. endPoint: Vector2);
  82592. }
  82593. /**
  82594. * Represents a 2D path made up of multiple 2D points
  82595. */
  82596. export class Path2 {
  82597. private _points;
  82598. private _length;
  82599. /**
  82600. * If the path start and end point are the same
  82601. */
  82602. closed: boolean;
  82603. /**
  82604. * Creates a Path2 object from the starting 2D coordinates x and y.
  82605. * @param x the starting points x value
  82606. * @param y the starting points y value
  82607. */
  82608. constructor(x: number, y: number);
  82609. /**
  82610. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  82611. * @param x the added points x value
  82612. * @param y the added points y value
  82613. * @returns the updated Path2.
  82614. */
  82615. addLineTo(x: number, y: number): Path2;
  82616. /**
  82617. * 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.
  82618. * @param midX middle point x value
  82619. * @param midY middle point y value
  82620. * @param endX end point x value
  82621. * @param endY end point y value
  82622. * @param numberOfSegments (default: 36)
  82623. * @returns the updated Path2.
  82624. */
  82625. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  82626. /**
  82627. * Closes the Path2.
  82628. * @returns the Path2.
  82629. */
  82630. close(): Path2;
  82631. /**
  82632. * Gets the sum of the distance between each sequential point in the path
  82633. * @returns the Path2 total length (float).
  82634. */
  82635. length(): number;
  82636. /**
  82637. * Gets the points which construct the path
  82638. * @returns the Path2 internal array of points.
  82639. */
  82640. getPoints(): Vector2[];
  82641. /**
  82642. * Retreives the point at the distance aways from the starting point
  82643. * @param normalizedLengthPosition the length along the path to retreive the point from
  82644. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  82645. */
  82646. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  82647. /**
  82648. * Creates a new path starting from an x and y position
  82649. * @param x starting x value
  82650. * @param y starting y value
  82651. * @returns a new Path2 starting at the coordinates (x, y).
  82652. */
  82653. static StartingAt(x: number, y: number): Path2;
  82654. }
  82655. /**
  82656. * Represents a 3D path made up of multiple 3D points
  82657. */
  82658. export class Path3D {
  82659. /**
  82660. * an array of Vector3, the curve axis of the Path3D
  82661. */
  82662. path: Vector3[];
  82663. private _curve;
  82664. private _distances;
  82665. private _tangents;
  82666. private _normals;
  82667. private _binormals;
  82668. private _raw;
  82669. private _alignTangentsWithPath;
  82670. private readonly _pointAtData;
  82671. /**
  82672. * new Path3D(path, normal, raw)
  82673. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  82674. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  82675. * @param path an array of Vector3, the curve axis of the Path3D
  82676. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  82677. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  82678. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  82679. */
  82680. constructor(
  82681. /**
  82682. * an array of Vector3, the curve axis of the Path3D
  82683. */
  82684. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  82685. /**
  82686. * Returns the Path3D array of successive Vector3 designing its curve.
  82687. * @returns the Path3D array of successive Vector3 designing its curve.
  82688. */
  82689. getCurve(): Vector3[];
  82690. /**
  82691. * Returns the Path3D array of successive Vector3 designing its curve.
  82692. * @returns the Path3D array of successive Vector3 designing its curve.
  82693. */
  82694. getPoints(): Vector3[];
  82695. /**
  82696. * @returns the computed length (float) of the path.
  82697. */
  82698. length(): number;
  82699. /**
  82700. * Returns an array populated with tangent vectors on each Path3D curve point.
  82701. * @returns an array populated with tangent vectors on each Path3D curve point.
  82702. */
  82703. getTangents(): Vector3[];
  82704. /**
  82705. * Returns an array populated with normal vectors on each Path3D curve point.
  82706. * @returns an array populated with normal vectors on each Path3D curve point.
  82707. */
  82708. getNormals(): Vector3[];
  82709. /**
  82710. * Returns an array populated with binormal vectors on each Path3D curve point.
  82711. * @returns an array populated with binormal vectors on each Path3D curve point.
  82712. */
  82713. getBinormals(): Vector3[];
  82714. /**
  82715. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  82716. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  82717. */
  82718. getDistances(): number[];
  82719. /**
  82720. * Returns an interpolated point along this path
  82721. * @param position the position of the point along this path, from 0.0 to 1.0
  82722. * @returns a new Vector3 as the point
  82723. */
  82724. getPointAt(position: number): Vector3;
  82725. /**
  82726. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82727. * @param position the position of the point along this path, from 0.0 to 1.0
  82728. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  82729. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  82730. */
  82731. getTangentAt(position: number, interpolated?: boolean): Vector3;
  82732. /**
  82733. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  82734. * @param position the position of the point along this path, from 0.0 to 1.0
  82735. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  82736. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  82737. */
  82738. getNormalAt(position: number, interpolated?: boolean): Vector3;
  82739. /**
  82740. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  82741. * @param position the position of the point along this path, from 0.0 to 1.0
  82742. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  82743. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  82744. */
  82745. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  82746. /**
  82747. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  82748. * @param position the position of the point along this path, from 0.0 to 1.0
  82749. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  82750. */
  82751. getDistanceAt(position: number): number;
  82752. /**
  82753. * Returns the array index of the previous point of an interpolated point along this path
  82754. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82755. * @returns the array index
  82756. */
  82757. getPreviousPointIndexAt(position: number): number;
  82758. /**
  82759. * 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)
  82760. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  82761. * @returns the sub position
  82762. */
  82763. getSubPositionAt(position: number): number;
  82764. /**
  82765. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  82766. * @param target the vector of which to get the closest position to
  82767. * @returns the position of the closest virtual point on this path to the target vector
  82768. */
  82769. getClosestPositionTo(target: Vector3): number;
  82770. /**
  82771. * Returns a sub path (slice) of this path
  82772. * @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
  82773. * @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
  82774. * @returns a sub path (slice) of this path
  82775. */
  82776. slice(start?: number, end?: number): Path3D;
  82777. /**
  82778. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  82779. * @param path path which all values are copied into the curves points
  82780. * @param firstNormal which should be projected onto the curve
  82781. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  82782. * @returns the same object updated.
  82783. */
  82784. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  82785. private _compute;
  82786. private _getFirstNonNullVector;
  82787. private _getLastNonNullVector;
  82788. private _normalVector;
  82789. /**
  82790. * Updates the point at data for an interpolated point along this curve
  82791. * @param position the position of the point along this curve, from 0.0 to 1.0
  82792. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  82793. * @returns the (updated) point at data
  82794. */
  82795. private _updatePointAtData;
  82796. /**
  82797. * Updates the point at data from the specified parameters
  82798. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  82799. * @param point the interpolated point
  82800. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  82801. */
  82802. private _setPointAtData;
  82803. /**
  82804. * Updates the point at interpolation matrix for the tangents, normals and binormals
  82805. */
  82806. private _updateInterpolationMatrix;
  82807. }
  82808. /**
  82809. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82810. * A Curve3 is designed from a series of successive Vector3.
  82811. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  82812. */
  82813. export class Curve3 {
  82814. private _points;
  82815. private _length;
  82816. /**
  82817. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  82818. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  82819. * @param v1 (Vector3) the control point
  82820. * @param v2 (Vector3) the end point of the Quadratic Bezier
  82821. * @param nbPoints (integer) the wanted number of points in the curve
  82822. * @returns the created Curve3
  82823. */
  82824. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82825. /**
  82826. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  82827. * @param v0 (Vector3) the origin point of the Cubic Bezier
  82828. * @param v1 (Vector3) the first control point
  82829. * @param v2 (Vector3) the second control point
  82830. * @param v3 (Vector3) the end point of the Cubic Bezier
  82831. * @param nbPoints (integer) the wanted number of points in the curve
  82832. * @returns the created Curve3
  82833. */
  82834. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82835. /**
  82836. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  82837. * @param p1 (Vector3) the origin point of the Hermite Spline
  82838. * @param t1 (Vector3) the tangent vector at the origin point
  82839. * @param p2 (Vector3) the end point of the Hermite Spline
  82840. * @param t2 (Vector3) the tangent vector at the end point
  82841. * @param nbPoints (integer) the wanted number of points in the curve
  82842. * @returns the created Curve3
  82843. */
  82844. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  82845. /**
  82846. * Returns a Curve3 object along a CatmullRom Spline curve :
  82847. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  82848. * @param nbPoints (integer) the wanted number of points between each curve control points
  82849. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  82850. * @returns the created Curve3
  82851. */
  82852. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  82853. /**
  82854. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  82855. * A Curve3 is designed from a series of successive Vector3.
  82856. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  82857. * @param points points which make up the curve
  82858. */
  82859. constructor(points: Vector3[]);
  82860. /**
  82861. * @returns the Curve3 stored array of successive Vector3
  82862. */
  82863. getPoints(): Vector3[];
  82864. /**
  82865. * @returns the computed length (float) of the curve.
  82866. */
  82867. length(): number;
  82868. /**
  82869. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  82870. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  82871. * curveA and curveB keep unchanged.
  82872. * @param curve the curve to continue from this curve
  82873. * @returns the newly constructed curve
  82874. */
  82875. continue(curve: DeepImmutable<Curve3>): Curve3;
  82876. private _computeLength;
  82877. }
  82878. }
  82879. declare module BABYLON {
  82880. /**
  82881. * This represents the main contract an easing function should follow.
  82882. * Easing functions are used throughout the animation system.
  82883. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82884. */
  82885. export interface IEasingFunction {
  82886. /**
  82887. * Given an input gradient between 0 and 1, this returns the corrseponding value
  82888. * of the easing function.
  82889. * The link below provides some of the most common examples of easing functions.
  82890. * @see https://easings.net/
  82891. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82892. * @returns the corresponding value on the curve defined by the easing function
  82893. */
  82894. ease(gradient: number): number;
  82895. }
  82896. /**
  82897. * Base class used for every default easing function.
  82898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82899. */
  82900. export class EasingFunction implements IEasingFunction {
  82901. /**
  82902. * Interpolation follows the mathematical formula associated with the easing function.
  82903. */
  82904. static readonly EASINGMODE_EASEIN: number;
  82905. /**
  82906. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  82907. */
  82908. static readonly EASINGMODE_EASEOUT: number;
  82909. /**
  82910. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  82911. */
  82912. static readonly EASINGMODE_EASEINOUT: number;
  82913. private _easingMode;
  82914. /**
  82915. * Sets the easing mode of the current function.
  82916. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  82917. */
  82918. setEasingMode(easingMode: number): void;
  82919. /**
  82920. * Gets the current easing mode.
  82921. * @returns the easing mode
  82922. */
  82923. getEasingMode(): number;
  82924. /**
  82925. * @hidden
  82926. */
  82927. easeInCore(gradient: number): number;
  82928. /**
  82929. * Given an input gradient between 0 and 1, this returns the corresponding value
  82930. * of the easing function.
  82931. * @param gradient Defines the value between 0 and 1 we want the easing value for
  82932. * @returns the corresponding value on the curve defined by the easing function
  82933. */
  82934. ease(gradient: number): number;
  82935. }
  82936. /**
  82937. * Easing function with a circle shape (see link below).
  82938. * @see https://easings.net/#easeInCirc
  82939. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82940. */
  82941. export class CircleEase extends EasingFunction implements IEasingFunction {
  82942. /** @hidden */
  82943. easeInCore(gradient: number): number;
  82944. }
  82945. /**
  82946. * Easing function with a ease back shape (see link below).
  82947. * @see https://easings.net/#easeInBack
  82948. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82949. */
  82950. export class BackEase extends EasingFunction implements IEasingFunction {
  82951. /** Defines the amplitude of the function */
  82952. amplitude: number;
  82953. /**
  82954. * Instantiates a back ease easing
  82955. * @see https://easings.net/#easeInBack
  82956. * @param amplitude Defines the amplitude of the function
  82957. */
  82958. constructor(
  82959. /** Defines the amplitude of the function */
  82960. amplitude?: number);
  82961. /** @hidden */
  82962. easeInCore(gradient: number): number;
  82963. }
  82964. /**
  82965. * Easing function with a bouncing shape (see link below).
  82966. * @see https://easings.net/#easeInBounce
  82967. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82968. */
  82969. export class BounceEase extends EasingFunction implements IEasingFunction {
  82970. /** Defines the number of bounces */
  82971. bounces: number;
  82972. /** Defines the amplitude of the bounce */
  82973. bounciness: number;
  82974. /**
  82975. * Instantiates a bounce easing
  82976. * @see https://easings.net/#easeInBounce
  82977. * @param bounces Defines the number of bounces
  82978. * @param bounciness Defines the amplitude of the bounce
  82979. */
  82980. constructor(
  82981. /** Defines the number of bounces */
  82982. bounces?: number,
  82983. /** Defines the amplitude of the bounce */
  82984. bounciness?: number);
  82985. /** @hidden */
  82986. easeInCore(gradient: number): number;
  82987. }
  82988. /**
  82989. * Easing function with a power of 3 shape (see link below).
  82990. * @see https://easings.net/#easeInCubic
  82991. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  82992. */
  82993. export class CubicEase extends EasingFunction implements IEasingFunction {
  82994. /** @hidden */
  82995. easeInCore(gradient: number): number;
  82996. }
  82997. /**
  82998. * Easing function with an elastic shape (see link below).
  82999. * @see https://easings.net/#easeInElastic
  83000. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83001. */
  83002. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83003. /** Defines the number of oscillations*/
  83004. oscillations: number;
  83005. /** Defines the amplitude of the oscillations*/
  83006. springiness: number;
  83007. /**
  83008. * Instantiates an elastic easing function
  83009. * @see https://easings.net/#easeInElastic
  83010. * @param oscillations Defines the number of oscillations
  83011. * @param springiness Defines the amplitude of the oscillations
  83012. */
  83013. constructor(
  83014. /** Defines the number of oscillations*/
  83015. oscillations?: number,
  83016. /** Defines the amplitude of the oscillations*/
  83017. springiness?: number);
  83018. /** @hidden */
  83019. easeInCore(gradient: number): number;
  83020. }
  83021. /**
  83022. * Easing function with an exponential shape (see link below).
  83023. * @see https://easings.net/#easeInExpo
  83024. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83025. */
  83026. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83027. /** Defines the exponent of the function */
  83028. exponent: number;
  83029. /**
  83030. * Instantiates an exponential easing function
  83031. * @see https://easings.net/#easeInExpo
  83032. * @param exponent Defines the exponent of the function
  83033. */
  83034. constructor(
  83035. /** Defines the exponent of the function */
  83036. exponent?: number);
  83037. /** @hidden */
  83038. easeInCore(gradient: number): number;
  83039. }
  83040. /**
  83041. * Easing function with a power shape (see link below).
  83042. * @see https://easings.net/#easeInQuad
  83043. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83044. */
  83045. export class PowerEase extends EasingFunction implements IEasingFunction {
  83046. /** Defines the power of the function */
  83047. power: number;
  83048. /**
  83049. * Instantiates an power base easing function
  83050. * @see https://easings.net/#easeInQuad
  83051. * @param power Defines the power of the function
  83052. */
  83053. constructor(
  83054. /** Defines the power of the function */
  83055. power?: number);
  83056. /** @hidden */
  83057. easeInCore(gradient: number): number;
  83058. }
  83059. /**
  83060. * Easing function with a power of 2 shape (see link below).
  83061. * @see https://easings.net/#easeInQuad
  83062. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83063. */
  83064. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83065. /** @hidden */
  83066. easeInCore(gradient: number): number;
  83067. }
  83068. /**
  83069. * Easing function with a power of 4 shape (see link below).
  83070. * @see https://easings.net/#easeInQuart
  83071. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83072. */
  83073. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83074. /** @hidden */
  83075. easeInCore(gradient: number): number;
  83076. }
  83077. /**
  83078. * Easing function with a power of 5 shape (see link below).
  83079. * @see https://easings.net/#easeInQuint
  83080. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83081. */
  83082. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83083. /** @hidden */
  83084. easeInCore(gradient: number): number;
  83085. }
  83086. /**
  83087. * Easing function with a sin shape (see link below).
  83088. * @see https://easings.net/#easeInSine
  83089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83090. */
  83091. export class SineEase extends EasingFunction implements IEasingFunction {
  83092. /** @hidden */
  83093. easeInCore(gradient: number): number;
  83094. }
  83095. /**
  83096. * Easing function with a bezier shape (see link below).
  83097. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  83099. */
  83100. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83101. /** Defines the x component of the start tangent in the bezier curve */
  83102. x1: number;
  83103. /** Defines the y component of the start tangent in the bezier curve */
  83104. y1: number;
  83105. /** Defines the x component of the end tangent in the bezier curve */
  83106. x2: number;
  83107. /** Defines the y component of the end tangent in the bezier curve */
  83108. y2: number;
  83109. /**
  83110. * Instantiates a bezier function
  83111. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83112. * @param x1 Defines the x component of the start tangent in the bezier curve
  83113. * @param y1 Defines the y component of the start tangent in the bezier curve
  83114. * @param x2 Defines the x component of the end tangent in the bezier curve
  83115. * @param y2 Defines the y component of the end tangent in the bezier curve
  83116. */
  83117. constructor(
  83118. /** Defines the x component of the start tangent in the bezier curve */
  83119. x1?: number,
  83120. /** Defines the y component of the start tangent in the bezier curve */
  83121. y1?: number,
  83122. /** Defines the x component of the end tangent in the bezier curve */
  83123. x2?: number,
  83124. /** Defines the y component of the end tangent in the bezier curve */
  83125. y2?: number);
  83126. /** @hidden */
  83127. easeInCore(gradient: number): number;
  83128. }
  83129. }
  83130. declare module BABYLON {
  83131. /**
  83132. * Class used to hold a RBG color
  83133. */
  83134. export class Color3 {
  83135. /**
  83136. * Defines the red component (between 0 and 1, default is 0)
  83137. */
  83138. r: number;
  83139. /**
  83140. * Defines the green component (between 0 and 1, default is 0)
  83141. */
  83142. g: number;
  83143. /**
  83144. * Defines the blue component (between 0 and 1, default is 0)
  83145. */
  83146. b: number;
  83147. /**
  83148. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83149. * @param r defines the red component (between 0 and 1, default is 0)
  83150. * @param g defines the green component (between 0 and 1, default is 0)
  83151. * @param b defines the blue component (between 0 and 1, default is 0)
  83152. */
  83153. constructor(
  83154. /**
  83155. * Defines the red component (between 0 and 1, default is 0)
  83156. */
  83157. r?: number,
  83158. /**
  83159. * Defines the green component (between 0 and 1, default is 0)
  83160. */
  83161. g?: number,
  83162. /**
  83163. * Defines the blue component (between 0 and 1, default is 0)
  83164. */
  83165. b?: number);
  83166. /**
  83167. * Creates a string with the Color3 current values
  83168. * @returns the string representation of the Color3 object
  83169. */
  83170. toString(): string;
  83171. /**
  83172. * Returns the string "Color3"
  83173. * @returns "Color3"
  83174. */
  83175. getClassName(): string;
  83176. /**
  83177. * Compute the Color3 hash code
  83178. * @returns an unique number that can be used to hash Color3 objects
  83179. */
  83180. getHashCode(): number;
  83181. /**
  83182. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83183. * @param array defines the array where to store the r,g,b components
  83184. * @param index defines an optional index in the target array to define where to start storing values
  83185. * @returns the current Color3 object
  83186. */
  83187. toArray(array: FloatArray, index?: number): Color3;
  83188. /**
  83189. * Returns a new Color4 object from the current Color3 and the given alpha
  83190. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83191. * @returns a new Color4 object
  83192. */
  83193. toColor4(alpha?: number): Color4;
  83194. /**
  83195. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83196. * @returns the new array
  83197. */
  83198. asArray(): number[];
  83199. /**
  83200. * Returns the luminance value
  83201. * @returns a float value
  83202. */
  83203. toLuminance(): number;
  83204. /**
  83205. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83206. * @param otherColor defines the second operand
  83207. * @returns the new Color3 object
  83208. */
  83209. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83210. /**
  83211. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83212. * @param otherColor defines the second operand
  83213. * @param result defines the Color3 object where to store the result
  83214. * @returns the current Color3
  83215. */
  83216. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83217. /**
  83218. * Determines equality between Color3 objects
  83219. * @param otherColor defines the second operand
  83220. * @returns true if the rgb values are equal to the given ones
  83221. */
  83222. equals(otherColor: DeepImmutable<Color3>): boolean;
  83223. /**
  83224. * Determines equality between the current Color3 object and a set of r,b,g values
  83225. * @param r defines the red component to check
  83226. * @param g defines the green component to check
  83227. * @param b defines the blue component to check
  83228. * @returns true if the rgb values are equal to the given ones
  83229. */
  83230. equalsFloats(r: number, g: number, b: number): boolean;
  83231. /**
  83232. * Multiplies in place each rgb value by scale
  83233. * @param scale defines the scaling factor
  83234. * @returns the updated Color3
  83235. */
  83236. scale(scale: number): Color3;
  83237. /**
  83238. * Multiplies the rgb values by scale and stores the result into "result"
  83239. * @param scale defines the scaling factor
  83240. * @param result defines the Color3 object where to store the result
  83241. * @returns the unmodified current Color3
  83242. */
  83243. scaleToRef(scale: number, result: Color3): Color3;
  83244. /**
  83245. * Scale the current Color3 values by a factor and add the result to a given Color3
  83246. * @param scale defines the scale factor
  83247. * @param result defines color to store the result into
  83248. * @returns the unmodified current Color3
  83249. */
  83250. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83251. /**
  83252. * Clamps the rgb values by the min and max values and stores the result into "result"
  83253. * @param min defines minimum clamping value (default is 0)
  83254. * @param max defines maximum clamping value (default is 1)
  83255. * @param result defines color to store the result into
  83256. * @returns the original Color3
  83257. */
  83258. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83259. /**
  83260. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83261. * @param otherColor defines the second operand
  83262. * @returns the new Color3
  83263. */
  83264. add(otherColor: DeepImmutable<Color3>): Color3;
  83265. /**
  83266. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83267. * @param otherColor defines the second operand
  83268. * @param result defines Color3 object to store the result into
  83269. * @returns the unmodified current Color3
  83270. */
  83271. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83272. /**
  83273. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83274. * @param otherColor defines the second operand
  83275. * @returns the new Color3
  83276. */
  83277. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83278. /**
  83279. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83280. * @param otherColor defines the second operand
  83281. * @param result defines Color3 object to store the result into
  83282. * @returns the unmodified current Color3
  83283. */
  83284. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83285. /**
  83286. * Copy the current object
  83287. * @returns a new Color3 copied the current one
  83288. */
  83289. clone(): Color3;
  83290. /**
  83291. * Copies the rgb values from the source in the current Color3
  83292. * @param source defines the source Color3 object
  83293. * @returns the updated Color3 object
  83294. */
  83295. copyFrom(source: DeepImmutable<Color3>): Color3;
  83296. /**
  83297. * Updates the Color3 rgb values from the given floats
  83298. * @param r defines the red component to read from
  83299. * @param g defines the green component to read from
  83300. * @param b defines the blue component to read from
  83301. * @returns the current Color3 object
  83302. */
  83303. copyFromFloats(r: number, g: number, b: number): Color3;
  83304. /**
  83305. * Updates the Color3 rgb values from the given floats
  83306. * @param r defines the red component to read from
  83307. * @param g defines the green component to read from
  83308. * @param b defines the blue component to read from
  83309. * @returns the current Color3 object
  83310. */
  83311. set(r: number, g: number, b: number): Color3;
  83312. /**
  83313. * Compute the Color3 hexadecimal code as a string
  83314. * @returns a string containing the hexadecimal representation of the Color3 object
  83315. */
  83316. toHexString(): string;
  83317. /**
  83318. * Computes a new Color3 converted from the current one to linear space
  83319. * @returns a new Color3 object
  83320. */
  83321. toLinearSpace(): Color3;
  83322. /**
  83323. * Converts current color in rgb space to HSV values
  83324. * @returns a new color3 representing the HSV values
  83325. */
  83326. toHSV(): Color3;
  83327. /**
  83328. * Converts current color in rgb space to HSV values
  83329. * @param result defines the Color3 where to store the HSV values
  83330. */
  83331. toHSVToRef(result: Color3): void;
  83332. /**
  83333. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  83334. * @param convertedColor defines the Color3 object where to store the linear space version
  83335. * @returns the unmodified Color3
  83336. */
  83337. toLinearSpaceToRef(convertedColor: Color3): Color3;
  83338. /**
  83339. * Computes a new Color3 converted from the current one to gamma space
  83340. * @returns a new Color3 object
  83341. */
  83342. toGammaSpace(): Color3;
  83343. /**
  83344. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  83345. * @param convertedColor defines the Color3 object where to store the gamma space version
  83346. * @returns the unmodified Color3
  83347. */
  83348. toGammaSpaceToRef(convertedColor: Color3): Color3;
  83349. private static _BlackReadOnly;
  83350. /**
  83351. * Convert Hue, saturation and value to a Color3 (RGB)
  83352. * @param hue defines the hue
  83353. * @param saturation defines the saturation
  83354. * @param value defines the value
  83355. * @param result defines the Color3 where to store the RGB values
  83356. */
  83357. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  83358. /**
  83359. * Creates a new Color3 from the string containing valid hexadecimal values
  83360. * @param hex defines a string containing valid hexadecimal values
  83361. * @returns a new Color3 object
  83362. */
  83363. static FromHexString(hex: string): Color3;
  83364. /**
  83365. * Creates a new Color3 from the starting index of the given array
  83366. * @param array defines the source array
  83367. * @param offset defines an offset in the source array
  83368. * @returns a new Color3 object
  83369. */
  83370. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  83371. /**
  83372. * Creates a new Color3 from integer values (< 256)
  83373. * @param r defines the red component to read from (value between 0 and 255)
  83374. * @param g defines the green component to read from (value between 0 and 255)
  83375. * @param b defines the blue component to read from (value between 0 and 255)
  83376. * @returns a new Color3 object
  83377. */
  83378. static FromInts(r: number, g: number, b: number): Color3;
  83379. /**
  83380. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83381. * @param start defines the start Color3 value
  83382. * @param end defines the end Color3 value
  83383. * @param amount defines the gradient value between start and end
  83384. * @returns a new Color3 object
  83385. */
  83386. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  83387. /**
  83388. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  83389. * @param left defines the start value
  83390. * @param right defines the end value
  83391. * @param amount defines the gradient factor
  83392. * @param result defines the Color3 object where to store the result
  83393. */
  83394. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  83395. /**
  83396. * Returns a Color3 value containing a red color
  83397. * @returns a new Color3 object
  83398. */
  83399. static Red(): Color3;
  83400. /**
  83401. * Returns a Color3 value containing a green color
  83402. * @returns a new Color3 object
  83403. */
  83404. static Green(): Color3;
  83405. /**
  83406. * Returns a Color3 value containing a blue color
  83407. * @returns a new Color3 object
  83408. */
  83409. static Blue(): Color3;
  83410. /**
  83411. * Returns a Color3 value containing a black color
  83412. * @returns a new Color3 object
  83413. */
  83414. static Black(): Color3;
  83415. /**
  83416. * Gets a Color3 value containing a black color that must not be updated
  83417. */
  83418. static get BlackReadOnly(): DeepImmutable<Color3>;
  83419. /**
  83420. * Returns a Color3 value containing a white color
  83421. * @returns a new Color3 object
  83422. */
  83423. static White(): Color3;
  83424. /**
  83425. * Returns a Color3 value containing a purple color
  83426. * @returns a new Color3 object
  83427. */
  83428. static Purple(): Color3;
  83429. /**
  83430. * Returns a Color3 value containing a magenta color
  83431. * @returns a new Color3 object
  83432. */
  83433. static Magenta(): Color3;
  83434. /**
  83435. * Returns a Color3 value containing a yellow color
  83436. * @returns a new Color3 object
  83437. */
  83438. static Yellow(): Color3;
  83439. /**
  83440. * Returns a Color3 value containing a gray color
  83441. * @returns a new Color3 object
  83442. */
  83443. static Gray(): Color3;
  83444. /**
  83445. * Returns a Color3 value containing a teal color
  83446. * @returns a new Color3 object
  83447. */
  83448. static Teal(): Color3;
  83449. /**
  83450. * Returns a Color3 value containing a random color
  83451. * @returns a new Color3 object
  83452. */
  83453. static Random(): Color3;
  83454. }
  83455. /**
  83456. * Class used to hold a RBGA color
  83457. */
  83458. export class Color4 {
  83459. /**
  83460. * Defines the red component (between 0 and 1, default is 0)
  83461. */
  83462. r: number;
  83463. /**
  83464. * Defines the green component (between 0 and 1, default is 0)
  83465. */
  83466. g: number;
  83467. /**
  83468. * Defines the blue component (between 0 and 1, default is 0)
  83469. */
  83470. b: number;
  83471. /**
  83472. * Defines the alpha component (between 0 and 1, default is 1)
  83473. */
  83474. a: number;
  83475. /**
  83476. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  83477. * @param r defines the red component (between 0 and 1, default is 0)
  83478. * @param g defines the green component (between 0 and 1, default is 0)
  83479. * @param b defines the blue component (between 0 and 1, default is 0)
  83480. * @param a defines the alpha component (between 0 and 1, default is 1)
  83481. */
  83482. constructor(
  83483. /**
  83484. * Defines the red component (between 0 and 1, default is 0)
  83485. */
  83486. r?: number,
  83487. /**
  83488. * Defines the green component (between 0 and 1, default is 0)
  83489. */
  83490. g?: number,
  83491. /**
  83492. * Defines the blue component (between 0 and 1, default is 0)
  83493. */
  83494. b?: number,
  83495. /**
  83496. * Defines the alpha component (between 0 and 1, default is 1)
  83497. */
  83498. a?: number);
  83499. /**
  83500. * Adds in place the given Color4 values to the current Color4 object
  83501. * @param right defines the second operand
  83502. * @returns the current updated Color4 object
  83503. */
  83504. addInPlace(right: DeepImmutable<Color4>): Color4;
  83505. /**
  83506. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  83507. * @returns the new array
  83508. */
  83509. asArray(): number[];
  83510. /**
  83511. * Stores from the starting index in the given array the Color4 successive values
  83512. * @param array defines the array where to store the r,g,b components
  83513. * @param index defines an optional index in the target array to define where to start storing values
  83514. * @returns the current Color4 object
  83515. */
  83516. toArray(array: number[], index?: number): Color4;
  83517. /**
  83518. * Determines equality between Color4 objects
  83519. * @param otherColor defines the second operand
  83520. * @returns true if the rgba values are equal to the given ones
  83521. */
  83522. equals(otherColor: DeepImmutable<Color4>): boolean;
  83523. /**
  83524. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  83525. * @param right defines the second operand
  83526. * @returns a new Color4 object
  83527. */
  83528. add(right: DeepImmutable<Color4>): Color4;
  83529. /**
  83530. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  83531. * @param right defines the second operand
  83532. * @returns a new Color4 object
  83533. */
  83534. subtract(right: DeepImmutable<Color4>): Color4;
  83535. /**
  83536. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  83537. * @param right defines the second operand
  83538. * @param result defines the Color4 object where to store the result
  83539. * @returns the current Color4 object
  83540. */
  83541. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  83542. /**
  83543. * Creates a new Color4 with the current Color4 values multiplied by scale
  83544. * @param scale defines the scaling factor to apply
  83545. * @returns a new Color4 object
  83546. */
  83547. scale(scale: number): Color4;
  83548. /**
  83549. * Multiplies the current Color4 values by scale and stores the result in "result"
  83550. * @param scale defines the scaling factor to apply
  83551. * @param result defines the Color4 object where to store the result
  83552. * @returns the current unmodified Color4
  83553. */
  83554. scaleToRef(scale: number, result: Color4): Color4;
  83555. /**
  83556. * Scale the current Color4 values by a factor and add the result to a given Color4
  83557. * @param scale defines the scale factor
  83558. * @param result defines the Color4 object where to store the result
  83559. * @returns the unmodified current Color4
  83560. */
  83561. scaleAndAddToRef(scale: number, result: Color4): Color4;
  83562. /**
  83563. * Clamps the rgb values by the min and max values and stores the result into "result"
  83564. * @param min defines minimum clamping value (default is 0)
  83565. * @param max defines maximum clamping value (default is 1)
  83566. * @param result defines color to store the result into.
  83567. * @returns the cuurent Color4
  83568. */
  83569. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  83570. /**
  83571. * Multipy an Color4 value by another and return a new Color4 object
  83572. * @param color defines the Color4 value to multiply by
  83573. * @returns a new Color4 object
  83574. */
  83575. multiply(color: Color4): Color4;
  83576. /**
  83577. * Multipy a Color4 value by another and push the result in a reference value
  83578. * @param color defines the Color4 value to multiply by
  83579. * @param result defines the Color4 to fill the result in
  83580. * @returns the result Color4
  83581. */
  83582. multiplyToRef(color: Color4, result: Color4): Color4;
  83583. /**
  83584. * Creates a string with the Color4 current values
  83585. * @returns the string representation of the Color4 object
  83586. */
  83587. toString(): string;
  83588. /**
  83589. * Returns the string "Color4"
  83590. * @returns "Color4"
  83591. */
  83592. getClassName(): string;
  83593. /**
  83594. * Compute the Color4 hash code
  83595. * @returns an unique number that can be used to hash Color4 objects
  83596. */
  83597. getHashCode(): number;
  83598. /**
  83599. * Creates a new Color4 copied from the current one
  83600. * @returns a new Color4 object
  83601. */
  83602. clone(): Color4;
  83603. /**
  83604. * Copies the given Color4 values into the current one
  83605. * @param source defines the source Color4 object
  83606. * @returns the current updated Color4 object
  83607. */
  83608. copyFrom(source: Color4): Color4;
  83609. /**
  83610. * Copies the given float values into the current one
  83611. * @param r defines the red component to read from
  83612. * @param g defines the green component to read from
  83613. * @param b defines the blue component to read from
  83614. * @param a defines the alpha component to read from
  83615. * @returns the current updated Color4 object
  83616. */
  83617. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  83618. /**
  83619. * Copies the given float values into the current one
  83620. * @param r defines the red component to read from
  83621. * @param g defines the green component to read from
  83622. * @param b defines the blue component to read from
  83623. * @param a defines the alpha component to read from
  83624. * @returns the current updated Color4 object
  83625. */
  83626. set(r: number, g: number, b: number, a: number): Color4;
  83627. /**
  83628. * Compute the Color4 hexadecimal code as a string
  83629. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  83630. * @returns a string containing the hexadecimal representation of the Color4 object
  83631. */
  83632. toHexString(returnAsColor3?: boolean): string;
  83633. /**
  83634. * Computes a new Color4 converted from the current one to linear space
  83635. * @returns a new Color4 object
  83636. */
  83637. toLinearSpace(): Color4;
  83638. /**
  83639. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  83640. * @param convertedColor defines the Color4 object where to store the linear space version
  83641. * @returns the unmodified Color4
  83642. */
  83643. toLinearSpaceToRef(convertedColor: Color4): Color4;
  83644. /**
  83645. * Computes a new Color4 converted from the current one to gamma space
  83646. * @returns a new Color4 object
  83647. */
  83648. toGammaSpace(): Color4;
  83649. /**
  83650. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  83651. * @param convertedColor defines the Color4 object where to store the gamma space version
  83652. * @returns the unmodified Color4
  83653. */
  83654. toGammaSpaceToRef(convertedColor: Color4): Color4;
  83655. /**
  83656. * Creates a new Color4 from the string containing valid hexadecimal values
  83657. * @param hex defines a string containing valid hexadecimal values
  83658. * @returns a new Color4 object
  83659. */
  83660. static FromHexString(hex: string): Color4;
  83661. /**
  83662. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83663. * @param left defines the start value
  83664. * @param right defines the end value
  83665. * @param amount defines the gradient factor
  83666. * @returns a new Color4 object
  83667. */
  83668. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  83669. /**
  83670. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  83671. * @param left defines the start value
  83672. * @param right defines the end value
  83673. * @param amount defines the gradient factor
  83674. * @param result defines the Color4 object where to store data
  83675. */
  83676. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  83677. /**
  83678. * Creates a new Color4 from a Color3 and an alpha value
  83679. * @param color3 defines the source Color3 to read from
  83680. * @param alpha defines the alpha component (1.0 by default)
  83681. * @returns a new Color4 object
  83682. */
  83683. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  83684. /**
  83685. * Creates a new Color4 from the starting index element of the given array
  83686. * @param array defines the source array to read from
  83687. * @param offset defines the offset in the source array
  83688. * @returns a new Color4 object
  83689. */
  83690. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  83691. /**
  83692. * Creates a new Color3 from integer values (< 256)
  83693. * @param r defines the red component to read from (value between 0 and 255)
  83694. * @param g defines the green component to read from (value between 0 and 255)
  83695. * @param b defines the blue component to read from (value between 0 and 255)
  83696. * @param a defines the alpha component to read from (value between 0 and 255)
  83697. * @returns a new Color3 object
  83698. */
  83699. static FromInts(r: number, g: number, b: number, a: number): Color4;
  83700. /**
  83701. * Check the content of a given array and convert it to an array containing RGBA data
  83702. * If the original array was already containing count * 4 values then it is returned directly
  83703. * @param colors defines the array to check
  83704. * @param count defines the number of RGBA data to expect
  83705. * @returns an array containing count * 4 values (RGBA)
  83706. */
  83707. static CheckColors4(colors: number[], count: number): number[];
  83708. }
  83709. /**
  83710. * @hidden
  83711. */
  83712. export class TmpColors {
  83713. static Color3: Color3[];
  83714. static Color4: Color4[];
  83715. }
  83716. }
  83717. declare module BABYLON {
  83718. /**
  83719. * Defines an interface which represents an animation key frame
  83720. */
  83721. export interface IAnimationKey {
  83722. /**
  83723. * Frame of the key frame
  83724. */
  83725. frame: number;
  83726. /**
  83727. * Value at the specifies key frame
  83728. */
  83729. value: any;
  83730. /**
  83731. * The input tangent for the cubic hermite spline
  83732. */
  83733. inTangent?: any;
  83734. /**
  83735. * The output tangent for the cubic hermite spline
  83736. */
  83737. outTangent?: any;
  83738. /**
  83739. * The animation interpolation type
  83740. */
  83741. interpolation?: AnimationKeyInterpolation;
  83742. }
  83743. /**
  83744. * Enum for the animation key frame interpolation type
  83745. */
  83746. export enum AnimationKeyInterpolation {
  83747. /**
  83748. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  83749. */
  83750. STEP = 1
  83751. }
  83752. }
  83753. declare module BABYLON {
  83754. /**
  83755. * Represents the range of an animation
  83756. */
  83757. export class AnimationRange {
  83758. /**The name of the animation range**/
  83759. name: string;
  83760. /**The starting frame of the animation */
  83761. from: number;
  83762. /**The ending frame of the animation*/
  83763. to: number;
  83764. /**
  83765. * Initializes the range of an animation
  83766. * @param name The name of the animation range
  83767. * @param from The starting frame of the animation
  83768. * @param to The ending frame of the animation
  83769. */
  83770. constructor(
  83771. /**The name of the animation range**/
  83772. name: string,
  83773. /**The starting frame of the animation */
  83774. from: number,
  83775. /**The ending frame of the animation*/
  83776. to: number);
  83777. /**
  83778. * Makes a copy of the animation range
  83779. * @returns A copy of the animation range
  83780. */
  83781. clone(): AnimationRange;
  83782. }
  83783. }
  83784. declare module BABYLON {
  83785. /**
  83786. * Composed of a frame, and an action function
  83787. */
  83788. export class AnimationEvent {
  83789. /** The frame for which the event is triggered **/
  83790. frame: number;
  83791. /** The event to perform when triggered **/
  83792. action: (currentFrame: number) => void;
  83793. /** Specifies if the event should be triggered only once**/
  83794. onlyOnce?: boolean | undefined;
  83795. /**
  83796. * Specifies if the animation event is done
  83797. */
  83798. isDone: boolean;
  83799. /**
  83800. * Initializes the animation event
  83801. * @param frame The frame for which the event is triggered
  83802. * @param action The event to perform when triggered
  83803. * @param onlyOnce Specifies if the event should be triggered only once
  83804. */
  83805. constructor(
  83806. /** The frame for which the event is triggered **/
  83807. frame: number,
  83808. /** The event to perform when triggered **/
  83809. action: (currentFrame: number) => void,
  83810. /** Specifies if the event should be triggered only once**/
  83811. onlyOnce?: boolean | undefined);
  83812. /** @hidden */
  83813. _clone(): AnimationEvent;
  83814. }
  83815. }
  83816. declare module BABYLON {
  83817. /**
  83818. * Interface used to define a behavior
  83819. */
  83820. export interface Behavior<T> {
  83821. /** gets or sets behavior's name */
  83822. name: string;
  83823. /**
  83824. * Function called when the behavior needs to be initialized (after attaching it to a target)
  83825. */
  83826. init(): void;
  83827. /**
  83828. * Called when the behavior is attached to a target
  83829. * @param target defines the target where the behavior is attached to
  83830. */
  83831. attach(target: T): void;
  83832. /**
  83833. * Called when the behavior is detached from its target
  83834. */
  83835. detach(): void;
  83836. }
  83837. /**
  83838. * Interface implemented by classes supporting behaviors
  83839. */
  83840. export interface IBehaviorAware<T> {
  83841. /**
  83842. * Attach a behavior
  83843. * @param behavior defines the behavior to attach
  83844. * @returns the current host
  83845. */
  83846. addBehavior(behavior: Behavior<T>): T;
  83847. /**
  83848. * Remove a behavior from the current object
  83849. * @param behavior defines the behavior to detach
  83850. * @returns the current host
  83851. */
  83852. removeBehavior(behavior: Behavior<T>): T;
  83853. /**
  83854. * Gets a behavior using its name to search
  83855. * @param name defines the name to search
  83856. * @returns the behavior or null if not found
  83857. */
  83858. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  83859. }
  83860. }
  83861. declare module BABYLON {
  83862. /**
  83863. * Defines an array and its length.
  83864. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83865. */
  83866. export interface ISmartArrayLike<T> {
  83867. /**
  83868. * The data of the array.
  83869. */
  83870. data: Array<T>;
  83871. /**
  83872. * The active length of the array.
  83873. */
  83874. length: number;
  83875. }
  83876. /**
  83877. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83878. */
  83879. export class SmartArray<T> implements ISmartArrayLike<T> {
  83880. /**
  83881. * The full set of data from the array.
  83882. */
  83883. data: Array<T>;
  83884. /**
  83885. * The active length of the array.
  83886. */
  83887. length: number;
  83888. protected _id: number;
  83889. /**
  83890. * Instantiates a Smart Array.
  83891. * @param capacity defines the default capacity of the array.
  83892. */
  83893. constructor(capacity: number);
  83894. /**
  83895. * Pushes a value at the end of the active data.
  83896. * @param value defines the object to push in the array.
  83897. */
  83898. push(value: T): void;
  83899. /**
  83900. * Iterates over the active data and apply the lambda to them.
  83901. * @param func defines the action to apply on each value.
  83902. */
  83903. forEach(func: (content: T) => void): void;
  83904. /**
  83905. * Sorts the full sets of data.
  83906. * @param compareFn defines the comparison function to apply.
  83907. */
  83908. sort(compareFn: (a: T, b: T) => number): void;
  83909. /**
  83910. * Resets the active data to an empty array.
  83911. */
  83912. reset(): void;
  83913. /**
  83914. * Releases all the data from the array as well as the array.
  83915. */
  83916. dispose(): void;
  83917. /**
  83918. * Concats the active data with a given array.
  83919. * @param array defines the data to concatenate with.
  83920. */
  83921. concat(array: any): void;
  83922. /**
  83923. * Returns the position of a value in the active data.
  83924. * @param value defines the value to find the index for
  83925. * @returns the index if found in the active data otherwise -1
  83926. */
  83927. indexOf(value: T): number;
  83928. /**
  83929. * Returns whether an element is part of the active data.
  83930. * @param value defines the value to look for
  83931. * @returns true if found in the active data otherwise false
  83932. */
  83933. contains(value: T): boolean;
  83934. private static _GlobalId;
  83935. }
  83936. /**
  83937. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83938. * The data in this array can only be present once
  83939. */
  83940. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83941. private _duplicateId;
  83942. /**
  83943. * Pushes a value at the end of the active data.
  83944. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83945. * @param value defines the object to push in the array.
  83946. */
  83947. push(value: T): void;
  83948. /**
  83949. * Pushes a value at the end of the active data.
  83950. * If the data is already present, it won t be added again
  83951. * @param value defines the object to push in the array.
  83952. * @returns true if added false if it was already present
  83953. */
  83954. pushNoDuplicate(value: T): boolean;
  83955. /**
  83956. * Resets the active data to an empty array.
  83957. */
  83958. reset(): void;
  83959. /**
  83960. * Concats the active data with a given array.
  83961. * This ensures no dupplicate will be present in the result.
  83962. * @param array defines the data to concatenate with.
  83963. */
  83964. concatWithNoDuplicate(array: any): void;
  83965. }
  83966. }
  83967. declare module BABYLON {
  83968. /**
  83969. * @ignore
  83970. * This is a list of all the different input types that are available in the application.
  83971. * Fo instance: ArcRotateCameraGamepadInput...
  83972. */
  83973. export var CameraInputTypes: {};
  83974. /**
  83975. * This is the contract to implement in order to create a new input class.
  83976. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  83977. */
  83978. export interface ICameraInput<TCamera extends Camera> {
  83979. /**
  83980. * Defines the camera the input is attached to.
  83981. */
  83982. camera: Nullable<TCamera>;
  83983. /**
  83984. * Gets the class name of the current intput.
  83985. * @returns the class name
  83986. */
  83987. getClassName(): string;
  83988. /**
  83989. * Get the friendly name associated with the input class.
  83990. * @returns the input friendly name
  83991. */
  83992. getSimpleName(): string;
  83993. /**
  83994. * Attach the input controls to a specific dom element to get the input from.
  83995. * @param element Defines the element the controls should be listened from
  83996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83997. */
  83998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83999. /**
  84000. * Detach the current controls from the specified dom element.
  84001. * @param element Defines the element to stop listening the inputs from
  84002. */
  84003. detachControl(element: Nullable<HTMLElement>): void;
  84004. /**
  84005. * Update the current camera state depending on the inputs that have been used this frame.
  84006. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84007. */
  84008. checkInputs?: () => void;
  84009. }
  84010. /**
  84011. * Represents a map of input types to input instance or input index to input instance.
  84012. */
  84013. export interface CameraInputsMap<TCamera extends Camera> {
  84014. /**
  84015. * Accessor to the input by input type.
  84016. */
  84017. [name: string]: ICameraInput<TCamera>;
  84018. /**
  84019. * Accessor to the input by input index.
  84020. */
  84021. [idx: number]: ICameraInput<TCamera>;
  84022. }
  84023. /**
  84024. * This represents the input manager used within a camera.
  84025. * It helps dealing with all the different kind of input attached to a camera.
  84026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84027. */
  84028. export class CameraInputsManager<TCamera extends Camera> {
  84029. /**
  84030. * Defines the list of inputs attahed to the camera.
  84031. */
  84032. attached: CameraInputsMap<TCamera>;
  84033. /**
  84034. * Defines the dom element the camera is collecting inputs from.
  84035. * This is null if the controls have not been attached.
  84036. */
  84037. attachedElement: Nullable<HTMLElement>;
  84038. /**
  84039. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84040. */
  84041. noPreventDefault: boolean;
  84042. /**
  84043. * Defined the camera the input manager belongs to.
  84044. */
  84045. camera: TCamera;
  84046. /**
  84047. * Update the current camera state depending on the inputs that have been used this frame.
  84048. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84049. */
  84050. checkInputs: () => void;
  84051. /**
  84052. * Instantiate a new Camera Input Manager.
  84053. * @param camera Defines the camera the input manager blongs to
  84054. */
  84055. constructor(camera: TCamera);
  84056. /**
  84057. * Add an input method to a camera
  84058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  84059. * @param input camera input method
  84060. */
  84061. add(input: ICameraInput<TCamera>): void;
  84062. /**
  84063. * Remove a specific input method from a camera
  84064. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84065. * @param inputToRemove camera input method
  84066. */
  84067. remove(inputToRemove: ICameraInput<TCamera>): void;
  84068. /**
  84069. * Remove a specific input type from a camera
  84070. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84071. * @param inputType the type of the input to remove
  84072. */
  84073. removeByType(inputType: string): void;
  84074. private _addCheckInputs;
  84075. /**
  84076. * Attach the input controls to the currently attached dom element to listen the events from.
  84077. * @param input Defines the input to attach
  84078. */
  84079. attachInput(input: ICameraInput<TCamera>): void;
  84080. /**
  84081. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84082. * @param element Defines the dom element to collect the events from
  84083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84084. */
  84085. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84086. /**
  84087. * Detach the current manager inputs controls from a specific dom element.
  84088. * @param element Defines the dom element to collect the events from
  84089. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84090. */
  84091. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84092. /**
  84093. * Rebuild the dynamic inputCheck function from the current list of
  84094. * defined inputs in the manager.
  84095. */
  84096. rebuildInputCheck(): void;
  84097. /**
  84098. * Remove all attached input methods from a camera
  84099. */
  84100. clear(): void;
  84101. /**
  84102. * Serialize the current input manager attached to a camera.
  84103. * This ensures than once parsed,
  84104. * the input associated to the camera will be identical to the current ones
  84105. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84106. */
  84107. serialize(serializedCamera: any): void;
  84108. /**
  84109. * Parses an input manager serialized JSON to restore the previous list of inputs
  84110. * and states associated to a camera.
  84111. * @param parsedCamera Defines the JSON to parse
  84112. */
  84113. parse(parsedCamera: any): void;
  84114. }
  84115. }
  84116. declare module BABYLON {
  84117. /**
  84118. * Class used to store data that will be store in GPU memory
  84119. */
  84120. export class Buffer {
  84121. private _engine;
  84122. private _buffer;
  84123. /** @hidden */
  84124. _data: Nullable<DataArray>;
  84125. private _updatable;
  84126. private _instanced;
  84127. private _divisor;
  84128. /**
  84129. * Gets the byte stride.
  84130. */
  84131. readonly byteStride: number;
  84132. /**
  84133. * Constructor
  84134. * @param engine the engine
  84135. * @param data the data to use for this buffer
  84136. * @param updatable whether the data is updatable
  84137. * @param stride the stride (optional)
  84138. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84139. * @param instanced whether the buffer is instanced (optional)
  84140. * @param useBytes set to true if the stride in in bytes (optional)
  84141. * @param divisor sets an optional divisor for instances (1 by default)
  84142. */
  84143. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84144. /**
  84145. * Create a new VertexBuffer based on the current buffer
  84146. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84147. * @param offset defines offset in the buffer (0 by default)
  84148. * @param size defines the size in floats of attributes (position is 3 for instance)
  84149. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84150. * @param instanced defines if the vertex buffer contains indexed data
  84151. * @param useBytes defines if the offset and stride are in bytes *
  84152. * @param divisor sets an optional divisor for instances (1 by default)
  84153. * @returns the new vertex buffer
  84154. */
  84155. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84156. /**
  84157. * Gets a boolean indicating if the Buffer is updatable?
  84158. * @returns true if the buffer is updatable
  84159. */
  84160. isUpdatable(): boolean;
  84161. /**
  84162. * Gets current buffer's data
  84163. * @returns a DataArray or null
  84164. */
  84165. getData(): Nullable<DataArray>;
  84166. /**
  84167. * Gets underlying native buffer
  84168. * @returns underlying native buffer
  84169. */
  84170. getBuffer(): Nullable<DataBuffer>;
  84171. /**
  84172. * Gets the stride in float32 units (i.e. byte stride / 4).
  84173. * May not be an integer if the byte stride is not divisible by 4.
  84174. * @returns the stride in float32 units
  84175. * @deprecated Please use byteStride instead.
  84176. */
  84177. getStrideSize(): number;
  84178. /**
  84179. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84180. * @param data defines the data to store
  84181. */
  84182. create(data?: Nullable<DataArray>): void;
  84183. /** @hidden */
  84184. _rebuild(): void;
  84185. /**
  84186. * Update current buffer data
  84187. * @param data defines the data to store
  84188. */
  84189. update(data: DataArray): void;
  84190. /**
  84191. * Updates the data directly.
  84192. * @param data the new data
  84193. * @param offset the new offset
  84194. * @param vertexCount the vertex count (optional)
  84195. * @param useBytes set to true if the offset is in bytes
  84196. */
  84197. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84198. /**
  84199. * Release all resources
  84200. */
  84201. dispose(): void;
  84202. }
  84203. /**
  84204. * Specialized buffer used to store vertex data
  84205. */
  84206. export class VertexBuffer {
  84207. /** @hidden */
  84208. _buffer: Buffer;
  84209. private _kind;
  84210. private _size;
  84211. private _ownsBuffer;
  84212. private _instanced;
  84213. private _instanceDivisor;
  84214. /**
  84215. * The byte type.
  84216. */
  84217. static readonly BYTE: number;
  84218. /**
  84219. * The unsigned byte type.
  84220. */
  84221. static readonly UNSIGNED_BYTE: number;
  84222. /**
  84223. * The short type.
  84224. */
  84225. static readonly SHORT: number;
  84226. /**
  84227. * The unsigned short type.
  84228. */
  84229. static readonly UNSIGNED_SHORT: number;
  84230. /**
  84231. * The integer type.
  84232. */
  84233. static readonly INT: number;
  84234. /**
  84235. * The unsigned integer type.
  84236. */
  84237. static readonly UNSIGNED_INT: number;
  84238. /**
  84239. * The float type.
  84240. */
  84241. static readonly FLOAT: number;
  84242. /**
  84243. * Gets or sets the instance divisor when in instanced mode
  84244. */
  84245. get instanceDivisor(): number;
  84246. set instanceDivisor(value: number);
  84247. /**
  84248. * Gets the byte stride.
  84249. */
  84250. readonly byteStride: number;
  84251. /**
  84252. * Gets the byte offset.
  84253. */
  84254. readonly byteOffset: number;
  84255. /**
  84256. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84257. */
  84258. readonly normalized: boolean;
  84259. /**
  84260. * Gets the data type of each component in the array.
  84261. */
  84262. readonly type: number;
  84263. /**
  84264. * Constructor
  84265. * @param engine the engine
  84266. * @param data the data to use for this vertex buffer
  84267. * @param kind the vertex buffer kind
  84268. * @param updatable whether the data is updatable
  84269. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84270. * @param stride the stride (optional)
  84271. * @param instanced whether the buffer is instanced (optional)
  84272. * @param offset the offset of the data (optional)
  84273. * @param size the number of components (optional)
  84274. * @param type the type of the component (optional)
  84275. * @param normalized whether the data contains normalized data (optional)
  84276. * @param useBytes set to true if stride and offset are in bytes (optional)
  84277. * @param divisor defines the instance divisor to use (1 by default)
  84278. */
  84279. 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);
  84280. /** @hidden */
  84281. _rebuild(): void;
  84282. /**
  84283. * Returns the kind of the VertexBuffer (string)
  84284. * @returns a string
  84285. */
  84286. getKind(): string;
  84287. /**
  84288. * Gets a boolean indicating if the VertexBuffer is updatable?
  84289. * @returns true if the buffer is updatable
  84290. */
  84291. isUpdatable(): boolean;
  84292. /**
  84293. * Gets current buffer's data
  84294. * @returns a DataArray or null
  84295. */
  84296. getData(): Nullable<DataArray>;
  84297. /**
  84298. * Gets underlying native buffer
  84299. * @returns underlying native buffer
  84300. */
  84301. getBuffer(): Nullable<DataBuffer>;
  84302. /**
  84303. * Gets the stride in float32 units (i.e. byte stride / 4).
  84304. * May not be an integer if the byte stride is not divisible by 4.
  84305. * @returns the stride in float32 units
  84306. * @deprecated Please use byteStride instead.
  84307. */
  84308. getStrideSize(): number;
  84309. /**
  84310. * Returns the offset as a multiple of the type byte length.
  84311. * @returns the offset in bytes
  84312. * @deprecated Please use byteOffset instead.
  84313. */
  84314. getOffset(): number;
  84315. /**
  84316. * Returns the number of components per vertex attribute (integer)
  84317. * @returns the size in float
  84318. */
  84319. getSize(): number;
  84320. /**
  84321. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84322. * @returns true if this buffer is instanced
  84323. */
  84324. getIsInstanced(): boolean;
  84325. /**
  84326. * Returns the instancing divisor, zero for non-instanced (integer).
  84327. * @returns a number
  84328. */
  84329. getInstanceDivisor(): number;
  84330. /**
  84331. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84332. * @param data defines the data to store
  84333. */
  84334. create(data?: DataArray): void;
  84335. /**
  84336. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84337. * This function will create a new buffer if the current one is not updatable
  84338. * @param data defines the data to store
  84339. */
  84340. update(data: DataArray): void;
  84341. /**
  84342. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84343. * Returns the directly updated WebGLBuffer.
  84344. * @param data the new data
  84345. * @param offset the new offset
  84346. * @param useBytes set to true if the offset is in bytes
  84347. */
  84348. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  84349. /**
  84350. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84351. */
  84352. dispose(): void;
  84353. /**
  84354. * Enumerates each value of this vertex buffer as numbers.
  84355. * @param count the number of values to enumerate
  84356. * @param callback the callback function called for each value
  84357. */
  84358. forEach(count: number, callback: (value: number, index: number) => void): void;
  84359. /**
  84360. * Positions
  84361. */
  84362. static readonly PositionKind: string;
  84363. /**
  84364. * Normals
  84365. */
  84366. static readonly NormalKind: string;
  84367. /**
  84368. * Tangents
  84369. */
  84370. static readonly TangentKind: string;
  84371. /**
  84372. * Texture coordinates
  84373. */
  84374. static readonly UVKind: string;
  84375. /**
  84376. * Texture coordinates 2
  84377. */
  84378. static readonly UV2Kind: string;
  84379. /**
  84380. * Texture coordinates 3
  84381. */
  84382. static readonly UV3Kind: string;
  84383. /**
  84384. * Texture coordinates 4
  84385. */
  84386. static readonly UV4Kind: string;
  84387. /**
  84388. * Texture coordinates 5
  84389. */
  84390. static readonly UV5Kind: string;
  84391. /**
  84392. * Texture coordinates 6
  84393. */
  84394. static readonly UV6Kind: string;
  84395. /**
  84396. * Colors
  84397. */
  84398. static readonly ColorKind: string;
  84399. /**
  84400. * Matrix indices (for bones)
  84401. */
  84402. static readonly MatricesIndicesKind: string;
  84403. /**
  84404. * Matrix weights (for bones)
  84405. */
  84406. static readonly MatricesWeightsKind: string;
  84407. /**
  84408. * Additional matrix indices (for bones)
  84409. */
  84410. static readonly MatricesIndicesExtraKind: string;
  84411. /**
  84412. * Additional matrix weights (for bones)
  84413. */
  84414. static readonly MatricesWeightsExtraKind: string;
  84415. /**
  84416. * Deduces the stride given a kind.
  84417. * @param kind The kind string to deduce
  84418. * @returns The deduced stride
  84419. */
  84420. static DeduceStride(kind: string): number;
  84421. /**
  84422. * Gets the byte length of the given type.
  84423. * @param type the type
  84424. * @returns the number of bytes
  84425. */
  84426. static GetTypeByteLength(type: number): number;
  84427. /**
  84428. * Enumerates each value of the given parameters as numbers.
  84429. * @param data the data to enumerate
  84430. * @param byteOffset the byte offset of the data
  84431. * @param byteStride the byte stride of the data
  84432. * @param componentCount the number of components per element
  84433. * @param componentType the type of the component
  84434. * @param count the number of values to enumerate
  84435. * @param normalized whether the data is normalized
  84436. * @param callback the callback function called for each value
  84437. */
  84438. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  84439. private static _GetFloatValue;
  84440. }
  84441. }
  84442. declare module BABYLON {
  84443. /**
  84444. * @hidden
  84445. */
  84446. export class IntersectionInfo {
  84447. bu: Nullable<number>;
  84448. bv: Nullable<number>;
  84449. distance: number;
  84450. faceId: number;
  84451. subMeshId: number;
  84452. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  84453. }
  84454. }
  84455. declare module BABYLON {
  84456. /**
  84457. * Class used to store bounding sphere information
  84458. */
  84459. export class BoundingSphere {
  84460. /**
  84461. * Gets the center of the bounding sphere in local space
  84462. */
  84463. readonly center: Vector3;
  84464. /**
  84465. * Radius of the bounding sphere in local space
  84466. */
  84467. radius: number;
  84468. /**
  84469. * Gets the center of the bounding sphere in world space
  84470. */
  84471. readonly centerWorld: Vector3;
  84472. /**
  84473. * Radius of the bounding sphere in world space
  84474. */
  84475. radiusWorld: number;
  84476. /**
  84477. * Gets the minimum vector in local space
  84478. */
  84479. readonly minimum: Vector3;
  84480. /**
  84481. * Gets the maximum vector in local space
  84482. */
  84483. readonly maximum: Vector3;
  84484. private _worldMatrix;
  84485. private static readonly TmpVector3;
  84486. /**
  84487. * Creates a new bounding sphere
  84488. * @param min defines the minimum vector (in local space)
  84489. * @param max defines the maximum vector (in local space)
  84490. * @param worldMatrix defines the new world matrix
  84491. */
  84492. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84493. /**
  84494. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  84495. * @param min defines the new minimum vector (in local space)
  84496. * @param max defines the new maximum vector (in local space)
  84497. * @param worldMatrix defines the new world matrix
  84498. */
  84499. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84500. /**
  84501. * Scale the current bounding sphere by applying a scale factor
  84502. * @param factor defines the scale factor to apply
  84503. * @returns the current bounding box
  84504. */
  84505. scale(factor: number): BoundingSphere;
  84506. /**
  84507. * Gets the world matrix of the bounding box
  84508. * @returns a matrix
  84509. */
  84510. getWorldMatrix(): DeepImmutable<Matrix>;
  84511. /** @hidden */
  84512. _update(worldMatrix: DeepImmutable<Matrix>): void;
  84513. /**
  84514. * Tests if the bounding sphere is intersecting the frustum planes
  84515. * @param frustumPlanes defines the frustum planes to test
  84516. * @returns true if there is an intersection
  84517. */
  84518. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84519. /**
  84520. * Tests if the bounding sphere center is in between the frustum planes.
  84521. * Used for optimistic fast inclusion.
  84522. * @param frustumPlanes defines the frustum planes to test
  84523. * @returns true if the sphere center is in between the frustum planes
  84524. */
  84525. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84526. /**
  84527. * Tests if a point is inside the bounding sphere
  84528. * @param point defines the point to test
  84529. * @returns true if the point is inside the bounding sphere
  84530. */
  84531. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84532. /**
  84533. * Checks if two sphere intersct
  84534. * @param sphere0 sphere 0
  84535. * @param sphere1 sphere 1
  84536. * @returns true if the speres intersect
  84537. */
  84538. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  84539. }
  84540. }
  84541. declare module BABYLON {
  84542. /**
  84543. * Class used to store bounding box information
  84544. */
  84545. export class BoundingBox implements ICullable {
  84546. /**
  84547. * Gets the 8 vectors representing the bounding box in local space
  84548. */
  84549. readonly vectors: Vector3[];
  84550. /**
  84551. * Gets the center of the bounding box in local space
  84552. */
  84553. readonly center: Vector3;
  84554. /**
  84555. * Gets the center of the bounding box in world space
  84556. */
  84557. readonly centerWorld: Vector3;
  84558. /**
  84559. * Gets the extend size in local space
  84560. */
  84561. readonly extendSize: Vector3;
  84562. /**
  84563. * Gets the extend size in world space
  84564. */
  84565. readonly extendSizeWorld: Vector3;
  84566. /**
  84567. * Gets the OBB (object bounding box) directions
  84568. */
  84569. readonly directions: Vector3[];
  84570. /**
  84571. * Gets the 8 vectors representing the bounding box in world space
  84572. */
  84573. readonly vectorsWorld: Vector3[];
  84574. /**
  84575. * Gets the minimum vector in world space
  84576. */
  84577. readonly minimumWorld: Vector3;
  84578. /**
  84579. * Gets the maximum vector in world space
  84580. */
  84581. readonly maximumWorld: Vector3;
  84582. /**
  84583. * Gets the minimum vector in local space
  84584. */
  84585. readonly minimum: Vector3;
  84586. /**
  84587. * Gets the maximum vector in local space
  84588. */
  84589. readonly maximum: Vector3;
  84590. private _worldMatrix;
  84591. private static readonly TmpVector3;
  84592. /**
  84593. * @hidden
  84594. */
  84595. _tag: number;
  84596. /**
  84597. * Creates a new bounding box
  84598. * @param min defines the minimum vector (in local space)
  84599. * @param max defines the maximum vector (in local space)
  84600. * @param worldMatrix defines the new world matrix
  84601. */
  84602. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84603. /**
  84604. * Recreates the entire bounding box from scratch as if we call the constructor in place
  84605. * @param min defines the new minimum vector (in local space)
  84606. * @param max defines the new maximum vector (in local space)
  84607. * @param worldMatrix defines the new world matrix
  84608. */
  84609. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84610. /**
  84611. * Scale the current bounding box by applying a scale factor
  84612. * @param factor defines the scale factor to apply
  84613. * @returns the current bounding box
  84614. */
  84615. scale(factor: number): BoundingBox;
  84616. /**
  84617. * Gets the world matrix of the bounding box
  84618. * @returns a matrix
  84619. */
  84620. getWorldMatrix(): DeepImmutable<Matrix>;
  84621. /** @hidden */
  84622. _update(world: DeepImmutable<Matrix>): void;
  84623. /**
  84624. * Tests if the bounding box is intersecting the frustum planes
  84625. * @param frustumPlanes defines the frustum planes to test
  84626. * @returns true if there is an intersection
  84627. */
  84628. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84629. /**
  84630. * Tests if the bounding box is entirely inside the frustum planes
  84631. * @param frustumPlanes defines the frustum planes to test
  84632. * @returns true if there is an inclusion
  84633. */
  84634. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84635. /**
  84636. * Tests if a point is inside the bounding box
  84637. * @param point defines the point to test
  84638. * @returns true if the point is inside the bounding box
  84639. */
  84640. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84641. /**
  84642. * Tests if the bounding box intersects with a bounding sphere
  84643. * @param sphere defines the sphere to test
  84644. * @returns true if there is an intersection
  84645. */
  84646. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  84647. /**
  84648. * Tests if the bounding box intersects with a box defined by a min and max vectors
  84649. * @param min defines the min vector to use
  84650. * @param max defines the max vector to use
  84651. * @returns true if there is an intersection
  84652. */
  84653. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  84654. /**
  84655. * Tests if two bounding boxes are intersections
  84656. * @param box0 defines the first box to test
  84657. * @param box1 defines the second box to test
  84658. * @returns true if there is an intersection
  84659. */
  84660. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  84661. /**
  84662. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  84663. * @param minPoint defines the minimum vector of the bounding box
  84664. * @param maxPoint defines the maximum vector of the bounding box
  84665. * @param sphereCenter defines the sphere center
  84666. * @param sphereRadius defines the sphere radius
  84667. * @returns true if there is an intersection
  84668. */
  84669. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  84670. /**
  84671. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  84672. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84673. * @param frustumPlanes defines the frustum planes to test
  84674. * @return true if there is an inclusion
  84675. */
  84676. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84677. /**
  84678. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  84679. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  84680. * @param frustumPlanes defines the frustum planes to test
  84681. * @return true if there is an intersection
  84682. */
  84683. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84684. }
  84685. }
  84686. declare module BABYLON {
  84687. /** @hidden */
  84688. export class Collider {
  84689. /** Define if a collision was found */
  84690. collisionFound: boolean;
  84691. /**
  84692. * Define last intersection point in local space
  84693. */
  84694. intersectionPoint: Vector3;
  84695. /**
  84696. * Define last collided mesh
  84697. */
  84698. collidedMesh: Nullable<AbstractMesh>;
  84699. private _collisionPoint;
  84700. private _planeIntersectionPoint;
  84701. private _tempVector;
  84702. private _tempVector2;
  84703. private _tempVector3;
  84704. private _tempVector4;
  84705. private _edge;
  84706. private _baseToVertex;
  84707. private _destinationPoint;
  84708. private _slidePlaneNormal;
  84709. private _displacementVector;
  84710. /** @hidden */
  84711. _radius: Vector3;
  84712. /** @hidden */
  84713. _retry: number;
  84714. private _velocity;
  84715. private _basePoint;
  84716. private _epsilon;
  84717. /** @hidden */
  84718. _velocityWorldLength: number;
  84719. /** @hidden */
  84720. _basePointWorld: Vector3;
  84721. private _velocityWorld;
  84722. private _normalizedVelocity;
  84723. /** @hidden */
  84724. _initialVelocity: Vector3;
  84725. /** @hidden */
  84726. _initialPosition: Vector3;
  84727. private _nearestDistance;
  84728. private _collisionMask;
  84729. get collisionMask(): number;
  84730. set collisionMask(mask: number);
  84731. /**
  84732. * Gets the plane normal used to compute the sliding response (in local space)
  84733. */
  84734. get slidePlaneNormal(): Vector3;
  84735. /** @hidden */
  84736. _initialize(source: Vector3, dir: Vector3, e: number): void;
  84737. /** @hidden */
  84738. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  84739. /** @hidden */
  84740. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  84741. /** @hidden */
  84742. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84743. /** @hidden */
  84744. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  84745. /** @hidden */
  84746. _getResponse(pos: Vector3, vel: Vector3): void;
  84747. }
  84748. }
  84749. declare module BABYLON {
  84750. /**
  84751. * Interface for cullable objects
  84752. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  84753. */
  84754. export interface ICullable {
  84755. /**
  84756. * Checks if the object or part of the object is in the frustum
  84757. * @param frustumPlanes Camera near/planes
  84758. * @returns true if the object is in frustum otherwise false
  84759. */
  84760. isInFrustum(frustumPlanes: Plane[]): boolean;
  84761. /**
  84762. * Checks if a cullable object (mesh...) is in the camera frustum
  84763. * Unlike isInFrustum this cheks the full bounding box
  84764. * @param frustumPlanes Camera near/planes
  84765. * @returns true if the object is in frustum otherwise false
  84766. */
  84767. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84768. }
  84769. /**
  84770. * Info for a bounding data of a mesh
  84771. */
  84772. export class BoundingInfo implements ICullable {
  84773. /**
  84774. * Bounding box for the mesh
  84775. */
  84776. readonly boundingBox: BoundingBox;
  84777. /**
  84778. * Bounding sphere for the mesh
  84779. */
  84780. readonly boundingSphere: BoundingSphere;
  84781. private _isLocked;
  84782. private static readonly TmpVector3;
  84783. /**
  84784. * Constructs bounding info
  84785. * @param minimum min vector of the bounding box/sphere
  84786. * @param maximum max vector of the bounding box/sphere
  84787. * @param worldMatrix defines the new world matrix
  84788. */
  84789. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  84790. /**
  84791. * Recreates the entire bounding info from scratch as if we call the constructor in place
  84792. * @param min defines the new minimum vector (in local space)
  84793. * @param max defines the new maximum vector (in local space)
  84794. * @param worldMatrix defines the new world matrix
  84795. */
  84796. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  84797. /**
  84798. * min vector of the bounding box/sphere
  84799. */
  84800. get minimum(): Vector3;
  84801. /**
  84802. * max vector of the bounding box/sphere
  84803. */
  84804. get maximum(): Vector3;
  84805. /**
  84806. * If the info is locked and won't be updated to avoid perf overhead
  84807. */
  84808. get isLocked(): boolean;
  84809. set isLocked(value: boolean);
  84810. /**
  84811. * Updates the bounding sphere and box
  84812. * @param world world matrix to be used to update
  84813. */
  84814. update(world: DeepImmutable<Matrix>): void;
  84815. /**
  84816. * Recreate the bounding info to be centered around a specific point given a specific extend.
  84817. * @param center New center of the bounding info
  84818. * @param extend New extend of the bounding info
  84819. * @returns the current bounding info
  84820. */
  84821. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  84822. /**
  84823. * Scale the current bounding info by applying a scale factor
  84824. * @param factor defines the scale factor to apply
  84825. * @returns the current bounding info
  84826. */
  84827. scale(factor: number): BoundingInfo;
  84828. /**
  84829. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  84830. * @param frustumPlanes defines the frustum to test
  84831. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  84832. * @returns true if the bounding info is in the frustum planes
  84833. */
  84834. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  84835. /**
  84836. * Gets the world distance between the min and max points of the bounding box
  84837. */
  84838. get diagonalLength(): number;
  84839. /**
  84840. * Checks if a cullable object (mesh...) is in the camera frustum
  84841. * Unlike isInFrustum this cheks the full bounding box
  84842. * @param frustumPlanes Camera near/planes
  84843. * @returns true if the object is in frustum otherwise false
  84844. */
  84845. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  84846. /** @hidden */
  84847. _checkCollision(collider: Collider): boolean;
  84848. /**
  84849. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  84850. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84851. * @param point the point to check intersection with
  84852. * @returns if the point intersects
  84853. */
  84854. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  84855. /**
  84856. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  84857. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84858. * @param boundingInfo the bounding info to check intersection with
  84859. * @param precise if the intersection should be done using OBB
  84860. * @returns if the bounding info intersects
  84861. */
  84862. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  84863. }
  84864. }
  84865. declare module BABYLON {
  84866. /**
  84867. * Extracts minimum and maximum values from a list of indexed positions
  84868. * @param positions defines the positions to use
  84869. * @param indices defines the indices to the positions
  84870. * @param indexStart defines the start index
  84871. * @param indexCount defines the end index
  84872. * @param bias defines bias value to add to the result
  84873. * @return minimum and maximum values
  84874. */
  84875. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  84876. minimum: Vector3;
  84877. maximum: Vector3;
  84878. };
  84879. /**
  84880. * Extracts minimum and maximum values from a list of positions
  84881. * @param positions defines the positions to use
  84882. * @param start defines the start index in the positions array
  84883. * @param count defines the number of positions to handle
  84884. * @param bias defines bias value to add to the result
  84885. * @param stride defines the stride size to use (distance between two positions in the positions array)
  84886. * @return minimum and maximum values
  84887. */
  84888. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  84889. minimum: Vector3;
  84890. maximum: Vector3;
  84891. };
  84892. }
  84893. declare module BABYLON {
  84894. /** @hidden */
  84895. export class WebGLDataBuffer extends DataBuffer {
  84896. private _buffer;
  84897. constructor(resource: WebGLBuffer);
  84898. get underlyingResource(): any;
  84899. }
  84900. }
  84901. declare module BABYLON {
  84902. /** @hidden */
  84903. export class WebGLPipelineContext implements IPipelineContext {
  84904. engine: ThinEngine;
  84905. program: Nullable<WebGLProgram>;
  84906. context?: WebGLRenderingContext;
  84907. vertexShader?: WebGLShader;
  84908. fragmentShader?: WebGLShader;
  84909. isParallelCompiled: boolean;
  84910. onCompiled?: () => void;
  84911. transformFeedback?: WebGLTransformFeedback | null;
  84912. vertexCompilationError: Nullable<string>;
  84913. fragmentCompilationError: Nullable<string>;
  84914. programLinkError: Nullable<string>;
  84915. programValidationError: Nullable<string>;
  84916. get isAsync(): boolean;
  84917. get isReady(): boolean;
  84918. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  84919. _getVertexShaderCode(): string | null;
  84920. _getFragmentShaderCode(): string | null;
  84921. }
  84922. }
  84923. declare module BABYLON {
  84924. interface ThinEngine {
  84925. /**
  84926. * Create an uniform buffer
  84927. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84928. * @param elements defines the content of the uniform buffer
  84929. * @returns the webGL uniform buffer
  84930. */
  84931. createUniformBuffer(elements: FloatArray): DataBuffer;
  84932. /**
  84933. * Create a dynamic uniform buffer
  84934. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84935. * @param elements defines the content of the uniform buffer
  84936. * @returns the webGL uniform buffer
  84937. */
  84938. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  84939. /**
  84940. * Update an existing uniform buffer
  84941. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  84942. * @param uniformBuffer defines the target uniform buffer
  84943. * @param elements defines the content to update
  84944. * @param offset defines the offset in the uniform buffer where update should start
  84945. * @param count defines the size of the data to update
  84946. */
  84947. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  84948. /**
  84949. * Bind an uniform buffer to the current webGL context
  84950. * @param buffer defines the buffer to bind
  84951. */
  84952. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  84953. /**
  84954. * Bind a buffer to the current webGL context at a given location
  84955. * @param buffer defines the buffer to bind
  84956. * @param location defines the index where to bind the buffer
  84957. */
  84958. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  84959. /**
  84960. * Bind a specific block at a given index in a specific shader program
  84961. * @param pipelineContext defines the pipeline context to use
  84962. * @param blockName defines the block name
  84963. * @param index defines the index where to bind the block
  84964. */
  84965. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  84966. }
  84967. }
  84968. declare module BABYLON {
  84969. /**
  84970. * Uniform buffer objects.
  84971. *
  84972. * Handles blocks of uniform on the GPU.
  84973. *
  84974. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84975. *
  84976. * For more information, please refer to :
  84977. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84978. */
  84979. export class UniformBuffer {
  84980. private _engine;
  84981. private _buffer;
  84982. private _data;
  84983. private _bufferData;
  84984. private _dynamic?;
  84985. private _uniformLocations;
  84986. private _uniformSizes;
  84987. private _uniformLocationPointer;
  84988. private _needSync;
  84989. private _noUBO;
  84990. private _currentEffect;
  84991. /** @hidden */
  84992. _alreadyBound: boolean;
  84993. private static _MAX_UNIFORM_SIZE;
  84994. private static _tempBuffer;
  84995. /**
  84996. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  84997. * This is dynamic to allow compat with webgl 1 and 2.
  84998. * You will need to pass the name of the uniform as well as the value.
  84999. */
  85000. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85001. /**
  85002. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85003. * This is dynamic to allow compat with webgl 1 and 2.
  85004. * You will need to pass the name of the uniform as well as the value.
  85005. */
  85006. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85007. /**
  85008. * Lambda to Update a single float in a uniform buffer.
  85009. * This is dynamic to allow compat with webgl 1 and 2.
  85010. * You will need to pass the name of the uniform as well as the value.
  85011. */
  85012. updateFloat: (name: string, x: number) => void;
  85013. /**
  85014. * Lambda to Update a vec2 of float in a uniform buffer.
  85015. * This is dynamic to allow compat with webgl 1 and 2.
  85016. * You will need to pass the name of the uniform as well as the value.
  85017. */
  85018. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85019. /**
  85020. * Lambda to Update a vec3 of float in a uniform buffer.
  85021. * This is dynamic to allow compat with webgl 1 and 2.
  85022. * You will need to pass the name of the uniform as well as the value.
  85023. */
  85024. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85025. /**
  85026. * Lambda to Update a vec4 of float in a uniform buffer.
  85027. * This is dynamic to allow compat with webgl 1 and 2.
  85028. * You will need to pass the name of the uniform as well as the value.
  85029. */
  85030. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85031. /**
  85032. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85033. * This is dynamic to allow compat with webgl 1 and 2.
  85034. * You will need to pass the name of the uniform as well as the value.
  85035. */
  85036. updateMatrix: (name: string, mat: Matrix) => void;
  85037. /**
  85038. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85039. * This is dynamic to allow compat with webgl 1 and 2.
  85040. * You will need to pass the name of the uniform as well as the value.
  85041. */
  85042. updateVector3: (name: string, vector: Vector3) => void;
  85043. /**
  85044. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85045. * This is dynamic to allow compat with webgl 1 and 2.
  85046. * You will need to pass the name of the uniform as well as the value.
  85047. */
  85048. updateVector4: (name: string, vector: Vector4) => void;
  85049. /**
  85050. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85051. * This is dynamic to allow compat with webgl 1 and 2.
  85052. * You will need to pass the name of the uniform as well as the value.
  85053. */
  85054. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85055. /**
  85056. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85057. * This is dynamic to allow compat with webgl 1 and 2.
  85058. * You will need to pass the name of the uniform as well as the value.
  85059. */
  85060. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85061. /**
  85062. * Instantiates a new Uniform buffer objects.
  85063. *
  85064. * Handles blocks of uniform on the GPU.
  85065. *
  85066. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85067. *
  85068. * For more information, please refer to :
  85069. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85070. * @param engine Define the engine the buffer is associated with
  85071. * @param data Define the data contained in the buffer
  85072. * @param dynamic Define if the buffer is updatable
  85073. */
  85074. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85075. /**
  85076. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85077. * or just falling back on setUniformXXX calls.
  85078. */
  85079. get useUbo(): boolean;
  85080. /**
  85081. * Indicates if the WebGL underlying uniform buffer is in sync
  85082. * with the javascript cache data.
  85083. */
  85084. get isSync(): boolean;
  85085. /**
  85086. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85087. * Also, a dynamic UniformBuffer will disable cache verification and always
  85088. * update the underlying WebGL uniform buffer to the GPU.
  85089. * @returns if Dynamic, otherwise false
  85090. */
  85091. isDynamic(): boolean;
  85092. /**
  85093. * The data cache on JS side.
  85094. * @returns the underlying data as a float array
  85095. */
  85096. getData(): Float32Array;
  85097. /**
  85098. * The underlying WebGL Uniform buffer.
  85099. * @returns the webgl buffer
  85100. */
  85101. getBuffer(): Nullable<DataBuffer>;
  85102. /**
  85103. * std140 layout specifies how to align data within an UBO structure.
  85104. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85105. * for specs.
  85106. */
  85107. private _fillAlignment;
  85108. /**
  85109. * Adds an uniform in the buffer.
  85110. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85111. * for the layout to be correct !
  85112. * @param name Name of the uniform, as used in the uniform block in the shader.
  85113. * @param size Data size, or data directly.
  85114. */
  85115. addUniform(name: string, size: number | number[]): void;
  85116. /**
  85117. * Adds a Matrix 4x4 to the uniform buffer.
  85118. * @param name Name of the uniform, as used in the uniform block in the shader.
  85119. * @param mat A 4x4 matrix.
  85120. */
  85121. addMatrix(name: string, mat: Matrix): void;
  85122. /**
  85123. * Adds a vec2 to the uniform buffer.
  85124. * @param name Name of the uniform, as used in the uniform block in the shader.
  85125. * @param x Define the x component value of the vec2
  85126. * @param y Define the y component value of the vec2
  85127. */
  85128. addFloat2(name: string, x: number, y: number): void;
  85129. /**
  85130. * Adds a vec3 to the uniform buffer.
  85131. * @param name Name of the uniform, as used in the uniform block in the shader.
  85132. * @param x Define the x component value of the vec3
  85133. * @param y Define the y component value of the vec3
  85134. * @param z Define the z component value of the vec3
  85135. */
  85136. addFloat3(name: string, x: number, y: number, z: number): void;
  85137. /**
  85138. * Adds a vec3 to the uniform buffer.
  85139. * @param name Name of the uniform, as used in the uniform block in the shader.
  85140. * @param color Define the vec3 from a Color
  85141. */
  85142. addColor3(name: string, color: Color3): void;
  85143. /**
  85144. * Adds a vec4 to the uniform buffer.
  85145. * @param name Name of the uniform, as used in the uniform block in the shader.
  85146. * @param color Define the rgb components from a Color
  85147. * @param alpha Define the a component of the vec4
  85148. */
  85149. addColor4(name: string, color: Color3, alpha: number): void;
  85150. /**
  85151. * Adds a vec3 to the uniform buffer.
  85152. * @param name Name of the uniform, as used in the uniform block in the shader.
  85153. * @param vector Define the vec3 components from a Vector
  85154. */
  85155. addVector3(name: string, vector: Vector3): void;
  85156. /**
  85157. * Adds a Matrix 3x3 to the uniform buffer.
  85158. * @param name Name of the uniform, as used in the uniform block in the shader.
  85159. */
  85160. addMatrix3x3(name: string): void;
  85161. /**
  85162. * Adds a Matrix 2x2 to the uniform buffer.
  85163. * @param name Name of the uniform, as used in the uniform block in the shader.
  85164. */
  85165. addMatrix2x2(name: string): void;
  85166. /**
  85167. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85168. */
  85169. create(): void;
  85170. /** @hidden */
  85171. _rebuild(): void;
  85172. /**
  85173. * Updates the WebGL Uniform Buffer on the GPU.
  85174. * If the `dynamic` flag is set to true, no cache comparison is done.
  85175. * Otherwise, the buffer will be updated only if the cache differs.
  85176. */
  85177. update(): void;
  85178. /**
  85179. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85180. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85181. * @param data Define the flattened data
  85182. * @param size Define the size of the data.
  85183. */
  85184. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85185. private _valueCache;
  85186. private _cacheMatrix;
  85187. private _updateMatrix3x3ForUniform;
  85188. private _updateMatrix3x3ForEffect;
  85189. private _updateMatrix2x2ForEffect;
  85190. private _updateMatrix2x2ForUniform;
  85191. private _updateFloatForEffect;
  85192. private _updateFloatForUniform;
  85193. private _updateFloat2ForEffect;
  85194. private _updateFloat2ForUniform;
  85195. private _updateFloat3ForEffect;
  85196. private _updateFloat3ForUniform;
  85197. private _updateFloat4ForEffect;
  85198. private _updateFloat4ForUniform;
  85199. private _updateMatrixForEffect;
  85200. private _updateMatrixForUniform;
  85201. private _updateVector3ForEffect;
  85202. private _updateVector3ForUniform;
  85203. private _updateVector4ForEffect;
  85204. private _updateVector4ForUniform;
  85205. private _updateColor3ForEffect;
  85206. private _updateColor3ForUniform;
  85207. private _updateColor4ForEffect;
  85208. private _updateColor4ForUniform;
  85209. /**
  85210. * Sets a sampler uniform on the effect.
  85211. * @param name Define the name of the sampler.
  85212. * @param texture Define the texture to set in the sampler
  85213. */
  85214. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85215. /**
  85216. * Directly updates the value of the uniform in the cache AND on the GPU.
  85217. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85218. * @param data Define the flattened data
  85219. */
  85220. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85221. /**
  85222. * Binds this uniform buffer to an effect.
  85223. * @param effect Define the effect to bind the buffer to
  85224. * @param name Name of the uniform block in the shader.
  85225. */
  85226. bindToEffect(effect: Effect, name: string): void;
  85227. /**
  85228. * Disposes the uniform buffer.
  85229. */
  85230. dispose(): void;
  85231. }
  85232. }
  85233. declare module BABYLON {
  85234. /**
  85235. * Enum that determines the text-wrapping mode to use.
  85236. */
  85237. export enum InspectableType {
  85238. /**
  85239. * Checkbox for booleans
  85240. */
  85241. Checkbox = 0,
  85242. /**
  85243. * Sliders for numbers
  85244. */
  85245. Slider = 1,
  85246. /**
  85247. * Vector3
  85248. */
  85249. Vector3 = 2,
  85250. /**
  85251. * Quaternions
  85252. */
  85253. Quaternion = 3,
  85254. /**
  85255. * Color3
  85256. */
  85257. Color3 = 4,
  85258. /**
  85259. * String
  85260. */
  85261. String = 5
  85262. }
  85263. /**
  85264. * Interface used to define custom inspectable properties.
  85265. * This interface is used by the inspector to display custom property grids
  85266. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85267. */
  85268. export interface IInspectable {
  85269. /**
  85270. * Gets the label to display
  85271. */
  85272. label: string;
  85273. /**
  85274. * Gets the name of the property to edit
  85275. */
  85276. propertyName: string;
  85277. /**
  85278. * Gets the type of the editor to use
  85279. */
  85280. type: InspectableType;
  85281. /**
  85282. * Gets the minimum value of the property when using in "slider" mode
  85283. */
  85284. min?: number;
  85285. /**
  85286. * Gets the maximum value of the property when using in "slider" mode
  85287. */
  85288. max?: number;
  85289. /**
  85290. * Gets the setp to use when using in "slider" mode
  85291. */
  85292. step?: number;
  85293. }
  85294. }
  85295. declare module BABYLON {
  85296. /**
  85297. * Class used to provide helper for timing
  85298. */
  85299. export class TimingTools {
  85300. /**
  85301. * Polyfill for setImmediate
  85302. * @param action defines the action to execute after the current execution block
  85303. */
  85304. static SetImmediate(action: () => void): void;
  85305. }
  85306. }
  85307. declare module BABYLON {
  85308. /**
  85309. * Class used to enable instatition of objects by class name
  85310. */
  85311. export class InstantiationTools {
  85312. /**
  85313. * Use this object to register external classes like custom textures or material
  85314. * to allow the laoders to instantiate them
  85315. */
  85316. static RegisteredExternalClasses: {
  85317. [key: string]: Object;
  85318. };
  85319. /**
  85320. * Tries to instantiate a new object from a given class name
  85321. * @param className defines the class name to instantiate
  85322. * @returns the new object or null if the system was not able to do the instantiation
  85323. */
  85324. static Instantiate(className: string): any;
  85325. }
  85326. }
  85327. declare module BABYLON {
  85328. /**
  85329. * Define options used to create a depth texture
  85330. */
  85331. export class DepthTextureCreationOptions {
  85332. /** Specifies whether or not a stencil should be allocated in the texture */
  85333. generateStencil?: boolean;
  85334. /** Specifies whether or not bilinear filtering is enable on the texture */
  85335. bilinearFiltering?: boolean;
  85336. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  85337. comparisonFunction?: number;
  85338. /** Specifies if the created texture is a cube texture */
  85339. isCube?: boolean;
  85340. }
  85341. }
  85342. declare module BABYLON {
  85343. interface ThinEngine {
  85344. /**
  85345. * Creates a depth stencil cube texture.
  85346. * This is only available in WebGL 2.
  85347. * @param size The size of face edge in the cube texture.
  85348. * @param options The options defining the cube texture.
  85349. * @returns The cube texture
  85350. */
  85351. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  85352. /**
  85353. * Creates a cube texture
  85354. * @param rootUrl defines the url where the files to load is located
  85355. * @param scene defines the current scene
  85356. * @param files defines the list of files to load (1 per face)
  85357. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85358. * @param onLoad defines an optional callback raised when the texture is loaded
  85359. * @param onError defines an optional callback raised if there is an issue to load the texture
  85360. * @param format defines the format of the data
  85361. * @param forcedExtension defines the extension to use to pick the right loader
  85362. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85363. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85364. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85365. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  85366. * @returns the cube texture as an InternalTexture
  85367. */
  85368. 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;
  85369. /**
  85370. * Creates a cube texture
  85371. * @param rootUrl defines the url where the files to load is located
  85372. * @param scene defines the current scene
  85373. * @param files defines the list of files to load (1 per face)
  85374. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85375. * @param onLoad defines an optional callback raised when the texture is loaded
  85376. * @param onError defines an optional callback raised if there is an issue to load the texture
  85377. * @param format defines the format of the data
  85378. * @param forcedExtension defines the extension to use to pick the right loader
  85379. * @returns the cube texture as an InternalTexture
  85380. */
  85381. 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;
  85382. /**
  85383. * Creates a cube texture
  85384. * @param rootUrl defines the url where the files to load is located
  85385. * @param scene defines the current scene
  85386. * @param files defines the list of files to load (1 per face)
  85387. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  85388. * @param onLoad defines an optional callback raised when the texture is loaded
  85389. * @param onError defines an optional callback raised if there is an issue to load the texture
  85390. * @param format defines the format of the data
  85391. * @param forcedExtension defines the extension to use to pick the right loader
  85392. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  85393. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85394. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85395. * @returns the cube texture as an InternalTexture
  85396. */
  85397. 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;
  85398. /** @hidden */
  85399. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  85400. /** @hidden */
  85401. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  85402. /** @hidden */
  85403. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85404. /** @hidden */
  85405. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  85406. /**
  85407. * @hidden
  85408. */
  85409. _setCubeMapTextureParams(loadMipmap: boolean): void;
  85410. }
  85411. }
  85412. declare module BABYLON {
  85413. /**
  85414. * Class for creating a cube texture
  85415. */
  85416. export class CubeTexture extends BaseTexture {
  85417. private _delayedOnLoad;
  85418. /**
  85419. * Observable triggered once the texture has been loaded.
  85420. */
  85421. onLoadObservable: Observable<CubeTexture>;
  85422. /**
  85423. * The url of the texture
  85424. */
  85425. url: string;
  85426. /**
  85427. * Gets or sets the center of the bounding box associated with the cube texture.
  85428. * It must define where the camera used to render the texture was set
  85429. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85430. */
  85431. boundingBoxPosition: Vector3;
  85432. private _boundingBoxSize;
  85433. /**
  85434. * Gets or sets the size of the bounding box associated with the cube texture
  85435. * When defined, the cubemap will switch to local mode
  85436. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85437. * @example https://www.babylonjs-playground.com/#RNASML
  85438. */
  85439. set boundingBoxSize(value: Vector3);
  85440. /**
  85441. * Returns the bounding box size
  85442. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  85443. */
  85444. get boundingBoxSize(): Vector3;
  85445. protected _rotationY: number;
  85446. /**
  85447. * Sets texture matrix rotation angle around Y axis in radians.
  85448. */
  85449. set rotationY(value: number);
  85450. /**
  85451. * Gets texture matrix rotation angle around Y axis radians.
  85452. */
  85453. get rotationY(): number;
  85454. /**
  85455. * Are mip maps generated for this texture or not.
  85456. */
  85457. get noMipmap(): boolean;
  85458. private _noMipmap;
  85459. private _files;
  85460. protected _forcedExtension: Nullable<string>;
  85461. private _extensions;
  85462. private _textureMatrix;
  85463. private _format;
  85464. private _createPolynomials;
  85465. /**
  85466. * Creates a cube texture from an array of image urls
  85467. * @param files defines an array of image urls
  85468. * @param scene defines the hosting scene
  85469. * @param noMipmap specifies if mip maps are not used
  85470. * @returns a cube texture
  85471. */
  85472. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  85473. /**
  85474. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  85475. * @param url defines the url of the prefiltered texture
  85476. * @param scene defines the scene the texture is attached to
  85477. * @param forcedExtension defines the extension of the file if different from the url
  85478. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85479. * @return the prefiltered texture
  85480. */
  85481. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  85482. /**
  85483. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  85484. * as prefiltered data.
  85485. * @param rootUrl defines the url of the texture or the root name of the six images
  85486. * @param null defines the scene or engine the texture is attached to
  85487. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  85488. * @param noMipmap defines if mipmaps should be created or not
  85489. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  85490. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  85491. * @param onError defines a callback triggered in case of error during load
  85492. * @param format defines the internal format to use for the texture once loaded
  85493. * @param prefiltered defines whether or not the texture is created from prefiltered data
  85494. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  85495. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  85496. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  85497. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  85498. * @return the cube texture
  85499. */
  85500. 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);
  85501. /**
  85502. * Get the current class name of the texture useful for serialization or dynamic coding.
  85503. * @returns "CubeTexture"
  85504. */
  85505. getClassName(): string;
  85506. /**
  85507. * Update the url (and optional buffer) of this texture if url was null during construction.
  85508. * @param url the url of the texture
  85509. * @param forcedExtension defines the extension to use
  85510. * @param onLoad callback called when the texture is loaded (defaults to null)
  85511. * @param prefiltered Defines whether the updated texture is prefiltered or not
  85512. */
  85513. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  85514. /**
  85515. * Delays loading of the cube texture
  85516. * @param forcedExtension defines the extension to use
  85517. */
  85518. delayLoad(forcedExtension?: string): void;
  85519. /**
  85520. * Returns the reflection texture matrix
  85521. * @returns the reflection texture matrix
  85522. */
  85523. getReflectionTextureMatrix(): Matrix;
  85524. /**
  85525. * Sets the reflection texture matrix
  85526. * @param value Reflection texture matrix
  85527. */
  85528. setReflectionTextureMatrix(value: Matrix): void;
  85529. /**
  85530. * Parses text to create a cube texture
  85531. * @param parsedTexture define the serialized text to read from
  85532. * @param scene defines the hosting scene
  85533. * @param rootUrl defines the root url of the cube texture
  85534. * @returns a cube texture
  85535. */
  85536. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  85537. /**
  85538. * Makes a clone, or deep copy, of the cube texture
  85539. * @returns a new cube texture
  85540. */
  85541. clone(): CubeTexture;
  85542. }
  85543. }
  85544. declare module BABYLON {
  85545. /**
  85546. * Manages the defines for the Material
  85547. */
  85548. export class MaterialDefines {
  85549. /** @hidden */
  85550. protected _keys: string[];
  85551. private _isDirty;
  85552. /** @hidden */
  85553. _renderId: number;
  85554. /** @hidden */
  85555. _areLightsDirty: boolean;
  85556. /** @hidden */
  85557. _areLightsDisposed: boolean;
  85558. /** @hidden */
  85559. _areAttributesDirty: boolean;
  85560. /** @hidden */
  85561. _areTexturesDirty: boolean;
  85562. /** @hidden */
  85563. _areFresnelDirty: boolean;
  85564. /** @hidden */
  85565. _areMiscDirty: boolean;
  85566. /** @hidden */
  85567. _areImageProcessingDirty: boolean;
  85568. /** @hidden */
  85569. _normals: boolean;
  85570. /** @hidden */
  85571. _uvs: boolean;
  85572. /** @hidden */
  85573. _needNormals: boolean;
  85574. /** @hidden */
  85575. _needUVs: boolean;
  85576. [id: string]: any;
  85577. /**
  85578. * Specifies if the material needs to be re-calculated
  85579. */
  85580. get isDirty(): boolean;
  85581. /**
  85582. * Marks the material to indicate that it has been re-calculated
  85583. */
  85584. markAsProcessed(): void;
  85585. /**
  85586. * Marks the material to indicate that it needs to be re-calculated
  85587. */
  85588. markAsUnprocessed(): void;
  85589. /**
  85590. * Marks the material to indicate all of its defines need to be re-calculated
  85591. */
  85592. markAllAsDirty(): void;
  85593. /**
  85594. * Marks the material to indicate that image processing needs to be re-calculated
  85595. */
  85596. markAsImageProcessingDirty(): void;
  85597. /**
  85598. * Marks the material to indicate the lights need to be re-calculated
  85599. * @param disposed Defines whether the light is dirty due to dispose or not
  85600. */
  85601. markAsLightDirty(disposed?: boolean): void;
  85602. /**
  85603. * Marks the attribute state as changed
  85604. */
  85605. markAsAttributesDirty(): void;
  85606. /**
  85607. * Marks the texture state as changed
  85608. */
  85609. markAsTexturesDirty(): void;
  85610. /**
  85611. * Marks the fresnel state as changed
  85612. */
  85613. markAsFresnelDirty(): void;
  85614. /**
  85615. * Marks the misc state as changed
  85616. */
  85617. markAsMiscDirty(): void;
  85618. /**
  85619. * Rebuilds the material defines
  85620. */
  85621. rebuild(): void;
  85622. /**
  85623. * Specifies if two material defines are equal
  85624. * @param other - A material define instance to compare to
  85625. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  85626. */
  85627. isEqual(other: MaterialDefines): boolean;
  85628. /**
  85629. * Clones this instance's defines to another instance
  85630. * @param other - material defines to clone values to
  85631. */
  85632. cloneTo(other: MaterialDefines): void;
  85633. /**
  85634. * Resets the material define values
  85635. */
  85636. reset(): void;
  85637. /**
  85638. * Converts the material define values to a string
  85639. * @returns - String of material define information
  85640. */
  85641. toString(): string;
  85642. }
  85643. }
  85644. declare module BABYLON {
  85645. /**
  85646. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85647. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85648. * 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;
  85649. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85650. */
  85651. export class ColorCurves {
  85652. private _dirty;
  85653. private _tempColor;
  85654. private _globalCurve;
  85655. private _highlightsCurve;
  85656. private _midtonesCurve;
  85657. private _shadowsCurve;
  85658. private _positiveCurve;
  85659. private _negativeCurve;
  85660. private _globalHue;
  85661. private _globalDensity;
  85662. private _globalSaturation;
  85663. private _globalExposure;
  85664. /**
  85665. * Gets the global Hue value.
  85666. * 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).
  85667. */
  85668. get globalHue(): number;
  85669. /**
  85670. * Sets the global Hue value.
  85671. * 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).
  85672. */
  85673. set globalHue(value: number);
  85674. /**
  85675. * Gets the global Density value.
  85676. * 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.
  85677. * Values less than zero provide a filter of opposite hue.
  85678. */
  85679. get globalDensity(): number;
  85680. /**
  85681. * Sets the global Density value.
  85682. * 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.
  85683. * Values less than zero provide a filter of opposite hue.
  85684. */
  85685. set globalDensity(value: number);
  85686. /**
  85687. * Gets the global Saturation value.
  85688. * 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.
  85689. */
  85690. get globalSaturation(): number;
  85691. /**
  85692. * Sets the global Saturation value.
  85693. * 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.
  85694. */
  85695. set globalSaturation(value: number);
  85696. /**
  85697. * Gets the global Exposure value.
  85698. * 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.
  85699. */
  85700. get globalExposure(): number;
  85701. /**
  85702. * Sets the global Exposure value.
  85703. * 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.
  85704. */
  85705. set globalExposure(value: number);
  85706. private _highlightsHue;
  85707. private _highlightsDensity;
  85708. private _highlightsSaturation;
  85709. private _highlightsExposure;
  85710. /**
  85711. * Gets the highlights Hue value.
  85712. * 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).
  85713. */
  85714. get highlightsHue(): number;
  85715. /**
  85716. * Sets the highlights Hue value.
  85717. * 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).
  85718. */
  85719. set highlightsHue(value: number);
  85720. /**
  85721. * Gets the highlights Density value.
  85722. * 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.
  85723. * Values less than zero provide a filter of opposite hue.
  85724. */
  85725. get highlightsDensity(): number;
  85726. /**
  85727. * Sets the highlights Density value.
  85728. * 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.
  85729. * Values less than zero provide a filter of opposite hue.
  85730. */
  85731. set highlightsDensity(value: number);
  85732. /**
  85733. * Gets the highlights Saturation value.
  85734. * 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.
  85735. */
  85736. get highlightsSaturation(): number;
  85737. /**
  85738. * Sets the highlights Saturation value.
  85739. * 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.
  85740. */
  85741. set highlightsSaturation(value: number);
  85742. /**
  85743. * Gets the highlights Exposure value.
  85744. * 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.
  85745. */
  85746. get highlightsExposure(): number;
  85747. /**
  85748. * Sets the highlights Exposure value.
  85749. * 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.
  85750. */
  85751. set highlightsExposure(value: number);
  85752. private _midtonesHue;
  85753. private _midtonesDensity;
  85754. private _midtonesSaturation;
  85755. private _midtonesExposure;
  85756. /**
  85757. * Gets the midtones Hue value.
  85758. * 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).
  85759. */
  85760. get midtonesHue(): number;
  85761. /**
  85762. * Sets the midtones Hue value.
  85763. * 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).
  85764. */
  85765. set midtonesHue(value: number);
  85766. /**
  85767. * Gets the midtones Density value.
  85768. * 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.
  85769. * Values less than zero provide a filter of opposite hue.
  85770. */
  85771. get midtonesDensity(): number;
  85772. /**
  85773. * Sets the midtones Density value.
  85774. * 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.
  85775. * Values less than zero provide a filter of opposite hue.
  85776. */
  85777. set midtonesDensity(value: number);
  85778. /**
  85779. * Gets the midtones Saturation value.
  85780. * 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.
  85781. */
  85782. get midtonesSaturation(): number;
  85783. /**
  85784. * Sets the midtones Saturation value.
  85785. * 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.
  85786. */
  85787. set midtonesSaturation(value: number);
  85788. /**
  85789. * Gets the midtones Exposure value.
  85790. * 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.
  85791. */
  85792. get midtonesExposure(): number;
  85793. /**
  85794. * Sets the midtones Exposure value.
  85795. * 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.
  85796. */
  85797. set midtonesExposure(value: number);
  85798. private _shadowsHue;
  85799. private _shadowsDensity;
  85800. private _shadowsSaturation;
  85801. private _shadowsExposure;
  85802. /**
  85803. * Gets the shadows Hue value.
  85804. * 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).
  85805. */
  85806. get shadowsHue(): number;
  85807. /**
  85808. * Sets the shadows Hue value.
  85809. * 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).
  85810. */
  85811. set shadowsHue(value: number);
  85812. /**
  85813. * Gets the shadows Density value.
  85814. * 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.
  85815. * Values less than zero provide a filter of opposite hue.
  85816. */
  85817. get shadowsDensity(): number;
  85818. /**
  85819. * Sets the shadows Density value.
  85820. * 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.
  85821. * Values less than zero provide a filter of opposite hue.
  85822. */
  85823. set shadowsDensity(value: number);
  85824. /**
  85825. * Gets the shadows Saturation value.
  85826. * 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.
  85827. */
  85828. get shadowsSaturation(): number;
  85829. /**
  85830. * Sets the shadows Saturation value.
  85831. * 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.
  85832. */
  85833. set shadowsSaturation(value: number);
  85834. /**
  85835. * Gets the shadows Exposure value.
  85836. * 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.
  85837. */
  85838. get shadowsExposure(): number;
  85839. /**
  85840. * Sets the shadows Exposure value.
  85841. * 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.
  85842. */
  85843. set shadowsExposure(value: number);
  85844. /**
  85845. * Returns the class name
  85846. * @returns The class name
  85847. */
  85848. getClassName(): string;
  85849. /**
  85850. * Binds the color curves to the shader.
  85851. * @param colorCurves The color curve to bind
  85852. * @param effect The effect to bind to
  85853. * @param positiveUniform The positive uniform shader parameter
  85854. * @param neutralUniform The neutral uniform shader parameter
  85855. * @param negativeUniform The negative uniform shader parameter
  85856. */
  85857. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85858. /**
  85859. * Prepare the list of uniforms associated with the ColorCurves effects.
  85860. * @param uniformsList The list of uniforms used in the effect
  85861. */
  85862. static PrepareUniforms(uniformsList: string[]): void;
  85863. /**
  85864. * Returns color grading data based on a hue, density, saturation and exposure value.
  85865. * @param filterHue The hue of the color filter.
  85866. * @param filterDensity The density of the color filter.
  85867. * @param saturation The saturation.
  85868. * @param exposure The exposure.
  85869. * @param result The result data container.
  85870. */
  85871. private getColorGradingDataToRef;
  85872. /**
  85873. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85874. * @param value The input slider value in range [-100,100].
  85875. * @returns Adjusted value.
  85876. */
  85877. private static applyColorGradingSliderNonlinear;
  85878. /**
  85879. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85880. * @param hue The hue (H) input.
  85881. * @param saturation The saturation (S) input.
  85882. * @param brightness The brightness (B) input.
  85883. * @result An RGBA color represented as Vector4.
  85884. */
  85885. private static fromHSBToRef;
  85886. /**
  85887. * Returns a value clamped between min and max
  85888. * @param value The value to clamp
  85889. * @param min The minimum of value
  85890. * @param max The maximum of value
  85891. * @returns The clamped value.
  85892. */
  85893. private static clamp;
  85894. /**
  85895. * Clones the current color curve instance.
  85896. * @return The cloned curves
  85897. */
  85898. clone(): ColorCurves;
  85899. /**
  85900. * Serializes the current color curve instance to a json representation.
  85901. * @return a JSON representation
  85902. */
  85903. serialize(): any;
  85904. /**
  85905. * Parses the color curve from a json representation.
  85906. * @param source the JSON source to parse
  85907. * @return The parsed curves
  85908. */
  85909. static Parse(source: any): ColorCurves;
  85910. }
  85911. }
  85912. declare module BABYLON {
  85913. /**
  85914. * Interface to follow in your material defines to integrate easily the
  85915. * Image proccessing functions.
  85916. * @hidden
  85917. */
  85918. export interface IImageProcessingConfigurationDefines {
  85919. IMAGEPROCESSING: boolean;
  85920. VIGNETTE: boolean;
  85921. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85922. VIGNETTEBLENDMODEOPAQUE: boolean;
  85923. TONEMAPPING: boolean;
  85924. TONEMAPPING_ACES: boolean;
  85925. CONTRAST: boolean;
  85926. EXPOSURE: boolean;
  85927. COLORCURVES: boolean;
  85928. COLORGRADING: boolean;
  85929. COLORGRADING3D: boolean;
  85930. SAMPLER3DGREENDEPTH: boolean;
  85931. SAMPLER3DBGRMAP: boolean;
  85932. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85933. }
  85934. /**
  85935. * @hidden
  85936. */
  85937. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85938. IMAGEPROCESSING: boolean;
  85939. VIGNETTE: boolean;
  85940. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85941. VIGNETTEBLENDMODEOPAQUE: boolean;
  85942. TONEMAPPING: boolean;
  85943. TONEMAPPING_ACES: boolean;
  85944. CONTRAST: boolean;
  85945. COLORCURVES: boolean;
  85946. COLORGRADING: boolean;
  85947. COLORGRADING3D: boolean;
  85948. SAMPLER3DGREENDEPTH: boolean;
  85949. SAMPLER3DBGRMAP: boolean;
  85950. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85951. EXPOSURE: boolean;
  85952. constructor();
  85953. }
  85954. /**
  85955. * This groups together the common properties used for image processing either in direct forward pass
  85956. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85957. * or not.
  85958. */
  85959. export class ImageProcessingConfiguration {
  85960. /**
  85961. * Default tone mapping applied in BabylonJS.
  85962. */
  85963. static readonly TONEMAPPING_STANDARD: number;
  85964. /**
  85965. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85966. * to other engines rendering to increase portability.
  85967. */
  85968. static readonly TONEMAPPING_ACES: number;
  85969. /**
  85970. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85971. */
  85972. colorCurves: Nullable<ColorCurves>;
  85973. private _colorCurvesEnabled;
  85974. /**
  85975. * Gets wether the color curves effect is enabled.
  85976. */
  85977. get colorCurvesEnabled(): boolean;
  85978. /**
  85979. * Sets wether the color curves effect is enabled.
  85980. */
  85981. set colorCurvesEnabled(value: boolean);
  85982. private _colorGradingTexture;
  85983. /**
  85984. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85985. */
  85986. get colorGradingTexture(): Nullable<BaseTexture>;
  85987. /**
  85988. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85989. */
  85990. set colorGradingTexture(value: Nullable<BaseTexture>);
  85991. private _colorGradingEnabled;
  85992. /**
  85993. * Gets wether the color grading effect is enabled.
  85994. */
  85995. get colorGradingEnabled(): boolean;
  85996. /**
  85997. * Sets wether the color grading effect is enabled.
  85998. */
  85999. set colorGradingEnabled(value: boolean);
  86000. private _colorGradingWithGreenDepth;
  86001. /**
  86002. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86003. */
  86004. get colorGradingWithGreenDepth(): boolean;
  86005. /**
  86006. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86007. */
  86008. set colorGradingWithGreenDepth(value: boolean);
  86009. private _colorGradingBGR;
  86010. /**
  86011. * Gets wether the color grading texture contains BGR values.
  86012. */
  86013. get colorGradingBGR(): boolean;
  86014. /**
  86015. * Sets wether the color grading texture contains BGR values.
  86016. */
  86017. set colorGradingBGR(value: boolean);
  86018. /** @hidden */
  86019. _exposure: number;
  86020. /**
  86021. * Gets the Exposure used in the effect.
  86022. */
  86023. get exposure(): number;
  86024. /**
  86025. * Sets the Exposure used in the effect.
  86026. */
  86027. set exposure(value: number);
  86028. private _toneMappingEnabled;
  86029. /**
  86030. * Gets wether the tone mapping effect is enabled.
  86031. */
  86032. get toneMappingEnabled(): boolean;
  86033. /**
  86034. * Sets wether the tone mapping effect is enabled.
  86035. */
  86036. set toneMappingEnabled(value: boolean);
  86037. private _toneMappingType;
  86038. /**
  86039. * Gets the type of tone mapping effect.
  86040. */
  86041. get toneMappingType(): number;
  86042. /**
  86043. * Sets the type of tone mapping effect used in BabylonJS.
  86044. */
  86045. set toneMappingType(value: number);
  86046. protected _contrast: number;
  86047. /**
  86048. * Gets the contrast used in the effect.
  86049. */
  86050. get contrast(): number;
  86051. /**
  86052. * Sets the contrast used in the effect.
  86053. */
  86054. set contrast(value: number);
  86055. /**
  86056. * Vignette stretch size.
  86057. */
  86058. vignetteStretch: number;
  86059. /**
  86060. * Vignette centre X Offset.
  86061. */
  86062. vignetteCentreX: number;
  86063. /**
  86064. * Vignette centre Y Offset.
  86065. */
  86066. vignetteCentreY: number;
  86067. /**
  86068. * Vignette weight or intensity of the vignette effect.
  86069. */
  86070. vignetteWeight: number;
  86071. /**
  86072. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86073. * if vignetteEnabled is set to true.
  86074. */
  86075. vignetteColor: Color4;
  86076. /**
  86077. * Camera field of view used by the Vignette effect.
  86078. */
  86079. vignetteCameraFov: number;
  86080. private _vignetteBlendMode;
  86081. /**
  86082. * Gets the vignette blend mode allowing different kind of effect.
  86083. */
  86084. get vignetteBlendMode(): number;
  86085. /**
  86086. * Sets the vignette blend mode allowing different kind of effect.
  86087. */
  86088. set vignetteBlendMode(value: number);
  86089. private _vignetteEnabled;
  86090. /**
  86091. * Gets wether the vignette effect is enabled.
  86092. */
  86093. get vignetteEnabled(): boolean;
  86094. /**
  86095. * Sets wether the vignette effect is enabled.
  86096. */
  86097. set vignetteEnabled(value: boolean);
  86098. private _applyByPostProcess;
  86099. /**
  86100. * Gets wether the image processing is applied through a post process or not.
  86101. */
  86102. get applyByPostProcess(): boolean;
  86103. /**
  86104. * Sets wether the image processing is applied through a post process or not.
  86105. */
  86106. set applyByPostProcess(value: boolean);
  86107. private _isEnabled;
  86108. /**
  86109. * Gets wether the image processing is enabled or not.
  86110. */
  86111. get isEnabled(): boolean;
  86112. /**
  86113. * Sets wether the image processing is enabled or not.
  86114. */
  86115. set isEnabled(value: boolean);
  86116. /**
  86117. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86118. */
  86119. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86120. /**
  86121. * Method called each time the image processing information changes requires to recompile the effect.
  86122. */
  86123. protected _updateParameters(): void;
  86124. /**
  86125. * Gets the current class name.
  86126. * @return "ImageProcessingConfiguration"
  86127. */
  86128. getClassName(): string;
  86129. /**
  86130. * Prepare the list of uniforms associated with the Image Processing effects.
  86131. * @param uniforms The list of uniforms used in the effect
  86132. * @param defines the list of defines currently in use
  86133. */
  86134. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86135. /**
  86136. * Prepare the list of samplers associated with the Image Processing effects.
  86137. * @param samplersList The list of uniforms used in the effect
  86138. * @param defines the list of defines currently in use
  86139. */
  86140. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86141. /**
  86142. * Prepare the list of defines associated to the shader.
  86143. * @param defines the list of defines to complete
  86144. * @param forPostProcess Define if we are currently in post process mode or not
  86145. */
  86146. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86147. /**
  86148. * Returns true if all the image processing information are ready.
  86149. * @returns True if ready, otherwise, false
  86150. */
  86151. isReady(): boolean;
  86152. /**
  86153. * Binds the image processing to the shader.
  86154. * @param effect The effect to bind to
  86155. * @param overrideAspectRatio Override the aspect ratio of the effect
  86156. */
  86157. bind(effect: Effect, overrideAspectRatio?: number): void;
  86158. /**
  86159. * Clones the current image processing instance.
  86160. * @return The cloned image processing
  86161. */
  86162. clone(): ImageProcessingConfiguration;
  86163. /**
  86164. * Serializes the current image processing instance to a json representation.
  86165. * @return a JSON representation
  86166. */
  86167. serialize(): any;
  86168. /**
  86169. * Parses the image processing from a json representation.
  86170. * @param source the JSON source to parse
  86171. * @return The parsed image processing
  86172. */
  86173. static Parse(source: any): ImageProcessingConfiguration;
  86174. private static _VIGNETTEMODE_MULTIPLY;
  86175. private static _VIGNETTEMODE_OPAQUE;
  86176. /**
  86177. * Used to apply the vignette as a mix with the pixel color.
  86178. */
  86179. static get VIGNETTEMODE_MULTIPLY(): number;
  86180. /**
  86181. * Used to apply the vignette as a replacement of the pixel color.
  86182. */
  86183. static get VIGNETTEMODE_OPAQUE(): number;
  86184. }
  86185. }
  86186. declare module BABYLON {
  86187. /** @hidden */
  86188. export var postprocessVertexShader: {
  86189. name: string;
  86190. shader: string;
  86191. };
  86192. }
  86193. declare module BABYLON {
  86194. interface ThinEngine {
  86195. /**
  86196. * Creates a new render target texture
  86197. * @param size defines the size of the texture
  86198. * @param options defines the options used to create the texture
  86199. * @returns a new render target texture stored in an InternalTexture
  86200. */
  86201. createRenderTargetTexture(size: number | {
  86202. width: number;
  86203. height: number;
  86204. layers?: number;
  86205. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86206. /**
  86207. * Creates a depth stencil texture.
  86208. * This is only available in WebGL 2 or with the depth texture extension available.
  86209. * @param size The size of face edge in the texture.
  86210. * @param options The options defining the texture.
  86211. * @returns The texture
  86212. */
  86213. createDepthStencilTexture(size: number | {
  86214. width: number;
  86215. height: number;
  86216. layers?: number;
  86217. }, options: DepthTextureCreationOptions): InternalTexture;
  86218. /** @hidden */
  86219. _createDepthStencilTexture(size: number | {
  86220. width: number;
  86221. height: number;
  86222. layers?: number;
  86223. }, options: DepthTextureCreationOptions): InternalTexture;
  86224. }
  86225. }
  86226. declare module BABYLON {
  86227. /**
  86228. * Defines the kind of connection point for node based material
  86229. */
  86230. export enum NodeMaterialBlockConnectionPointTypes {
  86231. /** Float */
  86232. Float = 1,
  86233. /** Int */
  86234. Int = 2,
  86235. /** Vector2 */
  86236. Vector2 = 4,
  86237. /** Vector3 */
  86238. Vector3 = 8,
  86239. /** Vector4 */
  86240. Vector4 = 16,
  86241. /** Color3 */
  86242. Color3 = 32,
  86243. /** Color4 */
  86244. Color4 = 64,
  86245. /** Matrix */
  86246. Matrix = 128,
  86247. /** Custom object */
  86248. Object = 256,
  86249. /** Detect type based on connection */
  86250. AutoDetect = 1024,
  86251. /** Output type that will be defined by input type */
  86252. BasedOnInput = 2048
  86253. }
  86254. }
  86255. declare module BABYLON {
  86256. /**
  86257. * Enum used to define the target of a block
  86258. */
  86259. export enum NodeMaterialBlockTargets {
  86260. /** Vertex shader */
  86261. Vertex = 1,
  86262. /** Fragment shader */
  86263. Fragment = 2,
  86264. /** Neutral */
  86265. Neutral = 4,
  86266. /** Vertex and Fragment */
  86267. VertexAndFragment = 3
  86268. }
  86269. }
  86270. declare module BABYLON {
  86271. /**
  86272. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86273. */
  86274. export enum NodeMaterialBlockConnectionPointMode {
  86275. /** Value is an uniform */
  86276. Uniform = 0,
  86277. /** Value is a mesh attribute */
  86278. Attribute = 1,
  86279. /** Value is a varying between vertex and fragment shaders */
  86280. Varying = 2,
  86281. /** Mode is undefined */
  86282. Undefined = 3
  86283. }
  86284. }
  86285. declare module BABYLON {
  86286. /**
  86287. * Enum used to define system values e.g. values automatically provided by the system
  86288. */
  86289. export enum NodeMaterialSystemValues {
  86290. /** World */
  86291. World = 1,
  86292. /** View */
  86293. View = 2,
  86294. /** Projection */
  86295. Projection = 3,
  86296. /** ViewProjection */
  86297. ViewProjection = 4,
  86298. /** WorldView */
  86299. WorldView = 5,
  86300. /** WorldViewProjection */
  86301. WorldViewProjection = 6,
  86302. /** CameraPosition */
  86303. CameraPosition = 7,
  86304. /** Fog Color */
  86305. FogColor = 8,
  86306. /** Delta time */
  86307. DeltaTime = 9
  86308. }
  86309. }
  86310. declare module BABYLON {
  86311. /** Defines supported spaces */
  86312. export enum Space {
  86313. /** Local (object) space */
  86314. LOCAL = 0,
  86315. /** World space */
  86316. WORLD = 1,
  86317. /** Bone space */
  86318. BONE = 2
  86319. }
  86320. /** Defines the 3 main axes */
  86321. export class Axis {
  86322. /** X axis */
  86323. static X: Vector3;
  86324. /** Y axis */
  86325. static Y: Vector3;
  86326. /** Z axis */
  86327. static Z: Vector3;
  86328. }
  86329. }
  86330. declare module BABYLON {
  86331. /**
  86332. * Represents a camera frustum
  86333. */
  86334. export class Frustum {
  86335. /**
  86336. * Gets the planes representing the frustum
  86337. * @param transform matrix to be applied to the returned planes
  86338. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86339. */
  86340. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86341. /**
  86342. * Gets the near frustum plane transformed by the transform matrix
  86343. * @param transform transformation matrix to be applied to the resulting frustum plane
  86344. * @param frustumPlane the resuling frustum plane
  86345. */
  86346. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86347. /**
  86348. * Gets the far frustum plane transformed by the transform matrix
  86349. * @param transform transformation matrix to be applied to the resulting frustum plane
  86350. * @param frustumPlane the resuling frustum plane
  86351. */
  86352. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86353. /**
  86354. * Gets the left frustum plane transformed by the transform matrix
  86355. * @param transform transformation matrix to be applied to the resulting frustum plane
  86356. * @param frustumPlane the resuling frustum plane
  86357. */
  86358. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86359. /**
  86360. * Gets the right frustum plane transformed by the transform matrix
  86361. * @param transform transformation matrix to be applied to the resulting frustum plane
  86362. * @param frustumPlane the resuling frustum plane
  86363. */
  86364. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86365. /**
  86366. * Gets the top frustum plane transformed by the transform matrix
  86367. * @param transform transformation matrix to be applied to the resulting frustum plane
  86368. * @param frustumPlane the resuling frustum plane
  86369. */
  86370. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86371. /**
  86372. * Gets the bottom frustum plane transformed by the transform matrix
  86373. * @param transform transformation matrix to be applied to the resulting frustum plane
  86374. * @param frustumPlane the resuling frustum plane
  86375. */
  86376. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86377. /**
  86378. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86379. * @param transform transformation matrix to be applied to the resulting frustum planes
  86380. * @param frustumPlanes the resuling frustum planes
  86381. */
  86382. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86383. }
  86384. }
  86385. declare module BABYLON {
  86386. /**
  86387. * Interface for the size containing width and height
  86388. */
  86389. export interface ISize {
  86390. /**
  86391. * Width
  86392. */
  86393. width: number;
  86394. /**
  86395. * Heighht
  86396. */
  86397. height: number;
  86398. }
  86399. /**
  86400. * Size containing widht and height
  86401. */
  86402. export class Size implements ISize {
  86403. /**
  86404. * Width
  86405. */
  86406. width: number;
  86407. /**
  86408. * Height
  86409. */
  86410. height: number;
  86411. /**
  86412. * Creates a Size object from the given width and height (floats).
  86413. * @param width width of the new size
  86414. * @param height height of the new size
  86415. */
  86416. constructor(width: number, height: number);
  86417. /**
  86418. * Returns a string with the Size width and height
  86419. * @returns a string with the Size width and height
  86420. */
  86421. toString(): string;
  86422. /**
  86423. * "Size"
  86424. * @returns the string "Size"
  86425. */
  86426. getClassName(): string;
  86427. /**
  86428. * Returns the Size hash code.
  86429. * @returns a hash code for a unique width and height
  86430. */
  86431. getHashCode(): number;
  86432. /**
  86433. * Updates the current size from the given one.
  86434. * @param src the given size
  86435. */
  86436. copyFrom(src: Size): void;
  86437. /**
  86438. * Updates in place the current Size from the given floats.
  86439. * @param width width of the new size
  86440. * @param height height of the new size
  86441. * @returns the updated Size.
  86442. */
  86443. copyFromFloats(width: number, height: number): Size;
  86444. /**
  86445. * Updates in place the current Size from the given floats.
  86446. * @param width width to set
  86447. * @param height height to set
  86448. * @returns the updated Size.
  86449. */
  86450. set(width: number, height: number): Size;
  86451. /**
  86452. * Multiplies the width and height by numbers
  86453. * @param w factor to multiple the width by
  86454. * @param h factor to multiple the height by
  86455. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  86456. */
  86457. multiplyByFloats(w: number, h: number): Size;
  86458. /**
  86459. * Clones the size
  86460. * @returns a new Size copied from the given one.
  86461. */
  86462. clone(): Size;
  86463. /**
  86464. * True if the current Size and the given one width and height are strictly equal.
  86465. * @param other the other size to compare against
  86466. * @returns True if the current Size and the given one width and height are strictly equal.
  86467. */
  86468. equals(other: Size): boolean;
  86469. /**
  86470. * The surface of the Size : width * height (float).
  86471. */
  86472. get surface(): number;
  86473. /**
  86474. * Create a new size of zero
  86475. * @returns a new Size set to (0.0, 0.0)
  86476. */
  86477. static Zero(): Size;
  86478. /**
  86479. * Sums the width and height of two sizes
  86480. * @param otherSize size to add to this size
  86481. * @returns a new Size set as the addition result of the current Size and the given one.
  86482. */
  86483. add(otherSize: Size): Size;
  86484. /**
  86485. * Subtracts the width and height of two
  86486. * @param otherSize size to subtract to this size
  86487. * @returns a new Size set as the subtraction result of the given one from the current Size.
  86488. */
  86489. subtract(otherSize: Size): Size;
  86490. /**
  86491. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  86492. * @param start starting size to lerp between
  86493. * @param end end size to lerp between
  86494. * @param amount amount to lerp between the start and end values
  86495. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  86496. */
  86497. static Lerp(start: Size, end: Size, amount: number): Size;
  86498. }
  86499. }
  86500. declare module BABYLON {
  86501. /**
  86502. * Contains position and normal vectors for a vertex
  86503. */
  86504. export class PositionNormalVertex {
  86505. /** the position of the vertex (defaut: 0,0,0) */
  86506. position: Vector3;
  86507. /** the normal of the vertex (defaut: 0,1,0) */
  86508. normal: Vector3;
  86509. /**
  86510. * Creates a PositionNormalVertex
  86511. * @param position the position of the vertex (defaut: 0,0,0)
  86512. * @param normal the normal of the vertex (defaut: 0,1,0)
  86513. */
  86514. constructor(
  86515. /** the position of the vertex (defaut: 0,0,0) */
  86516. position?: Vector3,
  86517. /** the normal of the vertex (defaut: 0,1,0) */
  86518. normal?: Vector3);
  86519. /**
  86520. * Clones the PositionNormalVertex
  86521. * @returns the cloned PositionNormalVertex
  86522. */
  86523. clone(): PositionNormalVertex;
  86524. }
  86525. /**
  86526. * Contains position, normal and uv vectors for a vertex
  86527. */
  86528. export class PositionNormalTextureVertex {
  86529. /** the position of the vertex (defaut: 0,0,0) */
  86530. position: Vector3;
  86531. /** the normal of the vertex (defaut: 0,1,0) */
  86532. normal: Vector3;
  86533. /** the uv of the vertex (default: 0,0) */
  86534. uv: Vector2;
  86535. /**
  86536. * Creates a PositionNormalTextureVertex
  86537. * @param position the position of the vertex (defaut: 0,0,0)
  86538. * @param normal the normal of the vertex (defaut: 0,1,0)
  86539. * @param uv the uv of the vertex (default: 0,0)
  86540. */
  86541. constructor(
  86542. /** the position of the vertex (defaut: 0,0,0) */
  86543. position?: Vector3,
  86544. /** the normal of the vertex (defaut: 0,1,0) */
  86545. normal?: Vector3,
  86546. /** the uv of the vertex (default: 0,0) */
  86547. uv?: Vector2);
  86548. /**
  86549. * Clones the PositionNormalTextureVertex
  86550. * @returns the cloned PositionNormalTextureVertex
  86551. */
  86552. clone(): PositionNormalTextureVertex;
  86553. }
  86554. }
  86555. declare module BABYLON {
  86556. /**
  86557. * Enum defining the type of animations supported by InputBlock
  86558. */
  86559. export enum AnimatedInputBlockTypes {
  86560. /** No animation */
  86561. None = 0,
  86562. /** Time based animation. Will only work for floats */
  86563. Time = 1
  86564. }
  86565. }
  86566. declare module BABYLON {
  86567. /**
  86568. * Interface describing all the common properties and methods a shadow light needs to implement.
  86569. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  86570. * as well as binding the different shadow properties to the effects.
  86571. */
  86572. export interface IShadowLight extends Light {
  86573. /**
  86574. * The light id in the scene (used in scene.findLighById for instance)
  86575. */
  86576. id: string;
  86577. /**
  86578. * The position the shdow will be casted from.
  86579. */
  86580. position: Vector3;
  86581. /**
  86582. * In 2d mode (needCube being false), the direction used to cast the shadow.
  86583. */
  86584. direction: Vector3;
  86585. /**
  86586. * The transformed position. Position of the light in world space taking parenting in account.
  86587. */
  86588. transformedPosition: Vector3;
  86589. /**
  86590. * The transformed direction. Direction of the light in world space taking parenting in account.
  86591. */
  86592. transformedDirection: Vector3;
  86593. /**
  86594. * The friendly name of the light in the scene.
  86595. */
  86596. name: string;
  86597. /**
  86598. * Defines the shadow projection clipping minimum z value.
  86599. */
  86600. shadowMinZ: number;
  86601. /**
  86602. * Defines the shadow projection clipping maximum z value.
  86603. */
  86604. shadowMaxZ: number;
  86605. /**
  86606. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86607. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86608. */
  86609. computeTransformedInformation(): boolean;
  86610. /**
  86611. * Gets the scene the light belongs to.
  86612. * @returns The scene
  86613. */
  86614. getScene(): Scene;
  86615. /**
  86616. * Callback defining a custom Projection Matrix Builder.
  86617. * This can be used to override the default projection matrix computation.
  86618. */
  86619. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86620. /**
  86621. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86622. * @param matrix The materix to updated with the projection information
  86623. * @param viewMatrix The transform matrix of the light
  86624. * @param renderList The list of mesh to render in the map
  86625. * @returns The current light
  86626. */
  86627. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86628. /**
  86629. * Gets the current depth scale used in ESM.
  86630. * @returns The scale
  86631. */
  86632. getDepthScale(): number;
  86633. /**
  86634. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86635. * @returns true if a cube texture needs to be use
  86636. */
  86637. needCube(): boolean;
  86638. /**
  86639. * Detects if the projection matrix requires to be recomputed this frame.
  86640. * @returns true if it requires to be recomputed otherwise, false.
  86641. */
  86642. needProjectionMatrixCompute(): boolean;
  86643. /**
  86644. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86645. */
  86646. forceProjectionMatrixCompute(): void;
  86647. /**
  86648. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86649. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86650. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86651. */
  86652. getShadowDirection(faceIndex?: number): Vector3;
  86653. /**
  86654. * Gets the minZ used for shadow according to both the scene and the light.
  86655. * @param activeCamera The camera we are returning the min for
  86656. * @returns the depth min z
  86657. */
  86658. getDepthMinZ(activeCamera: Camera): number;
  86659. /**
  86660. * Gets the maxZ used for shadow according to both the scene and the light.
  86661. * @param activeCamera The camera we are returning the max for
  86662. * @returns the depth max z
  86663. */
  86664. getDepthMaxZ(activeCamera: Camera): number;
  86665. }
  86666. /**
  86667. * Base implementation IShadowLight
  86668. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  86669. */
  86670. export abstract class ShadowLight extends Light implements IShadowLight {
  86671. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  86672. protected _position: Vector3;
  86673. protected _setPosition(value: Vector3): void;
  86674. /**
  86675. * Sets the position the shadow will be casted from. Also use as the light position for both
  86676. * point and spot lights.
  86677. */
  86678. get position(): Vector3;
  86679. /**
  86680. * Sets the position the shadow will be casted from. Also use as the light position for both
  86681. * point and spot lights.
  86682. */
  86683. set position(value: Vector3);
  86684. protected _direction: Vector3;
  86685. protected _setDirection(value: Vector3): void;
  86686. /**
  86687. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  86688. * Also use as the light direction on spot and directional lights.
  86689. */
  86690. get direction(): Vector3;
  86691. /**
  86692. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  86693. * Also use as the light direction on spot and directional lights.
  86694. */
  86695. set direction(value: Vector3);
  86696. protected _shadowMinZ: number;
  86697. /**
  86698. * Gets the shadow projection clipping minimum z value.
  86699. */
  86700. get shadowMinZ(): number;
  86701. /**
  86702. * Sets the shadow projection clipping minimum z value.
  86703. */
  86704. set shadowMinZ(value: number);
  86705. protected _shadowMaxZ: number;
  86706. /**
  86707. * Sets the shadow projection clipping maximum z value.
  86708. */
  86709. get shadowMaxZ(): number;
  86710. /**
  86711. * Gets the shadow projection clipping maximum z value.
  86712. */
  86713. set shadowMaxZ(value: number);
  86714. /**
  86715. * Callback defining a custom Projection Matrix Builder.
  86716. * This can be used to override the default projection matrix computation.
  86717. */
  86718. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  86719. /**
  86720. * The transformed position. Position of the light in world space taking parenting in account.
  86721. */
  86722. transformedPosition: Vector3;
  86723. /**
  86724. * The transformed direction. Direction of the light in world space taking parenting in account.
  86725. */
  86726. transformedDirection: Vector3;
  86727. private _needProjectionMatrixCompute;
  86728. /**
  86729. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  86730. * @returns true if the information has been computed, false if it does not need to (no parenting)
  86731. */
  86732. computeTransformedInformation(): boolean;
  86733. /**
  86734. * Return the depth scale used for the shadow map.
  86735. * @returns the depth scale.
  86736. */
  86737. getDepthScale(): number;
  86738. /**
  86739. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  86740. * @param faceIndex The index of the face we are computed the direction to generate shadow
  86741. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  86742. */
  86743. getShadowDirection(faceIndex?: number): Vector3;
  86744. /**
  86745. * Returns the ShadowLight absolute position in the World.
  86746. * @returns the position vector in world space
  86747. */
  86748. getAbsolutePosition(): Vector3;
  86749. /**
  86750. * Sets the ShadowLight direction toward the passed target.
  86751. * @param target The point to target in local space
  86752. * @returns the updated ShadowLight direction
  86753. */
  86754. setDirectionToTarget(target: Vector3): Vector3;
  86755. /**
  86756. * Returns the light rotation in euler definition.
  86757. * @returns the x y z rotation in local space.
  86758. */
  86759. getRotation(): Vector3;
  86760. /**
  86761. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  86762. * @returns true if a cube texture needs to be use
  86763. */
  86764. needCube(): boolean;
  86765. /**
  86766. * Detects if the projection matrix requires to be recomputed this frame.
  86767. * @returns true if it requires to be recomputed otherwise, false.
  86768. */
  86769. needProjectionMatrixCompute(): boolean;
  86770. /**
  86771. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  86772. */
  86773. forceProjectionMatrixCompute(): void;
  86774. /** @hidden */
  86775. _initCache(): void;
  86776. /** @hidden */
  86777. _isSynchronized(): boolean;
  86778. /**
  86779. * Computes the world matrix of the node
  86780. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86781. * @returns the world matrix
  86782. */
  86783. computeWorldMatrix(force?: boolean): Matrix;
  86784. /**
  86785. * Gets the minZ used for shadow according to both the scene and the light.
  86786. * @param activeCamera The camera we are returning the min for
  86787. * @returns the depth min z
  86788. */
  86789. getDepthMinZ(activeCamera: Camera): number;
  86790. /**
  86791. * Gets the maxZ used for shadow according to both the scene and the light.
  86792. * @param activeCamera The camera we are returning the max for
  86793. * @returns the depth max z
  86794. */
  86795. getDepthMaxZ(activeCamera: Camera): number;
  86796. /**
  86797. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  86798. * @param matrix The materix to updated with the projection information
  86799. * @param viewMatrix The transform matrix of the light
  86800. * @param renderList The list of mesh to render in the map
  86801. * @returns The current light
  86802. */
  86803. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  86804. }
  86805. }
  86806. declare module BABYLON {
  86807. /** @hidden */
  86808. export var packingFunctions: {
  86809. name: string;
  86810. shader: string;
  86811. };
  86812. }
  86813. declare module BABYLON {
  86814. /** @hidden */
  86815. export var bayerDitherFunctions: {
  86816. name: string;
  86817. shader: string;
  86818. };
  86819. }
  86820. declare module BABYLON {
  86821. /** @hidden */
  86822. export var shadowMapFragmentDeclaration: {
  86823. name: string;
  86824. shader: string;
  86825. };
  86826. }
  86827. declare module BABYLON {
  86828. /** @hidden */
  86829. export var clipPlaneFragmentDeclaration: {
  86830. name: string;
  86831. shader: string;
  86832. };
  86833. }
  86834. declare module BABYLON {
  86835. /** @hidden */
  86836. export var clipPlaneFragment: {
  86837. name: string;
  86838. shader: string;
  86839. };
  86840. }
  86841. declare module BABYLON {
  86842. /** @hidden */
  86843. export var shadowMapFragment: {
  86844. name: string;
  86845. shader: string;
  86846. };
  86847. }
  86848. declare module BABYLON {
  86849. /** @hidden */
  86850. export var shadowMapPixelShader: {
  86851. name: string;
  86852. shader: string;
  86853. };
  86854. }
  86855. declare module BABYLON {
  86856. /** @hidden */
  86857. export var bonesDeclaration: {
  86858. name: string;
  86859. shader: string;
  86860. };
  86861. }
  86862. declare module BABYLON {
  86863. /** @hidden */
  86864. export var morphTargetsVertexGlobalDeclaration: {
  86865. name: string;
  86866. shader: string;
  86867. };
  86868. }
  86869. declare module BABYLON {
  86870. /** @hidden */
  86871. export var morphTargetsVertexDeclaration: {
  86872. name: string;
  86873. shader: string;
  86874. };
  86875. }
  86876. declare module BABYLON {
  86877. /** @hidden */
  86878. export var instancesDeclaration: {
  86879. name: string;
  86880. shader: string;
  86881. };
  86882. }
  86883. declare module BABYLON {
  86884. /** @hidden */
  86885. export var helperFunctions: {
  86886. name: string;
  86887. shader: string;
  86888. };
  86889. }
  86890. declare module BABYLON {
  86891. /** @hidden */
  86892. export var shadowMapVertexDeclaration: {
  86893. name: string;
  86894. shader: string;
  86895. };
  86896. }
  86897. declare module BABYLON {
  86898. /** @hidden */
  86899. export var clipPlaneVertexDeclaration: {
  86900. name: string;
  86901. shader: string;
  86902. };
  86903. }
  86904. declare module BABYLON {
  86905. /** @hidden */
  86906. export var morphTargetsVertex: {
  86907. name: string;
  86908. shader: string;
  86909. };
  86910. }
  86911. declare module BABYLON {
  86912. /** @hidden */
  86913. export var instancesVertex: {
  86914. name: string;
  86915. shader: string;
  86916. };
  86917. }
  86918. declare module BABYLON {
  86919. /** @hidden */
  86920. export var bonesVertex: {
  86921. name: string;
  86922. shader: string;
  86923. };
  86924. }
  86925. declare module BABYLON {
  86926. /** @hidden */
  86927. export var shadowMapVertexNormalBias: {
  86928. name: string;
  86929. shader: string;
  86930. };
  86931. }
  86932. declare module BABYLON {
  86933. /** @hidden */
  86934. export var shadowMapVertexMetric: {
  86935. name: string;
  86936. shader: string;
  86937. };
  86938. }
  86939. declare module BABYLON {
  86940. /** @hidden */
  86941. export var clipPlaneVertex: {
  86942. name: string;
  86943. shader: string;
  86944. };
  86945. }
  86946. declare module BABYLON {
  86947. /** @hidden */
  86948. export var shadowMapVertexShader: {
  86949. name: string;
  86950. shader: string;
  86951. };
  86952. }
  86953. declare module BABYLON {
  86954. /** @hidden */
  86955. export var depthBoxBlurPixelShader: {
  86956. name: string;
  86957. shader: string;
  86958. };
  86959. }
  86960. declare module BABYLON {
  86961. /** @hidden */
  86962. export var shadowMapFragmentSoftTransparentShadow: {
  86963. name: string;
  86964. shader: string;
  86965. };
  86966. }
  86967. declare module BABYLON {
  86968. /**
  86969. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86970. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86971. */
  86972. export class EffectFallbacks implements IEffectFallbacks {
  86973. private _defines;
  86974. private _currentRank;
  86975. private _maxRank;
  86976. private _mesh;
  86977. /**
  86978. * Removes the fallback from the bound mesh.
  86979. */
  86980. unBindMesh(): void;
  86981. /**
  86982. * Adds a fallback on the specified property.
  86983. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86984. * @param define The name of the define in the shader
  86985. */
  86986. addFallback(rank: number, define: string): void;
  86987. /**
  86988. * Sets the mesh to use CPU skinning when needing to fallback.
  86989. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86990. * @param mesh The mesh to use the fallbacks.
  86991. */
  86992. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86993. /**
  86994. * Checks to see if more fallbacks are still availible.
  86995. */
  86996. get hasMoreFallbacks(): boolean;
  86997. /**
  86998. * Removes the defines that should be removed when falling back.
  86999. * @param currentDefines defines the current define statements for the shader.
  87000. * @param effect defines the current effect we try to compile
  87001. * @returns The resulting defines with defines of the current rank removed.
  87002. */
  87003. reduce(currentDefines: string, effect: Effect): string;
  87004. }
  87005. }
  87006. declare module BABYLON {
  87007. /**
  87008. * Interface used to define Action
  87009. */
  87010. export interface IAction {
  87011. /**
  87012. * Trigger for the action
  87013. */
  87014. trigger: number;
  87015. /** Options of the trigger */
  87016. triggerOptions: any;
  87017. /**
  87018. * Gets the trigger parameters
  87019. * @returns the trigger parameters
  87020. */
  87021. getTriggerParameter(): any;
  87022. /**
  87023. * Internal only - executes current action event
  87024. * @hidden
  87025. */
  87026. _executeCurrent(evt?: ActionEvent): void;
  87027. /**
  87028. * Serialize placeholder for child classes
  87029. * @param parent of child
  87030. * @returns the serialized object
  87031. */
  87032. serialize(parent: any): any;
  87033. /**
  87034. * Internal only
  87035. * @hidden
  87036. */
  87037. _prepare(): void;
  87038. /**
  87039. * Internal only - manager for action
  87040. * @hidden
  87041. */
  87042. _actionManager: AbstractActionManager;
  87043. /**
  87044. * Adds action to chain of actions, may be a DoNothingAction
  87045. * @param action defines the next action to execute
  87046. * @returns The action passed in
  87047. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87048. */
  87049. then(action: IAction): IAction;
  87050. }
  87051. /**
  87052. * The action to be carried out following a trigger
  87053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87054. */
  87055. export class Action implements IAction {
  87056. /** the trigger, with or without parameters, for the action */
  87057. triggerOptions: any;
  87058. /**
  87059. * Trigger for the action
  87060. */
  87061. trigger: number;
  87062. /**
  87063. * Internal only - manager for action
  87064. * @hidden
  87065. */
  87066. _actionManager: ActionManager;
  87067. private _nextActiveAction;
  87068. private _child;
  87069. private _condition?;
  87070. private _triggerParameter;
  87071. /**
  87072. * An event triggered prior to action being executed.
  87073. */
  87074. onBeforeExecuteObservable: Observable<Action>;
  87075. /**
  87076. * Creates a new Action
  87077. * @param triggerOptions the trigger, with or without parameters, for the action
  87078. * @param condition an optional determinant of action
  87079. */
  87080. constructor(
  87081. /** the trigger, with or without parameters, for the action */
  87082. triggerOptions: any, condition?: Condition);
  87083. /**
  87084. * Internal only
  87085. * @hidden
  87086. */
  87087. _prepare(): void;
  87088. /**
  87089. * Gets the trigger parameters
  87090. * @returns the trigger parameters
  87091. */
  87092. getTriggerParameter(): any;
  87093. /**
  87094. * Internal only - executes current action event
  87095. * @hidden
  87096. */
  87097. _executeCurrent(evt?: ActionEvent): void;
  87098. /**
  87099. * Execute placeholder for child classes
  87100. * @param evt optional action event
  87101. */
  87102. execute(evt?: ActionEvent): void;
  87103. /**
  87104. * Skips to next active action
  87105. */
  87106. skipToNextActiveAction(): void;
  87107. /**
  87108. * Adds action to chain of actions, may be a DoNothingAction
  87109. * @param action defines the next action to execute
  87110. * @returns The action passed in
  87111. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87112. */
  87113. then(action: Action): Action;
  87114. /**
  87115. * Internal only
  87116. * @hidden
  87117. */
  87118. _getProperty(propertyPath: string): string;
  87119. /**
  87120. * Internal only
  87121. * @hidden
  87122. */
  87123. _getEffectiveTarget(target: any, propertyPath: string): any;
  87124. /**
  87125. * Serialize placeholder for child classes
  87126. * @param parent of child
  87127. * @returns the serialized object
  87128. */
  87129. serialize(parent: any): any;
  87130. /**
  87131. * Internal only called by serialize
  87132. * @hidden
  87133. */
  87134. protected _serialize(serializedAction: any, parent?: any): any;
  87135. /**
  87136. * Internal only
  87137. * @hidden
  87138. */
  87139. static _SerializeValueAsString: (value: any) => string;
  87140. /**
  87141. * Internal only
  87142. * @hidden
  87143. */
  87144. static _GetTargetProperty: (target: Node | Scene) => {
  87145. name: string;
  87146. targetType: string;
  87147. value: string;
  87148. };
  87149. }
  87150. }
  87151. declare module BABYLON {
  87152. /**
  87153. * A Condition applied to an Action
  87154. */
  87155. export class Condition {
  87156. /**
  87157. * Internal only - manager for action
  87158. * @hidden
  87159. */
  87160. _actionManager: ActionManager;
  87161. /**
  87162. * Internal only
  87163. * @hidden
  87164. */
  87165. _evaluationId: number;
  87166. /**
  87167. * Internal only
  87168. * @hidden
  87169. */
  87170. _currentResult: boolean;
  87171. /**
  87172. * Creates a new Condition
  87173. * @param actionManager the manager of the action the condition is applied to
  87174. */
  87175. constructor(actionManager: ActionManager);
  87176. /**
  87177. * Check if the current condition is valid
  87178. * @returns a boolean
  87179. */
  87180. isValid(): boolean;
  87181. /**
  87182. * Internal only
  87183. * @hidden
  87184. */
  87185. _getProperty(propertyPath: string): string;
  87186. /**
  87187. * Internal only
  87188. * @hidden
  87189. */
  87190. _getEffectiveTarget(target: any, propertyPath: string): any;
  87191. /**
  87192. * Serialize placeholder for child classes
  87193. * @returns the serialized object
  87194. */
  87195. serialize(): any;
  87196. /**
  87197. * Internal only
  87198. * @hidden
  87199. */
  87200. protected _serialize(serializedCondition: any): any;
  87201. }
  87202. /**
  87203. * Defines specific conditional operators as extensions of Condition
  87204. */
  87205. export class ValueCondition extends Condition {
  87206. /** path to specify the property of the target the conditional operator uses */
  87207. propertyPath: string;
  87208. /** the value compared by the conditional operator against the current value of the property */
  87209. value: any;
  87210. /** the conditional operator, default ValueCondition.IsEqual */
  87211. operator: number;
  87212. /**
  87213. * Internal only
  87214. * @hidden
  87215. */
  87216. private static _IsEqual;
  87217. /**
  87218. * Internal only
  87219. * @hidden
  87220. */
  87221. private static _IsDifferent;
  87222. /**
  87223. * Internal only
  87224. * @hidden
  87225. */
  87226. private static _IsGreater;
  87227. /**
  87228. * Internal only
  87229. * @hidden
  87230. */
  87231. private static _IsLesser;
  87232. /**
  87233. * returns the number for IsEqual
  87234. */
  87235. static get IsEqual(): number;
  87236. /**
  87237. * Returns the number for IsDifferent
  87238. */
  87239. static get IsDifferent(): number;
  87240. /**
  87241. * Returns the number for IsGreater
  87242. */
  87243. static get IsGreater(): number;
  87244. /**
  87245. * Returns the number for IsLesser
  87246. */
  87247. static get IsLesser(): number;
  87248. /**
  87249. * Internal only The action manager for the condition
  87250. * @hidden
  87251. */
  87252. _actionManager: ActionManager;
  87253. /**
  87254. * Internal only
  87255. * @hidden
  87256. */
  87257. private _target;
  87258. /**
  87259. * Internal only
  87260. * @hidden
  87261. */
  87262. private _effectiveTarget;
  87263. /**
  87264. * Internal only
  87265. * @hidden
  87266. */
  87267. private _property;
  87268. /**
  87269. * Creates a new ValueCondition
  87270. * @param actionManager manager for the action the condition applies to
  87271. * @param target for the action
  87272. * @param propertyPath path to specify the property of the target the conditional operator uses
  87273. * @param value the value compared by the conditional operator against the current value of the property
  87274. * @param operator the conditional operator, default ValueCondition.IsEqual
  87275. */
  87276. constructor(actionManager: ActionManager, target: any,
  87277. /** path to specify the property of the target the conditional operator uses */
  87278. propertyPath: string,
  87279. /** the value compared by the conditional operator against the current value of the property */
  87280. value: any,
  87281. /** the conditional operator, default ValueCondition.IsEqual */
  87282. operator?: number);
  87283. /**
  87284. * Compares the given value with the property value for the specified conditional operator
  87285. * @returns the result of the comparison
  87286. */
  87287. isValid(): boolean;
  87288. /**
  87289. * Serialize the ValueCondition into a JSON compatible object
  87290. * @returns serialization object
  87291. */
  87292. serialize(): any;
  87293. /**
  87294. * Gets the name of the conditional operator for the ValueCondition
  87295. * @param operator the conditional operator
  87296. * @returns the name
  87297. */
  87298. static GetOperatorName(operator: number): string;
  87299. }
  87300. /**
  87301. * Defines a predicate condition as an extension of Condition
  87302. */
  87303. export class PredicateCondition extends Condition {
  87304. /** defines the predicate function used to validate the condition */
  87305. predicate: () => boolean;
  87306. /**
  87307. * Internal only - manager for action
  87308. * @hidden
  87309. */
  87310. _actionManager: ActionManager;
  87311. /**
  87312. * Creates a new PredicateCondition
  87313. * @param actionManager manager for the action the condition applies to
  87314. * @param predicate defines the predicate function used to validate the condition
  87315. */
  87316. constructor(actionManager: ActionManager,
  87317. /** defines the predicate function used to validate the condition */
  87318. predicate: () => boolean);
  87319. /**
  87320. * @returns the validity of the predicate condition
  87321. */
  87322. isValid(): boolean;
  87323. }
  87324. /**
  87325. * Defines a state condition as an extension of Condition
  87326. */
  87327. export class StateCondition extends Condition {
  87328. /** Value to compare with target state */
  87329. value: string;
  87330. /**
  87331. * Internal only - manager for action
  87332. * @hidden
  87333. */
  87334. _actionManager: ActionManager;
  87335. /**
  87336. * Internal only
  87337. * @hidden
  87338. */
  87339. private _target;
  87340. /**
  87341. * Creates a new StateCondition
  87342. * @param actionManager manager for the action the condition applies to
  87343. * @param target of the condition
  87344. * @param value to compare with target state
  87345. */
  87346. constructor(actionManager: ActionManager, target: any,
  87347. /** Value to compare with target state */
  87348. value: string);
  87349. /**
  87350. * Gets a boolean indicating if the current condition is met
  87351. * @returns the validity of the state
  87352. */
  87353. isValid(): boolean;
  87354. /**
  87355. * Serialize the StateCondition into a JSON compatible object
  87356. * @returns serialization object
  87357. */
  87358. serialize(): any;
  87359. }
  87360. }
  87361. declare module BABYLON {
  87362. /**
  87363. * This defines an action responsible to toggle a boolean once triggered.
  87364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87365. */
  87366. export class SwitchBooleanAction extends Action {
  87367. /**
  87368. * The path to the boolean property in the target object
  87369. */
  87370. propertyPath: string;
  87371. private _target;
  87372. private _effectiveTarget;
  87373. private _property;
  87374. /**
  87375. * Instantiate the action
  87376. * @param triggerOptions defines the trigger options
  87377. * @param target defines the object containing the boolean
  87378. * @param propertyPath defines the path to the boolean property in the target object
  87379. * @param condition defines the trigger related conditions
  87380. */
  87381. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  87382. /** @hidden */
  87383. _prepare(): void;
  87384. /**
  87385. * Execute the action toggle the boolean value.
  87386. */
  87387. execute(): void;
  87388. /**
  87389. * Serializes the actions and its related information.
  87390. * @param parent defines the object to serialize in
  87391. * @returns the serialized object
  87392. */
  87393. serialize(parent: any): any;
  87394. }
  87395. /**
  87396. * This defines an action responsible to set a the state field of the target
  87397. * to a desired value once triggered.
  87398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87399. */
  87400. export class SetStateAction extends Action {
  87401. /**
  87402. * The value to store in the state field.
  87403. */
  87404. value: string;
  87405. private _target;
  87406. /**
  87407. * Instantiate the action
  87408. * @param triggerOptions defines the trigger options
  87409. * @param target defines the object containing the state property
  87410. * @param value defines the value to store in the state field
  87411. * @param condition defines the trigger related conditions
  87412. */
  87413. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  87414. /**
  87415. * Execute the action and store the value on the target state property.
  87416. */
  87417. execute(): void;
  87418. /**
  87419. * Serializes the actions and its related information.
  87420. * @param parent defines the object to serialize in
  87421. * @returns the serialized object
  87422. */
  87423. serialize(parent: any): any;
  87424. }
  87425. /**
  87426. * This defines an action responsible to set a property of the target
  87427. * to a desired value once triggered.
  87428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87429. */
  87430. export class SetValueAction extends Action {
  87431. /**
  87432. * The path of the property to set in the target.
  87433. */
  87434. propertyPath: string;
  87435. /**
  87436. * The value to set in the property
  87437. */
  87438. value: any;
  87439. private _target;
  87440. private _effectiveTarget;
  87441. private _property;
  87442. /**
  87443. * Instantiate the action
  87444. * @param triggerOptions defines the trigger options
  87445. * @param target defines the object containing the property
  87446. * @param propertyPath defines the path of the property to set in the target
  87447. * @param value defines the value to set in the property
  87448. * @param condition defines the trigger related conditions
  87449. */
  87450. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87451. /** @hidden */
  87452. _prepare(): void;
  87453. /**
  87454. * Execute the action and set the targetted property to the desired value.
  87455. */
  87456. execute(): void;
  87457. /**
  87458. * Serializes the actions and its related information.
  87459. * @param parent defines the object to serialize in
  87460. * @returns the serialized object
  87461. */
  87462. serialize(parent: any): any;
  87463. }
  87464. /**
  87465. * This defines an action responsible to increment the target value
  87466. * to a desired value once triggered.
  87467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87468. */
  87469. export class IncrementValueAction extends Action {
  87470. /**
  87471. * The path of the property to increment in the target.
  87472. */
  87473. propertyPath: string;
  87474. /**
  87475. * The value we should increment the property by.
  87476. */
  87477. value: any;
  87478. private _target;
  87479. private _effectiveTarget;
  87480. private _property;
  87481. /**
  87482. * Instantiate the action
  87483. * @param triggerOptions defines the trigger options
  87484. * @param target defines the object containing the property
  87485. * @param propertyPath defines the path of the property to increment in the target
  87486. * @param value defines the value value we should increment the property by
  87487. * @param condition defines the trigger related conditions
  87488. */
  87489. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  87490. /** @hidden */
  87491. _prepare(): void;
  87492. /**
  87493. * Execute the action and increment the target of the value amount.
  87494. */
  87495. execute(): void;
  87496. /**
  87497. * Serializes the actions and its related information.
  87498. * @param parent defines the object to serialize in
  87499. * @returns the serialized object
  87500. */
  87501. serialize(parent: any): any;
  87502. }
  87503. /**
  87504. * This defines an action responsible to start an animation once triggered.
  87505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87506. */
  87507. export class PlayAnimationAction extends Action {
  87508. /**
  87509. * Where the animation should start (animation frame)
  87510. */
  87511. from: number;
  87512. /**
  87513. * Where the animation should stop (animation frame)
  87514. */
  87515. to: number;
  87516. /**
  87517. * Define if the animation should loop or stop after the first play.
  87518. */
  87519. loop?: boolean;
  87520. private _target;
  87521. /**
  87522. * Instantiate the action
  87523. * @param triggerOptions defines the trigger options
  87524. * @param target defines the target animation or animation name
  87525. * @param from defines from where the animation should start (animation frame)
  87526. * @param end defines where the animation should stop (animation frame)
  87527. * @param loop defines if the animation should loop or stop after the first play
  87528. * @param condition defines the trigger related conditions
  87529. */
  87530. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  87531. /** @hidden */
  87532. _prepare(): void;
  87533. /**
  87534. * Execute the action and play the animation.
  87535. */
  87536. execute(): void;
  87537. /**
  87538. * Serializes the actions and its related information.
  87539. * @param parent defines the object to serialize in
  87540. * @returns the serialized object
  87541. */
  87542. serialize(parent: any): any;
  87543. }
  87544. /**
  87545. * This defines an action responsible to stop an animation once triggered.
  87546. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87547. */
  87548. export class StopAnimationAction extends Action {
  87549. private _target;
  87550. /**
  87551. * Instantiate the action
  87552. * @param triggerOptions defines the trigger options
  87553. * @param target defines the target animation or animation name
  87554. * @param condition defines the trigger related conditions
  87555. */
  87556. constructor(triggerOptions: any, target: any, condition?: Condition);
  87557. /** @hidden */
  87558. _prepare(): void;
  87559. /**
  87560. * Execute the action and stop the animation.
  87561. */
  87562. execute(): void;
  87563. /**
  87564. * Serializes the actions and its related information.
  87565. * @param parent defines the object to serialize in
  87566. * @returns the serialized object
  87567. */
  87568. serialize(parent: any): any;
  87569. }
  87570. /**
  87571. * This defines an action responsible that does nothing once triggered.
  87572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87573. */
  87574. export class DoNothingAction extends Action {
  87575. /**
  87576. * Instantiate the action
  87577. * @param triggerOptions defines the trigger options
  87578. * @param condition defines the trigger related conditions
  87579. */
  87580. constructor(triggerOptions?: any, condition?: Condition);
  87581. /**
  87582. * Execute the action and do nothing.
  87583. */
  87584. execute(): void;
  87585. /**
  87586. * Serializes the actions and its related information.
  87587. * @param parent defines the object to serialize in
  87588. * @returns the serialized object
  87589. */
  87590. serialize(parent: any): any;
  87591. }
  87592. /**
  87593. * This defines an action responsible to trigger several actions once triggered.
  87594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87595. */
  87596. export class CombineAction extends Action {
  87597. /**
  87598. * The list of aggregated animations to run.
  87599. */
  87600. children: Action[];
  87601. /**
  87602. * Instantiate the action
  87603. * @param triggerOptions defines the trigger options
  87604. * @param children defines the list of aggregated animations to run
  87605. * @param condition defines the trigger related conditions
  87606. */
  87607. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  87608. /** @hidden */
  87609. _prepare(): void;
  87610. /**
  87611. * Execute the action and executes all the aggregated actions.
  87612. */
  87613. execute(evt: ActionEvent): void;
  87614. /**
  87615. * Serializes the actions and its related information.
  87616. * @param parent defines the object to serialize in
  87617. * @returns the serialized object
  87618. */
  87619. serialize(parent: any): any;
  87620. }
  87621. /**
  87622. * This defines an action responsible to run code (external event) once triggered.
  87623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87624. */
  87625. export class ExecuteCodeAction extends Action {
  87626. /**
  87627. * The callback function to run.
  87628. */
  87629. func: (evt: ActionEvent) => void;
  87630. /**
  87631. * Instantiate the action
  87632. * @param triggerOptions defines the trigger options
  87633. * @param func defines the callback function to run
  87634. * @param condition defines the trigger related conditions
  87635. */
  87636. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  87637. /**
  87638. * Execute the action and run the attached code.
  87639. */
  87640. execute(evt: ActionEvent): void;
  87641. }
  87642. /**
  87643. * This defines an action responsible to set the parent property of the target once triggered.
  87644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87645. */
  87646. export class SetParentAction extends Action {
  87647. private _parent;
  87648. private _target;
  87649. /**
  87650. * Instantiate the action
  87651. * @param triggerOptions defines the trigger options
  87652. * @param target defines the target containing the parent property
  87653. * @param parent defines from where the animation should start (animation frame)
  87654. * @param condition defines the trigger related conditions
  87655. */
  87656. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  87657. /** @hidden */
  87658. _prepare(): void;
  87659. /**
  87660. * Execute the action and set the parent property.
  87661. */
  87662. execute(): void;
  87663. /**
  87664. * Serializes the actions and its related information.
  87665. * @param parent defines the object to serialize in
  87666. * @returns the serialized object
  87667. */
  87668. serialize(parent: any): any;
  87669. }
  87670. }
  87671. declare module BABYLON {
  87672. /**
  87673. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  87674. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  87675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87676. */
  87677. export class ActionManager extends AbstractActionManager {
  87678. /**
  87679. * Nothing
  87680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87681. */
  87682. static readonly NothingTrigger: number;
  87683. /**
  87684. * On pick
  87685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87686. */
  87687. static readonly OnPickTrigger: number;
  87688. /**
  87689. * On left pick
  87690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87691. */
  87692. static readonly OnLeftPickTrigger: number;
  87693. /**
  87694. * On right pick
  87695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87696. */
  87697. static readonly OnRightPickTrigger: number;
  87698. /**
  87699. * On center pick
  87700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87701. */
  87702. static readonly OnCenterPickTrigger: number;
  87703. /**
  87704. * On pick down
  87705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87706. */
  87707. static readonly OnPickDownTrigger: number;
  87708. /**
  87709. * On double pick
  87710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87711. */
  87712. static readonly OnDoublePickTrigger: number;
  87713. /**
  87714. * On pick up
  87715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87716. */
  87717. static readonly OnPickUpTrigger: number;
  87718. /**
  87719. * On pick out.
  87720. * This trigger will only be raised if you also declared a OnPickDown
  87721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87722. */
  87723. static readonly OnPickOutTrigger: number;
  87724. /**
  87725. * On long press
  87726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87727. */
  87728. static readonly OnLongPressTrigger: number;
  87729. /**
  87730. * On pointer over
  87731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87732. */
  87733. static readonly OnPointerOverTrigger: number;
  87734. /**
  87735. * On pointer out
  87736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87737. */
  87738. static readonly OnPointerOutTrigger: number;
  87739. /**
  87740. * On every frame
  87741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87742. */
  87743. static readonly OnEveryFrameTrigger: number;
  87744. /**
  87745. * On intersection enter
  87746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87747. */
  87748. static readonly OnIntersectionEnterTrigger: number;
  87749. /**
  87750. * On intersection exit
  87751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87752. */
  87753. static readonly OnIntersectionExitTrigger: number;
  87754. /**
  87755. * On key down
  87756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87757. */
  87758. static readonly OnKeyDownTrigger: number;
  87759. /**
  87760. * On key up
  87761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  87762. */
  87763. static readonly OnKeyUpTrigger: number;
  87764. private _scene;
  87765. /**
  87766. * Creates a new action manager
  87767. * @param scene defines the hosting scene
  87768. */
  87769. constructor(scene: Scene);
  87770. /**
  87771. * Releases all associated resources
  87772. */
  87773. dispose(): void;
  87774. /**
  87775. * Gets hosting scene
  87776. * @returns the hosting scene
  87777. */
  87778. getScene(): Scene;
  87779. /**
  87780. * Does this action manager handles actions of any of the given triggers
  87781. * @param triggers defines the triggers to be tested
  87782. * @return a boolean indicating whether one (or more) of the triggers is handled
  87783. */
  87784. hasSpecificTriggers(triggers: number[]): boolean;
  87785. /**
  87786. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87787. * speed.
  87788. * @param triggerA defines the trigger to be tested
  87789. * @param triggerB defines the trigger to be tested
  87790. * @return a boolean indicating whether one (or more) of the triggers is handled
  87791. */
  87792. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87793. /**
  87794. * Does this action manager handles actions of a given trigger
  87795. * @param trigger defines the trigger to be tested
  87796. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87797. * @return whether the trigger is handled
  87798. */
  87799. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87800. /**
  87801. * Does this action manager has pointer triggers
  87802. */
  87803. get hasPointerTriggers(): boolean;
  87804. /**
  87805. * Does this action manager has pick triggers
  87806. */
  87807. get hasPickTriggers(): boolean;
  87808. /**
  87809. * Registers an action to this action manager
  87810. * @param action defines the action to be registered
  87811. * @return the action amended (prepared) after registration
  87812. */
  87813. registerAction(action: IAction): Nullable<IAction>;
  87814. /**
  87815. * Unregisters an action to this action manager
  87816. * @param action defines the action to be unregistered
  87817. * @return a boolean indicating whether the action has been unregistered
  87818. */
  87819. unregisterAction(action: IAction): Boolean;
  87820. /**
  87821. * Process a specific trigger
  87822. * @param trigger defines the trigger to process
  87823. * @param evt defines the event details to be processed
  87824. */
  87825. processTrigger(trigger: number, evt?: IActionEvent): void;
  87826. /** @hidden */
  87827. _getEffectiveTarget(target: any, propertyPath: string): any;
  87828. /** @hidden */
  87829. _getProperty(propertyPath: string): string;
  87830. /**
  87831. * Serialize this manager to a JSON object
  87832. * @param name defines the property name to store this manager
  87833. * @returns a JSON representation of this manager
  87834. */
  87835. serialize(name: string): any;
  87836. /**
  87837. * Creates a new ActionManager from a JSON data
  87838. * @param parsedActions defines the JSON data to read from
  87839. * @param object defines the hosting mesh
  87840. * @param scene defines the hosting scene
  87841. */
  87842. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  87843. /**
  87844. * Get a trigger name by index
  87845. * @param trigger defines the trigger index
  87846. * @returns a trigger name
  87847. */
  87848. static GetTriggerName(trigger: number): string;
  87849. }
  87850. }
  87851. declare module BABYLON {
  87852. /**
  87853. * Class used to represent a sprite
  87854. * @see http://doc.babylonjs.com/babylon101/sprites
  87855. */
  87856. export class Sprite implements IAnimatable {
  87857. /** defines the name */
  87858. name: string;
  87859. /** Gets or sets the current world position */
  87860. position: Vector3;
  87861. /** Gets or sets the main color */
  87862. color: Color4;
  87863. /** Gets or sets the width */
  87864. width: number;
  87865. /** Gets or sets the height */
  87866. height: number;
  87867. /** Gets or sets rotation angle */
  87868. angle: number;
  87869. /** Gets or sets the cell index in the sprite sheet */
  87870. cellIndex: number;
  87871. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  87872. cellRef: string;
  87873. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  87874. invertU: boolean;
  87875. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  87876. invertV: boolean;
  87877. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  87878. disposeWhenFinishedAnimating: boolean;
  87879. /** Gets the list of attached animations */
  87880. animations: Nullable<Array<Animation>>;
  87881. /** Gets or sets a boolean indicating if the sprite can be picked */
  87882. isPickable: boolean;
  87883. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  87884. useAlphaForPicking: boolean;
  87885. /** @hidden */
  87886. _xOffset: number;
  87887. /** @hidden */
  87888. _yOffset: number;
  87889. /** @hidden */
  87890. _xSize: number;
  87891. /** @hidden */
  87892. _ySize: number;
  87893. /**
  87894. * Gets or sets the associated action manager
  87895. */
  87896. actionManager: Nullable<ActionManager>;
  87897. /**
  87898. * An event triggered when the control has been disposed
  87899. */
  87900. onDisposeObservable: Observable<Sprite>;
  87901. private _animationStarted;
  87902. private _loopAnimation;
  87903. private _fromIndex;
  87904. private _toIndex;
  87905. private _delay;
  87906. private _direction;
  87907. private _manager;
  87908. private _time;
  87909. private _onAnimationEnd;
  87910. /**
  87911. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  87912. */
  87913. isVisible: boolean;
  87914. /**
  87915. * Gets or sets the sprite size
  87916. */
  87917. get size(): number;
  87918. set size(value: number);
  87919. /**
  87920. * Returns a boolean indicating if the animation is started
  87921. */
  87922. get animationStarted(): boolean;
  87923. /**
  87924. * Gets or sets the unique id of the sprite
  87925. */
  87926. uniqueId: number;
  87927. /**
  87928. * Gets the manager of this sprite
  87929. */
  87930. get manager(): ISpriteManager;
  87931. /**
  87932. * Creates a new Sprite
  87933. * @param name defines the name
  87934. * @param manager defines the manager
  87935. */
  87936. constructor(
  87937. /** defines the name */
  87938. name: string, manager: ISpriteManager);
  87939. /**
  87940. * Returns the string "Sprite"
  87941. * @returns "Sprite"
  87942. */
  87943. getClassName(): string;
  87944. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  87945. get fromIndex(): number;
  87946. set fromIndex(value: number);
  87947. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  87948. get toIndex(): number;
  87949. set toIndex(value: number);
  87950. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  87951. get loopAnimation(): boolean;
  87952. set loopAnimation(value: boolean);
  87953. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  87954. get delay(): number;
  87955. set delay(value: number);
  87956. /**
  87957. * Starts an animation
  87958. * @param from defines the initial key
  87959. * @param to defines the end key
  87960. * @param loop defines if the animation must loop
  87961. * @param delay defines the start delay (in ms)
  87962. * @param onAnimationEnd defines a callback to call when animation ends
  87963. */
  87964. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  87965. /** Stops current animation (if any) */
  87966. stopAnimation(): void;
  87967. /** @hidden */
  87968. _animate(deltaTime: number): void;
  87969. /** Release associated resources */
  87970. dispose(): void;
  87971. /**
  87972. * Serializes the sprite to a JSON object
  87973. * @returns the JSON object
  87974. */
  87975. serialize(): any;
  87976. /**
  87977. * Parses a JSON object to create a new sprite
  87978. * @param parsedSprite The JSON object to parse
  87979. * @param manager defines the hosting manager
  87980. * @returns the new sprite
  87981. */
  87982. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  87983. }
  87984. }
  87985. declare module BABYLON {
  87986. /**
  87987. * Information about the result of picking within a scene
  87988. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  87989. */
  87990. export class PickingInfo {
  87991. /** @hidden */
  87992. _pickingUnavailable: boolean;
  87993. /**
  87994. * If the pick collided with an object
  87995. */
  87996. hit: boolean;
  87997. /**
  87998. * Distance away where the pick collided
  87999. */
  88000. distance: number;
  88001. /**
  88002. * The location of pick collision
  88003. */
  88004. pickedPoint: Nullable<Vector3>;
  88005. /**
  88006. * The mesh corresponding the the pick collision
  88007. */
  88008. pickedMesh: Nullable<AbstractMesh>;
  88009. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88010. bu: number;
  88011. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88012. bv: number;
  88013. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88014. faceId: number;
  88015. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88016. subMeshFaceId: number;
  88017. /** Id of the the submesh that was picked */
  88018. subMeshId: number;
  88019. /** If a sprite was picked, this will be the sprite the pick collided with */
  88020. pickedSprite: Nullable<Sprite>;
  88021. /**
  88022. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88023. */
  88024. originMesh: Nullable<AbstractMesh>;
  88025. /**
  88026. * The ray that was used to perform the picking.
  88027. */
  88028. ray: Nullable<Ray>;
  88029. /**
  88030. * Gets the normal correspodning to the face the pick collided with
  88031. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88032. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88033. * @returns The normal correspodning to the face the pick collided with
  88034. */
  88035. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88036. /**
  88037. * Gets the texture coordinates of where the pick occured
  88038. * @returns the vector containing the coordnates of the texture
  88039. */
  88040. getTextureCoordinates(): Nullable<Vector2>;
  88041. }
  88042. }
  88043. declare module BABYLON {
  88044. /**
  88045. * Class representing a ray with position and direction
  88046. */
  88047. export class Ray {
  88048. /** origin point */
  88049. origin: Vector3;
  88050. /** direction */
  88051. direction: Vector3;
  88052. /** length of the ray */
  88053. length: number;
  88054. private static readonly TmpVector3;
  88055. private _tmpRay;
  88056. /**
  88057. * Creates a new ray
  88058. * @param origin origin point
  88059. * @param direction direction
  88060. * @param length length of the ray
  88061. */
  88062. constructor(
  88063. /** origin point */
  88064. origin: Vector3,
  88065. /** direction */
  88066. direction: Vector3,
  88067. /** length of the ray */
  88068. length?: number);
  88069. /**
  88070. * Checks if the ray intersects a box
  88071. * This does not account for the ray lenght by design to improve perfs.
  88072. * @param minimum bound of the box
  88073. * @param maximum bound of the box
  88074. * @param intersectionTreshold extra extend to be added to the box in all direction
  88075. * @returns if the box was hit
  88076. */
  88077. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88078. /**
  88079. * Checks if the ray intersects a box
  88080. * This does not account for the ray lenght by design to improve perfs.
  88081. * @param box the bounding box to check
  88082. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88083. * @returns if the box was hit
  88084. */
  88085. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88086. /**
  88087. * If the ray hits a sphere
  88088. * @param sphere the bounding sphere to check
  88089. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88090. * @returns true if it hits the sphere
  88091. */
  88092. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88093. /**
  88094. * If the ray hits a triange
  88095. * @param vertex0 triangle vertex
  88096. * @param vertex1 triangle vertex
  88097. * @param vertex2 triangle vertex
  88098. * @returns intersection information if hit
  88099. */
  88100. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88101. /**
  88102. * Checks if ray intersects a plane
  88103. * @param plane the plane to check
  88104. * @returns the distance away it was hit
  88105. */
  88106. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88107. /**
  88108. * Calculate the intercept of a ray on a given axis
  88109. * @param axis to check 'x' | 'y' | 'z'
  88110. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88111. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88112. */
  88113. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88114. /**
  88115. * Checks if ray intersects a mesh
  88116. * @param mesh the mesh to check
  88117. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88118. * @returns picking info of the intersecton
  88119. */
  88120. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88121. /**
  88122. * Checks if ray intersects a mesh
  88123. * @param meshes the meshes to check
  88124. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88125. * @param results array to store result in
  88126. * @returns Array of picking infos
  88127. */
  88128. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88129. private _comparePickingInfo;
  88130. private static smallnum;
  88131. private static rayl;
  88132. /**
  88133. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88134. * @param sega the first point of the segment to test the intersection against
  88135. * @param segb the second point of the segment to test the intersection against
  88136. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88137. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88138. */
  88139. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88140. /**
  88141. * Update the ray from viewport position
  88142. * @param x position
  88143. * @param y y position
  88144. * @param viewportWidth viewport width
  88145. * @param viewportHeight viewport height
  88146. * @param world world matrix
  88147. * @param view view matrix
  88148. * @param projection projection matrix
  88149. * @returns this ray updated
  88150. */
  88151. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88152. /**
  88153. * Creates a ray with origin and direction of 0,0,0
  88154. * @returns the new ray
  88155. */
  88156. static Zero(): Ray;
  88157. /**
  88158. * Creates a new ray from screen space and viewport
  88159. * @param x position
  88160. * @param y y position
  88161. * @param viewportWidth viewport width
  88162. * @param viewportHeight viewport height
  88163. * @param world world matrix
  88164. * @param view view matrix
  88165. * @param projection projection matrix
  88166. * @returns new ray
  88167. */
  88168. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88169. /**
  88170. * 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
  88171. * transformed to the given world matrix.
  88172. * @param origin The origin point
  88173. * @param end The end point
  88174. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88175. * @returns the new ray
  88176. */
  88177. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  88178. /**
  88179. * Transforms a ray by a matrix
  88180. * @param ray ray to transform
  88181. * @param matrix matrix to apply
  88182. * @returns the resulting new ray
  88183. */
  88184. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88185. /**
  88186. * Transforms a ray by a matrix
  88187. * @param ray ray to transform
  88188. * @param matrix matrix to apply
  88189. * @param result ray to store result in
  88190. */
  88191. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88192. /**
  88193. * Unproject a ray from screen space to object space
  88194. * @param sourceX defines the screen space x coordinate to use
  88195. * @param sourceY defines the screen space y coordinate to use
  88196. * @param viewportWidth defines the current width of the viewport
  88197. * @param viewportHeight defines the current height of the viewport
  88198. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88199. * @param view defines the view matrix to use
  88200. * @param projection defines the projection matrix to use
  88201. */
  88202. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88203. }
  88204. /**
  88205. * Type used to define predicate used to select faces when a mesh intersection is detected
  88206. */
  88207. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88208. interface Scene {
  88209. /** @hidden */
  88210. _tempPickingRay: Nullable<Ray>;
  88211. /** @hidden */
  88212. _cachedRayForTransform: Ray;
  88213. /** @hidden */
  88214. _pickWithRayInverseMatrix: Matrix;
  88215. /** @hidden */
  88216. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88217. /** @hidden */
  88218. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88219. }
  88220. }
  88221. declare module BABYLON {
  88222. /**
  88223. * Groups all the scene component constants in one place to ease maintenance.
  88224. * @hidden
  88225. */
  88226. export class SceneComponentConstants {
  88227. static readonly NAME_EFFECTLAYER: string;
  88228. static readonly NAME_LAYER: string;
  88229. static readonly NAME_LENSFLARESYSTEM: string;
  88230. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88231. static readonly NAME_PARTICLESYSTEM: string;
  88232. static readonly NAME_GAMEPAD: string;
  88233. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88234. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88235. static readonly NAME_DEPTHRENDERER: string;
  88236. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88237. static readonly NAME_SPRITE: string;
  88238. static readonly NAME_OUTLINERENDERER: string;
  88239. static readonly NAME_PROCEDURALTEXTURE: string;
  88240. static readonly NAME_SHADOWGENERATOR: string;
  88241. static readonly NAME_OCTREE: string;
  88242. static readonly NAME_PHYSICSENGINE: string;
  88243. static readonly NAME_AUDIO: string;
  88244. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88245. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88246. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88247. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88248. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88249. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88250. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88251. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88252. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88253. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88254. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88255. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88256. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88257. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88258. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88259. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88260. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88261. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88262. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88263. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88264. static readonly STEP_AFTERRENDER_AUDIO: number;
  88265. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88266. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88267. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88268. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88269. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88270. static readonly STEP_POINTERMOVE_SPRITE: number;
  88271. static readonly STEP_POINTERDOWN_SPRITE: number;
  88272. static readonly STEP_POINTERUP_SPRITE: number;
  88273. }
  88274. /**
  88275. * This represents a scene component.
  88276. *
  88277. * This is used to decouple the dependency the scene is having on the different workloads like
  88278. * layers, post processes...
  88279. */
  88280. export interface ISceneComponent {
  88281. /**
  88282. * The name of the component. Each component must have a unique name.
  88283. */
  88284. name: string;
  88285. /**
  88286. * The scene the component belongs to.
  88287. */
  88288. scene: Scene;
  88289. /**
  88290. * Register the component to one instance of a scene.
  88291. */
  88292. register(): void;
  88293. /**
  88294. * Rebuilds the elements related to this component in case of
  88295. * context lost for instance.
  88296. */
  88297. rebuild(): void;
  88298. /**
  88299. * Disposes the component and the associated ressources.
  88300. */
  88301. dispose(): void;
  88302. }
  88303. /**
  88304. * This represents a SERIALIZABLE scene component.
  88305. *
  88306. * This extends Scene Component to add Serialization methods on top.
  88307. */
  88308. export interface ISceneSerializableComponent extends ISceneComponent {
  88309. /**
  88310. * Adds all the elements from the container to the scene
  88311. * @param container the container holding the elements
  88312. */
  88313. addFromContainer(container: AbstractScene): void;
  88314. /**
  88315. * Removes all the elements in the container from the scene
  88316. * @param container contains the elements to remove
  88317. * @param dispose if the removed element should be disposed (default: false)
  88318. */
  88319. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88320. /**
  88321. * Serializes the component data to the specified json object
  88322. * @param serializationObject The object to serialize to
  88323. */
  88324. serialize(serializationObject: any): void;
  88325. }
  88326. /**
  88327. * Strong typing of a Mesh related stage step action
  88328. */
  88329. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  88330. /**
  88331. * Strong typing of a Evaluate Sub Mesh related stage step action
  88332. */
  88333. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  88334. /**
  88335. * Strong typing of a Active Mesh related stage step action
  88336. */
  88337. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  88338. /**
  88339. * Strong typing of a Camera related stage step action
  88340. */
  88341. export type CameraStageAction = (camera: Camera) => void;
  88342. /**
  88343. * Strong typing of a Camera Frame buffer related stage step action
  88344. */
  88345. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  88346. /**
  88347. * Strong typing of a Render Target related stage step action
  88348. */
  88349. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  88350. /**
  88351. * Strong typing of a RenderingGroup related stage step action
  88352. */
  88353. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  88354. /**
  88355. * Strong typing of a Mesh Render related stage step action
  88356. */
  88357. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  88358. /**
  88359. * Strong typing of a simple stage step action
  88360. */
  88361. export type SimpleStageAction = () => void;
  88362. /**
  88363. * Strong typing of a render target action.
  88364. */
  88365. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  88366. /**
  88367. * Strong typing of a pointer move action.
  88368. */
  88369. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  88370. /**
  88371. * Strong typing of a pointer up/down action.
  88372. */
  88373. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  88374. /**
  88375. * Representation of a stage in the scene (Basically a list of ordered steps)
  88376. * @hidden
  88377. */
  88378. export class Stage<T extends Function> extends Array<{
  88379. index: number;
  88380. component: ISceneComponent;
  88381. action: T;
  88382. }> {
  88383. /**
  88384. * Hide ctor from the rest of the world.
  88385. * @param items The items to add.
  88386. */
  88387. private constructor();
  88388. /**
  88389. * Creates a new Stage.
  88390. * @returns A new instance of a Stage
  88391. */
  88392. static Create<T extends Function>(): Stage<T>;
  88393. /**
  88394. * Registers a step in an ordered way in the targeted stage.
  88395. * @param index Defines the position to register the step in
  88396. * @param component Defines the component attached to the step
  88397. * @param action Defines the action to launch during the step
  88398. */
  88399. registerStep(index: number, component: ISceneComponent, action: T): void;
  88400. /**
  88401. * Clears all the steps from the stage.
  88402. */
  88403. clear(): void;
  88404. }
  88405. }
  88406. declare module BABYLON {
  88407. interface Scene {
  88408. /** @hidden */
  88409. _pointerOverSprite: Nullable<Sprite>;
  88410. /** @hidden */
  88411. _pickedDownSprite: Nullable<Sprite>;
  88412. /** @hidden */
  88413. _tempSpritePickingRay: Nullable<Ray>;
  88414. /**
  88415. * All of the sprite managers added to this scene
  88416. * @see http://doc.babylonjs.com/babylon101/sprites
  88417. */
  88418. spriteManagers: Array<ISpriteManager>;
  88419. /**
  88420. * An event triggered when sprites rendering is about to start
  88421. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88422. */
  88423. onBeforeSpritesRenderingObservable: Observable<Scene>;
  88424. /**
  88425. * An event triggered when sprites rendering is done
  88426. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  88427. */
  88428. onAfterSpritesRenderingObservable: Observable<Scene>;
  88429. /** @hidden */
  88430. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88431. /** Launch a ray to try to pick a sprite in the scene
  88432. * @param x position on screen
  88433. * @param y position on screen
  88434. * @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
  88435. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88436. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88437. * @returns a PickingInfo
  88438. */
  88439. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88440. /** Use the given ray to pick a sprite in the scene
  88441. * @param ray The ray (in world space) to use to pick meshes
  88442. * @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
  88443. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88444. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88445. * @returns a PickingInfo
  88446. */
  88447. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  88448. /** @hidden */
  88449. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88450. /** Launch a ray to try to pick sprites in the scene
  88451. * @param x position on screen
  88452. * @param y position on screen
  88453. * @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
  88454. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88455. * @returns a PickingInfo array
  88456. */
  88457. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88458. /** Use the given ray to pick sprites in the scene
  88459. * @param ray The ray (in world space) to use to pick meshes
  88460. * @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
  88461. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  88462. * @returns a PickingInfo array
  88463. */
  88464. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88465. /**
  88466. * Force the sprite under the pointer
  88467. * @param sprite defines the sprite to use
  88468. */
  88469. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  88470. /**
  88471. * Gets the sprite under the pointer
  88472. * @returns a Sprite or null if no sprite is under the pointer
  88473. */
  88474. getPointerOverSprite(): Nullable<Sprite>;
  88475. }
  88476. /**
  88477. * Defines the sprite scene component responsible to manage sprites
  88478. * in a given scene.
  88479. */
  88480. export class SpriteSceneComponent implements ISceneComponent {
  88481. /**
  88482. * The component name helpfull to identify the component in the list of scene components.
  88483. */
  88484. readonly name: string;
  88485. /**
  88486. * The scene the component belongs to.
  88487. */
  88488. scene: Scene;
  88489. /** @hidden */
  88490. private _spritePredicate;
  88491. /**
  88492. * Creates a new instance of the component for the given scene
  88493. * @param scene Defines the scene to register the component in
  88494. */
  88495. constructor(scene: Scene);
  88496. /**
  88497. * Registers the component in a given scene
  88498. */
  88499. register(): void;
  88500. /**
  88501. * Rebuilds the elements related to this component in case of
  88502. * context lost for instance.
  88503. */
  88504. rebuild(): void;
  88505. /**
  88506. * Disposes the component and the associated ressources.
  88507. */
  88508. dispose(): void;
  88509. private _pickSpriteButKeepRay;
  88510. private _pointerMove;
  88511. private _pointerDown;
  88512. private _pointerUp;
  88513. }
  88514. }
  88515. declare module BABYLON {
  88516. /** @hidden */
  88517. export var fogFragmentDeclaration: {
  88518. name: string;
  88519. shader: string;
  88520. };
  88521. }
  88522. declare module BABYLON {
  88523. /** @hidden */
  88524. export var fogFragment: {
  88525. name: string;
  88526. shader: string;
  88527. };
  88528. }
  88529. declare module BABYLON {
  88530. /** @hidden */
  88531. export var spritesPixelShader: {
  88532. name: string;
  88533. shader: string;
  88534. };
  88535. }
  88536. declare module BABYLON {
  88537. /** @hidden */
  88538. export var fogVertexDeclaration: {
  88539. name: string;
  88540. shader: string;
  88541. };
  88542. }
  88543. declare module BABYLON {
  88544. /** @hidden */
  88545. export var spritesVertexShader: {
  88546. name: string;
  88547. shader: string;
  88548. };
  88549. }
  88550. declare module BABYLON {
  88551. /**
  88552. * Defines the minimum interface to fullfil in order to be a sprite manager.
  88553. */
  88554. export interface ISpriteManager extends IDisposable {
  88555. /**
  88556. * Gets manager's name
  88557. */
  88558. name: string;
  88559. /**
  88560. * Restricts the camera to viewing objects with the same layerMask.
  88561. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  88562. */
  88563. layerMask: number;
  88564. /**
  88565. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  88566. */
  88567. isPickable: boolean;
  88568. /**
  88569. * Gets the hosting scene
  88570. */
  88571. scene: Scene;
  88572. /**
  88573. * Specifies the rendering group id for this mesh (0 by default)
  88574. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  88575. */
  88576. renderingGroupId: number;
  88577. /**
  88578. * Defines the list of sprites managed by the manager.
  88579. */
  88580. sprites: Array<Sprite>;
  88581. /**
  88582. * Gets or sets the spritesheet texture
  88583. */
  88584. texture: Texture;
  88585. /** Defines the default width of a cell in the spritesheet */
  88586. cellWidth: number;
  88587. /** Defines the default height of a cell in the spritesheet */
  88588. cellHeight: number;
  88589. /**
  88590. * Tests the intersection of a sprite with a specific ray.
  88591. * @param ray The ray we are sending to test the collision
  88592. * @param camera The camera space we are sending rays in
  88593. * @param predicate A predicate allowing excluding sprites from the list of object to test
  88594. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88595. * @returns picking info or null.
  88596. */
  88597. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88598. /**
  88599. * Intersects the sprites with a ray
  88600. * @param ray defines the ray to intersect with
  88601. * @param camera defines the current active camera
  88602. * @param predicate defines a predicate used to select candidate sprites
  88603. * @returns null if no hit or a PickingInfo array
  88604. */
  88605. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88606. /**
  88607. * Renders the list of sprites on screen.
  88608. */
  88609. render(): void;
  88610. }
  88611. /**
  88612. * Class used to manage multiple sprites on the same spritesheet
  88613. * @see http://doc.babylonjs.com/babylon101/sprites
  88614. */
  88615. export class SpriteManager implements ISpriteManager {
  88616. /** defines the manager's name */
  88617. name: string;
  88618. /** Define the Url to load snippets */
  88619. static SnippetUrl: string;
  88620. /** Snippet ID if the manager was created from the snippet server */
  88621. snippetId: string;
  88622. /** Gets the list of sprites */
  88623. sprites: Sprite[];
  88624. /** Gets or sets the rendering group id (0 by default) */
  88625. renderingGroupId: number;
  88626. /** Gets or sets camera layer mask */
  88627. layerMask: number;
  88628. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  88629. fogEnabled: boolean;
  88630. /** Gets or sets a boolean indicating if the sprites are pickable */
  88631. isPickable: boolean;
  88632. /** Defines the default width of a cell in the spritesheet */
  88633. cellWidth: number;
  88634. /** Defines the default height of a cell in the spritesheet */
  88635. cellHeight: number;
  88636. /** Associative array from JSON sprite data file */
  88637. private _cellData;
  88638. /** Array of sprite names from JSON sprite data file */
  88639. private _spriteMap;
  88640. /** True when packed cell data from JSON file is ready*/
  88641. private _packedAndReady;
  88642. private _textureContent;
  88643. /**
  88644. * An event triggered when the manager is disposed.
  88645. */
  88646. onDisposeObservable: Observable<SpriteManager>;
  88647. private _onDisposeObserver;
  88648. /**
  88649. * Callback called when the manager is disposed
  88650. */
  88651. set onDispose(callback: () => void);
  88652. private _capacity;
  88653. private _fromPacked;
  88654. private _spriteTexture;
  88655. private _epsilon;
  88656. private _scene;
  88657. private _vertexData;
  88658. private _buffer;
  88659. private _vertexBuffers;
  88660. private _indexBuffer;
  88661. private _effectBase;
  88662. private _effectFog;
  88663. /**
  88664. * Gets or sets the unique id of the sprite
  88665. */
  88666. uniqueId: number;
  88667. /**
  88668. * Gets the array of sprites
  88669. */
  88670. get children(): Sprite[];
  88671. /**
  88672. * Gets the hosting scene
  88673. */
  88674. get scene(): Scene;
  88675. /**
  88676. * Gets the capacity of the manager
  88677. */
  88678. get capacity(): number;
  88679. /**
  88680. * Gets or sets the spritesheet texture
  88681. */
  88682. get texture(): Texture;
  88683. set texture(value: Texture);
  88684. private _blendMode;
  88685. /**
  88686. * Blend mode use to render the particle, it can be any of
  88687. * the static Constants.ALPHA_x properties provided in this class.
  88688. * Default value is Constants.ALPHA_COMBINE
  88689. */
  88690. get blendMode(): number;
  88691. set blendMode(blendMode: number);
  88692. /** Disables writing to the depth buffer when rendering the sprites.
  88693. * It can be handy to disable depth writing when using textures without alpha channel
  88694. * and setting some specific blend modes.
  88695. */
  88696. disableDepthWrite: boolean;
  88697. /**
  88698. * Creates a new sprite manager
  88699. * @param name defines the manager's name
  88700. * @param imgUrl defines the sprite sheet url
  88701. * @param capacity defines the maximum allowed number of sprites
  88702. * @param cellSize defines the size of a sprite cell
  88703. * @param scene defines the hosting scene
  88704. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  88705. * @param samplingMode defines the smapling mode to use with spritesheet
  88706. * @param fromPacked set to false; do not alter
  88707. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  88708. */
  88709. constructor(
  88710. /** defines the manager's name */
  88711. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  88712. /**
  88713. * Returns the string "SpriteManager"
  88714. * @returns "SpriteManager"
  88715. */
  88716. getClassName(): string;
  88717. private _makePacked;
  88718. private _appendSpriteVertex;
  88719. private _checkTextureAlpha;
  88720. /**
  88721. * Intersects the sprites with a ray
  88722. * @param ray defines the ray to intersect with
  88723. * @param camera defines the current active camera
  88724. * @param predicate defines a predicate used to select candidate sprites
  88725. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  88726. * @returns null if no hit or a PickingInfo
  88727. */
  88728. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88729. /**
  88730. * Intersects the sprites with a ray
  88731. * @param ray defines the ray to intersect with
  88732. * @param camera defines the current active camera
  88733. * @param predicate defines a predicate used to select candidate sprites
  88734. * @returns null if no hit or a PickingInfo array
  88735. */
  88736. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  88737. /**
  88738. * Render all child sprites
  88739. */
  88740. render(): void;
  88741. /**
  88742. * Release associated resources
  88743. */
  88744. dispose(): void;
  88745. /**
  88746. * Serializes the sprite manager to a JSON object
  88747. * @param serializeTexture defines if the texture must be serialized as well
  88748. * @returns the JSON object
  88749. */
  88750. serialize(serializeTexture?: boolean): any;
  88751. /**
  88752. * Parses a JSON object to create a new sprite manager.
  88753. * @param parsedManager The JSON object to parse
  88754. * @param scene The scene to create the sprite managerin
  88755. * @param rootUrl The root url to use to load external dependencies like texture
  88756. * @returns the new sprite manager
  88757. */
  88758. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  88759. /**
  88760. * Creates a sprite manager from a snippet saved in a remote file
  88761. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  88762. * @param url defines the url to load from
  88763. * @param scene defines the hosting scene
  88764. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88765. * @returns a promise that will resolve to the new sprite manager
  88766. */
  88767. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88768. /**
  88769. * Creates a sprite manager from a snippet saved by the sprite editor
  88770. * @param snippetId defines the snippet to load
  88771. * @param scene defines the hosting scene
  88772. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88773. * @returns a promise that will resolve to the new sprite manager
  88774. */
  88775. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  88776. }
  88777. }
  88778. declare module BABYLON {
  88779. /** Interface used by value gradients (color, factor, ...) */
  88780. export interface IValueGradient {
  88781. /**
  88782. * Gets or sets the gradient value (between 0 and 1)
  88783. */
  88784. gradient: number;
  88785. }
  88786. /** Class used to store color4 gradient */
  88787. export class ColorGradient implements IValueGradient {
  88788. /**
  88789. * Gets or sets the gradient value (between 0 and 1)
  88790. */
  88791. gradient: number;
  88792. /**
  88793. * Gets or sets first associated color
  88794. */
  88795. color1: Color4;
  88796. /**
  88797. * Gets or sets second associated color
  88798. */
  88799. color2?: Color4 | undefined;
  88800. /**
  88801. * Creates a new color4 gradient
  88802. * @param gradient gets or sets the gradient value (between 0 and 1)
  88803. * @param color1 gets or sets first associated color
  88804. * @param color2 gets or sets first second color
  88805. */
  88806. constructor(
  88807. /**
  88808. * Gets or sets the gradient value (between 0 and 1)
  88809. */
  88810. gradient: number,
  88811. /**
  88812. * Gets or sets first associated color
  88813. */
  88814. color1: Color4,
  88815. /**
  88816. * Gets or sets second associated color
  88817. */
  88818. color2?: Color4 | undefined);
  88819. /**
  88820. * Will get a color picked randomly between color1 and color2.
  88821. * If color2 is undefined then color1 will be used
  88822. * @param result defines the target Color4 to store the result in
  88823. */
  88824. getColorToRef(result: Color4): void;
  88825. }
  88826. /** Class used to store color 3 gradient */
  88827. export class Color3Gradient implements IValueGradient {
  88828. /**
  88829. * Gets or sets the gradient value (between 0 and 1)
  88830. */
  88831. gradient: number;
  88832. /**
  88833. * Gets or sets the associated color
  88834. */
  88835. color: Color3;
  88836. /**
  88837. * Creates a new color3 gradient
  88838. * @param gradient gets or sets the gradient value (between 0 and 1)
  88839. * @param color gets or sets associated color
  88840. */
  88841. constructor(
  88842. /**
  88843. * Gets or sets the gradient value (between 0 and 1)
  88844. */
  88845. gradient: number,
  88846. /**
  88847. * Gets or sets the associated color
  88848. */
  88849. color: Color3);
  88850. }
  88851. /** Class used to store factor gradient */
  88852. export class FactorGradient implements IValueGradient {
  88853. /**
  88854. * Gets or sets the gradient value (between 0 and 1)
  88855. */
  88856. gradient: number;
  88857. /**
  88858. * Gets or sets first associated factor
  88859. */
  88860. factor1: number;
  88861. /**
  88862. * Gets or sets second associated factor
  88863. */
  88864. factor2?: number | undefined;
  88865. /**
  88866. * Creates a new factor gradient
  88867. * @param gradient gets or sets the gradient value (between 0 and 1)
  88868. * @param factor1 gets or sets first associated factor
  88869. * @param factor2 gets or sets second associated factor
  88870. */
  88871. constructor(
  88872. /**
  88873. * Gets or sets the gradient value (between 0 and 1)
  88874. */
  88875. gradient: number,
  88876. /**
  88877. * Gets or sets first associated factor
  88878. */
  88879. factor1: number,
  88880. /**
  88881. * Gets or sets second associated factor
  88882. */
  88883. factor2?: number | undefined);
  88884. /**
  88885. * Will get a number picked randomly between factor1 and factor2.
  88886. * If factor2 is undefined then factor1 will be used
  88887. * @returns the picked number
  88888. */
  88889. getFactor(): number;
  88890. }
  88891. /**
  88892. * Helper used to simplify some generic gradient tasks
  88893. */
  88894. export class GradientHelper {
  88895. /**
  88896. * Gets the current gradient from an array of IValueGradient
  88897. * @param ratio defines the current ratio to get
  88898. * @param gradients defines the array of IValueGradient
  88899. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  88900. */
  88901. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  88902. }
  88903. }
  88904. declare module BABYLON {
  88905. interface ThinEngine {
  88906. /**
  88907. * Creates a raw texture
  88908. * @param data defines the data to store in the texture
  88909. * @param width defines the width of the texture
  88910. * @param height defines the height of the texture
  88911. * @param format defines the format of the data
  88912. * @param generateMipMaps defines if the engine should generate the mip levels
  88913. * @param invertY defines if data must be stored with Y axis inverted
  88914. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88915. * @param compression defines the compression used (null by default)
  88916. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88917. * @returns the raw texture inside an InternalTexture
  88918. */
  88919. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  88920. /**
  88921. * Update a raw texture
  88922. * @param texture defines the texture to update
  88923. * @param data defines the data to store in the texture
  88924. * @param format defines the format of the data
  88925. * @param invertY defines if data must be stored with Y axis inverted
  88926. */
  88927. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  88928. /**
  88929. * Update a raw texture
  88930. * @param texture defines the texture to update
  88931. * @param data defines the data to store in the texture
  88932. * @param format defines the format of the data
  88933. * @param invertY defines if data must be stored with Y axis inverted
  88934. * @param compression defines the compression used (null by default)
  88935. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88936. */
  88937. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  88938. /**
  88939. * Creates a new raw cube texture
  88940. * @param data defines the array of data to use to create each face
  88941. * @param size defines the size of the textures
  88942. * @param format defines the format of the data
  88943. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88944. * @param generateMipMaps defines if the engine should generate the mip levels
  88945. * @param invertY defines if data must be stored with Y axis inverted
  88946. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88947. * @param compression defines the compression used (null by default)
  88948. * @returns the cube texture as an InternalTexture
  88949. */
  88950. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  88951. /**
  88952. * Update a raw cube texture
  88953. * @param texture defines the texture to udpdate
  88954. * @param data defines the data to store
  88955. * @param format defines the data format
  88956. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88957. * @param invertY defines if data must be stored with Y axis inverted
  88958. */
  88959. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  88960. /**
  88961. * Update a raw cube texture
  88962. * @param texture defines the texture to udpdate
  88963. * @param data defines the data to store
  88964. * @param format defines the data format
  88965. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88966. * @param invertY defines if data must be stored with Y axis inverted
  88967. * @param compression defines the compression used (null by default)
  88968. */
  88969. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  88970. /**
  88971. * Update a raw cube texture
  88972. * @param texture defines the texture to udpdate
  88973. * @param data defines the data to store
  88974. * @param format defines the data format
  88975. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88976. * @param invertY defines if data must be stored with Y axis inverted
  88977. * @param compression defines the compression used (null by default)
  88978. * @param level defines which level of the texture to update
  88979. */
  88980. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  88981. /**
  88982. * Creates a new raw cube texture from a specified url
  88983. * @param url defines the url where the data is located
  88984. * @param scene defines the current scene
  88985. * @param size defines the size of the textures
  88986. * @param format defines the format of the data
  88987. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88988. * @param noMipmap defines if the engine should avoid generating the mip levels
  88989. * @param callback defines a callback used to extract texture data from loaded data
  88990. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88991. * @param onLoad defines a callback called when texture is loaded
  88992. * @param onError defines a callback called if there is an error
  88993. * @returns the cube texture as an InternalTexture
  88994. */
  88995. 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;
  88996. /**
  88997. * Creates a new raw cube texture from a specified url
  88998. * @param url defines the url where the data is located
  88999. * @param scene defines the current scene
  89000. * @param size defines the size of the textures
  89001. * @param format defines the format of the data
  89002. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89003. * @param noMipmap defines if the engine should avoid generating the mip levels
  89004. * @param callback defines a callback used to extract texture data from loaded data
  89005. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89006. * @param onLoad defines a callback called when texture is loaded
  89007. * @param onError defines a callback called if there is an error
  89008. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89009. * @param invertY defines if data must be stored with Y axis inverted
  89010. * @returns the cube texture as an InternalTexture
  89011. */
  89012. 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;
  89013. /**
  89014. * Creates a new raw 3D texture
  89015. * @param data defines the data used to create the texture
  89016. * @param width defines the width of the texture
  89017. * @param height defines the height of the texture
  89018. * @param depth defines the depth of the texture
  89019. * @param format defines the format of the texture
  89020. * @param generateMipMaps defines if the engine must generate mip levels
  89021. * @param invertY defines if data must be stored with Y axis inverted
  89022. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89023. * @param compression defines the compressed used (can be null)
  89024. * @param textureType defines the compressed used (can be null)
  89025. * @returns a new raw 3D texture (stored in an InternalTexture)
  89026. */
  89027. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89028. /**
  89029. * Update a raw 3D texture
  89030. * @param texture defines the texture to update
  89031. * @param data defines the data to store
  89032. * @param format defines the data format
  89033. * @param invertY defines if data must be stored with Y axis inverted
  89034. */
  89035. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89036. /**
  89037. * Update a raw 3D texture
  89038. * @param texture defines the texture to update
  89039. * @param data defines the data to store
  89040. * @param format defines the data format
  89041. * @param invertY defines if data must be stored with Y axis inverted
  89042. * @param compression defines the used compression (can be null)
  89043. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89044. */
  89045. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89046. /**
  89047. * Creates a new raw 2D array texture
  89048. * @param data defines the data used to create the texture
  89049. * @param width defines the width of the texture
  89050. * @param height defines the height of the texture
  89051. * @param depth defines the number of layers of the texture
  89052. * @param format defines the format of the texture
  89053. * @param generateMipMaps defines if the engine must generate mip levels
  89054. * @param invertY defines if data must be stored with Y axis inverted
  89055. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89056. * @param compression defines the compressed used (can be null)
  89057. * @param textureType defines the compressed used (can be null)
  89058. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89059. */
  89060. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89061. /**
  89062. * Update a raw 2D array texture
  89063. * @param texture defines the texture to update
  89064. * @param data defines the data to store
  89065. * @param format defines the data format
  89066. * @param invertY defines if data must be stored with Y axis inverted
  89067. */
  89068. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89069. /**
  89070. * Update a raw 2D array texture
  89071. * @param texture defines the texture to update
  89072. * @param data defines the data to store
  89073. * @param format defines the data format
  89074. * @param invertY defines if data must be stored with Y axis inverted
  89075. * @param compression defines the used compression (can be null)
  89076. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89077. */
  89078. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89079. }
  89080. }
  89081. declare module BABYLON {
  89082. /**
  89083. * Raw texture can help creating a texture directly from an array of data.
  89084. * This can be super useful if you either get the data from an uncompressed source or
  89085. * if you wish to create your texture pixel by pixel.
  89086. */
  89087. export class RawTexture extends Texture {
  89088. /**
  89089. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89090. */
  89091. format: number;
  89092. /**
  89093. * Instantiates a new RawTexture.
  89094. * Raw texture can help creating a texture directly from an array of data.
  89095. * This can be super useful if you either get the data from an uncompressed source or
  89096. * if you wish to create your texture pixel by pixel.
  89097. * @param data define the array of data to use to create the texture
  89098. * @param width define the width of the texture
  89099. * @param height define the height of the texture
  89100. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89101. * @param scene define the scene the texture belongs to
  89102. * @param generateMipMaps define whether mip maps should be generated or not
  89103. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89104. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89105. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89106. */
  89107. constructor(data: ArrayBufferView, width: number, height: number,
  89108. /**
  89109. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89110. */
  89111. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89112. /**
  89113. * Updates the texture underlying data.
  89114. * @param data Define the new data of the texture
  89115. */
  89116. update(data: ArrayBufferView): void;
  89117. /**
  89118. * Creates a luminance texture from some data.
  89119. * @param data Define the texture data
  89120. * @param width Define the width of the texture
  89121. * @param height Define the height of the texture
  89122. * @param scene Define the scene the texture belongs to
  89123. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89124. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89125. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89126. * @returns the luminance texture
  89127. */
  89128. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89129. /**
  89130. * Creates a luminance alpha texture from some data.
  89131. * @param data Define the texture data
  89132. * @param width Define the width of the texture
  89133. * @param height Define the height of the texture
  89134. * @param scene Define the scene the texture belongs to
  89135. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89136. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89137. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89138. * @returns the luminance alpha texture
  89139. */
  89140. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89141. /**
  89142. * Creates an alpha texture from some data.
  89143. * @param data Define the texture data
  89144. * @param width Define the width of the texture
  89145. * @param height Define the height of the texture
  89146. * @param scene Define the scene the texture belongs to
  89147. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89148. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89149. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89150. * @returns the alpha texture
  89151. */
  89152. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89153. /**
  89154. * Creates a RGB texture from some data.
  89155. * @param data Define the texture data
  89156. * @param width Define the width of the texture
  89157. * @param height Define the height of the texture
  89158. * @param scene Define the scene the texture belongs to
  89159. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89160. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89161. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89162. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89163. * @returns the RGB alpha texture
  89164. */
  89165. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89166. /**
  89167. * Creates a RGBA texture from some data.
  89168. * @param data Define the texture data
  89169. * @param width Define the width of the texture
  89170. * @param height Define the height of the texture
  89171. * @param scene Define the scene the texture belongs to
  89172. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89173. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89174. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89175. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89176. * @returns the RGBA texture
  89177. */
  89178. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89179. /**
  89180. * Creates a R texture from some data.
  89181. * @param data Define the texture data
  89182. * @param width Define the width of the texture
  89183. * @param height Define the height of the texture
  89184. * @param scene Define the scene the texture belongs to
  89185. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89186. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89187. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89188. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89189. * @returns the R texture
  89190. */
  89191. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89192. }
  89193. }
  89194. declare module BABYLON {
  89195. interface AbstractScene {
  89196. /**
  89197. * The list of procedural textures added to the scene
  89198. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89199. */
  89200. proceduralTextures: Array<ProceduralTexture>;
  89201. }
  89202. /**
  89203. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89204. * in a given scene.
  89205. */
  89206. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89207. /**
  89208. * The component name helpfull to identify the component in the list of scene components.
  89209. */
  89210. readonly name: string;
  89211. /**
  89212. * The scene the component belongs to.
  89213. */
  89214. scene: Scene;
  89215. /**
  89216. * Creates a new instance of the component for the given scene
  89217. * @param scene Defines the scene to register the component in
  89218. */
  89219. constructor(scene: Scene);
  89220. /**
  89221. * Registers the component in a given scene
  89222. */
  89223. register(): void;
  89224. /**
  89225. * Rebuilds the elements related to this component in case of
  89226. * context lost for instance.
  89227. */
  89228. rebuild(): void;
  89229. /**
  89230. * Disposes the component and the associated ressources.
  89231. */
  89232. dispose(): void;
  89233. private _beforeClear;
  89234. }
  89235. }
  89236. declare module BABYLON {
  89237. interface ThinEngine {
  89238. /**
  89239. * Creates a new render target cube texture
  89240. * @param size defines the size of the texture
  89241. * @param options defines the options used to create the texture
  89242. * @returns a new render target cube texture stored in an InternalTexture
  89243. */
  89244. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89245. }
  89246. }
  89247. declare module BABYLON {
  89248. /** @hidden */
  89249. export var proceduralVertexShader: {
  89250. name: string;
  89251. shader: string;
  89252. };
  89253. }
  89254. declare module BABYLON {
  89255. /**
  89256. * 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.
  89257. * This is the base class of any Procedural texture and contains most of the shareable code.
  89258. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89259. */
  89260. export class ProceduralTexture extends Texture {
  89261. isCube: boolean;
  89262. /**
  89263. * Define if the texture is enabled or not (disabled texture will not render)
  89264. */
  89265. isEnabled: boolean;
  89266. /**
  89267. * Define if the texture must be cleared before rendering (default is true)
  89268. */
  89269. autoClear: boolean;
  89270. /**
  89271. * Callback called when the texture is generated
  89272. */
  89273. onGenerated: () => void;
  89274. /**
  89275. * Event raised when the texture is generated
  89276. */
  89277. onGeneratedObservable: Observable<ProceduralTexture>;
  89278. /** @hidden */
  89279. _generateMipMaps: boolean;
  89280. /** @hidden **/
  89281. _effect: Effect;
  89282. /** @hidden */
  89283. _textures: {
  89284. [key: string]: Texture;
  89285. };
  89286. /** @hidden */
  89287. protected _fallbackTexture: Nullable<Texture>;
  89288. private _size;
  89289. private _currentRefreshId;
  89290. private _frameId;
  89291. private _refreshRate;
  89292. private _vertexBuffers;
  89293. private _indexBuffer;
  89294. private _uniforms;
  89295. private _samplers;
  89296. private _fragment;
  89297. private _floats;
  89298. private _ints;
  89299. private _floatsArrays;
  89300. private _colors3;
  89301. private _colors4;
  89302. private _vectors2;
  89303. private _vectors3;
  89304. private _matrices;
  89305. private _fallbackTextureUsed;
  89306. private _fullEngine;
  89307. private _cachedDefines;
  89308. private _contentUpdateId;
  89309. private _contentData;
  89310. /**
  89311. * Instantiates a new procedural texture.
  89312. * 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.
  89313. * This is the base class of any Procedural texture and contains most of the shareable code.
  89314. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89315. * @param name Define the name of the texture
  89316. * @param size Define the size of the texture to create
  89317. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89318. * @param scene Define the scene the texture belongs to
  89319. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89320. * @param generateMipMaps Define if the texture should creates mip maps or not
  89321. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89322. */
  89323. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89324. /**
  89325. * The effect that is created when initializing the post process.
  89326. * @returns The created effect corresponding the the postprocess.
  89327. */
  89328. getEffect(): Effect;
  89329. /**
  89330. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  89331. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  89332. */
  89333. getContent(): Nullable<ArrayBufferView>;
  89334. private _createIndexBuffer;
  89335. /** @hidden */
  89336. _rebuild(): void;
  89337. /**
  89338. * Resets the texture in order to recreate its associated resources.
  89339. * This can be called in case of context loss
  89340. */
  89341. reset(): void;
  89342. protected _getDefines(): string;
  89343. /**
  89344. * Is the texture ready to be used ? (rendered at least once)
  89345. * @returns true if ready, otherwise, false.
  89346. */
  89347. isReady(): boolean;
  89348. /**
  89349. * Resets the refresh counter of the texture and start bak from scratch.
  89350. * Could be useful to regenerate the texture if it is setup to render only once.
  89351. */
  89352. resetRefreshCounter(): void;
  89353. /**
  89354. * Set the fragment shader to use in order to render the texture.
  89355. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  89356. */
  89357. setFragment(fragment: any): void;
  89358. /**
  89359. * Define the refresh rate of the texture or the rendering frequency.
  89360. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  89361. */
  89362. get refreshRate(): number;
  89363. set refreshRate(value: number);
  89364. /** @hidden */
  89365. _shouldRender(): boolean;
  89366. /**
  89367. * Get the size the texture is rendering at.
  89368. * @returns the size (texture is always squared)
  89369. */
  89370. getRenderSize(): number;
  89371. /**
  89372. * Resize the texture to new value.
  89373. * @param size Define the new size the texture should have
  89374. * @param generateMipMaps Define whether the new texture should create mip maps
  89375. */
  89376. resize(size: number, generateMipMaps: boolean): void;
  89377. private _checkUniform;
  89378. /**
  89379. * Set a texture in the shader program used to render.
  89380. * @param name Define the name of the uniform samplers as defined in the shader
  89381. * @param texture Define the texture to bind to this sampler
  89382. * @return the texture itself allowing "fluent" like uniform updates
  89383. */
  89384. setTexture(name: string, texture: Texture): ProceduralTexture;
  89385. /**
  89386. * Set a float in the shader.
  89387. * @param name Define the name of the uniform as defined in the shader
  89388. * @param value Define the value to give to the uniform
  89389. * @return the texture itself allowing "fluent" like uniform updates
  89390. */
  89391. setFloat(name: string, value: number): ProceduralTexture;
  89392. /**
  89393. * Set a int in the shader.
  89394. * @param name Define the name of the uniform as defined in the shader
  89395. * @param value Define the value to give to the uniform
  89396. * @return the texture itself allowing "fluent" like uniform updates
  89397. */
  89398. setInt(name: string, value: number): ProceduralTexture;
  89399. /**
  89400. * Set an array of floats in the shader.
  89401. * @param name Define the name of the uniform as defined in the shader
  89402. * @param value Define the value to give to the uniform
  89403. * @return the texture itself allowing "fluent" like uniform updates
  89404. */
  89405. setFloats(name: string, value: number[]): ProceduralTexture;
  89406. /**
  89407. * Set a vec3 in the shader from a Color3.
  89408. * @param name Define the name of the uniform as defined in the shader
  89409. * @param value Define the value to give to the uniform
  89410. * @return the texture itself allowing "fluent" like uniform updates
  89411. */
  89412. setColor3(name: string, value: Color3): ProceduralTexture;
  89413. /**
  89414. * Set a vec4 in the shader from a Color4.
  89415. * @param name Define the name of the uniform as defined in the shader
  89416. * @param value Define the value to give to the uniform
  89417. * @return the texture itself allowing "fluent" like uniform updates
  89418. */
  89419. setColor4(name: string, value: Color4): ProceduralTexture;
  89420. /**
  89421. * Set a vec2 in the shader from a Vector2.
  89422. * @param name Define the name of the uniform as defined in the shader
  89423. * @param value Define the value to give to the uniform
  89424. * @return the texture itself allowing "fluent" like uniform updates
  89425. */
  89426. setVector2(name: string, value: Vector2): ProceduralTexture;
  89427. /**
  89428. * Set a vec3 in the shader from a Vector3.
  89429. * @param name Define the name of the uniform as defined in the shader
  89430. * @param value Define the value to give to the uniform
  89431. * @return the texture itself allowing "fluent" like uniform updates
  89432. */
  89433. setVector3(name: string, value: Vector3): ProceduralTexture;
  89434. /**
  89435. * Set a mat4 in the shader from a MAtrix.
  89436. * @param name Define the name of the uniform as defined in the shader
  89437. * @param value Define the value to give to the uniform
  89438. * @return the texture itself allowing "fluent" like uniform updates
  89439. */
  89440. setMatrix(name: string, value: Matrix): ProceduralTexture;
  89441. /**
  89442. * Render the texture to its associated render target.
  89443. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  89444. */
  89445. render(useCameraPostProcess?: boolean): void;
  89446. /**
  89447. * Clone the texture.
  89448. * @returns the cloned texture
  89449. */
  89450. clone(): ProceduralTexture;
  89451. /**
  89452. * Dispose the texture and release its asoociated resources.
  89453. */
  89454. dispose(): void;
  89455. }
  89456. }
  89457. declare module BABYLON {
  89458. /**
  89459. * This represents the base class for particle system in Babylon.
  89460. * 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.
  89461. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  89462. * @example https://doc.babylonjs.com/babylon101/particles
  89463. */
  89464. export class BaseParticleSystem {
  89465. /**
  89466. * Source color is added to the destination color without alpha affecting the result
  89467. */
  89468. static BLENDMODE_ONEONE: number;
  89469. /**
  89470. * Blend current color and particle color using particle’s alpha
  89471. */
  89472. static BLENDMODE_STANDARD: number;
  89473. /**
  89474. * Add current color and particle color multiplied by particle’s alpha
  89475. */
  89476. static BLENDMODE_ADD: number;
  89477. /**
  89478. * Multiply current color with particle color
  89479. */
  89480. static BLENDMODE_MULTIPLY: number;
  89481. /**
  89482. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  89483. */
  89484. static BLENDMODE_MULTIPLYADD: number;
  89485. /**
  89486. * List of animations used by the particle system.
  89487. */
  89488. animations: Animation[];
  89489. /**
  89490. * Gets or sets the unique id of the particle system
  89491. */
  89492. uniqueId: number;
  89493. /**
  89494. * The id of the Particle system.
  89495. */
  89496. id: string;
  89497. /**
  89498. * The friendly name of the Particle system.
  89499. */
  89500. name: string;
  89501. /**
  89502. * Snippet ID if the particle system was created from the snippet server
  89503. */
  89504. snippetId: string;
  89505. /**
  89506. * The rendering group used by the Particle system to chose when to render.
  89507. */
  89508. renderingGroupId: number;
  89509. /**
  89510. * The emitter represents the Mesh or position we are attaching the particle system to.
  89511. */
  89512. emitter: Nullable<AbstractMesh | Vector3>;
  89513. /**
  89514. * The maximum number of particles to emit per frame
  89515. */
  89516. emitRate: number;
  89517. /**
  89518. * If you want to launch only a few particles at once, that can be done, as well.
  89519. */
  89520. manualEmitCount: number;
  89521. /**
  89522. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  89523. */
  89524. updateSpeed: number;
  89525. /**
  89526. * The amount of time the particle system is running (depends of the overall update speed).
  89527. */
  89528. targetStopDuration: number;
  89529. /**
  89530. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  89531. */
  89532. disposeOnStop: boolean;
  89533. /**
  89534. * Minimum power of emitting particles.
  89535. */
  89536. minEmitPower: number;
  89537. /**
  89538. * Maximum power of emitting particles.
  89539. */
  89540. maxEmitPower: number;
  89541. /**
  89542. * Minimum life time of emitting particles.
  89543. */
  89544. minLifeTime: number;
  89545. /**
  89546. * Maximum life time of emitting particles.
  89547. */
  89548. maxLifeTime: number;
  89549. /**
  89550. * Minimum Size of emitting particles.
  89551. */
  89552. minSize: number;
  89553. /**
  89554. * Maximum Size of emitting particles.
  89555. */
  89556. maxSize: number;
  89557. /**
  89558. * Minimum scale of emitting particles on X axis.
  89559. */
  89560. minScaleX: number;
  89561. /**
  89562. * Maximum scale of emitting particles on X axis.
  89563. */
  89564. maxScaleX: number;
  89565. /**
  89566. * Minimum scale of emitting particles on Y axis.
  89567. */
  89568. minScaleY: number;
  89569. /**
  89570. * Maximum scale of emitting particles on Y axis.
  89571. */
  89572. maxScaleY: number;
  89573. /**
  89574. * Gets or sets the minimal initial rotation in radians.
  89575. */
  89576. minInitialRotation: number;
  89577. /**
  89578. * Gets or sets the maximal initial rotation in radians.
  89579. */
  89580. maxInitialRotation: number;
  89581. /**
  89582. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  89583. */
  89584. minAngularSpeed: number;
  89585. /**
  89586. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  89587. */
  89588. maxAngularSpeed: number;
  89589. /**
  89590. * The texture used to render each particle. (this can be a spritesheet)
  89591. */
  89592. particleTexture: Nullable<Texture>;
  89593. /**
  89594. * The layer mask we are rendering the particles through.
  89595. */
  89596. layerMask: number;
  89597. /**
  89598. * This can help using your own shader to render the particle system.
  89599. * The according effect will be created
  89600. */
  89601. customShader: any;
  89602. /**
  89603. * By default particle system starts as soon as they are created. This prevents the
  89604. * automatic start to happen and let you decide when to start emitting particles.
  89605. */
  89606. preventAutoStart: boolean;
  89607. private _noiseTexture;
  89608. /**
  89609. * Gets or sets a texture used to add random noise to particle positions
  89610. */
  89611. get noiseTexture(): Nullable<ProceduralTexture>;
  89612. set noiseTexture(value: Nullable<ProceduralTexture>);
  89613. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  89614. noiseStrength: Vector3;
  89615. /**
  89616. * Callback triggered when the particle animation is ending.
  89617. */
  89618. onAnimationEnd: Nullable<() => void>;
  89619. /**
  89620. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  89621. */
  89622. blendMode: number;
  89623. /**
  89624. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  89625. * to override the particles.
  89626. */
  89627. forceDepthWrite: boolean;
  89628. /** 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 */
  89629. preWarmCycles: number;
  89630. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  89631. preWarmStepOffset: number;
  89632. /**
  89633. * 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)
  89634. */
  89635. spriteCellChangeSpeed: number;
  89636. /**
  89637. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  89638. */
  89639. startSpriteCellID: number;
  89640. /**
  89641. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  89642. */
  89643. endSpriteCellID: number;
  89644. /**
  89645. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  89646. */
  89647. spriteCellWidth: number;
  89648. /**
  89649. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  89650. */
  89651. spriteCellHeight: number;
  89652. /**
  89653. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  89654. */
  89655. spriteRandomStartCell: boolean;
  89656. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  89657. translationPivot: Vector2;
  89658. /** @hidden */
  89659. protected _isAnimationSheetEnabled: boolean;
  89660. /**
  89661. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  89662. */
  89663. beginAnimationOnStart: boolean;
  89664. /**
  89665. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  89666. */
  89667. beginAnimationFrom: number;
  89668. /**
  89669. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  89670. */
  89671. beginAnimationTo: number;
  89672. /**
  89673. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  89674. */
  89675. beginAnimationLoop: boolean;
  89676. /**
  89677. * Gets or sets a world offset applied to all particles
  89678. */
  89679. worldOffset: Vector3;
  89680. /**
  89681. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  89682. */
  89683. get isAnimationSheetEnabled(): boolean;
  89684. set isAnimationSheetEnabled(value: boolean);
  89685. /**
  89686. * Get hosting scene
  89687. * @returns the scene
  89688. */
  89689. getScene(): Scene;
  89690. /**
  89691. * You can use gravity if you want to give an orientation to your particles.
  89692. */
  89693. gravity: Vector3;
  89694. protected _colorGradients: Nullable<Array<ColorGradient>>;
  89695. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  89696. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  89697. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  89698. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  89699. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  89700. protected _dragGradients: Nullable<Array<FactorGradient>>;
  89701. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  89702. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  89703. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  89704. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  89705. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  89706. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  89707. /**
  89708. * Defines the delay in milliseconds before starting the system (0 by default)
  89709. */
  89710. startDelay: number;
  89711. /**
  89712. * Gets the current list of drag gradients.
  89713. * You must use addDragGradient and removeDragGradient to udpate this list
  89714. * @returns the list of drag gradients
  89715. */
  89716. getDragGradients(): Nullable<Array<FactorGradient>>;
  89717. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  89718. limitVelocityDamping: number;
  89719. /**
  89720. * Gets the current list of limit velocity gradients.
  89721. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  89722. * @returns the list of limit velocity gradients
  89723. */
  89724. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  89725. /**
  89726. * Gets the current list of color gradients.
  89727. * You must use addColorGradient and removeColorGradient to udpate this list
  89728. * @returns the list of color gradients
  89729. */
  89730. getColorGradients(): Nullable<Array<ColorGradient>>;
  89731. /**
  89732. * Gets the current list of size gradients.
  89733. * You must use addSizeGradient and removeSizeGradient to udpate this list
  89734. * @returns the list of size gradients
  89735. */
  89736. getSizeGradients(): Nullable<Array<FactorGradient>>;
  89737. /**
  89738. * Gets the current list of color remap gradients.
  89739. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  89740. * @returns the list of color remap gradients
  89741. */
  89742. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  89743. /**
  89744. * Gets the current list of alpha remap gradients.
  89745. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  89746. * @returns the list of alpha remap gradients
  89747. */
  89748. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  89749. /**
  89750. * Gets the current list of life time gradients.
  89751. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  89752. * @returns the list of life time gradients
  89753. */
  89754. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  89755. /**
  89756. * Gets the current list of angular speed gradients.
  89757. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  89758. * @returns the list of angular speed gradients
  89759. */
  89760. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  89761. /**
  89762. * Gets the current list of velocity gradients.
  89763. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  89764. * @returns the list of velocity gradients
  89765. */
  89766. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  89767. /**
  89768. * Gets the current list of start size gradients.
  89769. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  89770. * @returns the list of start size gradients
  89771. */
  89772. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  89773. /**
  89774. * Gets the current list of emit rate gradients.
  89775. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  89776. * @returns the list of emit rate gradients
  89777. */
  89778. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  89779. /**
  89780. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89781. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89782. */
  89783. get direction1(): Vector3;
  89784. set direction1(value: Vector3);
  89785. /**
  89786. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89787. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89788. */
  89789. get direction2(): Vector3;
  89790. set direction2(value: Vector3);
  89791. /**
  89792. * 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.
  89793. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89794. */
  89795. get minEmitBox(): Vector3;
  89796. set minEmitBox(value: Vector3);
  89797. /**
  89798. * 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.
  89799. * This only works when particleEmitterTyps is a BoxParticleEmitter
  89800. */
  89801. get maxEmitBox(): Vector3;
  89802. set maxEmitBox(value: Vector3);
  89803. /**
  89804. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89805. */
  89806. color1: Color4;
  89807. /**
  89808. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  89809. */
  89810. color2: Color4;
  89811. /**
  89812. * Color the particle will have at the end of its lifetime
  89813. */
  89814. colorDead: Color4;
  89815. /**
  89816. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  89817. */
  89818. textureMask: Color4;
  89819. /**
  89820. * The particle emitter type defines the emitter used by the particle system.
  89821. * It can be for example box, sphere, or cone...
  89822. */
  89823. particleEmitterType: IParticleEmitterType;
  89824. /** @hidden */
  89825. _isSubEmitter: boolean;
  89826. /**
  89827. * Gets or sets the billboard mode to use when isBillboardBased = true.
  89828. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  89829. */
  89830. billboardMode: number;
  89831. protected _isBillboardBased: boolean;
  89832. /**
  89833. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  89834. */
  89835. get isBillboardBased(): boolean;
  89836. set isBillboardBased(value: boolean);
  89837. /**
  89838. * The scene the particle system belongs to.
  89839. */
  89840. protected _scene: Scene;
  89841. /**
  89842. * Local cache of defines for image processing.
  89843. */
  89844. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  89845. /**
  89846. * Default configuration related to image processing available in the standard Material.
  89847. */
  89848. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89849. /**
  89850. * Gets the image processing configuration used either in this material.
  89851. */
  89852. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  89853. /**
  89854. * Sets the Default image processing configuration used either in the this material.
  89855. *
  89856. * If sets to null, the scene one is in use.
  89857. */
  89858. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  89859. /**
  89860. * Attaches a new image processing configuration to the Standard Material.
  89861. * @param configuration
  89862. */
  89863. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  89864. /** @hidden */
  89865. protected _reset(): void;
  89866. /** @hidden */
  89867. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  89868. /**
  89869. * Instantiates a particle system.
  89870. * 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.
  89871. * @param name The name of the particle system
  89872. */
  89873. constructor(name: string);
  89874. /**
  89875. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  89876. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89877. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89878. * @returns the emitter
  89879. */
  89880. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  89881. /**
  89882. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  89883. * @param radius The radius of the hemisphere to emit from
  89884. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89885. * @returns the emitter
  89886. */
  89887. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  89888. /**
  89889. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  89890. * @param radius The radius of the sphere to emit from
  89891. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  89892. * @returns the emitter
  89893. */
  89894. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  89895. /**
  89896. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  89897. * @param radius The radius of the sphere to emit from
  89898. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  89899. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  89900. * @returns the emitter
  89901. */
  89902. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  89903. /**
  89904. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  89905. * @param radius The radius of the emission cylinder
  89906. * @param height The height of the emission cylinder
  89907. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  89908. * @param directionRandomizer How much to randomize the particle direction [0-1]
  89909. * @returns the emitter
  89910. */
  89911. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  89912. /**
  89913. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  89914. * @param radius The radius of the cylinder to emit from
  89915. * @param height The height of the emission cylinder
  89916. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89917. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  89918. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  89919. * @returns the emitter
  89920. */
  89921. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  89922. /**
  89923. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  89924. * @param radius The radius of the cone to emit from
  89925. * @param angle The base angle of the cone
  89926. * @returns the emitter
  89927. */
  89928. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  89929. /**
  89930. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  89931. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  89932. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  89933. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89934. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  89935. * @returns the emitter
  89936. */
  89937. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  89938. }
  89939. }
  89940. declare module BABYLON {
  89941. /**
  89942. * Type of sub emitter
  89943. */
  89944. export enum SubEmitterType {
  89945. /**
  89946. * Attached to the particle over it's lifetime
  89947. */
  89948. ATTACHED = 0,
  89949. /**
  89950. * Created when the particle dies
  89951. */
  89952. END = 1
  89953. }
  89954. /**
  89955. * Sub emitter class used to emit particles from an existing particle
  89956. */
  89957. export class SubEmitter {
  89958. /**
  89959. * the particle system to be used by the sub emitter
  89960. */
  89961. particleSystem: ParticleSystem;
  89962. /**
  89963. * Type of the submitter (Default: END)
  89964. */
  89965. type: SubEmitterType;
  89966. /**
  89967. * 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)
  89968. * Note: This only is supported when using an emitter of type Mesh
  89969. */
  89970. inheritDirection: boolean;
  89971. /**
  89972. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  89973. */
  89974. inheritedVelocityAmount: number;
  89975. /**
  89976. * Creates a sub emitter
  89977. * @param particleSystem the particle system to be used by the sub emitter
  89978. */
  89979. constructor(
  89980. /**
  89981. * the particle system to be used by the sub emitter
  89982. */
  89983. particleSystem: ParticleSystem);
  89984. /**
  89985. * Clones the sub emitter
  89986. * @returns the cloned sub emitter
  89987. */
  89988. clone(): SubEmitter;
  89989. /**
  89990. * Serialize current object to a JSON object
  89991. * @returns the serialized object
  89992. */
  89993. serialize(): any;
  89994. /** @hidden */
  89995. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  89996. /**
  89997. * Creates a new SubEmitter from a serialized JSON version
  89998. * @param serializationObject defines the JSON object to read from
  89999. * @param scene defines the hosting scene
  90000. * @param rootUrl defines the rootUrl for data loading
  90001. * @returns a new SubEmitter
  90002. */
  90003. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90004. /** Release associated resources */
  90005. dispose(): void;
  90006. }
  90007. }
  90008. declare module BABYLON {
  90009. /** @hidden */
  90010. export var imageProcessingDeclaration: {
  90011. name: string;
  90012. shader: string;
  90013. };
  90014. }
  90015. declare module BABYLON {
  90016. /** @hidden */
  90017. export var imageProcessingFunctions: {
  90018. name: string;
  90019. shader: string;
  90020. };
  90021. }
  90022. declare module BABYLON {
  90023. /** @hidden */
  90024. export var particlesPixelShader: {
  90025. name: string;
  90026. shader: string;
  90027. };
  90028. }
  90029. declare module BABYLON {
  90030. /** @hidden */
  90031. export var particlesVertexShader: {
  90032. name: string;
  90033. shader: string;
  90034. };
  90035. }
  90036. declare module BABYLON {
  90037. /**
  90038. * This represents a particle system in Babylon.
  90039. * 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.
  90040. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90041. * @example https://doc.babylonjs.com/babylon101/particles
  90042. */
  90043. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90044. /**
  90045. * Billboard mode will only apply to Y axis
  90046. */
  90047. static readonly BILLBOARDMODE_Y: number;
  90048. /**
  90049. * Billboard mode will apply to all axes
  90050. */
  90051. static readonly BILLBOARDMODE_ALL: number;
  90052. /**
  90053. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90054. */
  90055. static readonly BILLBOARDMODE_STRETCHED: number;
  90056. /**
  90057. * This function can be defined to provide custom update for active particles.
  90058. * This function will be called instead of regular update (age, position, color, etc.).
  90059. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90060. */
  90061. updateFunction: (particles: Particle[]) => void;
  90062. private _emitterWorldMatrix;
  90063. /**
  90064. * This function can be defined to specify initial direction for every new particle.
  90065. * It by default use the emitterType defined function
  90066. */
  90067. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90068. /**
  90069. * This function can be defined to specify initial position for every new particle.
  90070. * It by default use the emitterType defined function
  90071. */
  90072. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90073. /**
  90074. * @hidden
  90075. */
  90076. _inheritedVelocityOffset: Vector3;
  90077. /**
  90078. * An event triggered when the system is disposed
  90079. */
  90080. onDisposeObservable: Observable<IParticleSystem>;
  90081. private _onDisposeObserver;
  90082. /**
  90083. * Sets a callback that will be triggered when the system is disposed
  90084. */
  90085. set onDispose(callback: () => void);
  90086. private _particles;
  90087. private _epsilon;
  90088. private _capacity;
  90089. private _stockParticles;
  90090. private _newPartsExcess;
  90091. private _vertexData;
  90092. private _vertexBuffer;
  90093. private _vertexBuffers;
  90094. private _spriteBuffer;
  90095. private _indexBuffer;
  90096. private _effect;
  90097. private _customEffect;
  90098. private _cachedDefines;
  90099. private _scaledColorStep;
  90100. private _colorDiff;
  90101. private _scaledDirection;
  90102. private _scaledGravity;
  90103. private _currentRenderId;
  90104. private _alive;
  90105. private _useInstancing;
  90106. private _started;
  90107. private _stopped;
  90108. private _actualFrame;
  90109. private _scaledUpdateSpeed;
  90110. private _vertexBufferSize;
  90111. /** @hidden */
  90112. _currentEmitRateGradient: Nullable<FactorGradient>;
  90113. /** @hidden */
  90114. _currentEmitRate1: number;
  90115. /** @hidden */
  90116. _currentEmitRate2: number;
  90117. /** @hidden */
  90118. _currentStartSizeGradient: Nullable<FactorGradient>;
  90119. /** @hidden */
  90120. _currentStartSize1: number;
  90121. /** @hidden */
  90122. _currentStartSize2: number;
  90123. private readonly _rawTextureWidth;
  90124. private _rampGradientsTexture;
  90125. private _useRampGradients;
  90126. /** Gets or sets a boolean indicating that ramp gradients must be used
  90127. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90128. */
  90129. get useRampGradients(): boolean;
  90130. set useRampGradients(value: boolean);
  90131. /**
  90132. * 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.
  90133. * 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: [])
  90134. */
  90135. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90136. private _subEmitters;
  90137. /**
  90138. * @hidden
  90139. * If the particle systems emitter should be disposed when the particle system is disposed
  90140. */
  90141. _disposeEmitterOnDispose: boolean;
  90142. /**
  90143. * The current active Sub-systems, this property is used by the root particle system only.
  90144. */
  90145. activeSubSystems: Array<ParticleSystem>;
  90146. /**
  90147. * Specifies if the particles are updated in emitter local space or world space
  90148. */
  90149. isLocal: boolean;
  90150. private _rootParticleSystem;
  90151. /**
  90152. * Gets the current list of active particles
  90153. */
  90154. get particles(): Particle[];
  90155. /**
  90156. * Gets the number of particles active at the same time.
  90157. * @returns The number of active particles.
  90158. */
  90159. getActiveCount(): number;
  90160. /**
  90161. * Returns the string "ParticleSystem"
  90162. * @returns a string containing the class name
  90163. */
  90164. getClassName(): string;
  90165. /**
  90166. * Gets a boolean indicating that the system is stopping
  90167. * @returns true if the system is currently stopping
  90168. */
  90169. isStopping(): boolean;
  90170. /**
  90171. * Gets the custom effect used to render the particles
  90172. * @param blendMode Blend mode for which the effect should be retrieved
  90173. * @returns The effect
  90174. */
  90175. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90176. /**
  90177. * Sets the custom effect used to render the particles
  90178. * @param effect The effect to set
  90179. * @param blendMode Blend mode for which the effect should be set
  90180. */
  90181. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90182. /** @hidden */
  90183. private _onBeforeDrawParticlesObservable;
  90184. /**
  90185. * Observable that will be called just before the particles are drawn
  90186. */
  90187. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90188. /**
  90189. * Gets the name of the particle vertex shader
  90190. */
  90191. get vertexShaderName(): string;
  90192. /**
  90193. * Instantiates a particle system.
  90194. * 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.
  90195. * @param name The name of the particle system
  90196. * @param capacity The max number of particles alive at the same time
  90197. * @param scene The scene the particle system belongs to
  90198. * @param customEffect a custom effect used to change the way particles are rendered by default
  90199. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90200. * @param epsilon Offset used to render the particles
  90201. */
  90202. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90203. private _addFactorGradient;
  90204. private _removeFactorGradient;
  90205. /**
  90206. * Adds a new life time gradient
  90207. * @param gradient defines the gradient to use (between 0 and 1)
  90208. * @param factor defines the life time factor to affect to the specified gradient
  90209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90210. * @returns the current particle system
  90211. */
  90212. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90213. /**
  90214. * Remove a specific life time gradient
  90215. * @param gradient defines the gradient to remove
  90216. * @returns the current particle system
  90217. */
  90218. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90219. /**
  90220. * Adds a new size gradient
  90221. * @param gradient defines the gradient to use (between 0 and 1)
  90222. * @param factor defines the size factor to affect to the specified gradient
  90223. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90224. * @returns the current particle system
  90225. */
  90226. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90227. /**
  90228. * Remove a specific size gradient
  90229. * @param gradient defines the gradient to remove
  90230. * @returns the current particle system
  90231. */
  90232. removeSizeGradient(gradient: number): IParticleSystem;
  90233. /**
  90234. * Adds a new color remap gradient
  90235. * @param gradient defines the gradient to use (between 0 and 1)
  90236. * @param min defines the color remap minimal range
  90237. * @param max defines the color remap maximal range
  90238. * @returns the current particle system
  90239. */
  90240. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90241. /**
  90242. * Remove a specific color remap gradient
  90243. * @param gradient defines the gradient to remove
  90244. * @returns the current particle system
  90245. */
  90246. removeColorRemapGradient(gradient: number): IParticleSystem;
  90247. /**
  90248. * Adds a new alpha remap gradient
  90249. * @param gradient defines the gradient to use (between 0 and 1)
  90250. * @param min defines the alpha remap minimal range
  90251. * @param max defines the alpha remap maximal range
  90252. * @returns the current particle system
  90253. */
  90254. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90255. /**
  90256. * Remove a specific alpha remap gradient
  90257. * @param gradient defines the gradient to remove
  90258. * @returns the current particle system
  90259. */
  90260. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90261. /**
  90262. * Adds a new angular speed gradient
  90263. * @param gradient defines the gradient to use (between 0 and 1)
  90264. * @param factor defines the angular speed to affect to the specified gradient
  90265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90266. * @returns the current particle system
  90267. */
  90268. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90269. /**
  90270. * Remove a specific angular speed gradient
  90271. * @param gradient defines the gradient to remove
  90272. * @returns the current particle system
  90273. */
  90274. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90275. /**
  90276. * Adds a new velocity gradient
  90277. * @param gradient defines the gradient to use (between 0 and 1)
  90278. * @param factor defines the velocity to affect to the specified gradient
  90279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90280. * @returns the current particle system
  90281. */
  90282. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90283. /**
  90284. * Remove a specific velocity gradient
  90285. * @param gradient defines the gradient to remove
  90286. * @returns the current particle system
  90287. */
  90288. removeVelocityGradient(gradient: number): IParticleSystem;
  90289. /**
  90290. * Adds a new limit velocity gradient
  90291. * @param gradient defines the gradient to use (between 0 and 1)
  90292. * @param factor defines the limit velocity value to affect to the specified gradient
  90293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90294. * @returns the current particle system
  90295. */
  90296. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90297. /**
  90298. * Remove a specific limit velocity gradient
  90299. * @param gradient defines the gradient to remove
  90300. * @returns the current particle system
  90301. */
  90302. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90303. /**
  90304. * Adds a new drag gradient
  90305. * @param gradient defines the gradient to use (between 0 and 1)
  90306. * @param factor defines the drag value to affect to the specified gradient
  90307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90308. * @returns the current particle system
  90309. */
  90310. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90311. /**
  90312. * Remove a specific drag gradient
  90313. * @param gradient defines the gradient to remove
  90314. * @returns the current particle system
  90315. */
  90316. removeDragGradient(gradient: number): IParticleSystem;
  90317. /**
  90318. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90319. * @param gradient defines the gradient to use (between 0 and 1)
  90320. * @param factor defines the emit rate value to affect to the specified gradient
  90321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90322. * @returns the current particle system
  90323. */
  90324. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90325. /**
  90326. * Remove a specific emit rate gradient
  90327. * @param gradient defines the gradient to remove
  90328. * @returns the current particle system
  90329. */
  90330. removeEmitRateGradient(gradient: number): IParticleSystem;
  90331. /**
  90332. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90333. * @param gradient defines the gradient to use (between 0 and 1)
  90334. * @param factor defines the start size value to affect to the specified gradient
  90335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90336. * @returns the current particle system
  90337. */
  90338. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90339. /**
  90340. * Remove a specific start size gradient
  90341. * @param gradient defines the gradient to remove
  90342. * @returns the current particle system
  90343. */
  90344. removeStartSizeGradient(gradient: number): IParticleSystem;
  90345. private _createRampGradientTexture;
  90346. /**
  90347. * Gets the current list of ramp gradients.
  90348. * You must use addRampGradient and removeRampGradient to udpate this list
  90349. * @returns the list of ramp gradients
  90350. */
  90351. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90352. /** Force the system to rebuild all gradients that need to be resync */
  90353. forceRefreshGradients(): void;
  90354. private _syncRampGradientTexture;
  90355. /**
  90356. * Adds a new ramp gradient used to remap particle colors
  90357. * @param gradient defines the gradient to use (between 0 and 1)
  90358. * @param color defines the color to affect to the specified gradient
  90359. * @returns the current particle system
  90360. */
  90361. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  90362. /**
  90363. * Remove a specific ramp gradient
  90364. * @param gradient defines the gradient to remove
  90365. * @returns the current particle system
  90366. */
  90367. removeRampGradient(gradient: number): ParticleSystem;
  90368. /**
  90369. * Adds a new color gradient
  90370. * @param gradient defines the gradient to use (between 0 and 1)
  90371. * @param color1 defines the color to affect to the specified gradient
  90372. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90373. * @returns this particle system
  90374. */
  90375. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90376. /**
  90377. * Remove a specific color gradient
  90378. * @param gradient defines the gradient to remove
  90379. * @returns this particle system
  90380. */
  90381. removeColorGradient(gradient: number): IParticleSystem;
  90382. private _fetchR;
  90383. protected _reset(): void;
  90384. private _resetEffect;
  90385. private _createVertexBuffers;
  90386. private _createIndexBuffer;
  90387. /**
  90388. * Gets the maximum number of particles active at the same time.
  90389. * @returns The max number of active particles.
  90390. */
  90391. getCapacity(): number;
  90392. /**
  90393. * Gets whether there are still active particles in the system.
  90394. * @returns True if it is alive, otherwise false.
  90395. */
  90396. isAlive(): boolean;
  90397. /**
  90398. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90399. * @returns True if it has been started, otherwise false.
  90400. */
  90401. isStarted(): boolean;
  90402. private _prepareSubEmitterInternalArray;
  90403. /**
  90404. * Starts the particle system and begins to emit
  90405. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  90406. */
  90407. start(delay?: number): void;
  90408. /**
  90409. * Stops the particle system.
  90410. * @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.
  90411. */
  90412. stop(stopSubEmitters?: boolean): void;
  90413. /**
  90414. * Remove all active particles
  90415. */
  90416. reset(): void;
  90417. /**
  90418. * @hidden (for internal use only)
  90419. */
  90420. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  90421. /**
  90422. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  90423. * Its lifetime will start back at 0.
  90424. */
  90425. recycleParticle: (particle: Particle) => void;
  90426. private _stopSubEmitters;
  90427. private _createParticle;
  90428. private _removeFromRoot;
  90429. private _emitFromParticle;
  90430. private _update;
  90431. /** @hidden */
  90432. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  90433. /** @hidden */
  90434. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  90435. /**
  90436. * Fill the defines array according to the current settings of the particle system
  90437. * @param defines Array to be updated
  90438. * @param blendMode blend mode to take into account when updating the array
  90439. */
  90440. fillDefines(defines: Array<string>, blendMode: number): void;
  90441. /**
  90442. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  90443. * @param uniforms Uniforms array to fill
  90444. * @param attributes Attributes array to fill
  90445. * @param samplers Samplers array to fill
  90446. */
  90447. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  90448. /** @hidden */
  90449. private _getEffect;
  90450. /**
  90451. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  90452. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  90453. */
  90454. animate(preWarmOnly?: boolean): void;
  90455. private _appendParticleVertices;
  90456. /**
  90457. * Rebuilds the particle system.
  90458. */
  90459. rebuild(): void;
  90460. /**
  90461. * Is this system ready to be used/rendered
  90462. * @return true if the system is ready
  90463. */
  90464. isReady(): boolean;
  90465. private _render;
  90466. /**
  90467. * Renders the particle system in its current state.
  90468. * @returns the current number of particles
  90469. */
  90470. render(): number;
  90471. /**
  90472. * Disposes the particle system and free the associated resources
  90473. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90474. */
  90475. dispose(disposeTexture?: boolean): void;
  90476. /**
  90477. * Clones the particle system.
  90478. * @param name The name of the cloned object
  90479. * @param newEmitter The new emitter to use
  90480. * @returns the cloned particle system
  90481. */
  90482. clone(name: string, newEmitter: any): ParticleSystem;
  90483. /**
  90484. * Serializes the particle system to a JSON object
  90485. * @param serializeTexture defines if the texture must be serialized as well
  90486. * @returns the JSON object
  90487. */
  90488. serialize(serializeTexture?: boolean): any;
  90489. /** @hidden */
  90490. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  90491. /** @hidden */
  90492. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  90493. /**
  90494. * Parses a JSON object to create a particle system.
  90495. * @param parsedParticleSystem The JSON object to parse
  90496. * @param scene The scene to create the particle system in
  90497. * @param rootUrl The root url to use to load external dependencies like texture
  90498. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  90499. * @returns the Parsed particle system
  90500. */
  90501. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  90502. }
  90503. }
  90504. declare module BABYLON {
  90505. /**
  90506. * A particle represents one of the element emitted by a particle system.
  90507. * This is mainly define by its coordinates, direction, velocity and age.
  90508. */
  90509. export class Particle {
  90510. /**
  90511. * The particle system the particle belongs to.
  90512. */
  90513. particleSystem: ParticleSystem;
  90514. private static _Count;
  90515. /**
  90516. * Unique ID of the particle
  90517. */
  90518. id: number;
  90519. /**
  90520. * The world position of the particle in the scene.
  90521. */
  90522. position: Vector3;
  90523. /**
  90524. * The world direction of the particle in the scene.
  90525. */
  90526. direction: Vector3;
  90527. /**
  90528. * The color of the particle.
  90529. */
  90530. color: Color4;
  90531. /**
  90532. * The color change of the particle per step.
  90533. */
  90534. colorStep: Color4;
  90535. /**
  90536. * Defines how long will the life of the particle be.
  90537. */
  90538. lifeTime: number;
  90539. /**
  90540. * The current age of the particle.
  90541. */
  90542. age: number;
  90543. /**
  90544. * The current size of the particle.
  90545. */
  90546. size: number;
  90547. /**
  90548. * The current scale of the particle.
  90549. */
  90550. scale: Vector2;
  90551. /**
  90552. * The current angle of the particle.
  90553. */
  90554. angle: number;
  90555. /**
  90556. * Defines how fast is the angle changing.
  90557. */
  90558. angularSpeed: number;
  90559. /**
  90560. * Defines the cell index used by the particle to be rendered from a sprite.
  90561. */
  90562. cellIndex: number;
  90563. /**
  90564. * The information required to support color remapping
  90565. */
  90566. remapData: Vector4;
  90567. /** @hidden */
  90568. _randomCellOffset?: number;
  90569. /** @hidden */
  90570. _initialDirection: Nullable<Vector3>;
  90571. /** @hidden */
  90572. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  90573. /** @hidden */
  90574. _initialStartSpriteCellID: number;
  90575. /** @hidden */
  90576. _initialEndSpriteCellID: number;
  90577. /** @hidden */
  90578. _currentColorGradient: Nullable<ColorGradient>;
  90579. /** @hidden */
  90580. _currentColor1: Color4;
  90581. /** @hidden */
  90582. _currentColor2: Color4;
  90583. /** @hidden */
  90584. _currentSizeGradient: Nullable<FactorGradient>;
  90585. /** @hidden */
  90586. _currentSize1: number;
  90587. /** @hidden */
  90588. _currentSize2: number;
  90589. /** @hidden */
  90590. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  90591. /** @hidden */
  90592. _currentAngularSpeed1: number;
  90593. /** @hidden */
  90594. _currentAngularSpeed2: number;
  90595. /** @hidden */
  90596. _currentVelocityGradient: Nullable<FactorGradient>;
  90597. /** @hidden */
  90598. _currentVelocity1: number;
  90599. /** @hidden */
  90600. _currentVelocity2: number;
  90601. /** @hidden */
  90602. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  90603. /** @hidden */
  90604. _currentLimitVelocity1: number;
  90605. /** @hidden */
  90606. _currentLimitVelocity2: number;
  90607. /** @hidden */
  90608. _currentDragGradient: Nullable<FactorGradient>;
  90609. /** @hidden */
  90610. _currentDrag1: number;
  90611. /** @hidden */
  90612. _currentDrag2: number;
  90613. /** @hidden */
  90614. _randomNoiseCoordinates1: Vector3;
  90615. /** @hidden */
  90616. _randomNoiseCoordinates2: Vector3;
  90617. /** @hidden */
  90618. _localPosition?: Vector3;
  90619. /**
  90620. * Creates a new instance Particle
  90621. * @param particleSystem the particle system the particle belongs to
  90622. */
  90623. constructor(
  90624. /**
  90625. * The particle system the particle belongs to.
  90626. */
  90627. particleSystem: ParticleSystem);
  90628. private updateCellInfoFromSystem;
  90629. /**
  90630. * Defines how the sprite cell index is updated for the particle
  90631. */
  90632. updateCellIndex(): void;
  90633. /** @hidden */
  90634. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  90635. /** @hidden */
  90636. _inheritParticleInfoToSubEmitters(): void;
  90637. /** @hidden */
  90638. _reset(): void;
  90639. /**
  90640. * Copy the properties of particle to another one.
  90641. * @param other the particle to copy the information to.
  90642. */
  90643. copyTo(other: Particle): void;
  90644. }
  90645. }
  90646. declare module BABYLON {
  90647. /**
  90648. * Particle emitter represents a volume emitting particles.
  90649. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  90650. */
  90651. export interface IParticleEmitterType {
  90652. /**
  90653. * Called by the particle System when the direction is computed for the created particle.
  90654. * @param worldMatrix is the world matrix of the particle system
  90655. * @param directionToUpdate is the direction vector to update with the result
  90656. * @param particle is the particle we are computed the direction for
  90657. * @param isLocal defines if the direction should be set in local space
  90658. */
  90659. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90660. /**
  90661. * Called by the particle System when the position is computed for the created particle.
  90662. * @param worldMatrix is the world matrix of the particle system
  90663. * @param positionToUpdate is the position vector to update with the result
  90664. * @param particle is the particle we are computed the position for
  90665. * @param isLocal defines if the position should be set in local space
  90666. */
  90667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90668. /**
  90669. * Clones the current emitter and returns a copy of it
  90670. * @returns the new emitter
  90671. */
  90672. clone(): IParticleEmitterType;
  90673. /**
  90674. * Called by the GPUParticleSystem to setup the update shader
  90675. * @param effect defines the update shader
  90676. */
  90677. applyToShader(effect: Effect): void;
  90678. /**
  90679. * Returns a string to use to update the GPU particles update shader
  90680. * @returns the effect defines string
  90681. */
  90682. getEffectDefines(): string;
  90683. /**
  90684. * Returns a string representing the class name
  90685. * @returns a string containing the class name
  90686. */
  90687. getClassName(): string;
  90688. /**
  90689. * Serializes the particle system to a JSON object.
  90690. * @returns the JSON object
  90691. */
  90692. serialize(): any;
  90693. /**
  90694. * Parse properties from a JSON object
  90695. * @param serializationObject defines the JSON object
  90696. * @param scene defines the hosting scene
  90697. */
  90698. parse(serializationObject: any, scene: Scene): void;
  90699. }
  90700. }
  90701. declare module BABYLON {
  90702. /**
  90703. * Particle emitter emitting particles from the inside of a box.
  90704. * It emits the particles randomly between 2 given directions.
  90705. */
  90706. export class BoxParticleEmitter implements IParticleEmitterType {
  90707. /**
  90708. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90709. */
  90710. direction1: Vector3;
  90711. /**
  90712. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90713. */
  90714. direction2: Vector3;
  90715. /**
  90716. * 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.
  90717. */
  90718. minEmitBox: Vector3;
  90719. /**
  90720. * 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.
  90721. */
  90722. maxEmitBox: Vector3;
  90723. /**
  90724. * Creates a new instance BoxParticleEmitter
  90725. */
  90726. constructor();
  90727. /**
  90728. * Called by the particle System when the direction is computed for the created particle.
  90729. * @param worldMatrix is the world matrix of the particle system
  90730. * @param directionToUpdate is the direction vector to update with the result
  90731. * @param particle is the particle we are computed the direction for
  90732. * @param isLocal defines if the direction should be set in local space
  90733. */
  90734. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90735. /**
  90736. * Called by the particle System when the position is computed for the created particle.
  90737. * @param worldMatrix is the world matrix of the particle system
  90738. * @param positionToUpdate is the position vector to update with the result
  90739. * @param particle is the particle we are computed the position for
  90740. * @param isLocal defines if the position should be set in local space
  90741. */
  90742. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90743. /**
  90744. * Clones the current emitter and returns a copy of it
  90745. * @returns the new emitter
  90746. */
  90747. clone(): BoxParticleEmitter;
  90748. /**
  90749. * Called by the GPUParticleSystem to setup the update shader
  90750. * @param effect defines the update shader
  90751. */
  90752. applyToShader(effect: Effect): void;
  90753. /**
  90754. * Returns a string to use to update the GPU particles update shader
  90755. * @returns a string containng the defines string
  90756. */
  90757. getEffectDefines(): string;
  90758. /**
  90759. * Returns the string "BoxParticleEmitter"
  90760. * @returns a string containing the class name
  90761. */
  90762. getClassName(): string;
  90763. /**
  90764. * Serializes the particle system to a JSON object.
  90765. * @returns the JSON object
  90766. */
  90767. serialize(): any;
  90768. /**
  90769. * Parse properties from a JSON object
  90770. * @param serializationObject defines the JSON object
  90771. */
  90772. parse(serializationObject: any): void;
  90773. }
  90774. }
  90775. declare module BABYLON {
  90776. /**
  90777. * Particle emitter emitting particles from the inside of a cone.
  90778. * It emits the particles alongside the cone volume from the base to the particle.
  90779. * The emission direction might be randomized.
  90780. */
  90781. export class ConeParticleEmitter implements IParticleEmitterType {
  90782. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90783. directionRandomizer: number;
  90784. private _radius;
  90785. private _angle;
  90786. private _height;
  90787. /**
  90788. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  90789. */
  90790. radiusRange: number;
  90791. /**
  90792. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  90793. */
  90794. heightRange: number;
  90795. /**
  90796. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  90797. */
  90798. emitFromSpawnPointOnly: boolean;
  90799. /**
  90800. * Gets or sets the radius of the emission cone
  90801. */
  90802. get radius(): number;
  90803. set radius(value: number);
  90804. /**
  90805. * Gets or sets the angle of the emission cone
  90806. */
  90807. get angle(): number;
  90808. set angle(value: number);
  90809. private _buildHeight;
  90810. /**
  90811. * Creates a new instance ConeParticleEmitter
  90812. * @param radius the radius of the emission cone (1 by default)
  90813. * @param angle the cone base angle (PI by default)
  90814. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  90815. */
  90816. constructor(radius?: number, angle?: number,
  90817. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  90818. directionRandomizer?: number);
  90819. /**
  90820. * Called by the particle System when the direction is computed for the created particle.
  90821. * @param worldMatrix is the world matrix of the particle system
  90822. * @param directionToUpdate is the direction vector to update with the result
  90823. * @param particle is the particle we are computed the direction for
  90824. * @param isLocal defines if the direction should be set in local space
  90825. */
  90826. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90827. /**
  90828. * Called by the particle System when the position is computed for the created particle.
  90829. * @param worldMatrix is the world matrix of the particle system
  90830. * @param positionToUpdate is the position vector to update with the result
  90831. * @param particle is the particle we are computed the position for
  90832. * @param isLocal defines if the position should be set in local space
  90833. */
  90834. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90835. /**
  90836. * Clones the current emitter and returns a copy of it
  90837. * @returns the new emitter
  90838. */
  90839. clone(): ConeParticleEmitter;
  90840. /**
  90841. * Called by the GPUParticleSystem to setup the update shader
  90842. * @param effect defines the update shader
  90843. */
  90844. applyToShader(effect: Effect): void;
  90845. /**
  90846. * Returns a string to use to update the GPU particles update shader
  90847. * @returns a string containng the defines string
  90848. */
  90849. getEffectDefines(): string;
  90850. /**
  90851. * Returns the string "ConeParticleEmitter"
  90852. * @returns a string containing the class name
  90853. */
  90854. getClassName(): string;
  90855. /**
  90856. * Serializes the particle system to a JSON object.
  90857. * @returns the JSON object
  90858. */
  90859. serialize(): any;
  90860. /**
  90861. * Parse properties from a JSON object
  90862. * @param serializationObject defines the JSON object
  90863. */
  90864. parse(serializationObject: any): void;
  90865. }
  90866. }
  90867. declare module BABYLON {
  90868. /**
  90869. * Particle emitter emitting particles from the inside of a cylinder.
  90870. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  90871. */
  90872. export class CylinderParticleEmitter implements IParticleEmitterType {
  90873. /**
  90874. * The radius of the emission cylinder.
  90875. */
  90876. radius: number;
  90877. /**
  90878. * The height of the emission cylinder.
  90879. */
  90880. height: number;
  90881. /**
  90882. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90883. */
  90884. radiusRange: number;
  90885. /**
  90886. * How much to randomize the particle direction [0-1].
  90887. */
  90888. directionRandomizer: number;
  90889. /**
  90890. * Creates a new instance CylinderParticleEmitter
  90891. * @param radius the radius of the emission cylinder (1 by default)
  90892. * @param height the height of the emission cylinder (1 by default)
  90893. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90894. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  90895. */
  90896. constructor(
  90897. /**
  90898. * The radius of the emission cylinder.
  90899. */
  90900. radius?: number,
  90901. /**
  90902. * The height of the emission cylinder.
  90903. */
  90904. height?: number,
  90905. /**
  90906. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  90907. */
  90908. radiusRange?: number,
  90909. /**
  90910. * How much to randomize the particle direction [0-1].
  90911. */
  90912. directionRandomizer?: number);
  90913. /**
  90914. * Called by the particle System when the direction is computed for the created particle.
  90915. * @param worldMatrix is the world matrix of the particle system
  90916. * @param directionToUpdate is the direction vector to update with the result
  90917. * @param particle is the particle we are computed the direction for
  90918. * @param isLocal defines if the direction should be set in local space
  90919. */
  90920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90921. /**
  90922. * Called by the particle System when the position is computed for the created particle.
  90923. * @param worldMatrix is the world matrix of the particle system
  90924. * @param positionToUpdate is the position vector to update with the result
  90925. * @param particle is the particle we are computed the position for
  90926. * @param isLocal defines if the position should be set in local space
  90927. */
  90928. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  90929. /**
  90930. * Clones the current emitter and returns a copy of it
  90931. * @returns the new emitter
  90932. */
  90933. clone(): CylinderParticleEmitter;
  90934. /**
  90935. * Called by the GPUParticleSystem to setup the update shader
  90936. * @param effect defines the update shader
  90937. */
  90938. applyToShader(effect: Effect): void;
  90939. /**
  90940. * Returns a string to use to update the GPU particles update shader
  90941. * @returns a string containng the defines string
  90942. */
  90943. getEffectDefines(): string;
  90944. /**
  90945. * Returns the string "CylinderParticleEmitter"
  90946. * @returns a string containing the class name
  90947. */
  90948. getClassName(): string;
  90949. /**
  90950. * Serializes the particle system to a JSON object.
  90951. * @returns the JSON object
  90952. */
  90953. serialize(): any;
  90954. /**
  90955. * Parse properties from a JSON object
  90956. * @param serializationObject defines the JSON object
  90957. */
  90958. parse(serializationObject: any): void;
  90959. }
  90960. /**
  90961. * Particle emitter emitting particles from the inside of a cylinder.
  90962. * It emits the particles randomly between two vectors.
  90963. */
  90964. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  90965. /**
  90966. * The min limit of the emission direction.
  90967. */
  90968. direction1: Vector3;
  90969. /**
  90970. * The max limit of the emission direction.
  90971. */
  90972. direction2: Vector3;
  90973. /**
  90974. * Creates a new instance CylinderDirectedParticleEmitter
  90975. * @param radius the radius of the emission cylinder (1 by default)
  90976. * @param height the height of the emission cylinder (1 by default)
  90977. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90978. * @param direction1 the min limit of the emission direction (up vector by default)
  90979. * @param direction2 the max limit of the emission direction (up vector by default)
  90980. */
  90981. constructor(radius?: number, height?: number, radiusRange?: number,
  90982. /**
  90983. * The min limit of the emission direction.
  90984. */
  90985. direction1?: Vector3,
  90986. /**
  90987. * The max limit of the emission direction.
  90988. */
  90989. direction2?: Vector3);
  90990. /**
  90991. * Called by the particle System when the direction is computed for the created particle.
  90992. * @param worldMatrix is the world matrix of the particle system
  90993. * @param directionToUpdate is the direction vector to update with the result
  90994. * @param particle is the particle we are computed the direction for
  90995. */
  90996. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  90997. /**
  90998. * Clones the current emitter and returns a copy of it
  90999. * @returns the new emitter
  91000. */
  91001. clone(): CylinderDirectedParticleEmitter;
  91002. /**
  91003. * Called by the GPUParticleSystem to setup the update shader
  91004. * @param effect defines the update shader
  91005. */
  91006. applyToShader(effect: Effect): void;
  91007. /**
  91008. * Returns a string to use to update the GPU particles update shader
  91009. * @returns a string containng the defines string
  91010. */
  91011. getEffectDefines(): string;
  91012. /**
  91013. * Returns the string "CylinderDirectedParticleEmitter"
  91014. * @returns a string containing the class name
  91015. */
  91016. getClassName(): string;
  91017. /**
  91018. * Serializes the particle system to a JSON object.
  91019. * @returns the JSON object
  91020. */
  91021. serialize(): any;
  91022. /**
  91023. * Parse properties from a JSON object
  91024. * @param serializationObject defines the JSON object
  91025. */
  91026. parse(serializationObject: any): void;
  91027. }
  91028. }
  91029. declare module BABYLON {
  91030. /**
  91031. * Particle emitter emitting particles from the inside of a hemisphere.
  91032. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91033. */
  91034. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91035. /**
  91036. * The radius of the emission hemisphere.
  91037. */
  91038. radius: number;
  91039. /**
  91040. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91041. */
  91042. radiusRange: number;
  91043. /**
  91044. * How much to randomize the particle direction [0-1].
  91045. */
  91046. directionRandomizer: number;
  91047. /**
  91048. * Creates a new instance HemisphericParticleEmitter
  91049. * @param radius the radius of the emission hemisphere (1 by default)
  91050. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91051. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91052. */
  91053. constructor(
  91054. /**
  91055. * The radius of the emission hemisphere.
  91056. */
  91057. radius?: number,
  91058. /**
  91059. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91060. */
  91061. radiusRange?: number,
  91062. /**
  91063. * How much to randomize the particle direction [0-1].
  91064. */
  91065. directionRandomizer?: number);
  91066. /**
  91067. * Called by the particle System when the direction is computed for the created particle.
  91068. * @param worldMatrix is the world matrix of the particle system
  91069. * @param directionToUpdate is the direction vector to update with the result
  91070. * @param particle is the particle we are computed the direction for
  91071. * @param isLocal defines if the direction should be set in local space
  91072. */
  91073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91074. /**
  91075. * Called by the particle System when the position is computed for the created particle.
  91076. * @param worldMatrix is the world matrix of the particle system
  91077. * @param positionToUpdate is the position vector to update with the result
  91078. * @param particle is the particle we are computed the position for
  91079. * @param isLocal defines if the position should be set in local space
  91080. */
  91081. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91082. /**
  91083. * Clones the current emitter and returns a copy of it
  91084. * @returns the new emitter
  91085. */
  91086. clone(): HemisphericParticleEmitter;
  91087. /**
  91088. * Called by the GPUParticleSystem to setup the update shader
  91089. * @param effect defines the update shader
  91090. */
  91091. applyToShader(effect: Effect): void;
  91092. /**
  91093. * Returns a string to use to update the GPU particles update shader
  91094. * @returns a string containng the defines string
  91095. */
  91096. getEffectDefines(): string;
  91097. /**
  91098. * Returns the string "HemisphericParticleEmitter"
  91099. * @returns a string containing the class name
  91100. */
  91101. getClassName(): string;
  91102. /**
  91103. * Serializes the particle system to a JSON object.
  91104. * @returns the JSON object
  91105. */
  91106. serialize(): any;
  91107. /**
  91108. * Parse properties from a JSON object
  91109. * @param serializationObject defines the JSON object
  91110. */
  91111. parse(serializationObject: any): void;
  91112. }
  91113. }
  91114. declare module BABYLON {
  91115. /**
  91116. * Particle emitter emitting particles from a point.
  91117. * It emits the particles randomly between 2 given directions.
  91118. */
  91119. export class PointParticleEmitter implements IParticleEmitterType {
  91120. /**
  91121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91122. */
  91123. direction1: Vector3;
  91124. /**
  91125. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91126. */
  91127. direction2: Vector3;
  91128. /**
  91129. * Creates a new instance PointParticleEmitter
  91130. */
  91131. constructor();
  91132. /**
  91133. * Called by the particle System when the direction is computed for the created particle.
  91134. * @param worldMatrix is the world matrix of the particle system
  91135. * @param directionToUpdate is the direction vector to update with the result
  91136. * @param particle is the particle we are computed the direction for
  91137. * @param isLocal defines if the direction should be set in local space
  91138. */
  91139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91140. /**
  91141. * Called by the particle System when the position is computed for the created particle.
  91142. * @param worldMatrix is the world matrix of the particle system
  91143. * @param positionToUpdate is the position vector to update with the result
  91144. * @param particle is the particle we are computed the position for
  91145. * @param isLocal defines if the position should be set in local space
  91146. */
  91147. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91148. /**
  91149. * Clones the current emitter and returns a copy of it
  91150. * @returns the new emitter
  91151. */
  91152. clone(): PointParticleEmitter;
  91153. /**
  91154. * Called by the GPUParticleSystem to setup the update shader
  91155. * @param effect defines the update shader
  91156. */
  91157. applyToShader(effect: Effect): void;
  91158. /**
  91159. * Returns a string to use to update the GPU particles update shader
  91160. * @returns a string containng the defines string
  91161. */
  91162. getEffectDefines(): string;
  91163. /**
  91164. * Returns the string "PointParticleEmitter"
  91165. * @returns a string containing the class name
  91166. */
  91167. getClassName(): string;
  91168. /**
  91169. * Serializes the particle system to a JSON object.
  91170. * @returns the JSON object
  91171. */
  91172. serialize(): any;
  91173. /**
  91174. * Parse properties from a JSON object
  91175. * @param serializationObject defines the JSON object
  91176. */
  91177. parse(serializationObject: any): void;
  91178. }
  91179. }
  91180. declare module BABYLON {
  91181. /**
  91182. * Particle emitter emitting particles from the inside of a sphere.
  91183. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91184. */
  91185. export class SphereParticleEmitter implements IParticleEmitterType {
  91186. /**
  91187. * The radius of the emission sphere.
  91188. */
  91189. radius: number;
  91190. /**
  91191. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91192. */
  91193. radiusRange: number;
  91194. /**
  91195. * How much to randomize the particle direction [0-1].
  91196. */
  91197. directionRandomizer: number;
  91198. /**
  91199. * Creates a new instance SphereParticleEmitter
  91200. * @param radius the radius of the emission sphere (1 by default)
  91201. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91202. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91203. */
  91204. constructor(
  91205. /**
  91206. * The radius of the emission sphere.
  91207. */
  91208. radius?: number,
  91209. /**
  91210. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91211. */
  91212. radiusRange?: number,
  91213. /**
  91214. * How much to randomize the particle direction [0-1].
  91215. */
  91216. directionRandomizer?: number);
  91217. /**
  91218. * Called by the particle System when the direction is computed for the created particle.
  91219. * @param worldMatrix is the world matrix of the particle system
  91220. * @param directionToUpdate is the direction vector to update with the result
  91221. * @param particle is the particle we are computed the direction for
  91222. * @param isLocal defines if the direction should be set in local space
  91223. */
  91224. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91225. /**
  91226. * Called by the particle System when the position is computed for the created particle.
  91227. * @param worldMatrix is the world matrix of the particle system
  91228. * @param positionToUpdate is the position vector to update with the result
  91229. * @param particle is the particle we are computed the position for
  91230. * @param isLocal defines if the position should be set in local space
  91231. */
  91232. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91233. /**
  91234. * Clones the current emitter and returns a copy of it
  91235. * @returns the new emitter
  91236. */
  91237. clone(): SphereParticleEmitter;
  91238. /**
  91239. * Called by the GPUParticleSystem to setup the update shader
  91240. * @param effect defines the update shader
  91241. */
  91242. applyToShader(effect: Effect): void;
  91243. /**
  91244. * Returns a string to use to update the GPU particles update shader
  91245. * @returns a string containng the defines string
  91246. */
  91247. getEffectDefines(): string;
  91248. /**
  91249. * Returns the string "SphereParticleEmitter"
  91250. * @returns a string containing the class name
  91251. */
  91252. getClassName(): string;
  91253. /**
  91254. * Serializes the particle system to a JSON object.
  91255. * @returns the JSON object
  91256. */
  91257. serialize(): any;
  91258. /**
  91259. * Parse properties from a JSON object
  91260. * @param serializationObject defines the JSON object
  91261. */
  91262. parse(serializationObject: any): void;
  91263. }
  91264. /**
  91265. * Particle emitter emitting particles from the inside of a sphere.
  91266. * It emits the particles randomly between two vectors.
  91267. */
  91268. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91269. /**
  91270. * The min limit of the emission direction.
  91271. */
  91272. direction1: Vector3;
  91273. /**
  91274. * The max limit of the emission direction.
  91275. */
  91276. direction2: Vector3;
  91277. /**
  91278. * Creates a new instance SphereDirectedParticleEmitter
  91279. * @param radius the radius of the emission sphere (1 by default)
  91280. * @param direction1 the min limit of the emission direction (up vector by default)
  91281. * @param direction2 the max limit of the emission direction (up vector by default)
  91282. */
  91283. constructor(radius?: number,
  91284. /**
  91285. * The min limit of the emission direction.
  91286. */
  91287. direction1?: Vector3,
  91288. /**
  91289. * The max limit of the emission direction.
  91290. */
  91291. direction2?: Vector3);
  91292. /**
  91293. * Called by the particle System when the direction is computed for the created particle.
  91294. * @param worldMatrix is the world matrix of the particle system
  91295. * @param directionToUpdate is the direction vector to update with the result
  91296. * @param particle is the particle we are computed the direction for
  91297. */
  91298. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91299. /**
  91300. * Clones the current emitter and returns a copy of it
  91301. * @returns the new emitter
  91302. */
  91303. clone(): SphereDirectedParticleEmitter;
  91304. /**
  91305. * Called by the GPUParticleSystem to setup the update shader
  91306. * @param effect defines the update shader
  91307. */
  91308. applyToShader(effect: Effect): void;
  91309. /**
  91310. * Returns a string to use to update the GPU particles update shader
  91311. * @returns a string containng the defines string
  91312. */
  91313. getEffectDefines(): string;
  91314. /**
  91315. * Returns the string "SphereDirectedParticleEmitter"
  91316. * @returns a string containing the class name
  91317. */
  91318. getClassName(): string;
  91319. /**
  91320. * Serializes the particle system to a JSON object.
  91321. * @returns the JSON object
  91322. */
  91323. serialize(): any;
  91324. /**
  91325. * Parse properties from a JSON object
  91326. * @param serializationObject defines the JSON object
  91327. */
  91328. parse(serializationObject: any): void;
  91329. }
  91330. }
  91331. declare module BABYLON {
  91332. /**
  91333. * Particle emitter emitting particles from a custom list of positions.
  91334. */
  91335. export class CustomParticleEmitter implements IParticleEmitterType {
  91336. /**
  91337. * Gets or sets the position generator that will create the inital position of each particle.
  91338. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91339. */
  91340. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  91341. /**
  91342. * Gets or sets the destination generator that will create the final destination of each particle.
  91343. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  91344. */
  91345. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  91346. /**
  91347. * Creates a new instance CustomParticleEmitter
  91348. */
  91349. constructor();
  91350. /**
  91351. * Called by the particle System when the direction is computed for the created particle.
  91352. * @param worldMatrix is the world matrix of the particle system
  91353. * @param directionToUpdate is the direction vector to update with the result
  91354. * @param particle is the particle we are computed the direction for
  91355. * @param isLocal defines if the direction should be set in local space
  91356. */
  91357. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91358. /**
  91359. * Called by the particle System when the position is computed for the created particle.
  91360. * @param worldMatrix is the world matrix of the particle system
  91361. * @param positionToUpdate is the position vector to update with the result
  91362. * @param particle is the particle we are computed the position for
  91363. * @param isLocal defines if the position should be set in local space
  91364. */
  91365. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91366. /**
  91367. * Clones the current emitter and returns a copy of it
  91368. * @returns the new emitter
  91369. */
  91370. clone(): CustomParticleEmitter;
  91371. /**
  91372. * Called by the GPUParticleSystem to setup the update shader
  91373. * @param effect defines the update shader
  91374. */
  91375. applyToShader(effect: Effect): void;
  91376. /**
  91377. * Returns a string to use to update the GPU particles update shader
  91378. * @returns a string containng the defines string
  91379. */
  91380. getEffectDefines(): string;
  91381. /**
  91382. * Returns the string "PointParticleEmitter"
  91383. * @returns a string containing the class name
  91384. */
  91385. getClassName(): string;
  91386. /**
  91387. * Serializes the particle system to a JSON object.
  91388. * @returns the JSON object
  91389. */
  91390. serialize(): any;
  91391. /**
  91392. * Parse properties from a JSON object
  91393. * @param serializationObject defines the JSON object
  91394. */
  91395. parse(serializationObject: any): void;
  91396. }
  91397. }
  91398. declare module BABYLON {
  91399. /**
  91400. * Particle emitter emitting particles from the inside of a box.
  91401. * It emits the particles randomly between 2 given directions.
  91402. */
  91403. export class MeshParticleEmitter implements IParticleEmitterType {
  91404. private _indices;
  91405. private _positions;
  91406. private _normals;
  91407. private _storedNormal;
  91408. private _mesh;
  91409. /**
  91410. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91411. */
  91412. direction1: Vector3;
  91413. /**
  91414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91415. */
  91416. direction2: Vector3;
  91417. /**
  91418. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  91419. */
  91420. useMeshNormalsForDirection: boolean;
  91421. /** Defines the mesh to use as source */
  91422. get mesh(): Nullable<AbstractMesh>;
  91423. set mesh(value: Nullable<AbstractMesh>);
  91424. /**
  91425. * Creates a new instance MeshParticleEmitter
  91426. * @param mesh defines the mesh to use as source
  91427. */
  91428. constructor(mesh?: Nullable<AbstractMesh>);
  91429. /**
  91430. * Called by the particle System when the direction is computed for the created particle.
  91431. * @param worldMatrix is the world matrix of the particle system
  91432. * @param directionToUpdate is the direction vector to update with the result
  91433. * @param particle is the particle we are computed the direction for
  91434. * @param isLocal defines if the direction should be set in local space
  91435. */
  91436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91437. /**
  91438. * Called by the particle System when the position is computed for the created particle.
  91439. * @param worldMatrix is the world matrix of the particle system
  91440. * @param positionToUpdate is the position vector to update with the result
  91441. * @param particle is the particle we are computed the position for
  91442. * @param isLocal defines if the position should be set in local space
  91443. */
  91444. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91445. /**
  91446. * Clones the current emitter and returns a copy of it
  91447. * @returns the new emitter
  91448. */
  91449. clone(): MeshParticleEmitter;
  91450. /**
  91451. * Called by the GPUParticleSystem to setup the update shader
  91452. * @param effect defines the update shader
  91453. */
  91454. applyToShader(effect: Effect): void;
  91455. /**
  91456. * Returns a string to use to update the GPU particles update shader
  91457. * @returns a string containng the defines string
  91458. */
  91459. getEffectDefines(): string;
  91460. /**
  91461. * Returns the string "BoxParticleEmitter"
  91462. * @returns a string containing the class name
  91463. */
  91464. getClassName(): string;
  91465. /**
  91466. * Serializes the particle system to a JSON object.
  91467. * @returns the JSON object
  91468. */
  91469. serialize(): any;
  91470. /**
  91471. * Parse properties from a JSON object
  91472. * @param serializationObject defines the JSON object
  91473. * @param scene defines the hosting scene
  91474. */
  91475. parse(serializationObject: any, scene: Scene): void;
  91476. }
  91477. }
  91478. declare module BABYLON {
  91479. /**
  91480. * Interface representing a particle system in Babylon.js.
  91481. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  91482. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  91483. */
  91484. export interface IParticleSystem {
  91485. /**
  91486. * List of animations used by the particle system.
  91487. */
  91488. animations: Animation[];
  91489. /**
  91490. * The id of the Particle system.
  91491. */
  91492. id: string;
  91493. /**
  91494. * The name of the Particle system.
  91495. */
  91496. name: string;
  91497. /**
  91498. * The emitter represents the Mesh or position we are attaching the particle system to.
  91499. */
  91500. emitter: Nullable<AbstractMesh | Vector3>;
  91501. /**
  91502. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  91503. */
  91504. isBillboardBased: boolean;
  91505. /**
  91506. * The rendering group used by the Particle system to chose when to render.
  91507. */
  91508. renderingGroupId: number;
  91509. /**
  91510. * The layer mask we are rendering the particles through.
  91511. */
  91512. layerMask: number;
  91513. /**
  91514. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  91515. */
  91516. updateSpeed: number;
  91517. /**
  91518. * The amount of time the particle system is running (depends of the overall update speed).
  91519. */
  91520. targetStopDuration: number;
  91521. /**
  91522. * The texture used to render each particle. (this can be a spritesheet)
  91523. */
  91524. particleTexture: Nullable<Texture>;
  91525. /**
  91526. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  91527. */
  91528. blendMode: number;
  91529. /**
  91530. * Minimum life time of emitting particles.
  91531. */
  91532. minLifeTime: number;
  91533. /**
  91534. * Maximum life time of emitting particles.
  91535. */
  91536. maxLifeTime: number;
  91537. /**
  91538. * Minimum Size of emitting particles.
  91539. */
  91540. minSize: number;
  91541. /**
  91542. * Maximum Size of emitting particles.
  91543. */
  91544. maxSize: number;
  91545. /**
  91546. * Minimum scale of emitting particles on X axis.
  91547. */
  91548. minScaleX: number;
  91549. /**
  91550. * Maximum scale of emitting particles on X axis.
  91551. */
  91552. maxScaleX: number;
  91553. /**
  91554. * Minimum scale of emitting particles on Y axis.
  91555. */
  91556. minScaleY: number;
  91557. /**
  91558. * Maximum scale of emitting particles on Y axis.
  91559. */
  91560. maxScaleY: number;
  91561. /**
  91562. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91563. */
  91564. color1: Color4;
  91565. /**
  91566. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  91567. */
  91568. color2: Color4;
  91569. /**
  91570. * Color the particle will have at the end of its lifetime.
  91571. */
  91572. colorDead: Color4;
  91573. /**
  91574. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  91575. */
  91576. emitRate: number;
  91577. /**
  91578. * You can use gravity if you want to give an orientation to your particles.
  91579. */
  91580. gravity: Vector3;
  91581. /**
  91582. * Minimum power of emitting particles.
  91583. */
  91584. minEmitPower: number;
  91585. /**
  91586. * Maximum power of emitting particles.
  91587. */
  91588. maxEmitPower: number;
  91589. /**
  91590. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  91591. */
  91592. minAngularSpeed: number;
  91593. /**
  91594. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  91595. */
  91596. maxAngularSpeed: number;
  91597. /**
  91598. * Gets or sets the minimal initial rotation in radians.
  91599. */
  91600. minInitialRotation: number;
  91601. /**
  91602. * Gets or sets the maximal initial rotation in radians.
  91603. */
  91604. maxInitialRotation: number;
  91605. /**
  91606. * The particle emitter type defines the emitter used by the particle system.
  91607. * It can be for example box, sphere, or cone...
  91608. */
  91609. particleEmitterType: Nullable<IParticleEmitterType>;
  91610. /**
  91611. * Defines the delay in milliseconds before starting the system (0 by default)
  91612. */
  91613. startDelay: number;
  91614. /**
  91615. * 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
  91616. */
  91617. preWarmCycles: number;
  91618. /**
  91619. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  91620. */
  91621. preWarmStepOffset: number;
  91622. /**
  91623. * 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)
  91624. */
  91625. spriteCellChangeSpeed: number;
  91626. /**
  91627. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  91628. */
  91629. startSpriteCellID: number;
  91630. /**
  91631. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  91632. */
  91633. endSpriteCellID: number;
  91634. /**
  91635. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  91636. */
  91637. spriteCellWidth: number;
  91638. /**
  91639. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  91640. */
  91641. spriteCellHeight: number;
  91642. /**
  91643. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  91644. */
  91645. spriteRandomStartCell: boolean;
  91646. /**
  91647. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  91648. */
  91649. isAnimationSheetEnabled: boolean;
  91650. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  91651. translationPivot: Vector2;
  91652. /**
  91653. * Gets or sets a texture used to add random noise to particle positions
  91654. */
  91655. noiseTexture: Nullable<BaseTexture>;
  91656. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  91657. noiseStrength: Vector3;
  91658. /**
  91659. * Gets or sets the billboard mode to use when isBillboardBased = true.
  91660. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  91661. */
  91662. billboardMode: number;
  91663. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  91664. limitVelocityDamping: number;
  91665. /**
  91666. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  91667. */
  91668. beginAnimationOnStart: boolean;
  91669. /**
  91670. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  91671. */
  91672. beginAnimationFrom: number;
  91673. /**
  91674. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  91675. */
  91676. beginAnimationTo: number;
  91677. /**
  91678. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  91679. */
  91680. beginAnimationLoop: boolean;
  91681. /**
  91682. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  91683. */
  91684. disposeOnStop: boolean;
  91685. /**
  91686. * Specifies if the particles are updated in emitter local space or world space
  91687. */
  91688. isLocal: boolean;
  91689. /** Snippet ID if the particle system was created from the snippet server */
  91690. snippetId: string;
  91691. /**
  91692. * Gets the maximum number of particles active at the same time.
  91693. * @returns The max number of active particles.
  91694. */
  91695. getCapacity(): number;
  91696. /**
  91697. * Gets the number of particles active at the same time.
  91698. * @returns The number of active particles.
  91699. */
  91700. getActiveCount(): number;
  91701. /**
  91702. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91703. * @returns True if it has been started, otherwise false.
  91704. */
  91705. isStarted(): boolean;
  91706. /**
  91707. * Animates the particle system for this frame.
  91708. */
  91709. animate(): void;
  91710. /**
  91711. * Renders the particle system in its current state.
  91712. * @returns the current number of particles
  91713. */
  91714. render(): number;
  91715. /**
  91716. * Dispose the particle system and frees its associated resources.
  91717. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91718. */
  91719. dispose(disposeTexture?: boolean): void;
  91720. /**
  91721. * An event triggered when the system is disposed
  91722. */
  91723. onDisposeObservable: Observable<IParticleSystem>;
  91724. /**
  91725. * Clones the particle system.
  91726. * @param name The name of the cloned object
  91727. * @param newEmitter The new emitter to use
  91728. * @returns the cloned particle system
  91729. */
  91730. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  91731. /**
  91732. * Serializes the particle system to a JSON object
  91733. * @param serializeTexture defines if the texture must be serialized as well
  91734. * @returns the JSON object
  91735. */
  91736. serialize(serializeTexture: boolean): any;
  91737. /**
  91738. * Rebuild the particle system
  91739. */
  91740. rebuild(): void;
  91741. /** Force the system to rebuild all gradients that need to be resync */
  91742. forceRefreshGradients(): void;
  91743. /**
  91744. * Starts the particle system and begins to emit
  91745. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  91746. */
  91747. start(delay?: number): void;
  91748. /**
  91749. * Stops the particle system.
  91750. */
  91751. stop(): void;
  91752. /**
  91753. * Remove all active particles
  91754. */
  91755. reset(): void;
  91756. /**
  91757. * Gets a boolean indicating that the system is stopping
  91758. * @returns true if the system is currently stopping
  91759. */
  91760. isStopping(): boolean;
  91761. /**
  91762. * Is this system ready to be used/rendered
  91763. * @return true if the system is ready
  91764. */
  91765. isReady(): boolean;
  91766. /**
  91767. * Returns the string "ParticleSystem"
  91768. * @returns a string containing the class name
  91769. */
  91770. getClassName(): string;
  91771. /**
  91772. * Gets the custom effect used to render the particles
  91773. * @param blendMode Blend mode for which the effect should be retrieved
  91774. * @returns The effect
  91775. */
  91776. getCustomEffect(blendMode: number): Nullable<Effect>;
  91777. /**
  91778. * Sets the custom effect used to render the particles
  91779. * @param effect The effect to set
  91780. * @param blendMode Blend mode for which the effect should be set
  91781. */
  91782. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  91783. /**
  91784. * Fill the defines array according to the current settings of the particle system
  91785. * @param defines Array to be updated
  91786. * @param blendMode blend mode to take into account when updating the array
  91787. */
  91788. fillDefines(defines: Array<string>, blendMode: number): void;
  91789. /**
  91790. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91791. * @param uniforms Uniforms array to fill
  91792. * @param attributes Attributes array to fill
  91793. * @param samplers Samplers array to fill
  91794. */
  91795. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91796. /**
  91797. * Observable that will be called just before the particles are drawn
  91798. */
  91799. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  91800. /**
  91801. * Gets the name of the particle vertex shader
  91802. */
  91803. vertexShaderName: string;
  91804. /**
  91805. * Adds a new color gradient
  91806. * @param gradient defines the gradient to use (between 0 and 1)
  91807. * @param color1 defines the color to affect to the specified gradient
  91808. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91809. * @returns the current particle system
  91810. */
  91811. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91812. /**
  91813. * Remove a specific color gradient
  91814. * @param gradient defines the gradient to remove
  91815. * @returns the current particle system
  91816. */
  91817. removeColorGradient(gradient: number): IParticleSystem;
  91818. /**
  91819. * Adds a new size gradient
  91820. * @param gradient defines the gradient to use (between 0 and 1)
  91821. * @param factor defines the size factor to affect to the specified gradient
  91822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91823. * @returns the current particle system
  91824. */
  91825. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91826. /**
  91827. * Remove a specific size gradient
  91828. * @param gradient defines the gradient to remove
  91829. * @returns the current particle system
  91830. */
  91831. removeSizeGradient(gradient: number): IParticleSystem;
  91832. /**
  91833. * Gets the current list of color gradients.
  91834. * You must use addColorGradient and removeColorGradient to udpate this list
  91835. * @returns the list of color gradients
  91836. */
  91837. getColorGradients(): Nullable<Array<ColorGradient>>;
  91838. /**
  91839. * Gets the current list of size gradients.
  91840. * You must use addSizeGradient and removeSizeGradient to udpate this list
  91841. * @returns the list of size gradients
  91842. */
  91843. getSizeGradients(): Nullable<Array<FactorGradient>>;
  91844. /**
  91845. * Gets the current list of angular speed gradients.
  91846. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  91847. * @returns the list of angular speed gradients
  91848. */
  91849. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  91850. /**
  91851. * Adds a new angular speed gradient
  91852. * @param gradient defines the gradient to use (between 0 and 1)
  91853. * @param factor defines the angular speed to affect to the specified gradient
  91854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91855. * @returns the current particle system
  91856. */
  91857. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91858. /**
  91859. * Remove a specific angular speed gradient
  91860. * @param gradient defines the gradient to remove
  91861. * @returns the current particle system
  91862. */
  91863. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  91864. /**
  91865. * Gets the current list of velocity gradients.
  91866. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  91867. * @returns the list of velocity gradients
  91868. */
  91869. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  91870. /**
  91871. * Adds a new velocity gradient
  91872. * @param gradient defines the gradient to use (between 0 and 1)
  91873. * @param factor defines the velocity to affect to the specified gradient
  91874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91875. * @returns the current particle system
  91876. */
  91877. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91878. /**
  91879. * Remove a specific velocity gradient
  91880. * @param gradient defines the gradient to remove
  91881. * @returns the current particle system
  91882. */
  91883. removeVelocityGradient(gradient: number): IParticleSystem;
  91884. /**
  91885. * Gets the current list of limit velocity gradients.
  91886. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  91887. * @returns the list of limit velocity gradients
  91888. */
  91889. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  91890. /**
  91891. * Adds a new limit velocity gradient
  91892. * @param gradient defines the gradient to use (between 0 and 1)
  91893. * @param factor defines the limit velocity to affect to the specified gradient
  91894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91895. * @returns the current particle system
  91896. */
  91897. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91898. /**
  91899. * Remove a specific limit velocity gradient
  91900. * @param gradient defines the gradient to remove
  91901. * @returns the current particle system
  91902. */
  91903. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  91904. /**
  91905. * Adds a new drag gradient
  91906. * @param gradient defines the gradient to use (between 0 and 1)
  91907. * @param factor defines the drag to affect to the specified gradient
  91908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91909. * @returns the current particle system
  91910. */
  91911. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91912. /**
  91913. * Remove a specific drag gradient
  91914. * @param gradient defines the gradient to remove
  91915. * @returns the current particle system
  91916. */
  91917. removeDragGradient(gradient: number): IParticleSystem;
  91918. /**
  91919. * Gets the current list of drag gradients.
  91920. * You must use addDragGradient and removeDragGradient to udpate this list
  91921. * @returns the list of drag gradients
  91922. */
  91923. getDragGradients(): Nullable<Array<FactorGradient>>;
  91924. /**
  91925. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  91926. * @param gradient defines the gradient to use (between 0 and 1)
  91927. * @param factor defines the emit rate to affect to the specified gradient
  91928. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91929. * @returns the current particle system
  91930. */
  91931. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91932. /**
  91933. * Remove a specific emit rate gradient
  91934. * @param gradient defines the gradient to remove
  91935. * @returns the current particle system
  91936. */
  91937. removeEmitRateGradient(gradient: number): IParticleSystem;
  91938. /**
  91939. * Gets the current list of emit rate gradients.
  91940. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  91941. * @returns the list of emit rate gradients
  91942. */
  91943. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  91944. /**
  91945. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91946. * @param gradient defines the gradient to use (between 0 and 1)
  91947. * @param factor defines the start size to affect to the specified gradient
  91948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91949. * @returns the current particle system
  91950. */
  91951. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91952. /**
  91953. * Remove a specific start size gradient
  91954. * @param gradient defines the gradient to remove
  91955. * @returns the current particle system
  91956. */
  91957. removeStartSizeGradient(gradient: number): IParticleSystem;
  91958. /**
  91959. * Gets the current list of start size gradients.
  91960. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  91961. * @returns the list of start size gradients
  91962. */
  91963. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  91964. /**
  91965. * Adds a new life time gradient
  91966. * @param gradient defines the gradient to use (between 0 and 1)
  91967. * @param factor defines the life time factor to affect to the specified gradient
  91968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91969. * @returns the current particle system
  91970. */
  91971. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91972. /**
  91973. * Remove a specific life time gradient
  91974. * @param gradient defines the gradient to remove
  91975. * @returns the current particle system
  91976. */
  91977. removeLifeTimeGradient(gradient: number): IParticleSystem;
  91978. /**
  91979. * Gets the current list of life time gradients.
  91980. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  91981. * @returns the list of life time gradients
  91982. */
  91983. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  91984. /**
  91985. * Gets the current list of color gradients.
  91986. * You must use addColorGradient and removeColorGradient to udpate this list
  91987. * @returns the list of color gradients
  91988. */
  91989. getColorGradients(): Nullable<Array<ColorGradient>>;
  91990. /**
  91991. * Adds a new ramp gradient used to remap particle colors
  91992. * @param gradient defines the gradient to use (between 0 and 1)
  91993. * @param color defines the color to affect to the specified gradient
  91994. * @returns the current particle system
  91995. */
  91996. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  91997. /**
  91998. * Gets the current list of ramp gradients.
  91999. * You must use addRampGradient and removeRampGradient to udpate this list
  92000. * @returns the list of ramp gradients
  92001. */
  92002. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92003. /** Gets or sets a boolean indicating that ramp gradients must be used
  92004. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92005. */
  92006. useRampGradients: boolean;
  92007. /**
  92008. * Adds a new color remap gradient
  92009. * @param gradient defines the gradient to use (between 0 and 1)
  92010. * @param min defines the color remap minimal range
  92011. * @param max defines the color remap maximal range
  92012. * @returns the current particle system
  92013. */
  92014. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92015. /**
  92016. * Gets the current list of color remap gradients.
  92017. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92018. * @returns the list of color remap gradients
  92019. */
  92020. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92021. /**
  92022. * Adds a new alpha remap gradient
  92023. * @param gradient defines the gradient to use (between 0 and 1)
  92024. * @param min defines the alpha remap minimal range
  92025. * @param max defines the alpha remap maximal range
  92026. * @returns the current particle system
  92027. */
  92028. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92029. /**
  92030. * Gets the current list of alpha remap gradients.
  92031. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92032. * @returns the list of alpha remap gradients
  92033. */
  92034. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92035. /**
  92036. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92037. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92038. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92039. * @returns the emitter
  92040. */
  92041. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92042. /**
  92043. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92044. * @param radius The radius of the hemisphere to emit from
  92045. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92046. * @returns the emitter
  92047. */
  92048. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92049. /**
  92050. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92051. * @param radius The radius of the sphere to emit from
  92052. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92053. * @returns the emitter
  92054. */
  92055. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92056. /**
  92057. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92058. * @param radius The radius of the sphere to emit from
  92059. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92060. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92061. * @returns the emitter
  92062. */
  92063. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92064. /**
  92065. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92066. * @param radius The radius of the emission cylinder
  92067. * @param height The height of the emission cylinder
  92068. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92069. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92070. * @returns the emitter
  92071. */
  92072. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92073. /**
  92074. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92075. * @param radius The radius of the cylinder to emit from
  92076. * @param height The height of the emission cylinder
  92077. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92078. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92079. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92080. * @returns the emitter
  92081. */
  92082. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92083. /**
  92084. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92085. * @param radius The radius of the cone to emit from
  92086. * @param angle The base angle of the cone
  92087. * @returns the emitter
  92088. */
  92089. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92090. /**
  92091. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92092. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92093. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92094. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92095. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92096. * @returns the emitter
  92097. */
  92098. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92099. /**
  92100. * Get hosting scene
  92101. * @returns the scene
  92102. */
  92103. getScene(): Scene;
  92104. }
  92105. }
  92106. declare module BABYLON {
  92107. /**
  92108. * 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.
  92109. * @see https://doc.babylonjs.com/how_to/transformnode
  92110. */
  92111. export class TransformNode extends Node {
  92112. /**
  92113. * Object will not rotate to face the camera
  92114. */
  92115. static BILLBOARDMODE_NONE: number;
  92116. /**
  92117. * Object will rotate to face the camera but only on the x axis
  92118. */
  92119. static BILLBOARDMODE_X: number;
  92120. /**
  92121. * Object will rotate to face the camera but only on the y axis
  92122. */
  92123. static BILLBOARDMODE_Y: number;
  92124. /**
  92125. * Object will rotate to face the camera but only on the z axis
  92126. */
  92127. static BILLBOARDMODE_Z: number;
  92128. /**
  92129. * Object will rotate to face the camera
  92130. */
  92131. static BILLBOARDMODE_ALL: number;
  92132. /**
  92133. * Object will rotate to face the camera's position instead of orientation
  92134. */
  92135. static BILLBOARDMODE_USE_POSITION: number;
  92136. private static _TmpRotation;
  92137. private static _TmpScaling;
  92138. private static _TmpTranslation;
  92139. private _forward;
  92140. private _forwardInverted;
  92141. private _up;
  92142. private _right;
  92143. private _rightInverted;
  92144. private _position;
  92145. private _rotation;
  92146. private _rotationQuaternion;
  92147. protected _scaling: Vector3;
  92148. protected _isDirty: boolean;
  92149. private _transformToBoneReferal;
  92150. private _isAbsoluteSynced;
  92151. private _billboardMode;
  92152. /**
  92153. * Gets or sets the billboard mode. Default is 0.
  92154. *
  92155. * | Value | Type | Description |
  92156. * | --- | --- | --- |
  92157. * | 0 | BILLBOARDMODE_NONE | |
  92158. * | 1 | BILLBOARDMODE_X | |
  92159. * | 2 | BILLBOARDMODE_Y | |
  92160. * | 4 | BILLBOARDMODE_Z | |
  92161. * | 7 | BILLBOARDMODE_ALL | |
  92162. *
  92163. */
  92164. get billboardMode(): number;
  92165. set billboardMode(value: number);
  92166. private _preserveParentRotationForBillboard;
  92167. /**
  92168. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92169. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92170. */
  92171. get preserveParentRotationForBillboard(): boolean;
  92172. set preserveParentRotationForBillboard(value: boolean);
  92173. /**
  92174. * 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
  92175. */
  92176. scalingDeterminant: number;
  92177. private _infiniteDistance;
  92178. /**
  92179. * Gets or sets the distance of the object to max, often used by skybox
  92180. */
  92181. get infiniteDistance(): boolean;
  92182. set infiniteDistance(value: boolean);
  92183. /**
  92184. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92185. * By default the system will update normals to compensate
  92186. */
  92187. ignoreNonUniformScaling: boolean;
  92188. /**
  92189. * 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
  92190. */
  92191. reIntegrateRotationIntoRotationQuaternion: boolean;
  92192. /** @hidden */
  92193. _poseMatrix: Nullable<Matrix>;
  92194. /** @hidden */
  92195. _localMatrix: Matrix;
  92196. private _usePivotMatrix;
  92197. private _absolutePosition;
  92198. private _absoluteScaling;
  92199. private _absoluteRotationQuaternion;
  92200. private _pivotMatrix;
  92201. private _pivotMatrixInverse;
  92202. protected _postMultiplyPivotMatrix: boolean;
  92203. protected _isWorldMatrixFrozen: boolean;
  92204. /** @hidden */
  92205. _indexInSceneTransformNodesArray: number;
  92206. /**
  92207. * An event triggered after the world matrix is updated
  92208. */
  92209. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92210. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92211. /**
  92212. * Gets a string identifying the name of the class
  92213. * @returns "TransformNode" string
  92214. */
  92215. getClassName(): string;
  92216. /**
  92217. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92218. */
  92219. get position(): Vector3;
  92220. set position(newPosition: Vector3);
  92221. /**
  92222. * 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)).
  92223. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92224. */
  92225. get rotation(): Vector3;
  92226. set rotation(newRotation: Vector3);
  92227. /**
  92228. * 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)).
  92229. */
  92230. get scaling(): Vector3;
  92231. set scaling(newScaling: Vector3);
  92232. /**
  92233. * 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).
  92234. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92235. */
  92236. get rotationQuaternion(): Nullable<Quaternion>;
  92237. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92238. /**
  92239. * The forward direction of that transform in world space.
  92240. */
  92241. get forward(): Vector3;
  92242. /**
  92243. * The up direction of that transform in world space.
  92244. */
  92245. get up(): Vector3;
  92246. /**
  92247. * The right direction of that transform in world space.
  92248. */
  92249. get right(): Vector3;
  92250. /**
  92251. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92252. * @param matrix the matrix to copy the pose from
  92253. * @returns this TransformNode.
  92254. */
  92255. updatePoseMatrix(matrix: Matrix): TransformNode;
  92256. /**
  92257. * Returns the mesh Pose matrix.
  92258. * @returns the pose matrix
  92259. */
  92260. getPoseMatrix(): Matrix;
  92261. /** @hidden */
  92262. _isSynchronized(): boolean;
  92263. /** @hidden */
  92264. _initCache(): void;
  92265. /**
  92266. * Flag the transform node as dirty (Forcing it to update everything)
  92267. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92268. * @returns this transform node
  92269. */
  92270. markAsDirty(property: string): TransformNode;
  92271. /**
  92272. * Returns the current mesh absolute position.
  92273. * Returns a Vector3.
  92274. */
  92275. get absolutePosition(): Vector3;
  92276. /**
  92277. * Returns the current mesh absolute scaling.
  92278. * Returns a Vector3.
  92279. */
  92280. get absoluteScaling(): Vector3;
  92281. /**
  92282. * Returns the current mesh absolute rotation.
  92283. * Returns a Quaternion.
  92284. */
  92285. get absoluteRotationQuaternion(): Quaternion;
  92286. /**
  92287. * Sets a new matrix to apply before all other transformation
  92288. * @param matrix defines the transform matrix
  92289. * @returns the current TransformNode
  92290. */
  92291. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92292. /**
  92293. * Sets a new pivot matrix to the current node
  92294. * @param matrix defines the new pivot matrix to use
  92295. * @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
  92296. * @returns the current TransformNode
  92297. */
  92298. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92299. /**
  92300. * Returns the mesh pivot matrix.
  92301. * Default : Identity.
  92302. * @returns the matrix
  92303. */
  92304. getPivotMatrix(): Matrix;
  92305. /**
  92306. * Instantiate (when possible) or clone that node with its hierarchy
  92307. * @param newParent defines the new parent to use for the instance (or clone)
  92308. * @param options defines options to configure how copy is done
  92309. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92310. * @returns an instance (or a clone) of the current node with its hiearchy
  92311. */
  92312. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92313. doNotInstantiate: boolean;
  92314. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92315. /**
  92316. * Prevents the World matrix to be computed any longer
  92317. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92318. * @returns the TransformNode.
  92319. */
  92320. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92321. /**
  92322. * Allows back the World matrix computation.
  92323. * @returns the TransformNode.
  92324. */
  92325. unfreezeWorldMatrix(): this;
  92326. /**
  92327. * True if the World matrix has been frozen.
  92328. */
  92329. get isWorldMatrixFrozen(): boolean;
  92330. /**
  92331. * Retuns the mesh absolute position in the World.
  92332. * @returns a Vector3.
  92333. */
  92334. getAbsolutePosition(): Vector3;
  92335. /**
  92336. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  92337. * @param absolutePosition the absolute position to set
  92338. * @returns the TransformNode.
  92339. */
  92340. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  92341. /**
  92342. * Sets the mesh position in its local space.
  92343. * @param vector3 the position to set in localspace
  92344. * @returns the TransformNode.
  92345. */
  92346. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  92347. /**
  92348. * Returns the mesh position in the local space from the current World matrix values.
  92349. * @returns a new Vector3.
  92350. */
  92351. getPositionExpressedInLocalSpace(): Vector3;
  92352. /**
  92353. * Translates the mesh along the passed Vector3 in its local space.
  92354. * @param vector3 the distance to translate in localspace
  92355. * @returns the TransformNode.
  92356. */
  92357. locallyTranslate(vector3: Vector3): TransformNode;
  92358. private static _lookAtVectorCache;
  92359. /**
  92360. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  92361. * @param targetPoint the position (must be in same space as current mesh) to look at
  92362. * @param yawCor optional yaw (y-axis) correction in radians
  92363. * @param pitchCor optional pitch (x-axis) correction in radians
  92364. * @param rollCor optional roll (z-axis) correction in radians
  92365. * @param space the choosen space of the target
  92366. * @returns the TransformNode.
  92367. */
  92368. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  92369. /**
  92370. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92371. * This Vector3 is expressed in the World space.
  92372. * @param localAxis axis to rotate
  92373. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  92374. */
  92375. getDirection(localAxis: Vector3): Vector3;
  92376. /**
  92377. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  92378. * localAxis is expressed in the mesh local space.
  92379. * result is computed in the Wordl space from the mesh World matrix.
  92380. * @param localAxis axis to rotate
  92381. * @param result the resulting transformnode
  92382. * @returns this TransformNode.
  92383. */
  92384. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  92385. /**
  92386. * Sets this transform node rotation to the given local axis.
  92387. * @param localAxis the axis in local space
  92388. * @param yawCor optional yaw (y-axis) correction in radians
  92389. * @param pitchCor optional pitch (x-axis) correction in radians
  92390. * @param rollCor optional roll (z-axis) correction in radians
  92391. * @returns this TransformNode
  92392. */
  92393. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  92394. /**
  92395. * Sets a new pivot point to the current node
  92396. * @param point defines the new pivot point to use
  92397. * @param space defines if the point is in world or local space (local by default)
  92398. * @returns the current TransformNode
  92399. */
  92400. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  92401. /**
  92402. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  92403. * @returns the pivot point
  92404. */
  92405. getPivotPoint(): Vector3;
  92406. /**
  92407. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  92408. * @param result the vector3 to store the result
  92409. * @returns this TransformNode.
  92410. */
  92411. getPivotPointToRef(result: Vector3): TransformNode;
  92412. /**
  92413. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  92414. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  92415. */
  92416. getAbsolutePivotPoint(): Vector3;
  92417. /**
  92418. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  92419. * @param result vector3 to store the result
  92420. * @returns this TransformNode.
  92421. */
  92422. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  92423. /**
  92424. * Defines the passed node as the parent of the current node.
  92425. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  92426. * @see https://doc.babylonjs.com/how_to/parenting
  92427. * @param node the node ot set as the parent
  92428. * @returns this TransformNode.
  92429. */
  92430. setParent(node: Nullable<Node>): TransformNode;
  92431. private _nonUniformScaling;
  92432. /**
  92433. * True if the scaling property of this object is non uniform eg. (1,2,1)
  92434. */
  92435. get nonUniformScaling(): boolean;
  92436. /** @hidden */
  92437. _updateNonUniformScalingState(value: boolean): boolean;
  92438. /**
  92439. * Attach the current TransformNode to another TransformNode associated with a bone
  92440. * @param bone Bone affecting the TransformNode
  92441. * @param affectedTransformNode TransformNode associated with the bone
  92442. * @returns this object
  92443. */
  92444. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  92445. /**
  92446. * Detach the transform node if its associated with a bone
  92447. * @returns this object
  92448. */
  92449. detachFromBone(): TransformNode;
  92450. private static _rotationAxisCache;
  92451. /**
  92452. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  92453. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92454. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92455. * The passed axis is also normalized.
  92456. * @param axis the axis to rotate around
  92457. * @param amount the amount to rotate in radians
  92458. * @param space Space to rotate in (Default: local)
  92459. * @returns the TransformNode.
  92460. */
  92461. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  92462. /**
  92463. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  92464. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  92465. * The passed axis is also normalized. .
  92466. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  92467. * @param point the point to rotate around
  92468. * @param axis the axis to rotate around
  92469. * @param amount the amount to rotate in radians
  92470. * @returns the TransformNode
  92471. */
  92472. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  92473. /**
  92474. * Translates the mesh along the axis vector for the passed distance in the given space.
  92475. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  92476. * @param axis the axis to translate in
  92477. * @param distance the distance to translate
  92478. * @param space Space to rotate in (Default: local)
  92479. * @returns the TransformNode.
  92480. */
  92481. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  92482. /**
  92483. * Adds a rotation step to the mesh current rotation.
  92484. * x, y, z are Euler angles expressed in radians.
  92485. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  92486. * This means this rotation is made in the mesh local space only.
  92487. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  92488. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  92489. * ```javascript
  92490. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  92491. * ```
  92492. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  92493. * 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.
  92494. * @param x Rotation to add
  92495. * @param y Rotation to add
  92496. * @param z Rotation to add
  92497. * @returns the TransformNode.
  92498. */
  92499. addRotation(x: number, y: number, z: number): TransformNode;
  92500. /**
  92501. * @hidden
  92502. */
  92503. protected _getEffectiveParent(): Nullable<Node>;
  92504. /**
  92505. * Computes the world matrix of the node
  92506. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92507. * @returns the world matrix
  92508. */
  92509. computeWorldMatrix(force?: boolean): Matrix;
  92510. /**
  92511. * Resets this nodeTransform's local matrix to Matrix.Identity().
  92512. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  92513. */
  92514. resetLocalMatrix(independentOfChildren?: boolean): void;
  92515. protected _afterComputeWorldMatrix(): void;
  92516. /**
  92517. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  92518. * @param func callback function to add
  92519. *
  92520. * @returns the TransformNode.
  92521. */
  92522. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92523. /**
  92524. * Removes a registered callback function.
  92525. * @param func callback function to remove
  92526. * @returns the TransformNode.
  92527. */
  92528. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  92529. /**
  92530. * Gets the position of the current mesh in camera space
  92531. * @param camera defines the camera to use
  92532. * @returns a position
  92533. */
  92534. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  92535. /**
  92536. * Returns the distance from the mesh to the active camera
  92537. * @param camera defines the camera to use
  92538. * @returns the distance
  92539. */
  92540. getDistanceToCamera(camera?: Nullable<Camera>): number;
  92541. /**
  92542. * Clone the current transform node
  92543. * @param name Name of the new clone
  92544. * @param newParent New parent for the clone
  92545. * @param doNotCloneChildren Do not clone children hierarchy
  92546. * @returns the new transform node
  92547. */
  92548. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  92549. /**
  92550. * Serializes the objects information.
  92551. * @param currentSerializationObject defines the object to serialize in
  92552. * @returns the serialized object
  92553. */
  92554. serialize(currentSerializationObject?: any): any;
  92555. /**
  92556. * Returns a new TransformNode object parsed from the source provided.
  92557. * @param parsedTransformNode is the source.
  92558. * @param scene the scne the object belongs to
  92559. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  92560. * @returns a new TransformNode object parsed from the source provided.
  92561. */
  92562. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  92563. /**
  92564. * Get all child-transformNodes of this node
  92565. * @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
  92566. * @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
  92567. * @returns an array of TransformNode
  92568. */
  92569. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  92570. /**
  92571. * Releases resources associated with this transform node.
  92572. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92573. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92574. */
  92575. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92576. /**
  92577. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92578. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92579. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92580. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92581. * @returns the current mesh
  92582. */
  92583. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  92584. private _syncAbsoluteScalingAndRotation;
  92585. }
  92586. }
  92587. declare module BABYLON {
  92588. /**
  92589. * Class used to override all child animations of a given target
  92590. */
  92591. export class AnimationPropertiesOverride {
  92592. /**
  92593. * Gets or sets a value indicating if animation blending must be used
  92594. */
  92595. enableBlending: boolean;
  92596. /**
  92597. * Gets or sets the blending speed to use when enableBlending is true
  92598. */
  92599. blendingSpeed: number;
  92600. /**
  92601. * Gets or sets the default loop mode to use
  92602. */
  92603. loopMode: number;
  92604. }
  92605. }
  92606. declare module BABYLON {
  92607. /**
  92608. * Class used to store bone information
  92609. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92610. */
  92611. export class Bone extends Node {
  92612. /**
  92613. * defines the bone name
  92614. */
  92615. name: string;
  92616. private static _tmpVecs;
  92617. private static _tmpQuat;
  92618. private static _tmpMats;
  92619. /**
  92620. * Gets the list of child bones
  92621. */
  92622. children: Bone[];
  92623. /** Gets the animations associated with this bone */
  92624. animations: Animation[];
  92625. /**
  92626. * Gets or sets bone length
  92627. */
  92628. length: number;
  92629. /**
  92630. * @hidden Internal only
  92631. * Set this value to map this bone to a different index in the transform matrices
  92632. * Set this value to -1 to exclude the bone from the transform matrices
  92633. */
  92634. _index: Nullable<number>;
  92635. private _skeleton;
  92636. private _localMatrix;
  92637. private _restPose;
  92638. private _baseMatrix;
  92639. private _absoluteTransform;
  92640. private _invertedAbsoluteTransform;
  92641. private _parent;
  92642. private _scalingDeterminant;
  92643. private _worldTransform;
  92644. private _localScaling;
  92645. private _localRotation;
  92646. private _localPosition;
  92647. private _needToDecompose;
  92648. private _needToCompose;
  92649. /** @hidden */
  92650. _linkedTransformNode: Nullable<TransformNode>;
  92651. /** @hidden */
  92652. _waitingTransformNodeId: Nullable<string>;
  92653. /** @hidden */
  92654. get _matrix(): Matrix;
  92655. /** @hidden */
  92656. set _matrix(value: Matrix);
  92657. /**
  92658. * Create a new bone
  92659. * @param name defines the bone name
  92660. * @param skeleton defines the parent skeleton
  92661. * @param parentBone defines the parent (can be null if the bone is the root)
  92662. * @param localMatrix defines the local matrix
  92663. * @param restPose defines the rest pose matrix
  92664. * @param baseMatrix defines the base matrix
  92665. * @param index defines index of the bone in the hiearchy
  92666. */
  92667. constructor(
  92668. /**
  92669. * defines the bone name
  92670. */
  92671. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  92672. /**
  92673. * Gets the current object class name.
  92674. * @return the class name
  92675. */
  92676. getClassName(): string;
  92677. /**
  92678. * Gets the parent skeleton
  92679. * @returns a skeleton
  92680. */
  92681. getSkeleton(): Skeleton;
  92682. /**
  92683. * Gets parent bone
  92684. * @returns a bone or null if the bone is the root of the bone hierarchy
  92685. */
  92686. getParent(): Nullable<Bone>;
  92687. /**
  92688. * Returns an array containing the root bones
  92689. * @returns an array containing the root bones
  92690. */
  92691. getChildren(): Array<Bone>;
  92692. /**
  92693. * Gets the node index in matrix array generated for rendering
  92694. * @returns the node index
  92695. */
  92696. getIndex(): number;
  92697. /**
  92698. * Sets the parent bone
  92699. * @param parent defines the parent (can be null if the bone is the root)
  92700. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92701. */
  92702. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  92703. /**
  92704. * Gets the local matrix
  92705. * @returns a matrix
  92706. */
  92707. getLocalMatrix(): Matrix;
  92708. /**
  92709. * Gets the base matrix (initial matrix which remains unchanged)
  92710. * @returns a matrix
  92711. */
  92712. getBaseMatrix(): Matrix;
  92713. /**
  92714. * Gets the rest pose matrix
  92715. * @returns a matrix
  92716. */
  92717. getRestPose(): Matrix;
  92718. /**
  92719. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  92720. */
  92721. getWorldMatrix(): Matrix;
  92722. /**
  92723. * Sets the local matrix to rest pose matrix
  92724. */
  92725. returnToRest(): void;
  92726. /**
  92727. * Gets the inverse of the absolute transform matrix.
  92728. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  92729. * @returns a matrix
  92730. */
  92731. getInvertedAbsoluteTransform(): Matrix;
  92732. /**
  92733. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  92734. * @returns a matrix
  92735. */
  92736. getAbsoluteTransform(): Matrix;
  92737. /**
  92738. * Links with the given transform node.
  92739. * The local matrix of this bone is copied from the transform node every frame.
  92740. * @param transformNode defines the transform node to link to
  92741. */
  92742. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  92743. /**
  92744. * Gets the node used to drive the bone's transformation
  92745. * @returns a transform node or null
  92746. */
  92747. getTransformNode(): Nullable<TransformNode>;
  92748. /** Gets or sets current position (in local space) */
  92749. get position(): Vector3;
  92750. set position(newPosition: Vector3);
  92751. /** Gets or sets current rotation (in local space) */
  92752. get rotation(): Vector3;
  92753. set rotation(newRotation: Vector3);
  92754. /** Gets or sets current rotation quaternion (in local space) */
  92755. get rotationQuaternion(): Quaternion;
  92756. set rotationQuaternion(newRotation: Quaternion);
  92757. /** Gets or sets current scaling (in local space) */
  92758. get scaling(): Vector3;
  92759. set scaling(newScaling: Vector3);
  92760. /**
  92761. * Gets the animation properties override
  92762. */
  92763. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  92764. private _decompose;
  92765. private _compose;
  92766. /**
  92767. * Update the base and local matrices
  92768. * @param matrix defines the new base or local matrix
  92769. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  92770. * @param updateLocalMatrix defines if the local matrix should be updated
  92771. */
  92772. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  92773. /** @hidden */
  92774. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  92775. /**
  92776. * Flag the bone as dirty (Forcing it to update everything)
  92777. */
  92778. markAsDirty(): void;
  92779. /** @hidden */
  92780. _markAsDirtyAndCompose(): void;
  92781. private _markAsDirtyAndDecompose;
  92782. /**
  92783. * Translate the bone in local or world space
  92784. * @param vec The amount to translate the bone
  92785. * @param space The space that the translation is in
  92786. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92787. */
  92788. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92789. /**
  92790. * Set the postion of the bone in local or world space
  92791. * @param position The position to set the bone
  92792. * @param space The space that the position is in
  92793. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92794. */
  92795. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92796. /**
  92797. * Set the absolute position of the bone (world space)
  92798. * @param position The position to set the bone
  92799. * @param mesh The mesh that this bone is attached to
  92800. */
  92801. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  92802. /**
  92803. * Scale the bone on the x, y and z axes (in local space)
  92804. * @param x The amount to scale the bone on the x axis
  92805. * @param y The amount to scale the bone on the y axis
  92806. * @param z The amount to scale the bone on the z axis
  92807. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  92808. */
  92809. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  92810. /**
  92811. * Set the bone scaling in local space
  92812. * @param scale defines the scaling vector
  92813. */
  92814. setScale(scale: Vector3): void;
  92815. /**
  92816. * Gets the current scaling in local space
  92817. * @returns the current scaling vector
  92818. */
  92819. getScale(): Vector3;
  92820. /**
  92821. * Gets the current scaling in local space and stores it in a target vector
  92822. * @param result defines the target vector
  92823. */
  92824. getScaleToRef(result: Vector3): void;
  92825. /**
  92826. * Set the yaw, pitch, and roll of the bone in local or world space
  92827. * @param yaw The rotation of the bone on the y axis
  92828. * @param pitch The rotation of the bone on the x axis
  92829. * @param roll The rotation of the bone on the z axis
  92830. * @param space The space that the axes of rotation are in
  92831. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92832. */
  92833. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  92834. /**
  92835. * Add a rotation to the bone on an axis in local or world space
  92836. * @param axis The axis to rotate the bone on
  92837. * @param amount The amount to rotate the bone
  92838. * @param space The space that the axis is in
  92839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92840. */
  92841. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  92842. /**
  92843. * Set the rotation of the bone to a particular axis angle in local or world space
  92844. * @param axis The axis to rotate the bone on
  92845. * @param angle The angle that the bone should be rotated to
  92846. * @param space The space that the axis is in
  92847. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92848. */
  92849. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  92850. /**
  92851. * Set the euler rotation of the bone in local of world space
  92852. * @param rotation The euler rotation that the bone should be set to
  92853. * @param space The space that the rotation is in
  92854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92855. */
  92856. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  92857. /**
  92858. * Set the quaternion rotation of the bone in local of world space
  92859. * @param quat The quaternion rotation that the bone should be set to
  92860. * @param space The space that the rotation is in
  92861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92862. */
  92863. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  92864. /**
  92865. * Set the rotation matrix of the bone in local of world space
  92866. * @param rotMat The rotation matrix that the bone should be set to
  92867. * @param space The space that the rotation is in
  92868. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92869. */
  92870. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  92871. private _rotateWithMatrix;
  92872. private _getNegativeRotationToRef;
  92873. /**
  92874. * Get the position of the bone in local or world space
  92875. * @param space The space that the returned position is in
  92876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92877. * @returns The position of the bone
  92878. */
  92879. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92880. /**
  92881. * Copy the position of the bone to a vector3 in local or world space
  92882. * @param space The space that the returned position is in
  92883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92884. * @param result The vector3 to copy the position to
  92885. */
  92886. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  92887. /**
  92888. * Get the absolute position of the bone (world space)
  92889. * @param mesh The mesh that this bone is attached to
  92890. * @returns The absolute position of the bone
  92891. */
  92892. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  92893. /**
  92894. * Copy the absolute position of the bone (world space) to the result param
  92895. * @param mesh The mesh that this bone is attached to
  92896. * @param result The vector3 to copy the absolute position to
  92897. */
  92898. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  92899. /**
  92900. * Compute the absolute transforms of this bone and its children
  92901. */
  92902. computeAbsoluteTransforms(): void;
  92903. /**
  92904. * Get the world direction from an axis that is in the local space of the bone
  92905. * @param localAxis The local direction that is used to compute the world direction
  92906. * @param mesh The mesh that this bone is attached to
  92907. * @returns The world direction
  92908. */
  92909. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92910. /**
  92911. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  92912. * @param localAxis The local direction that is used to compute the world direction
  92913. * @param mesh The mesh that this bone is attached to
  92914. * @param result The vector3 that the world direction will be copied to
  92915. */
  92916. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92917. /**
  92918. * Get the euler rotation of the bone in local or world space
  92919. * @param space The space that the rotation should be in
  92920. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92921. * @returns The euler rotation
  92922. */
  92923. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  92924. /**
  92925. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  92926. * @param space The space that the rotation should be in
  92927. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92928. * @param result The vector3 that the rotation should be copied to
  92929. */
  92930. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92931. /**
  92932. * Get the quaternion rotation of the bone in either local or world space
  92933. * @param space The space that the rotation should be in
  92934. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92935. * @returns The quaternion rotation
  92936. */
  92937. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  92938. /**
  92939. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  92940. * @param space The space that the rotation should be in
  92941. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92942. * @param result The quaternion that the rotation should be copied to
  92943. */
  92944. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  92945. /**
  92946. * Get the rotation matrix of the bone in local or world space
  92947. * @param space The space that the rotation should be in
  92948. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92949. * @returns The rotation matrix
  92950. */
  92951. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  92952. /**
  92953. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  92954. * @param space The space that the rotation should be in
  92955. * @param mesh The mesh that this bone is attached to. This is only used in world space
  92956. * @param result The quaternion that the rotation should be copied to
  92957. */
  92958. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  92959. /**
  92960. * Get the world position of a point that is in the local space of the bone
  92961. * @param position The local position
  92962. * @param mesh The mesh that this bone is attached to
  92963. * @returns The world position
  92964. */
  92965. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92966. /**
  92967. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  92968. * @param position The local position
  92969. * @param mesh The mesh that this bone is attached to
  92970. * @param result The vector3 that the world position should be copied to
  92971. */
  92972. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92973. /**
  92974. * Get the local position of a point that is in world space
  92975. * @param position The world position
  92976. * @param mesh The mesh that this bone is attached to
  92977. * @returns The local position
  92978. */
  92979. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  92980. /**
  92981. * Get the local position of a point that is in world space and copy it to the result param
  92982. * @param position The world position
  92983. * @param mesh The mesh that this bone is attached to
  92984. * @param result The vector3 that the local position should be copied to
  92985. */
  92986. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  92987. }
  92988. }
  92989. declare module BABYLON {
  92990. /**
  92991. * Defines a runtime animation
  92992. */
  92993. export class RuntimeAnimation {
  92994. private _events;
  92995. /**
  92996. * The current frame of the runtime animation
  92997. */
  92998. private _currentFrame;
  92999. /**
  93000. * The animation used by the runtime animation
  93001. */
  93002. private _animation;
  93003. /**
  93004. * The target of the runtime animation
  93005. */
  93006. private _target;
  93007. /**
  93008. * The initiating animatable
  93009. */
  93010. private _host;
  93011. /**
  93012. * The original value of the runtime animation
  93013. */
  93014. private _originalValue;
  93015. /**
  93016. * The original blend value of the runtime animation
  93017. */
  93018. private _originalBlendValue;
  93019. /**
  93020. * The offsets cache of the runtime animation
  93021. */
  93022. private _offsetsCache;
  93023. /**
  93024. * The high limits cache of the runtime animation
  93025. */
  93026. private _highLimitsCache;
  93027. /**
  93028. * Specifies if the runtime animation has been stopped
  93029. */
  93030. private _stopped;
  93031. /**
  93032. * The blending factor of the runtime animation
  93033. */
  93034. private _blendingFactor;
  93035. /**
  93036. * The BabylonJS scene
  93037. */
  93038. private _scene;
  93039. /**
  93040. * The current value of the runtime animation
  93041. */
  93042. private _currentValue;
  93043. /** @hidden */
  93044. _animationState: _IAnimationState;
  93045. /**
  93046. * The active target of the runtime animation
  93047. */
  93048. private _activeTargets;
  93049. private _currentActiveTarget;
  93050. private _directTarget;
  93051. /**
  93052. * The target path of the runtime animation
  93053. */
  93054. private _targetPath;
  93055. /**
  93056. * The weight of the runtime animation
  93057. */
  93058. private _weight;
  93059. /**
  93060. * The ratio offset of the runtime animation
  93061. */
  93062. private _ratioOffset;
  93063. /**
  93064. * The previous delay of the runtime animation
  93065. */
  93066. private _previousDelay;
  93067. /**
  93068. * The previous ratio of the runtime animation
  93069. */
  93070. private _previousRatio;
  93071. private _enableBlending;
  93072. private _keys;
  93073. private _minFrame;
  93074. private _maxFrame;
  93075. private _minValue;
  93076. private _maxValue;
  93077. private _targetIsArray;
  93078. /**
  93079. * Gets the current frame of the runtime animation
  93080. */
  93081. get currentFrame(): number;
  93082. /**
  93083. * Gets the weight of the runtime animation
  93084. */
  93085. get weight(): number;
  93086. /**
  93087. * Gets the current value of the runtime animation
  93088. */
  93089. get currentValue(): any;
  93090. /**
  93091. * Gets the target path of the runtime animation
  93092. */
  93093. get targetPath(): string;
  93094. /**
  93095. * Gets the actual target of the runtime animation
  93096. */
  93097. get target(): any;
  93098. /**
  93099. * Gets the additive state of the runtime animation
  93100. */
  93101. get isAdditive(): boolean;
  93102. /** @hidden */
  93103. _onLoop: () => void;
  93104. /**
  93105. * Create a new RuntimeAnimation object
  93106. * @param target defines the target of the animation
  93107. * @param animation defines the source animation object
  93108. * @param scene defines the hosting scene
  93109. * @param host defines the initiating Animatable
  93110. */
  93111. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93112. private _preparePath;
  93113. /**
  93114. * Gets the animation from the runtime animation
  93115. */
  93116. get animation(): Animation;
  93117. /**
  93118. * Resets the runtime animation to the beginning
  93119. * @param restoreOriginal defines whether to restore the target property to the original value
  93120. */
  93121. reset(restoreOriginal?: boolean): void;
  93122. /**
  93123. * Specifies if the runtime animation is stopped
  93124. * @returns Boolean specifying if the runtime animation is stopped
  93125. */
  93126. isStopped(): boolean;
  93127. /**
  93128. * Disposes of the runtime animation
  93129. */
  93130. dispose(): void;
  93131. /**
  93132. * Apply the interpolated value to the target
  93133. * @param currentValue defines the value computed by the animation
  93134. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93135. */
  93136. setValue(currentValue: any, weight: number): void;
  93137. private _getOriginalValues;
  93138. private _setValue;
  93139. /**
  93140. * Gets the loop pmode of the runtime animation
  93141. * @returns Loop Mode
  93142. */
  93143. private _getCorrectLoopMode;
  93144. /**
  93145. * Move the current animation to a given frame
  93146. * @param frame defines the frame to move to
  93147. */
  93148. goToFrame(frame: number): void;
  93149. /**
  93150. * @hidden Internal use only
  93151. */
  93152. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93153. /**
  93154. * Execute the current animation
  93155. * @param delay defines the delay to add to the current frame
  93156. * @param from defines the lower bound of the animation range
  93157. * @param to defines the upper bound of the animation range
  93158. * @param loop defines if the current animation must loop
  93159. * @param speedRatio defines the current speed ratio
  93160. * @param weight defines the weight of the animation (default is -1 so no weight)
  93161. * @param onLoop optional callback called when animation loops
  93162. * @returns a boolean indicating if the animation is running
  93163. */
  93164. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93165. }
  93166. }
  93167. declare module BABYLON {
  93168. /**
  93169. * Class used to store an actual running animation
  93170. */
  93171. export class Animatable {
  93172. /** defines the target object */
  93173. target: any;
  93174. /** defines the starting frame number (default is 0) */
  93175. fromFrame: number;
  93176. /** defines the ending frame number (default is 100) */
  93177. toFrame: number;
  93178. /** defines if the animation must loop (default is false) */
  93179. loopAnimation: boolean;
  93180. /** defines a callback to call when animation ends if it is not looping */
  93181. onAnimationEnd?: (() => void) | null | undefined;
  93182. /** defines a callback to call when animation loops */
  93183. onAnimationLoop?: (() => void) | null | undefined;
  93184. /** defines whether the animation should be evaluated additively */
  93185. isAdditive: boolean;
  93186. private _localDelayOffset;
  93187. private _pausedDelay;
  93188. private _runtimeAnimations;
  93189. private _paused;
  93190. private _scene;
  93191. private _speedRatio;
  93192. private _weight;
  93193. private _syncRoot;
  93194. /**
  93195. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93196. * This will only apply for non looping animation (default is true)
  93197. */
  93198. disposeOnEnd: boolean;
  93199. /**
  93200. * Gets a boolean indicating if the animation has started
  93201. */
  93202. animationStarted: boolean;
  93203. /**
  93204. * Observer raised when the animation ends
  93205. */
  93206. onAnimationEndObservable: Observable<Animatable>;
  93207. /**
  93208. * Observer raised when the animation loops
  93209. */
  93210. onAnimationLoopObservable: Observable<Animatable>;
  93211. /**
  93212. * Gets the root Animatable used to synchronize and normalize animations
  93213. */
  93214. get syncRoot(): Nullable<Animatable>;
  93215. /**
  93216. * Gets the current frame of the first RuntimeAnimation
  93217. * Used to synchronize Animatables
  93218. */
  93219. get masterFrame(): number;
  93220. /**
  93221. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93222. */
  93223. get weight(): number;
  93224. set weight(value: number);
  93225. /**
  93226. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93227. */
  93228. get speedRatio(): number;
  93229. set speedRatio(value: number);
  93230. /**
  93231. * Creates a new Animatable
  93232. * @param scene defines the hosting scene
  93233. * @param target defines the target object
  93234. * @param fromFrame defines the starting frame number (default is 0)
  93235. * @param toFrame defines the ending frame number (default is 100)
  93236. * @param loopAnimation defines if the animation must loop (default is false)
  93237. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93238. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93239. * @param animations defines a group of animation to add to the new Animatable
  93240. * @param onAnimationLoop defines a callback to call when animation loops
  93241. * @param isAdditive defines whether the animation should be evaluated additively
  93242. */
  93243. constructor(scene: Scene,
  93244. /** defines the target object */
  93245. target: any,
  93246. /** defines the starting frame number (default is 0) */
  93247. fromFrame?: number,
  93248. /** defines the ending frame number (default is 100) */
  93249. toFrame?: number,
  93250. /** defines if the animation must loop (default is false) */
  93251. loopAnimation?: boolean, speedRatio?: number,
  93252. /** defines a callback to call when animation ends if it is not looping */
  93253. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93254. /** defines a callback to call when animation loops */
  93255. onAnimationLoop?: (() => void) | null | undefined,
  93256. /** defines whether the animation should be evaluated additively */
  93257. isAdditive?: boolean);
  93258. /**
  93259. * Synchronize and normalize current Animatable with a source Animatable
  93260. * This is useful when using animation weights and when animations are not of the same length
  93261. * @param root defines the root Animatable to synchronize with
  93262. * @returns the current Animatable
  93263. */
  93264. syncWith(root: Animatable): Animatable;
  93265. /**
  93266. * Gets the list of runtime animations
  93267. * @returns an array of RuntimeAnimation
  93268. */
  93269. getAnimations(): RuntimeAnimation[];
  93270. /**
  93271. * Adds more animations to the current animatable
  93272. * @param target defines the target of the animations
  93273. * @param animations defines the new animations to add
  93274. */
  93275. appendAnimations(target: any, animations: Animation[]): void;
  93276. /**
  93277. * Gets the source animation for a specific property
  93278. * @param property defines the propertyu to look for
  93279. * @returns null or the source animation for the given property
  93280. */
  93281. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93282. /**
  93283. * Gets the runtime animation for a specific property
  93284. * @param property defines the propertyu to look for
  93285. * @returns null or the runtime animation for the given property
  93286. */
  93287. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93288. /**
  93289. * Resets the animatable to its original state
  93290. */
  93291. reset(): void;
  93292. /**
  93293. * Allows the animatable to blend with current running animations
  93294. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93295. * @param blendingSpeed defines the blending speed to use
  93296. */
  93297. enableBlending(blendingSpeed: number): void;
  93298. /**
  93299. * Disable animation blending
  93300. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93301. */
  93302. disableBlending(): void;
  93303. /**
  93304. * Jump directly to a given frame
  93305. * @param frame defines the frame to jump to
  93306. */
  93307. goToFrame(frame: number): void;
  93308. /**
  93309. * Pause the animation
  93310. */
  93311. pause(): void;
  93312. /**
  93313. * Restart the animation
  93314. */
  93315. restart(): void;
  93316. private _raiseOnAnimationEnd;
  93317. /**
  93318. * Stop and delete the current animation
  93319. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93320. * @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)
  93321. */
  93322. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93323. /**
  93324. * Wait asynchronously for the animation to end
  93325. * @returns a promise which will be fullfilled when the animation ends
  93326. */
  93327. waitAsync(): Promise<Animatable>;
  93328. /** @hidden */
  93329. _animate(delay: number): boolean;
  93330. }
  93331. interface Scene {
  93332. /** @hidden */
  93333. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  93334. /** @hidden */
  93335. _processLateAnimationBindingsForMatrices(holder: {
  93336. totalWeight: number;
  93337. totalAdditiveWeight: number;
  93338. animations: RuntimeAnimation[];
  93339. additiveAnimations: RuntimeAnimation[];
  93340. originalValue: Matrix;
  93341. }): any;
  93342. /** @hidden */
  93343. _processLateAnimationBindingsForQuaternions(holder: {
  93344. totalWeight: number;
  93345. totalAdditiveWeight: number;
  93346. animations: RuntimeAnimation[];
  93347. additiveAnimations: RuntimeAnimation[];
  93348. originalValue: Quaternion;
  93349. }, refQuaternion: Quaternion): Quaternion;
  93350. /** @hidden */
  93351. _processLateAnimationBindings(): void;
  93352. /**
  93353. * Will start the animation sequence of a given target
  93354. * @param target defines the target
  93355. * @param from defines from which frame should animation start
  93356. * @param to defines until which frame should animation run.
  93357. * @param weight defines the weight to apply to the animation (1.0 by default)
  93358. * @param loop defines if the animation loops
  93359. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93360. * @param onAnimationEnd defines the function to be executed when the animation ends
  93361. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93362. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93363. * @param onAnimationLoop defines the callback to call when an animation loops
  93364. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93365. * @returns the animatable object created for this animation
  93366. */
  93367. 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;
  93368. /**
  93369. * Will start the animation sequence of a given target
  93370. * @param target defines the target
  93371. * @param from defines from which frame should animation start
  93372. * @param to defines until which frame should animation run.
  93373. * @param loop defines if the animation loops
  93374. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93375. * @param onAnimationEnd defines the function to be executed when the animation ends
  93376. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93377. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93378. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  93379. * @param onAnimationLoop defines the callback to call when an animation loops
  93380. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93381. * @returns the animatable object created for this animation
  93382. */
  93383. 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;
  93384. /**
  93385. * Will start the animation sequence of a given target and its hierarchy
  93386. * @param target defines the target
  93387. * @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.
  93388. * @param from defines from which frame should animation start
  93389. * @param to defines until which frame should animation run.
  93390. * @param loop defines if the animation loops
  93391. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  93392. * @param onAnimationEnd defines the function to be executed when the animation ends
  93393. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  93394. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  93395. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  93396. * @param onAnimationLoop defines the callback to call when an animation loops
  93397. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93398. * @returns the list of created animatables
  93399. */
  93400. 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[];
  93401. /**
  93402. * Begin a new animation on a given node
  93403. * @param target defines the target where the animation will take place
  93404. * @param animations defines the list of animations to start
  93405. * @param from defines the initial value
  93406. * @param to defines the final value
  93407. * @param loop defines if you want animation to loop (off by default)
  93408. * @param speedRatio defines the speed ratio to apply to all animations
  93409. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93410. * @param onAnimationLoop defines the callback to call when an animation loops
  93411. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93412. * @returns the list of created animatables
  93413. */
  93414. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  93415. /**
  93416. * Begin a new animation on a given node and its hierarchy
  93417. * @param target defines the root node where the animation will take place
  93418. * @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.
  93419. * @param animations defines the list of animations to start
  93420. * @param from defines the initial value
  93421. * @param to defines the final value
  93422. * @param loop defines if you want animation to loop (off by default)
  93423. * @param speedRatio defines the speed ratio to apply to all animations
  93424. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93425. * @param onAnimationLoop defines the callback to call when an animation loops
  93426. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  93427. * @returns the list of animatables created for all nodes
  93428. */
  93429. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  93430. /**
  93431. * Gets the animatable associated with a specific target
  93432. * @param target defines the target of the animatable
  93433. * @returns the required animatable if found
  93434. */
  93435. getAnimatableByTarget(target: any): Nullable<Animatable>;
  93436. /**
  93437. * Gets all animatables associated with a given target
  93438. * @param target defines the target to look animatables for
  93439. * @returns an array of Animatables
  93440. */
  93441. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  93442. /**
  93443. * Stops and removes all animations that have been applied to the scene
  93444. */
  93445. stopAllAnimations(): void;
  93446. /**
  93447. * Gets the current delta time used by animation engine
  93448. */
  93449. deltaTime: number;
  93450. }
  93451. interface Bone {
  93452. /**
  93453. * Copy an animation range from another bone
  93454. * @param source defines the source bone
  93455. * @param rangeName defines the range name to copy
  93456. * @param frameOffset defines the frame offset
  93457. * @param rescaleAsRequired defines if rescaling must be applied if required
  93458. * @param skelDimensionsRatio defines the scaling ratio
  93459. * @returns true if operation was successful
  93460. */
  93461. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  93462. }
  93463. }
  93464. declare module BABYLON {
  93465. /**
  93466. * Class used to handle skinning animations
  93467. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93468. */
  93469. export class Skeleton implements IAnimatable {
  93470. /** defines the skeleton name */
  93471. name: string;
  93472. /** defines the skeleton Id */
  93473. id: string;
  93474. /**
  93475. * Defines the list of child bones
  93476. */
  93477. bones: Bone[];
  93478. /**
  93479. * Defines an estimate of the dimension of the skeleton at rest
  93480. */
  93481. dimensionsAtRest: Vector3;
  93482. /**
  93483. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  93484. */
  93485. needInitialSkinMatrix: boolean;
  93486. /**
  93487. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  93488. */
  93489. overrideMesh: Nullable<AbstractMesh>;
  93490. /**
  93491. * Gets the list of animations attached to this skeleton
  93492. */
  93493. animations: Array<Animation>;
  93494. private _scene;
  93495. private _isDirty;
  93496. private _transformMatrices;
  93497. private _transformMatrixTexture;
  93498. private _meshesWithPoseMatrix;
  93499. private _animatables;
  93500. private _identity;
  93501. private _synchronizedWithMesh;
  93502. private _ranges;
  93503. private _lastAbsoluteTransformsUpdateId;
  93504. private _canUseTextureForBones;
  93505. private _uniqueId;
  93506. /** @hidden */
  93507. _numBonesWithLinkedTransformNode: number;
  93508. /** @hidden */
  93509. _hasWaitingData: Nullable<boolean>;
  93510. /**
  93511. * Specifies if the skeleton should be serialized
  93512. */
  93513. doNotSerialize: boolean;
  93514. private _useTextureToStoreBoneMatrices;
  93515. /**
  93516. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  93517. * Please note that this option is not available if the hardware does not support it
  93518. */
  93519. get useTextureToStoreBoneMatrices(): boolean;
  93520. set useTextureToStoreBoneMatrices(value: boolean);
  93521. private _animationPropertiesOverride;
  93522. /**
  93523. * Gets or sets the animation properties override
  93524. */
  93525. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93526. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93527. /**
  93528. * List of inspectable custom properties (used by the Inspector)
  93529. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93530. */
  93531. inspectableCustomProperties: IInspectable[];
  93532. /**
  93533. * An observable triggered before computing the skeleton's matrices
  93534. */
  93535. onBeforeComputeObservable: Observable<Skeleton>;
  93536. /**
  93537. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  93538. */
  93539. get isUsingTextureForMatrices(): boolean;
  93540. /**
  93541. * Gets the unique ID of this skeleton
  93542. */
  93543. get uniqueId(): number;
  93544. /**
  93545. * Creates a new skeleton
  93546. * @param name defines the skeleton name
  93547. * @param id defines the skeleton Id
  93548. * @param scene defines the hosting scene
  93549. */
  93550. constructor(
  93551. /** defines the skeleton name */
  93552. name: string,
  93553. /** defines the skeleton Id */
  93554. id: string, scene: Scene);
  93555. /**
  93556. * Gets the current object class name.
  93557. * @return the class name
  93558. */
  93559. getClassName(): string;
  93560. /**
  93561. * Returns an array containing the root bones
  93562. * @returns an array containing the root bones
  93563. */
  93564. getChildren(): Array<Bone>;
  93565. /**
  93566. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  93567. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93568. * @returns a Float32Array containing matrices data
  93569. */
  93570. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  93571. /**
  93572. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  93573. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  93574. * @returns a raw texture containing the data
  93575. */
  93576. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  93577. /**
  93578. * Gets the current hosting scene
  93579. * @returns a scene object
  93580. */
  93581. getScene(): Scene;
  93582. /**
  93583. * Gets a string representing the current skeleton data
  93584. * @param fullDetails defines a boolean indicating if we want a verbose version
  93585. * @returns a string representing the current skeleton data
  93586. */
  93587. toString(fullDetails?: boolean): string;
  93588. /**
  93589. * Get bone's index searching by name
  93590. * @param name defines bone's name to search for
  93591. * @return the indice of the bone. Returns -1 if not found
  93592. */
  93593. getBoneIndexByName(name: string): number;
  93594. /**
  93595. * Creater a new animation range
  93596. * @param name defines the name of the range
  93597. * @param from defines the start key
  93598. * @param to defines the end key
  93599. */
  93600. createAnimationRange(name: string, from: number, to: number): void;
  93601. /**
  93602. * Delete a specific animation range
  93603. * @param name defines the name of the range
  93604. * @param deleteFrames defines if frames must be removed as well
  93605. */
  93606. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93607. /**
  93608. * Gets a specific animation range
  93609. * @param name defines the name of the range to look for
  93610. * @returns the requested animation range or null if not found
  93611. */
  93612. getAnimationRange(name: string): Nullable<AnimationRange>;
  93613. /**
  93614. * Gets the list of all animation ranges defined on this skeleton
  93615. * @returns an array
  93616. */
  93617. getAnimationRanges(): Nullable<AnimationRange>[];
  93618. /**
  93619. * Copy animation range from a source skeleton.
  93620. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  93621. * @param source defines the source skeleton
  93622. * @param name defines the name of the range to copy
  93623. * @param rescaleAsRequired defines if rescaling must be applied if required
  93624. * @returns true if operation was successful
  93625. */
  93626. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  93627. /**
  93628. * Forces the skeleton to go to rest pose
  93629. */
  93630. returnToRest(): void;
  93631. private _getHighestAnimationFrame;
  93632. /**
  93633. * Begin a specific animation range
  93634. * @param name defines the name of the range to start
  93635. * @param loop defines if looping must be turned on (false by default)
  93636. * @param speedRatio defines the speed ratio to apply (1 by default)
  93637. * @param onAnimationEnd defines a callback which will be called when animation will end
  93638. * @returns a new animatable
  93639. */
  93640. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93641. /**
  93642. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  93643. * @param skeleton defines the Skeleton containing the animation range to convert
  93644. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  93645. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  93646. * @returns the original skeleton
  93647. */
  93648. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  93649. /** @hidden */
  93650. _markAsDirty(): void;
  93651. /** @hidden */
  93652. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93653. /** @hidden */
  93654. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  93655. private _computeTransformMatrices;
  93656. /**
  93657. * Build all resources required to render a skeleton
  93658. */
  93659. prepare(): void;
  93660. /**
  93661. * Gets the list of animatables currently running for this skeleton
  93662. * @returns an array of animatables
  93663. */
  93664. getAnimatables(): IAnimatable[];
  93665. /**
  93666. * Clone the current skeleton
  93667. * @param name defines the name of the new skeleton
  93668. * @param id defines the id of the new skeleton
  93669. * @returns the new skeleton
  93670. */
  93671. clone(name: string, id?: string): Skeleton;
  93672. /**
  93673. * Enable animation blending for this skeleton
  93674. * @param blendingSpeed defines the blending speed to apply
  93675. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  93676. */
  93677. enableBlending(blendingSpeed?: number): void;
  93678. /**
  93679. * Releases all resources associated with the current skeleton
  93680. */
  93681. dispose(): void;
  93682. /**
  93683. * Serialize the skeleton in a JSON object
  93684. * @returns a JSON object
  93685. */
  93686. serialize(): any;
  93687. /**
  93688. * Creates a new skeleton from serialized data
  93689. * @param parsedSkeleton defines the serialized data
  93690. * @param scene defines the hosting scene
  93691. * @returns a new skeleton
  93692. */
  93693. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  93694. /**
  93695. * Compute all node absolute transforms
  93696. * @param forceUpdate defines if computation must be done even if cache is up to date
  93697. */
  93698. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  93699. /**
  93700. * Gets the root pose matrix
  93701. * @returns a matrix
  93702. */
  93703. getPoseMatrix(): Nullable<Matrix>;
  93704. /**
  93705. * Sorts bones per internal index
  93706. */
  93707. sortBones(): void;
  93708. private _sortBones;
  93709. }
  93710. }
  93711. declare module BABYLON {
  93712. /**
  93713. * Creates an instance based on a source mesh.
  93714. */
  93715. export class InstancedMesh extends AbstractMesh {
  93716. private _sourceMesh;
  93717. private _currentLOD;
  93718. /** @hidden */
  93719. _indexInSourceMeshInstanceArray: number;
  93720. constructor(name: string, source: Mesh);
  93721. /**
  93722. * Returns the string "InstancedMesh".
  93723. */
  93724. getClassName(): string;
  93725. /** Gets the list of lights affecting that mesh */
  93726. get lightSources(): Light[];
  93727. _resyncLightSources(): void;
  93728. _resyncLightSource(light: Light): void;
  93729. _removeLightSource(light: Light, dispose: boolean): void;
  93730. /**
  93731. * If the source mesh receives shadows
  93732. */
  93733. get receiveShadows(): boolean;
  93734. /**
  93735. * The material of the source mesh
  93736. */
  93737. get material(): Nullable<Material>;
  93738. /**
  93739. * Visibility of the source mesh
  93740. */
  93741. get visibility(): number;
  93742. /**
  93743. * Skeleton of the source mesh
  93744. */
  93745. get skeleton(): Nullable<Skeleton>;
  93746. /**
  93747. * Rendering ground id of the source mesh
  93748. */
  93749. get renderingGroupId(): number;
  93750. set renderingGroupId(value: number);
  93751. /**
  93752. * Returns the total number of vertices (integer).
  93753. */
  93754. getTotalVertices(): number;
  93755. /**
  93756. * Returns a positive integer : the total number of indices in this mesh geometry.
  93757. * @returns the numner of indices or zero if the mesh has no geometry.
  93758. */
  93759. getTotalIndices(): number;
  93760. /**
  93761. * The source mesh of the instance
  93762. */
  93763. get sourceMesh(): Mesh;
  93764. /**
  93765. * Creates a new InstancedMesh object from the mesh model.
  93766. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  93767. * @param name defines the name of the new instance
  93768. * @returns a new InstancedMesh
  93769. */
  93770. createInstance(name: string): InstancedMesh;
  93771. /**
  93772. * Is this node ready to be used/rendered
  93773. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93774. * @return {boolean} is it ready
  93775. */
  93776. isReady(completeCheck?: boolean): boolean;
  93777. /**
  93778. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93779. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  93780. * @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.
  93781. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  93782. */
  93783. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  93784. /**
  93785. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93786. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93787. * The `data` are either a numeric array either a Float32Array.
  93788. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  93789. * 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).
  93790. * Note that a new underlying VertexBuffer object is created each call.
  93791. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93792. *
  93793. * Possible `kind` values :
  93794. * - VertexBuffer.PositionKind
  93795. * - VertexBuffer.UVKind
  93796. * - VertexBuffer.UV2Kind
  93797. * - VertexBuffer.UV3Kind
  93798. * - VertexBuffer.UV4Kind
  93799. * - VertexBuffer.UV5Kind
  93800. * - VertexBuffer.UV6Kind
  93801. * - VertexBuffer.ColorKind
  93802. * - VertexBuffer.MatricesIndicesKind
  93803. * - VertexBuffer.MatricesIndicesExtraKind
  93804. * - VertexBuffer.MatricesWeightsKind
  93805. * - VertexBuffer.MatricesWeightsExtraKind
  93806. *
  93807. * Returns the Mesh.
  93808. */
  93809. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93810. /**
  93811. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93812. * If the mesh has no geometry, it is simply returned as it is.
  93813. * The `data` are either a numeric array either a Float32Array.
  93814. * No new underlying VertexBuffer object is created.
  93815. * 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.
  93816. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  93817. *
  93818. * Possible `kind` values :
  93819. * - VertexBuffer.PositionKind
  93820. * - VertexBuffer.UVKind
  93821. * - VertexBuffer.UV2Kind
  93822. * - VertexBuffer.UV3Kind
  93823. * - VertexBuffer.UV4Kind
  93824. * - VertexBuffer.UV5Kind
  93825. * - VertexBuffer.UV6Kind
  93826. * - VertexBuffer.ColorKind
  93827. * - VertexBuffer.MatricesIndicesKind
  93828. * - VertexBuffer.MatricesIndicesExtraKind
  93829. * - VertexBuffer.MatricesWeightsKind
  93830. * - VertexBuffer.MatricesWeightsExtraKind
  93831. *
  93832. * Returns the Mesh.
  93833. */
  93834. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  93835. /**
  93836. * Sets the mesh indices.
  93837. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  93838. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93839. * This method creates a new index buffer each call.
  93840. * Returns the Mesh.
  93841. */
  93842. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  93843. /**
  93844. * Boolean : True if the mesh owns the requested kind of data.
  93845. */
  93846. isVerticesDataPresent(kind: string): boolean;
  93847. /**
  93848. * Returns an array of indices (IndicesArray).
  93849. */
  93850. getIndices(): Nullable<IndicesArray>;
  93851. get _positions(): Nullable<Vector3[]>;
  93852. /**
  93853. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93854. * This means the mesh underlying bounding box and sphere are recomputed.
  93855. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93856. * @returns the current mesh
  93857. */
  93858. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  93859. /** @hidden */
  93860. _preActivate(): InstancedMesh;
  93861. /** @hidden */
  93862. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93863. /** @hidden */
  93864. _postActivate(): void;
  93865. getWorldMatrix(): Matrix;
  93866. get isAnInstance(): boolean;
  93867. /**
  93868. * Returns the current associated LOD AbstractMesh.
  93869. */
  93870. getLOD(camera: Camera): AbstractMesh;
  93871. /** @hidden */
  93872. _preActivateForIntermediateRendering(renderId: number): Mesh;
  93873. /** @hidden */
  93874. _syncSubMeshes(): InstancedMesh;
  93875. /** @hidden */
  93876. _generatePointsArray(): boolean;
  93877. /**
  93878. * Creates a new InstancedMesh from the current mesh.
  93879. * - name (string) : the cloned mesh name
  93880. * - newParent (optional Node) : the optional Node to parent the clone to.
  93881. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  93882. *
  93883. * Returns the clone.
  93884. */
  93885. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  93886. /**
  93887. * Disposes the InstancedMesh.
  93888. * Returns nothing.
  93889. */
  93890. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93891. }
  93892. interface Mesh {
  93893. /**
  93894. * Register a custom buffer that will be instanced
  93895. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93896. * @param kind defines the buffer kind
  93897. * @param stride defines the stride in floats
  93898. */
  93899. registerInstancedBuffer(kind: string, stride: number): void;
  93900. /**
  93901. * true to use the edge renderer for all instances of this mesh
  93902. */
  93903. edgesShareWithInstances: boolean;
  93904. /** @hidden */
  93905. _userInstancedBuffersStorage: {
  93906. data: {
  93907. [key: string]: Float32Array;
  93908. };
  93909. sizes: {
  93910. [key: string]: number;
  93911. };
  93912. vertexBuffers: {
  93913. [key: string]: Nullable<VertexBuffer>;
  93914. };
  93915. strides: {
  93916. [key: string]: number;
  93917. };
  93918. };
  93919. }
  93920. interface AbstractMesh {
  93921. /**
  93922. * Object used to store instanced buffers defined by user
  93923. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  93924. */
  93925. instancedBuffers: {
  93926. [key: string]: any;
  93927. };
  93928. }
  93929. }
  93930. declare module BABYLON {
  93931. /**
  93932. * Defines the options associated with the creation of a shader material.
  93933. */
  93934. export interface IShaderMaterialOptions {
  93935. /**
  93936. * Does the material work in alpha blend mode
  93937. */
  93938. needAlphaBlending: boolean;
  93939. /**
  93940. * Does the material work in alpha test mode
  93941. */
  93942. needAlphaTesting: boolean;
  93943. /**
  93944. * The list of attribute names used in the shader
  93945. */
  93946. attributes: string[];
  93947. /**
  93948. * The list of unifrom names used in the shader
  93949. */
  93950. uniforms: string[];
  93951. /**
  93952. * The list of UBO names used in the shader
  93953. */
  93954. uniformBuffers: string[];
  93955. /**
  93956. * The list of sampler names used in the shader
  93957. */
  93958. samplers: string[];
  93959. /**
  93960. * The list of defines used in the shader
  93961. */
  93962. defines: string[];
  93963. }
  93964. /**
  93965. * 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.
  93966. *
  93967. * This returned material effects how the mesh will look based on the code in the shaders.
  93968. *
  93969. * @see http://doc.babylonjs.com/how_to/shader_material
  93970. */
  93971. export class ShaderMaterial extends Material {
  93972. private _shaderPath;
  93973. private _options;
  93974. private _textures;
  93975. private _textureArrays;
  93976. private _floats;
  93977. private _ints;
  93978. private _floatsArrays;
  93979. private _colors3;
  93980. private _colors3Arrays;
  93981. private _colors4;
  93982. private _colors4Arrays;
  93983. private _vectors2;
  93984. private _vectors3;
  93985. private _vectors4;
  93986. private _matrices;
  93987. private _matrixArrays;
  93988. private _matrices3x3;
  93989. private _matrices2x2;
  93990. private _vectors2Arrays;
  93991. private _vectors3Arrays;
  93992. private _vectors4Arrays;
  93993. private _cachedWorldViewMatrix;
  93994. private _cachedWorldViewProjectionMatrix;
  93995. private _renderId;
  93996. private _multiview;
  93997. private _cachedDefines;
  93998. /** Define the Url to load snippets */
  93999. static SnippetUrl: string;
  94000. /** Snippet ID if the material was created from the snippet server */
  94001. snippetId: string;
  94002. /**
  94003. * Instantiate a new shader material.
  94004. * 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.
  94005. * This returned material effects how the mesh will look based on the code in the shaders.
  94006. * @see http://doc.babylonjs.com/how_to/shader_material
  94007. * @param name Define the name of the material in the scene
  94008. * @param scene Define the scene the material belongs to
  94009. * @param shaderPath Defines the route to the shader code in one of three ways:
  94010. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94011. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94012. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94013. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94014. * @param options Define the options used to create the shader
  94015. */
  94016. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94017. /**
  94018. * Gets the shader path used to define the shader code
  94019. * It can be modified to trigger a new compilation
  94020. */
  94021. get shaderPath(): any;
  94022. /**
  94023. * Sets the shader path used to define the shader code
  94024. * It can be modified to trigger a new compilation
  94025. */
  94026. set shaderPath(shaderPath: any);
  94027. /**
  94028. * Gets the options used to compile the shader.
  94029. * They can be modified to trigger a new compilation
  94030. */
  94031. get options(): IShaderMaterialOptions;
  94032. /**
  94033. * Gets the current class name of the material e.g. "ShaderMaterial"
  94034. * Mainly use in serialization.
  94035. * @returns the class name
  94036. */
  94037. getClassName(): string;
  94038. /**
  94039. * Specifies if the material will require alpha blending
  94040. * @returns a boolean specifying if alpha blending is needed
  94041. */
  94042. needAlphaBlending(): boolean;
  94043. /**
  94044. * Specifies if this material should be rendered in alpha test mode
  94045. * @returns a boolean specifying if an alpha test is needed.
  94046. */
  94047. needAlphaTesting(): boolean;
  94048. private _checkUniform;
  94049. /**
  94050. * Set a texture in the shader.
  94051. * @param name Define the name of the uniform samplers as defined in the shader
  94052. * @param texture Define the texture to bind to this sampler
  94053. * @return the material itself allowing "fluent" like uniform updates
  94054. */
  94055. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94056. /**
  94057. * Set a texture array in the shader.
  94058. * @param name Define the name of the uniform sampler array as defined in the shader
  94059. * @param textures Define the list of textures to bind to this sampler
  94060. * @return the material itself allowing "fluent" like uniform updates
  94061. */
  94062. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94063. /**
  94064. * Set a float in the shader.
  94065. * @param name Define the name of the uniform as defined in the shader
  94066. * @param value Define the value to give to the uniform
  94067. * @return the material itself allowing "fluent" like uniform updates
  94068. */
  94069. setFloat(name: string, value: number): ShaderMaterial;
  94070. /**
  94071. * Set a int in the shader.
  94072. * @param name Define the name of the uniform as defined in the shader
  94073. * @param value Define the value to give to the uniform
  94074. * @return the material itself allowing "fluent" like uniform updates
  94075. */
  94076. setInt(name: string, value: number): ShaderMaterial;
  94077. /**
  94078. * Set an array of floats in the shader.
  94079. * @param name Define the name of the uniform as defined in the shader
  94080. * @param value Define the value to give to the uniform
  94081. * @return the material itself allowing "fluent" like uniform updates
  94082. */
  94083. setFloats(name: string, value: number[]): ShaderMaterial;
  94084. /**
  94085. * Set a vec3 in the shader from a Color3.
  94086. * @param name Define the name of the uniform as defined in the shader
  94087. * @param value Define the value to give to the uniform
  94088. * @return the material itself allowing "fluent" like uniform updates
  94089. */
  94090. setColor3(name: string, value: Color3): ShaderMaterial;
  94091. /**
  94092. * Set a vec3 array in the shader from a Color3 array.
  94093. * @param name Define the name of the uniform as defined in the shader
  94094. * @param value Define the value to give to the uniform
  94095. * @return the material itself allowing "fluent" like uniform updates
  94096. */
  94097. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94098. /**
  94099. * Set a vec4 in the shader from a Color4.
  94100. * @param name Define the name of the uniform as defined in the shader
  94101. * @param value Define the value to give to the uniform
  94102. * @return the material itself allowing "fluent" like uniform updates
  94103. */
  94104. setColor4(name: string, value: Color4): ShaderMaterial;
  94105. /**
  94106. * Set a vec4 array in the shader from a Color4 array.
  94107. * @param name Define the name of the uniform as defined in the shader
  94108. * @param value Define the value to give to the uniform
  94109. * @return the material itself allowing "fluent" like uniform updates
  94110. */
  94111. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94112. /**
  94113. * Set a vec2 in the shader from a Vector2.
  94114. * @param name Define the name of the uniform as defined in the shader
  94115. * @param value Define the value to give to the uniform
  94116. * @return the material itself allowing "fluent" like uniform updates
  94117. */
  94118. setVector2(name: string, value: Vector2): ShaderMaterial;
  94119. /**
  94120. * Set a vec3 in the shader from a Vector3.
  94121. * @param name Define the name of the uniform as defined in the shader
  94122. * @param value Define the value to give to the uniform
  94123. * @return the material itself allowing "fluent" like uniform updates
  94124. */
  94125. setVector3(name: string, value: Vector3): ShaderMaterial;
  94126. /**
  94127. * Set a vec4 in the shader from a Vector4.
  94128. * @param name Define the name of the uniform as defined in the shader
  94129. * @param value Define the value to give to the uniform
  94130. * @return the material itself allowing "fluent" like uniform updates
  94131. */
  94132. setVector4(name: string, value: Vector4): ShaderMaterial;
  94133. /**
  94134. * Set a mat4 in the shader from a Matrix.
  94135. * @param name Define the name of the uniform as defined in the shader
  94136. * @param value Define the value to give to the uniform
  94137. * @return the material itself allowing "fluent" like uniform updates
  94138. */
  94139. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94140. /**
  94141. * Set a float32Array in the shader from a matrix array.
  94142. * @param name Define the name of the uniform as defined in the shader
  94143. * @param value Define the value to give to the uniform
  94144. * @return the material itself allowing "fluent" like uniform updates
  94145. */
  94146. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94147. /**
  94148. * Set a mat3 in the shader from a Float32Array.
  94149. * @param name Define the name of the uniform as defined in the shader
  94150. * @param value Define the value to give to the uniform
  94151. * @return the material itself allowing "fluent" like uniform updates
  94152. */
  94153. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94154. /**
  94155. * Set a mat2 in the shader from a Float32Array.
  94156. * @param name Define the name of the uniform as defined in the shader
  94157. * @param value Define the value to give to the uniform
  94158. * @return the material itself allowing "fluent" like uniform updates
  94159. */
  94160. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94161. /**
  94162. * Set a vec2 array in the shader from a number array.
  94163. * @param name Define the name of the uniform as defined in the shader
  94164. * @param value Define the value to give to the uniform
  94165. * @return the material itself allowing "fluent" like uniform updates
  94166. */
  94167. setArray2(name: string, value: number[]): ShaderMaterial;
  94168. /**
  94169. * Set a vec3 array in the shader from a number array.
  94170. * @param name Define the name of the uniform as defined in the shader
  94171. * @param value Define the value to give to the uniform
  94172. * @return the material itself allowing "fluent" like uniform updates
  94173. */
  94174. setArray3(name: string, value: number[]): ShaderMaterial;
  94175. /**
  94176. * Set a vec4 array in the shader from a number array.
  94177. * @param name Define the name of the uniform as defined in the shader
  94178. * @param value Define the value to give to the uniform
  94179. * @return the material itself allowing "fluent" like uniform updates
  94180. */
  94181. setArray4(name: string, value: number[]): ShaderMaterial;
  94182. private _checkCache;
  94183. /**
  94184. * Specifies that the submesh is ready to be used
  94185. * @param mesh defines the mesh to check
  94186. * @param subMesh defines which submesh to check
  94187. * @param useInstances specifies that instances should be used
  94188. * @returns a boolean indicating that the submesh is ready or not
  94189. */
  94190. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94191. /**
  94192. * Checks if the material is ready to render the requested mesh
  94193. * @param mesh Define the mesh to render
  94194. * @param useInstances Define whether or not the material is used with instances
  94195. * @returns true if ready, otherwise false
  94196. */
  94197. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94198. /**
  94199. * Binds the world matrix to the material
  94200. * @param world defines the world transformation matrix
  94201. * @param effectOverride - If provided, use this effect instead of internal effect
  94202. */
  94203. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94204. /**
  94205. * Binds the submesh to this material by preparing the effect and shader to draw
  94206. * @param world defines the world transformation matrix
  94207. * @param mesh defines the mesh containing the submesh
  94208. * @param subMesh defines the submesh to bind the material to
  94209. */
  94210. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94211. /**
  94212. * Binds the material to the mesh
  94213. * @param world defines the world transformation matrix
  94214. * @param mesh defines the mesh to bind the material to
  94215. * @param effectOverride - If provided, use this effect instead of internal effect
  94216. */
  94217. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94218. protected _afterBind(mesh?: Mesh): void;
  94219. /**
  94220. * Gets the active textures from the material
  94221. * @returns an array of textures
  94222. */
  94223. getActiveTextures(): BaseTexture[];
  94224. /**
  94225. * Specifies if the material uses a texture
  94226. * @param texture defines the texture to check against the material
  94227. * @returns a boolean specifying if the material uses the texture
  94228. */
  94229. hasTexture(texture: BaseTexture): boolean;
  94230. /**
  94231. * Makes a duplicate of the material, and gives it a new name
  94232. * @param name defines the new name for the duplicated material
  94233. * @returns the cloned material
  94234. */
  94235. clone(name: string): ShaderMaterial;
  94236. /**
  94237. * Disposes the material
  94238. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94239. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94240. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94241. */
  94242. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94243. /**
  94244. * Serializes this material in a JSON representation
  94245. * @returns the serialized material object
  94246. */
  94247. serialize(): any;
  94248. /**
  94249. * Creates a shader material from parsed shader material data
  94250. * @param source defines the JSON represnetation of the material
  94251. * @param scene defines the hosting scene
  94252. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94253. * @returns a new material
  94254. */
  94255. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94256. /**
  94257. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94258. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94259. * @param url defines the url to load from
  94260. * @param scene defines the hosting scene
  94261. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94262. * @returns a promise that will resolve to the new ShaderMaterial
  94263. */
  94264. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94265. /**
  94266. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94267. * @param snippetId defines the snippet to load
  94268. * @param scene defines the hosting scene
  94269. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94270. * @returns a promise that will resolve to the new ShaderMaterial
  94271. */
  94272. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94273. }
  94274. }
  94275. declare module BABYLON {
  94276. /** @hidden */
  94277. export var colorPixelShader: {
  94278. name: string;
  94279. shader: string;
  94280. };
  94281. }
  94282. declare module BABYLON {
  94283. /** @hidden */
  94284. export var colorVertexShader: {
  94285. name: string;
  94286. shader: string;
  94287. };
  94288. }
  94289. declare module BABYLON {
  94290. /**
  94291. * Line mesh
  94292. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94293. */
  94294. export class LinesMesh extends Mesh {
  94295. /**
  94296. * If vertex color should be applied to the mesh
  94297. */
  94298. readonly useVertexColor?: boolean | undefined;
  94299. /**
  94300. * If vertex alpha should be applied to the mesh
  94301. */
  94302. readonly useVertexAlpha?: boolean | undefined;
  94303. /**
  94304. * Color of the line (Default: White)
  94305. */
  94306. color: Color3;
  94307. /**
  94308. * Alpha of the line (Default: 1)
  94309. */
  94310. alpha: number;
  94311. /**
  94312. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94313. * This margin is expressed in world space coordinates, so its value may vary.
  94314. * Default value is 0.1
  94315. */
  94316. intersectionThreshold: number;
  94317. private _colorShader;
  94318. private color4;
  94319. /**
  94320. * Creates a new LinesMesh
  94321. * @param name defines the name
  94322. * @param scene defines the hosting scene
  94323. * @param parent defines the parent mesh if any
  94324. * @param source defines the optional source LinesMesh used to clone data from
  94325. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94326. * When false, achieved by calling a clone(), also passing False.
  94327. * This will make creation of children, recursive.
  94328. * @param useVertexColor defines if this LinesMesh supports vertex color
  94329. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  94330. */
  94331. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  94332. /**
  94333. * If vertex color should be applied to the mesh
  94334. */
  94335. useVertexColor?: boolean | undefined,
  94336. /**
  94337. * If vertex alpha should be applied to the mesh
  94338. */
  94339. useVertexAlpha?: boolean | undefined);
  94340. private _addClipPlaneDefine;
  94341. private _removeClipPlaneDefine;
  94342. isReady(): boolean;
  94343. /**
  94344. * Returns the string "LineMesh"
  94345. */
  94346. getClassName(): string;
  94347. /**
  94348. * @hidden
  94349. */
  94350. get material(): Material;
  94351. /**
  94352. * @hidden
  94353. */
  94354. set material(value: Material);
  94355. /**
  94356. * @hidden
  94357. */
  94358. get checkCollisions(): boolean;
  94359. /** @hidden */
  94360. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  94361. /** @hidden */
  94362. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  94363. /**
  94364. * Disposes of the line mesh
  94365. * @param doNotRecurse If children should be disposed
  94366. */
  94367. dispose(doNotRecurse?: boolean): void;
  94368. /**
  94369. * Returns a new LineMesh object cloned from the current one.
  94370. */
  94371. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  94372. /**
  94373. * Creates a new InstancedLinesMesh object from the mesh model.
  94374. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  94375. * @param name defines the name of the new instance
  94376. * @returns a new InstancedLinesMesh
  94377. */
  94378. createInstance(name: string): InstancedLinesMesh;
  94379. }
  94380. /**
  94381. * Creates an instance based on a source LinesMesh
  94382. */
  94383. export class InstancedLinesMesh extends InstancedMesh {
  94384. /**
  94385. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94386. * This margin is expressed in world space coordinates, so its value may vary.
  94387. * Initilized with the intersectionThreshold value of the source LinesMesh
  94388. */
  94389. intersectionThreshold: number;
  94390. constructor(name: string, source: LinesMesh);
  94391. /**
  94392. * Returns the string "InstancedLinesMesh".
  94393. */
  94394. getClassName(): string;
  94395. }
  94396. }
  94397. declare module BABYLON {
  94398. /** @hidden */
  94399. export var linePixelShader: {
  94400. name: string;
  94401. shader: string;
  94402. };
  94403. }
  94404. declare module BABYLON {
  94405. /** @hidden */
  94406. export var lineVertexShader: {
  94407. name: string;
  94408. shader: string;
  94409. };
  94410. }
  94411. declare module BABYLON {
  94412. interface Scene {
  94413. /** @hidden */
  94414. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  94415. }
  94416. interface AbstractMesh {
  94417. /**
  94418. * Gets the edgesRenderer associated with the mesh
  94419. */
  94420. edgesRenderer: Nullable<EdgesRenderer>;
  94421. }
  94422. interface LinesMesh {
  94423. /**
  94424. * Enables the edge rendering mode on the mesh.
  94425. * This mode makes the mesh edges visible
  94426. * @param epsilon defines the maximal distance between two angles to detect a face
  94427. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94428. * @returns the currentAbstractMesh
  94429. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94430. */
  94431. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  94432. }
  94433. interface InstancedLinesMesh {
  94434. /**
  94435. * Enables the edge rendering mode on the mesh.
  94436. * This mode makes the mesh edges visible
  94437. * @param epsilon defines the maximal distance between two angles to detect a face
  94438. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  94439. * @returns the current InstancedLinesMesh
  94440. * @see https://www.babylonjs-playground.com/#19O9TU#0
  94441. */
  94442. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  94443. }
  94444. /**
  94445. * Defines the minimum contract an Edges renderer should follow.
  94446. */
  94447. export interface IEdgesRenderer extends IDisposable {
  94448. /**
  94449. * Gets or sets a boolean indicating if the edgesRenderer is active
  94450. */
  94451. isEnabled: boolean;
  94452. /**
  94453. * Renders the edges of the attached mesh,
  94454. */
  94455. render(): void;
  94456. /**
  94457. * Checks wether or not the edges renderer is ready to render.
  94458. * @return true if ready, otherwise false.
  94459. */
  94460. isReady(): boolean;
  94461. /**
  94462. * List of instances to render in case the source mesh has instances
  94463. */
  94464. customInstances: SmartArray<Matrix>;
  94465. }
  94466. /**
  94467. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  94468. */
  94469. export class EdgesRenderer implements IEdgesRenderer {
  94470. /**
  94471. * Define the size of the edges with an orthographic camera
  94472. */
  94473. edgesWidthScalerForOrthographic: number;
  94474. /**
  94475. * Define the size of the edges with a perspective camera
  94476. */
  94477. edgesWidthScalerForPerspective: number;
  94478. protected _source: AbstractMesh;
  94479. protected _linesPositions: number[];
  94480. protected _linesNormals: number[];
  94481. protected _linesIndices: number[];
  94482. protected _epsilon: number;
  94483. protected _indicesCount: number;
  94484. protected _lineShader: ShaderMaterial;
  94485. protected _ib: DataBuffer;
  94486. protected _buffers: {
  94487. [key: string]: Nullable<VertexBuffer>;
  94488. };
  94489. protected _buffersForInstances: {
  94490. [key: string]: Nullable<VertexBuffer>;
  94491. };
  94492. protected _checkVerticesInsteadOfIndices: boolean;
  94493. private _meshRebuildObserver;
  94494. private _meshDisposeObserver;
  94495. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  94496. isEnabled: boolean;
  94497. /**
  94498. * List of instances to render in case the source mesh has instances
  94499. */
  94500. customInstances: SmartArray<Matrix>;
  94501. private static GetShader;
  94502. /**
  94503. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  94504. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  94505. * @param source Mesh used to create edges
  94506. * @param epsilon sum of angles in adjacency to check for edge
  94507. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  94508. * @param generateEdgesLines - should generate Lines or only prepare resources.
  94509. */
  94510. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  94511. protected _prepareRessources(): void;
  94512. /** @hidden */
  94513. _rebuild(): void;
  94514. /**
  94515. * Releases the required resources for the edges renderer
  94516. */
  94517. dispose(): void;
  94518. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  94519. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  94520. /**
  94521. * Checks if the pair of p0 and p1 is en edge
  94522. * @param faceIndex
  94523. * @param edge
  94524. * @param faceNormals
  94525. * @param p0
  94526. * @param p1
  94527. * @private
  94528. */
  94529. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  94530. /**
  94531. * push line into the position, normal and index buffer
  94532. * @protected
  94533. */
  94534. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  94535. /**
  94536. * Generates lines edges from adjacencjes
  94537. * @private
  94538. */
  94539. _generateEdgesLines(): void;
  94540. /**
  94541. * Checks wether or not the edges renderer is ready to render.
  94542. * @return true if ready, otherwise false.
  94543. */
  94544. isReady(): boolean;
  94545. /**
  94546. * Renders the edges of the attached mesh,
  94547. */
  94548. render(): void;
  94549. }
  94550. /**
  94551. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  94552. */
  94553. export class LineEdgesRenderer extends EdgesRenderer {
  94554. /**
  94555. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  94556. * @param source LineMesh used to generate edges
  94557. * @param epsilon not important (specified angle for edge detection)
  94558. * @param checkVerticesInsteadOfIndices not important for LineMesh
  94559. */
  94560. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  94561. /**
  94562. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  94563. */
  94564. _generateEdgesLines(): void;
  94565. }
  94566. }
  94567. declare module BABYLON {
  94568. /**
  94569. * This represents the object necessary to create a rendering group.
  94570. * This is exclusively used and created by the rendering manager.
  94571. * To modify the behavior, you use the available helpers in your scene or meshes.
  94572. * @hidden
  94573. */
  94574. export class RenderingGroup {
  94575. index: number;
  94576. private static _zeroVector;
  94577. private _scene;
  94578. private _opaqueSubMeshes;
  94579. private _transparentSubMeshes;
  94580. private _alphaTestSubMeshes;
  94581. private _depthOnlySubMeshes;
  94582. private _particleSystems;
  94583. private _spriteManagers;
  94584. private _opaqueSortCompareFn;
  94585. private _alphaTestSortCompareFn;
  94586. private _transparentSortCompareFn;
  94587. private _renderOpaque;
  94588. private _renderAlphaTest;
  94589. private _renderTransparent;
  94590. /** @hidden */
  94591. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  94592. onBeforeTransparentRendering: () => void;
  94593. /**
  94594. * Set the opaque sort comparison function.
  94595. * If null the sub meshes will be render in the order they were created
  94596. */
  94597. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94598. /**
  94599. * Set the alpha test sort comparison function.
  94600. * If null the sub meshes will be render in the order they were created
  94601. */
  94602. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94603. /**
  94604. * Set the transparent sort comparison function.
  94605. * If null the sub meshes will be render in the order they were created
  94606. */
  94607. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  94608. /**
  94609. * Creates a new rendering group.
  94610. * @param index The rendering group index
  94611. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  94612. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  94613. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  94614. */
  94615. 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>);
  94616. /**
  94617. * Render all the sub meshes contained in the group.
  94618. * @param customRenderFunction Used to override the default render behaviour of the group.
  94619. * @returns true if rendered some submeshes.
  94620. */
  94621. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  94622. /**
  94623. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  94624. * @param subMeshes The submeshes to render
  94625. */
  94626. private renderOpaqueSorted;
  94627. /**
  94628. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  94629. * @param subMeshes The submeshes to render
  94630. */
  94631. private renderAlphaTestSorted;
  94632. /**
  94633. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  94634. * @param subMeshes The submeshes to render
  94635. */
  94636. private renderTransparentSorted;
  94637. /**
  94638. * Renders the submeshes in a specified order.
  94639. * @param subMeshes The submeshes to sort before render
  94640. * @param sortCompareFn The comparison function use to sort
  94641. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  94642. * @param transparent Specifies to activate blending if true
  94643. */
  94644. private static renderSorted;
  94645. /**
  94646. * Renders the submeshes in the order they were dispatched (no sort applied).
  94647. * @param subMeshes The submeshes to render
  94648. */
  94649. private static renderUnsorted;
  94650. /**
  94651. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94652. * are rendered back to front if in the same alpha index.
  94653. *
  94654. * @param a The first submesh
  94655. * @param b The second submesh
  94656. * @returns The result of the comparison
  94657. */
  94658. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  94659. /**
  94660. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94661. * are rendered back to front.
  94662. *
  94663. * @param a The first submesh
  94664. * @param b The second submesh
  94665. * @returns The result of the comparison
  94666. */
  94667. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  94668. /**
  94669. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  94670. * are rendered front to back (prevent overdraw).
  94671. *
  94672. * @param a The first submesh
  94673. * @param b The second submesh
  94674. * @returns The result of the comparison
  94675. */
  94676. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  94677. /**
  94678. * Resets the different lists of submeshes to prepare a new frame.
  94679. */
  94680. prepare(): void;
  94681. dispose(): void;
  94682. /**
  94683. * Inserts the submesh in its correct queue depending on its material.
  94684. * @param subMesh The submesh to dispatch
  94685. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94686. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94687. */
  94688. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94689. dispatchSprites(spriteManager: ISpriteManager): void;
  94690. dispatchParticles(particleSystem: IParticleSystem): void;
  94691. private _renderParticles;
  94692. private _renderSprites;
  94693. }
  94694. }
  94695. declare module BABYLON {
  94696. /**
  94697. * Interface describing the different options available in the rendering manager
  94698. * regarding Auto Clear between groups.
  94699. */
  94700. export interface IRenderingManagerAutoClearSetup {
  94701. /**
  94702. * Defines whether or not autoclear is enable.
  94703. */
  94704. autoClear: boolean;
  94705. /**
  94706. * Defines whether or not to autoclear the depth buffer.
  94707. */
  94708. depth: boolean;
  94709. /**
  94710. * Defines whether or not to autoclear the stencil buffer.
  94711. */
  94712. stencil: boolean;
  94713. }
  94714. /**
  94715. * This class is used by the onRenderingGroupObservable
  94716. */
  94717. export class RenderingGroupInfo {
  94718. /**
  94719. * The Scene that being rendered
  94720. */
  94721. scene: Scene;
  94722. /**
  94723. * The camera currently used for the rendering pass
  94724. */
  94725. camera: Nullable<Camera>;
  94726. /**
  94727. * The ID of the renderingGroup being processed
  94728. */
  94729. renderingGroupId: number;
  94730. }
  94731. /**
  94732. * This is the manager responsible of all the rendering for meshes sprites and particles.
  94733. * It is enable to manage the different groups as well as the different necessary sort functions.
  94734. * This should not be used directly aside of the few static configurations
  94735. */
  94736. export class RenderingManager {
  94737. /**
  94738. * The max id used for rendering groups (not included)
  94739. */
  94740. static MAX_RENDERINGGROUPS: number;
  94741. /**
  94742. * The min id used for rendering groups (included)
  94743. */
  94744. static MIN_RENDERINGGROUPS: number;
  94745. /**
  94746. * Used to globally prevent autoclearing scenes.
  94747. */
  94748. static AUTOCLEAR: boolean;
  94749. /**
  94750. * @hidden
  94751. */
  94752. _useSceneAutoClearSetup: boolean;
  94753. private _scene;
  94754. private _renderingGroups;
  94755. private _depthStencilBufferAlreadyCleaned;
  94756. private _autoClearDepthStencil;
  94757. private _customOpaqueSortCompareFn;
  94758. private _customAlphaTestSortCompareFn;
  94759. private _customTransparentSortCompareFn;
  94760. private _renderingGroupInfo;
  94761. /**
  94762. * Instantiates a new rendering group for a particular scene
  94763. * @param scene Defines the scene the groups belongs to
  94764. */
  94765. constructor(scene: Scene);
  94766. private _clearDepthStencilBuffer;
  94767. /**
  94768. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  94769. * @hidden
  94770. */
  94771. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  94772. /**
  94773. * Resets the different information of the group to prepare a new frame
  94774. * @hidden
  94775. */
  94776. reset(): void;
  94777. /**
  94778. * Dispose and release the group and its associated resources.
  94779. * @hidden
  94780. */
  94781. dispose(): void;
  94782. /**
  94783. * Clear the info related to rendering groups preventing retention points during dispose.
  94784. */
  94785. freeRenderingGroups(): void;
  94786. private _prepareRenderingGroup;
  94787. /**
  94788. * Add a sprite manager to the rendering manager in order to render it this frame.
  94789. * @param spriteManager Define the sprite manager to render
  94790. */
  94791. dispatchSprites(spriteManager: ISpriteManager): void;
  94792. /**
  94793. * Add a particle system to the rendering manager in order to render it this frame.
  94794. * @param particleSystem Define the particle system to render
  94795. */
  94796. dispatchParticles(particleSystem: IParticleSystem): void;
  94797. /**
  94798. * Add a submesh to the manager in order to render it this frame
  94799. * @param subMesh The submesh to dispatch
  94800. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  94801. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  94802. */
  94803. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  94804. /**
  94805. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94806. * This allowed control for front to back rendering or reversly depending of the special needs.
  94807. *
  94808. * @param renderingGroupId The rendering group id corresponding to its index
  94809. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94810. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94811. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94812. */
  94813. 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;
  94814. /**
  94815. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94816. *
  94817. * @param renderingGroupId The rendering group id corresponding to its index
  94818. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94819. * @param depth Automatically clears depth between groups if true and autoClear is true.
  94820. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  94821. */
  94822. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  94823. /**
  94824. * Gets the current auto clear configuration for one rendering group of the rendering
  94825. * manager.
  94826. * @param index the rendering group index to get the information for
  94827. * @returns The auto clear setup for the requested rendering group
  94828. */
  94829. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  94830. }
  94831. }
  94832. declare module BABYLON {
  94833. /**
  94834. * Defines the options associated with the creation of a custom shader for a shadow generator.
  94835. */
  94836. export interface ICustomShaderOptions {
  94837. /**
  94838. * Gets or sets the custom shader name to use
  94839. */
  94840. shaderName: string;
  94841. /**
  94842. * The list of attribute names used in the shader
  94843. */
  94844. attributes?: string[];
  94845. /**
  94846. * The list of unifrom names used in the shader
  94847. */
  94848. uniforms?: string[];
  94849. /**
  94850. * The list of sampler names used in the shader
  94851. */
  94852. samplers?: string[];
  94853. /**
  94854. * The list of defines used in the shader
  94855. */
  94856. defines?: string[];
  94857. }
  94858. /**
  94859. * Interface to implement to create a shadow generator compatible with BJS.
  94860. */
  94861. export interface IShadowGenerator {
  94862. /**
  94863. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  94864. * @returns The render target texture if present otherwise, null
  94865. */
  94866. getShadowMap(): Nullable<RenderTargetTexture>;
  94867. /**
  94868. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  94869. * @param subMesh The submesh we want to render in the shadow map
  94870. * @param useInstances Defines wether will draw in the map using instances
  94871. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  94872. * @returns true if ready otherwise, false
  94873. */
  94874. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  94875. /**
  94876. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  94877. * @param defines Defines of the material we want to update
  94878. * @param lightIndex Index of the light in the enabled light list of the material
  94879. */
  94880. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  94881. /**
  94882. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  94883. * defined in the generator but impacting the effect).
  94884. * It implies the unifroms available on the materials are the standard BJS ones.
  94885. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  94886. * @param effect The effect we are binfing the information for
  94887. */
  94888. bindShadowLight(lightIndex: string, effect: Effect): void;
  94889. /**
  94890. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  94891. * (eq to shadow prjection matrix * light transform matrix)
  94892. * @returns The transform matrix used to create the shadow map
  94893. */
  94894. getTransformMatrix(): Matrix;
  94895. /**
  94896. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  94897. * Cube and 2D textures for instance.
  94898. */
  94899. recreateShadowMap(): void;
  94900. /**
  94901. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94902. * @param onCompiled Callback triggered at the and of the effects compilation
  94903. * @param options Sets of optional options forcing the compilation with different modes
  94904. */
  94905. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  94906. useInstances: boolean;
  94907. }>): void;
  94908. /**
  94909. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  94910. * @param options Sets of optional options forcing the compilation with different modes
  94911. * @returns A promise that resolves when the compilation completes
  94912. */
  94913. forceCompilationAsync(options?: Partial<{
  94914. useInstances: boolean;
  94915. }>): Promise<void>;
  94916. /**
  94917. * Serializes the shadow generator setup to a json object.
  94918. * @returns The serialized JSON object
  94919. */
  94920. serialize(): any;
  94921. /**
  94922. * Disposes the Shadow map and related Textures and effects.
  94923. */
  94924. dispose(): void;
  94925. }
  94926. /**
  94927. * Default implementation IShadowGenerator.
  94928. * This is the main object responsible of generating shadows in the framework.
  94929. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  94930. */
  94931. export class ShadowGenerator implements IShadowGenerator {
  94932. /**
  94933. * Name of the shadow generator class
  94934. */
  94935. static CLASSNAME: string;
  94936. /**
  94937. * Shadow generator mode None: no filtering applied.
  94938. */
  94939. static readonly FILTER_NONE: number;
  94940. /**
  94941. * Shadow generator mode ESM: Exponential Shadow Mapping.
  94942. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94943. */
  94944. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  94945. /**
  94946. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  94947. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  94948. */
  94949. static readonly FILTER_POISSONSAMPLING: number;
  94950. /**
  94951. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  94952. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94953. */
  94954. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  94955. /**
  94956. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  94957. * edge artifacts on steep falloff.
  94958. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94959. */
  94960. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  94961. /**
  94962. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  94963. * edge artifacts on steep falloff.
  94964. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  94965. */
  94966. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  94967. /**
  94968. * Shadow generator mode PCF: Percentage Closer Filtering
  94969. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94970. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  94971. */
  94972. static readonly FILTER_PCF: number;
  94973. /**
  94974. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  94975. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  94976. * Contact Hardening
  94977. */
  94978. static readonly FILTER_PCSS: number;
  94979. /**
  94980. * Reserved for PCF and PCSS
  94981. * Highest Quality.
  94982. *
  94983. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  94984. *
  94985. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  94986. */
  94987. static readonly QUALITY_HIGH: number;
  94988. /**
  94989. * Reserved for PCF and PCSS
  94990. * Good tradeoff for quality/perf cross devices
  94991. *
  94992. * Execute PCF on a 3*3 kernel.
  94993. *
  94994. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  94995. */
  94996. static readonly QUALITY_MEDIUM: number;
  94997. /**
  94998. * Reserved for PCF and PCSS
  94999. * The lowest quality but the fastest.
  95000. *
  95001. * Execute PCF on a 1*1 kernel.
  95002. *
  95003. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95004. */
  95005. static readonly QUALITY_LOW: number;
  95006. /** Gets or sets the custom shader name to use */
  95007. customShaderOptions: ICustomShaderOptions;
  95008. /**
  95009. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95010. */
  95011. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95012. /**
  95013. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95014. */
  95015. onAfterShadowMapRenderObservable: Observable<Effect>;
  95016. /**
  95017. * Observable triggered before a mesh is rendered in the shadow map.
  95018. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95019. */
  95020. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95021. /**
  95022. * Observable triggered after a mesh is rendered in the shadow map.
  95023. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95024. */
  95025. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95026. protected _bias: number;
  95027. /**
  95028. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95029. */
  95030. get bias(): number;
  95031. /**
  95032. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95033. */
  95034. set bias(bias: number);
  95035. protected _normalBias: number;
  95036. /**
  95037. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95038. */
  95039. get normalBias(): number;
  95040. /**
  95041. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95042. */
  95043. set normalBias(normalBias: number);
  95044. protected _blurBoxOffset: number;
  95045. /**
  95046. * Gets the blur box offset: offset applied during the blur pass.
  95047. * Only useful if useKernelBlur = false
  95048. */
  95049. get blurBoxOffset(): number;
  95050. /**
  95051. * Sets the blur box offset: offset applied during the blur pass.
  95052. * Only useful if useKernelBlur = false
  95053. */
  95054. set blurBoxOffset(value: number);
  95055. protected _blurScale: number;
  95056. /**
  95057. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95058. * 2 means half of the size.
  95059. */
  95060. get blurScale(): number;
  95061. /**
  95062. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95063. * 2 means half of the size.
  95064. */
  95065. set blurScale(value: number);
  95066. protected _blurKernel: number;
  95067. /**
  95068. * Gets the blur kernel: kernel size of the blur pass.
  95069. * Only useful if useKernelBlur = true
  95070. */
  95071. get blurKernel(): number;
  95072. /**
  95073. * Sets the blur kernel: kernel size of the blur pass.
  95074. * Only useful if useKernelBlur = true
  95075. */
  95076. set blurKernel(value: number);
  95077. protected _useKernelBlur: boolean;
  95078. /**
  95079. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95080. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95081. */
  95082. get useKernelBlur(): boolean;
  95083. /**
  95084. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95085. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95086. */
  95087. set useKernelBlur(value: boolean);
  95088. protected _depthScale: number;
  95089. /**
  95090. * Gets the depth scale used in ESM mode.
  95091. */
  95092. get depthScale(): number;
  95093. /**
  95094. * Sets the depth scale used in ESM mode.
  95095. * This can override the scale stored on the light.
  95096. */
  95097. set depthScale(value: number);
  95098. protected _validateFilter(filter: number): number;
  95099. protected _filter: number;
  95100. /**
  95101. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95102. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95103. */
  95104. get filter(): number;
  95105. /**
  95106. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95107. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95108. */
  95109. set filter(value: number);
  95110. /**
  95111. * Gets if the current filter is set to Poisson Sampling.
  95112. */
  95113. get usePoissonSampling(): boolean;
  95114. /**
  95115. * Sets the current filter to Poisson Sampling.
  95116. */
  95117. set usePoissonSampling(value: boolean);
  95118. /**
  95119. * Gets if the current filter is set to ESM.
  95120. */
  95121. get useExponentialShadowMap(): boolean;
  95122. /**
  95123. * Sets the current filter is to ESM.
  95124. */
  95125. set useExponentialShadowMap(value: boolean);
  95126. /**
  95127. * Gets if the current filter is set to filtered ESM.
  95128. */
  95129. get useBlurExponentialShadowMap(): boolean;
  95130. /**
  95131. * Gets if the current filter is set to filtered ESM.
  95132. */
  95133. set useBlurExponentialShadowMap(value: boolean);
  95134. /**
  95135. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95136. * exponential to prevent steep falloff artifacts).
  95137. */
  95138. get useCloseExponentialShadowMap(): boolean;
  95139. /**
  95140. * Sets the current filter to "close ESM" (using the inverse of the
  95141. * exponential to prevent steep falloff artifacts).
  95142. */
  95143. set useCloseExponentialShadowMap(value: boolean);
  95144. /**
  95145. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95146. * exponential to prevent steep falloff artifacts).
  95147. */
  95148. get useBlurCloseExponentialShadowMap(): boolean;
  95149. /**
  95150. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95151. * exponential to prevent steep falloff artifacts).
  95152. */
  95153. set useBlurCloseExponentialShadowMap(value: boolean);
  95154. /**
  95155. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95156. */
  95157. get usePercentageCloserFiltering(): boolean;
  95158. /**
  95159. * Sets the current filter to "PCF" (percentage closer filtering).
  95160. */
  95161. set usePercentageCloserFiltering(value: boolean);
  95162. protected _filteringQuality: number;
  95163. /**
  95164. * Gets the PCF or PCSS Quality.
  95165. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95166. */
  95167. get filteringQuality(): number;
  95168. /**
  95169. * Sets the PCF or PCSS Quality.
  95170. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95171. */
  95172. set filteringQuality(filteringQuality: number);
  95173. /**
  95174. * Gets if the current filter is set to "PCSS" (contact hardening).
  95175. */
  95176. get useContactHardeningShadow(): boolean;
  95177. /**
  95178. * Sets the current filter to "PCSS" (contact hardening).
  95179. */
  95180. set useContactHardeningShadow(value: boolean);
  95181. protected _contactHardeningLightSizeUVRatio: number;
  95182. /**
  95183. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95184. * Using a ratio helps keeping shape stability independently of the map size.
  95185. *
  95186. * It does not account for the light projection as it was having too much
  95187. * instability during the light setup or during light position changes.
  95188. *
  95189. * Only valid if useContactHardeningShadow is true.
  95190. */
  95191. get contactHardeningLightSizeUVRatio(): number;
  95192. /**
  95193. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95194. * Using a ratio helps keeping shape stability independently of the map size.
  95195. *
  95196. * It does not account for the light projection as it was having too much
  95197. * instability during the light setup or during light position changes.
  95198. *
  95199. * Only valid if useContactHardeningShadow is true.
  95200. */
  95201. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95202. protected _darkness: number;
  95203. /** Gets or sets the actual darkness of a shadow */
  95204. get darkness(): number;
  95205. set darkness(value: number);
  95206. /**
  95207. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95208. * 0 means strongest and 1 would means no shadow.
  95209. * @returns the darkness.
  95210. */
  95211. getDarkness(): number;
  95212. /**
  95213. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95214. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95215. * @returns the shadow generator allowing fluent coding.
  95216. */
  95217. setDarkness(darkness: number): ShadowGenerator;
  95218. protected _transparencyShadow: boolean;
  95219. /** Gets or sets the ability to have transparent shadow */
  95220. get transparencyShadow(): boolean;
  95221. set transparencyShadow(value: boolean);
  95222. /**
  95223. * Sets the ability to have transparent shadow (boolean).
  95224. * @param transparent True if transparent else False
  95225. * @returns the shadow generator allowing fluent coding
  95226. */
  95227. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95228. /**
  95229. * Enables or disables shadows with varying strength based on the transparency
  95230. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95231. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95232. * mesh.visibility * alphaTexture.a
  95233. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95234. */
  95235. enableSoftTransparentShadow: boolean;
  95236. protected _shadowMap: Nullable<RenderTargetTexture>;
  95237. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95238. /**
  95239. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95240. * @returns The render target texture if present otherwise, null
  95241. */
  95242. getShadowMap(): Nullable<RenderTargetTexture>;
  95243. /**
  95244. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95245. * @returns The render target texture if the shadow map is present otherwise, null
  95246. */
  95247. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95248. /**
  95249. * Gets the class name of that object
  95250. * @returns "ShadowGenerator"
  95251. */
  95252. getClassName(): string;
  95253. /**
  95254. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95255. * @param mesh Mesh to add
  95256. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95257. * @returns the Shadow Generator itself
  95258. */
  95259. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95260. /**
  95261. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95262. * @param mesh Mesh to remove
  95263. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95264. * @returns the Shadow Generator itself
  95265. */
  95266. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95267. /**
  95268. * Controls the extent to which the shadows fade out at the edge of the frustum
  95269. */
  95270. frustumEdgeFalloff: number;
  95271. protected _light: IShadowLight;
  95272. /**
  95273. * Returns the associated light object.
  95274. * @returns the light generating the shadow
  95275. */
  95276. getLight(): IShadowLight;
  95277. /**
  95278. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95279. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95280. * It might on the other hand introduce peter panning.
  95281. */
  95282. forceBackFacesOnly: boolean;
  95283. protected _scene: Scene;
  95284. protected _lightDirection: Vector3;
  95285. protected _effect: Effect;
  95286. protected _viewMatrix: Matrix;
  95287. protected _projectionMatrix: Matrix;
  95288. protected _transformMatrix: Matrix;
  95289. protected _cachedPosition: Vector3;
  95290. protected _cachedDirection: Vector3;
  95291. protected _cachedDefines: string;
  95292. protected _currentRenderID: number;
  95293. protected _boxBlurPostprocess: Nullable<PostProcess>;
  95294. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  95295. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  95296. protected _blurPostProcesses: PostProcess[];
  95297. protected _mapSize: number;
  95298. protected _currentFaceIndex: number;
  95299. protected _currentFaceIndexCache: number;
  95300. protected _textureType: number;
  95301. protected _defaultTextureMatrix: Matrix;
  95302. protected _storedUniqueId: Nullable<number>;
  95303. /** @hidden */
  95304. static _SceneComponentInitialization: (scene: Scene) => void;
  95305. /**
  95306. * Creates a ShadowGenerator object.
  95307. * A ShadowGenerator is the required tool to use the shadows.
  95308. * Each light casting shadows needs to use its own ShadowGenerator.
  95309. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  95310. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  95311. * @param light The light object generating the shadows.
  95312. * @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.
  95313. */
  95314. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  95315. protected _initializeGenerator(): void;
  95316. protected _createTargetRenderTexture(): void;
  95317. protected _initializeShadowMap(): void;
  95318. protected _initializeBlurRTTAndPostProcesses(): void;
  95319. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  95320. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  95321. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  95322. protected _applyFilterValues(): void;
  95323. /**
  95324. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95325. * @param onCompiled Callback triggered at the and of the effects compilation
  95326. * @param options Sets of optional options forcing the compilation with different modes
  95327. */
  95328. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95329. useInstances: boolean;
  95330. }>): void;
  95331. /**
  95332. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95333. * @param options Sets of optional options forcing the compilation with different modes
  95334. * @returns A promise that resolves when the compilation completes
  95335. */
  95336. forceCompilationAsync(options?: Partial<{
  95337. useInstances: boolean;
  95338. }>): Promise<void>;
  95339. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  95340. private _prepareShadowDefines;
  95341. /**
  95342. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95343. * @param subMesh The submesh we want to render in the shadow map
  95344. * @param useInstances Defines wether will draw in the map using instances
  95345. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95346. * @returns true if ready otherwise, false
  95347. */
  95348. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95349. /**
  95350. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95351. * @param defines Defines of the material we want to update
  95352. * @param lightIndex Index of the light in the enabled light list of the material
  95353. */
  95354. prepareDefines(defines: any, lightIndex: number): void;
  95355. /**
  95356. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95357. * defined in the generator but impacting the effect).
  95358. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95359. * @param effect The effect we are binfing the information for
  95360. */
  95361. bindShadowLight(lightIndex: string, effect: Effect): void;
  95362. /**
  95363. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95364. * (eq to shadow prjection matrix * light transform matrix)
  95365. * @returns The transform matrix used to create the shadow map
  95366. */
  95367. getTransformMatrix(): Matrix;
  95368. /**
  95369. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95370. * Cube and 2D textures for instance.
  95371. */
  95372. recreateShadowMap(): void;
  95373. protected _disposeBlurPostProcesses(): void;
  95374. protected _disposeRTTandPostProcesses(): void;
  95375. /**
  95376. * Disposes the ShadowGenerator.
  95377. * Returns nothing.
  95378. */
  95379. dispose(): void;
  95380. /**
  95381. * Serializes the shadow generator setup to a json object.
  95382. * @returns The serialized JSON object
  95383. */
  95384. serialize(): any;
  95385. /**
  95386. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  95387. * @param parsedShadowGenerator The JSON object to parse
  95388. * @param scene The scene to create the shadow map for
  95389. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  95390. * @returns The parsed shadow generator
  95391. */
  95392. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  95393. }
  95394. }
  95395. declare module BABYLON {
  95396. /**
  95397. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  95398. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  95399. * 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.
  95400. */
  95401. export abstract class Light extends Node {
  95402. /**
  95403. * Falloff Default: light is falling off following the material specification:
  95404. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  95405. */
  95406. static readonly FALLOFF_DEFAULT: number;
  95407. /**
  95408. * Falloff Physical: light is falling off following the inverse squared distance law.
  95409. */
  95410. static readonly FALLOFF_PHYSICAL: number;
  95411. /**
  95412. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  95413. * to enhance interoperability with other engines.
  95414. */
  95415. static readonly FALLOFF_GLTF: number;
  95416. /**
  95417. * Falloff Standard: light is falling off like in the standard material
  95418. * to enhance interoperability with other materials.
  95419. */
  95420. static readonly FALLOFF_STANDARD: number;
  95421. /**
  95422. * If every light affecting the material is in this lightmapMode,
  95423. * material.lightmapTexture adds or multiplies
  95424. * (depends on material.useLightmapAsShadowmap)
  95425. * after every other light calculations.
  95426. */
  95427. static readonly LIGHTMAP_DEFAULT: number;
  95428. /**
  95429. * material.lightmapTexture as only diffuse lighting from this light
  95430. * adds only specular lighting from this light
  95431. * adds dynamic shadows
  95432. */
  95433. static readonly LIGHTMAP_SPECULAR: number;
  95434. /**
  95435. * material.lightmapTexture as only lighting
  95436. * no light calculation from this light
  95437. * only adds dynamic shadows from this light
  95438. */
  95439. static readonly LIGHTMAP_SHADOWSONLY: number;
  95440. /**
  95441. * Each light type uses the default quantity according to its type:
  95442. * point/spot lights use luminous intensity
  95443. * directional lights use illuminance
  95444. */
  95445. static readonly INTENSITYMODE_AUTOMATIC: number;
  95446. /**
  95447. * lumen (lm)
  95448. */
  95449. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  95450. /**
  95451. * candela (lm/sr)
  95452. */
  95453. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  95454. /**
  95455. * lux (lm/m^2)
  95456. */
  95457. static readonly INTENSITYMODE_ILLUMINANCE: number;
  95458. /**
  95459. * nit (cd/m^2)
  95460. */
  95461. static readonly INTENSITYMODE_LUMINANCE: number;
  95462. /**
  95463. * Light type const id of the point light.
  95464. */
  95465. static readonly LIGHTTYPEID_POINTLIGHT: number;
  95466. /**
  95467. * Light type const id of the directional light.
  95468. */
  95469. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  95470. /**
  95471. * Light type const id of the spot light.
  95472. */
  95473. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  95474. /**
  95475. * Light type const id of the hemispheric light.
  95476. */
  95477. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  95478. /**
  95479. * Diffuse gives the basic color to an object.
  95480. */
  95481. diffuse: Color3;
  95482. /**
  95483. * Specular produces a highlight color on an object.
  95484. * Note: This is note affecting PBR materials.
  95485. */
  95486. specular: Color3;
  95487. /**
  95488. * Defines the falloff type for this light. This lets overrriding how punctual light are
  95489. * falling off base on range or angle.
  95490. * This can be set to any values in Light.FALLOFF_x.
  95491. *
  95492. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  95493. * other types of materials.
  95494. */
  95495. falloffType: number;
  95496. /**
  95497. * Strength of the light.
  95498. * Note: By default it is define in the framework own unit.
  95499. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  95500. */
  95501. intensity: number;
  95502. private _range;
  95503. protected _inverseSquaredRange: number;
  95504. /**
  95505. * Defines how far from the source the light is impacting in scene units.
  95506. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95507. */
  95508. get range(): number;
  95509. /**
  95510. * Defines how far from the source the light is impacting in scene units.
  95511. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  95512. */
  95513. set range(value: number);
  95514. /**
  95515. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  95516. * of light.
  95517. */
  95518. private _photometricScale;
  95519. private _intensityMode;
  95520. /**
  95521. * Gets the photometric scale used to interpret the intensity.
  95522. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95523. */
  95524. get intensityMode(): number;
  95525. /**
  95526. * Sets the photometric scale used to interpret the intensity.
  95527. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  95528. */
  95529. set intensityMode(value: number);
  95530. private _radius;
  95531. /**
  95532. * Gets the light radius used by PBR Materials to simulate soft area lights.
  95533. */
  95534. get radius(): number;
  95535. /**
  95536. * sets the light radius used by PBR Materials to simulate soft area lights.
  95537. */
  95538. set radius(value: number);
  95539. private _renderPriority;
  95540. /**
  95541. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  95542. * exceeding the number allowed of the materials.
  95543. */
  95544. renderPriority: number;
  95545. private _shadowEnabled;
  95546. /**
  95547. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95548. * the current shadow generator.
  95549. */
  95550. get shadowEnabled(): boolean;
  95551. /**
  95552. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  95553. * the current shadow generator.
  95554. */
  95555. set shadowEnabled(value: boolean);
  95556. private _includedOnlyMeshes;
  95557. /**
  95558. * Gets the only meshes impacted by this light.
  95559. */
  95560. get includedOnlyMeshes(): AbstractMesh[];
  95561. /**
  95562. * Sets the only meshes impacted by this light.
  95563. */
  95564. set includedOnlyMeshes(value: AbstractMesh[]);
  95565. private _excludedMeshes;
  95566. /**
  95567. * Gets the meshes not impacted by this light.
  95568. */
  95569. get excludedMeshes(): AbstractMesh[];
  95570. /**
  95571. * Sets the meshes not impacted by this light.
  95572. */
  95573. set excludedMeshes(value: AbstractMesh[]);
  95574. private _excludeWithLayerMask;
  95575. /**
  95576. * Gets the layer id use to find what meshes are not impacted by the light.
  95577. * Inactive if 0
  95578. */
  95579. get excludeWithLayerMask(): number;
  95580. /**
  95581. * Sets the layer id use to find what meshes are not impacted by the light.
  95582. * Inactive if 0
  95583. */
  95584. set excludeWithLayerMask(value: number);
  95585. private _includeOnlyWithLayerMask;
  95586. /**
  95587. * Gets the layer id use to find what meshes are impacted by the light.
  95588. * Inactive if 0
  95589. */
  95590. get includeOnlyWithLayerMask(): number;
  95591. /**
  95592. * Sets the layer id use to find what meshes are impacted by the light.
  95593. * Inactive if 0
  95594. */
  95595. set includeOnlyWithLayerMask(value: number);
  95596. private _lightmapMode;
  95597. /**
  95598. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95599. */
  95600. get lightmapMode(): number;
  95601. /**
  95602. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  95603. */
  95604. set lightmapMode(value: number);
  95605. /**
  95606. * Shadow generator associted to the light.
  95607. * @hidden Internal use only.
  95608. */
  95609. _shadowGenerator: Nullable<IShadowGenerator>;
  95610. /**
  95611. * @hidden Internal use only.
  95612. */
  95613. _excludedMeshesIds: string[];
  95614. /**
  95615. * @hidden Internal use only.
  95616. */
  95617. _includedOnlyMeshesIds: string[];
  95618. /**
  95619. * The current light unifom buffer.
  95620. * @hidden Internal use only.
  95621. */
  95622. _uniformBuffer: UniformBuffer;
  95623. /** @hidden */
  95624. _renderId: number;
  95625. /**
  95626. * Creates a Light object in the scene.
  95627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  95628. * @param name The firendly name of the light
  95629. * @param scene The scene the light belongs too
  95630. */
  95631. constructor(name: string, scene: Scene);
  95632. protected abstract _buildUniformLayout(): void;
  95633. /**
  95634. * Sets the passed Effect "effect" with the Light information.
  95635. * @param effect The effect to update
  95636. * @param lightIndex The index of the light in the effect to update
  95637. * @returns The light
  95638. */
  95639. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  95640. /**
  95641. * Sets the passed Effect "effect" with the Light textures.
  95642. * @param effect The effect to update
  95643. * @param lightIndex The index of the light in the effect to update
  95644. * @returns The light
  95645. */
  95646. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  95647. /**
  95648. * Binds the lights information from the scene to the effect for the given mesh.
  95649. * @param lightIndex Light index
  95650. * @param scene The scene where the light belongs to
  95651. * @param effect The effect we are binding the data to
  95652. * @param useSpecular Defines if specular is supported
  95653. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  95654. */
  95655. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  95656. /**
  95657. * Sets the passed Effect "effect" with the Light information.
  95658. * @param effect The effect to update
  95659. * @param lightDataUniformName The uniform used to store light data (position or direction)
  95660. * @returns The light
  95661. */
  95662. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  95663. /**
  95664. * Returns the string "Light".
  95665. * @returns the class name
  95666. */
  95667. getClassName(): string;
  95668. /** @hidden */
  95669. readonly _isLight: boolean;
  95670. /**
  95671. * Converts the light information to a readable string for debug purpose.
  95672. * @param fullDetails Supports for multiple levels of logging within scene loading
  95673. * @returns the human readable light info
  95674. */
  95675. toString(fullDetails?: boolean): string;
  95676. /** @hidden */
  95677. protected _syncParentEnabledState(): void;
  95678. /**
  95679. * Set the enabled state of this node.
  95680. * @param value - the new enabled state
  95681. */
  95682. setEnabled(value: boolean): void;
  95683. /**
  95684. * Returns the Light associated shadow generator if any.
  95685. * @return the associated shadow generator.
  95686. */
  95687. getShadowGenerator(): Nullable<IShadowGenerator>;
  95688. /**
  95689. * Returns a Vector3, the absolute light position in the World.
  95690. * @returns the world space position of the light
  95691. */
  95692. getAbsolutePosition(): Vector3;
  95693. /**
  95694. * Specifies if the light will affect the passed mesh.
  95695. * @param mesh The mesh to test against the light
  95696. * @return true the mesh is affected otherwise, false.
  95697. */
  95698. canAffectMesh(mesh: AbstractMesh): boolean;
  95699. /**
  95700. * Sort function to order lights for rendering.
  95701. * @param a First Light object to compare to second.
  95702. * @param b Second Light object to compare first.
  95703. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  95704. */
  95705. static CompareLightsPriority(a: Light, b: Light): number;
  95706. /**
  95707. * Releases resources associated with this node.
  95708. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95709. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95710. */
  95711. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95712. /**
  95713. * Returns the light type ID (integer).
  95714. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  95715. */
  95716. getTypeID(): number;
  95717. /**
  95718. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  95719. * @returns the scaled intensity in intensity mode unit
  95720. */
  95721. getScaledIntensity(): number;
  95722. /**
  95723. * Returns a new Light object, named "name", from the current one.
  95724. * @param name The name of the cloned light
  95725. * @param newParent The parent of this light, if it has one
  95726. * @returns the new created light
  95727. */
  95728. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  95729. /**
  95730. * Serializes the current light into a Serialization object.
  95731. * @returns the serialized object.
  95732. */
  95733. serialize(): any;
  95734. /**
  95735. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  95736. * This new light is named "name" and added to the passed scene.
  95737. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  95738. * @param name The friendly name of the light
  95739. * @param scene The scene the new light will belong to
  95740. * @returns the constructor function
  95741. */
  95742. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  95743. /**
  95744. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  95745. * @param parsedLight The JSON representation of the light
  95746. * @param scene The scene to create the parsed light in
  95747. * @returns the created light after parsing
  95748. */
  95749. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  95750. private _hookArrayForExcluded;
  95751. private _hookArrayForIncludedOnly;
  95752. private _resyncMeshes;
  95753. /**
  95754. * Forces the meshes to update their light related information in their rendering used effects
  95755. * @hidden Internal Use Only
  95756. */
  95757. _markMeshesAsLightDirty(): void;
  95758. /**
  95759. * Recomputes the cached photometric scale if needed.
  95760. */
  95761. private _computePhotometricScale;
  95762. /**
  95763. * Returns the Photometric Scale according to the light type and intensity mode.
  95764. */
  95765. private _getPhotometricScale;
  95766. /**
  95767. * Reorder the light in the scene according to their defined priority.
  95768. * @hidden Internal Use Only
  95769. */
  95770. _reorderLightsInScene(): void;
  95771. /**
  95772. * Prepares the list of defines specific to the light type.
  95773. * @param defines the list of defines
  95774. * @param lightIndex defines the index of the light for the effect
  95775. */
  95776. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  95777. }
  95778. }
  95779. declare module BABYLON {
  95780. /**
  95781. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  95782. * This is the base of the follow, arc rotate cameras and Free camera
  95783. * @see http://doc.babylonjs.com/features/cameras
  95784. */
  95785. export class TargetCamera extends Camera {
  95786. private static _RigCamTransformMatrix;
  95787. private static _TargetTransformMatrix;
  95788. private static _TargetFocalPoint;
  95789. private _tmpUpVector;
  95790. private _tmpTargetVector;
  95791. /**
  95792. * Define the current direction the camera is moving to
  95793. */
  95794. cameraDirection: Vector3;
  95795. /**
  95796. * Define the current rotation the camera is rotating to
  95797. */
  95798. cameraRotation: Vector2;
  95799. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  95800. ignoreParentScaling: boolean;
  95801. /**
  95802. * When set, the up vector of the camera will be updated by the rotation of the camera
  95803. */
  95804. updateUpVectorFromRotation: boolean;
  95805. private _tmpQuaternion;
  95806. /**
  95807. * Define the current rotation of the camera
  95808. */
  95809. rotation: Vector3;
  95810. /**
  95811. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  95812. */
  95813. rotationQuaternion: Quaternion;
  95814. /**
  95815. * Define the current speed of the camera
  95816. */
  95817. speed: number;
  95818. /**
  95819. * Add constraint to the camera to prevent it to move freely in all directions and
  95820. * around all axis.
  95821. */
  95822. noRotationConstraint: boolean;
  95823. /**
  95824. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  95825. * panning
  95826. */
  95827. invertRotation: boolean;
  95828. /**
  95829. * Speed multiplier for inverse camera panning
  95830. */
  95831. inverseRotationSpeed: number;
  95832. /**
  95833. * Define the current target of the camera as an object or a position.
  95834. */
  95835. lockedTarget: any;
  95836. /** @hidden */
  95837. _currentTarget: Vector3;
  95838. /** @hidden */
  95839. _initialFocalDistance: number;
  95840. /** @hidden */
  95841. _viewMatrix: Matrix;
  95842. /** @hidden */
  95843. _camMatrix: Matrix;
  95844. /** @hidden */
  95845. _cameraTransformMatrix: Matrix;
  95846. /** @hidden */
  95847. _cameraRotationMatrix: Matrix;
  95848. /** @hidden */
  95849. _referencePoint: Vector3;
  95850. /** @hidden */
  95851. _transformedReferencePoint: Vector3;
  95852. /** @hidden */
  95853. _reset: () => void;
  95854. private _defaultUp;
  95855. /**
  95856. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  95857. * This is the base of the follow, arc rotate cameras and Free camera
  95858. * @see http://doc.babylonjs.com/features/cameras
  95859. * @param name Defines the name of the camera in the scene
  95860. * @param position Defines the start position of the camera in the scene
  95861. * @param scene Defines the scene the camera belongs to
  95862. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  95863. */
  95864. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95865. /**
  95866. * Gets the position in front of the camera at a given distance.
  95867. * @param distance The distance from the camera we want the position to be
  95868. * @returns the position
  95869. */
  95870. getFrontPosition(distance: number): Vector3;
  95871. /** @hidden */
  95872. _getLockedTargetPosition(): Nullable<Vector3>;
  95873. private _storedPosition;
  95874. private _storedRotation;
  95875. private _storedRotationQuaternion;
  95876. /**
  95877. * Store current camera state of the camera (fov, position, rotation, etc..)
  95878. * @returns the camera
  95879. */
  95880. storeState(): Camera;
  95881. /**
  95882. * Restored camera state. You must call storeState() first
  95883. * @returns whether it was successful or not
  95884. * @hidden
  95885. */
  95886. _restoreStateValues(): boolean;
  95887. /** @hidden */
  95888. _initCache(): void;
  95889. /** @hidden */
  95890. _updateCache(ignoreParentClass?: boolean): void;
  95891. /** @hidden */
  95892. _isSynchronizedViewMatrix(): boolean;
  95893. /** @hidden */
  95894. _computeLocalCameraSpeed(): number;
  95895. /**
  95896. * Defines the target the camera should look at.
  95897. * @param target Defines the new target as a Vector or a mesh
  95898. */
  95899. setTarget(target: Vector3): void;
  95900. /**
  95901. * Return the current target position of the camera. This value is expressed in local space.
  95902. * @returns the target position
  95903. */
  95904. getTarget(): Vector3;
  95905. /** @hidden */
  95906. _decideIfNeedsToMove(): boolean;
  95907. /** @hidden */
  95908. _updatePosition(): void;
  95909. /** @hidden */
  95910. _checkInputs(): void;
  95911. protected _updateCameraRotationMatrix(): void;
  95912. /**
  95913. * 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)
  95914. * @returns the current camera
  95915. */
  95916. private _rotateUpVectorWithCameraRotationMatrix;
  95917. private _cachedRotationZ;
  95918. private _cachedQuaternionRotationZ;
  95919. /** @hidden */
  95920. _getViewMatrix(): Matrix;
  95921. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  95922. /**
  95923. * @hidden
  95924. */
  95925. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  95926. /**
  95927. * @hidden
  95928. */
  95929. _updateRigCameras(): void;
  95930. private _getRigCamPositionAndTarget;
  95931. /**
  95932. * Gets the current object class name.
  95933. * @return the class name
  95934. */
  95935. getClassName(): string;
  95936. }
  95937. }
  95938. declare module BABYLON {
  95939. /**
  95940. * Gather the list of keyboard event types as constants.
  95941. */
  95942. export class KeyboardEventTypes {
  95943. /**
  95944. * The keydown event is fired when a key becomes active (pressed).
  95945. */
  95946. static readonly KEYDOWN: number;
  95947. /**
  95948. * The keyup event is fired when a key has been released.
  95949. */
  95950. static readonly KEYUP: number;
  95951. }
  95952. /**
  95953. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95954. */
  95955. export class KeyboardInfo {
  95956. /**
  95957. * Defines the type of event (KeyboardEventTypes)
  95958. */
  95959. type: number;
  95960. /**
  95961. * Defines the related dom event
  95962. */
  95963. event: KeyboardEvent;
  95964. /**
  95965. * Instantiates a new keyboard info.
  95966. * This class is used to store keyboard related info for the onKeyboardObservable event.
  95967. * @param type Defines the type of event (KeyboardEventTypes)
  95968. * @param event Defines the related dom event
  95969. */
  95970. constructor(
  95971. /**
  95972. * Defines the type of event (KeyboardEventTypes)
  95973. */
  95974. type: number,
  95975. /**
  95976. * Defines the related dom event
  95977. */
  95978. event: KeyboardEvent);
  95979. }
  95980. /**
  95981. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  95982. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  95983. */
  95984. export class KeyboardInfoPre extends KeyboardInfo {
  95985. /**
  95986. * Defines the type of event (KeyboardEventTypes)
  95987. */
  95988. type: number;
  95989. /**
  95990. * Defines the related dom event
  95991. */
  95992. event: KeyboardEvent;
  95993. /**
  95994. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  95995. */
  95996. skipOnPointerObservable: boolean;
  95997. /**
  95998. * Instantiates a new keyboard pre info.
  95999. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96000. * @param type Defines the type of event (KeyboardEventTypes)
  96001. * @param event Defines the related dom event
  96002. */
  96003. constructor(
  96004. /**
  96005. * Defines the type of event (KeyboardEventTypes)
  96006. */
  96007. type: number,
  96008. /**
  96009. * Defines the related dom event
  96010. */
  96011. event: KeyboardEvent);
  96012. }
  96013. }
  96014. declare module BABYLON {
  96015. /**
  96016. * Manage the keyboard inputs to control the movement of a free camera.
  96017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96018. */
  96019. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96020. /**
  96021. * Defines the camera the input is attached to.
  96022. */
  96023. camera: FreeCamera;
  96024. /**
  96025. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96026. */
  96027. keysUp: number[];
  96028. /**
  96029. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96030. */
  96031. keysUpward: number[];
  96032. /**
  96033. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96034. */
  96035. keysDown: number[];
  96036. /**
  96037. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96038. */
  96039. keysDownward: number[];
  96040. /**
  96041. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96042. */
  96043. keysLeft: number[];
  96044. /**
  96045. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96046. */
  96047. keysRight: number[];
  96048. private _keys;
  96049. private _onCanvasBlurObserver;
  96050. private _onKeyboardObserver;
  96051. private _engine;
  96052. private _scene;
  96053. /**
  96054. * Attach the input controls to a specific dom element to get the input from.
  96055. * @param element Defines the element the controls should be listened from
  96056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96057. */
  96058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96059. /**
  96060. * Detach the current controls from the specified dom element.
  96061. * @param element Defines the element to stop listening the inputs from
  96062. */
  96063. detachControl(element: Nullable<HTMLElement>): void;
  96064. /**
  96065. * Update the current camera state depending on the inputs that have been used this frame.
  96066. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96067. */
  96068. checkInputs(): void;
  96069. /**
  96070. * Gets the class name of the current intput.
  96071. * @returns the class name
  96072. */
  96073. getClassName(): string;
  96074. /** @hidden */
  96075. _onLostFocus(): void;
  96076. /**
  96077. * Get the friendly name associated with the input class.
  96078. * @returns the input friendly name
  96079. */
  96080. getSimpleName(): string;
  96081. }
  96082. }
  96083. declare module BABYLON {
  96084. /**
  96085. * Gather the list of pointer event types as constants.
  96086. */
  96087. export class PointerEventTypes {
  96088. /**
  96089. * 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.
  96090. */
  96091. static readonly POINTERDOWN: number;
  96092. /**
  96093. * The pointerup event is fired when a pointer is no longer active.
  96094. */
  96095. static readonly POINTERUP: number;
  96096. /**
  96097. * The pointermove event is fired when a pointer changes coordinates.
  96098. */
  96099. static readonly POINTERMOVE: number;
  96100. /**
  96101. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96102. */
  96103. static readonly POINTERWHEEL: number;
  96104. /**
  96105. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96106. */
  96107. static readonly POINTERPICK: number;
  96108. /**
  96109. * The pointertap event is fired when a the object has been touched and released without drag.
  96110. */
  96111. static readonly POINTERTAP: number;
  96112. /**
  96113. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96114. */
  96115. static readonly POINTERDOUBLETAP: number;
  96116. }
  96117. /**
  96118. * Base class of pointer info types.
  96119. */
  96120. export class PointerInfoBase {
  96121. /**
  96122. * Defines the type of event (PointerEventTypes)
  96123. */
  96124. type: number;
  96125. /**
  96126. * Defines the related dom event
  96127. */
  96128. event: PointerEvent | MouseWheelEvent;
  96129. /**
  96130. * Instantiates the base class of pointers info.
  96131. * @param type Defines the type of event (PointerEventTypes)
  96132. * @param event Defines the related dom event
  96133. */
  96134. constructor(
  96135. /**
  96136. * Defines the type of event (PointerEventTypes)
  96137. */
  96138. type: number,
  96139. /**
  96140. * Defines the related dom event
  96141. */
  96142. event: PointerEvent | MouseWheelEvent);
  96143. }
  96144. /**
  96145. * This class is used to store pointer related info for the onPrePointerObservable event.
  96146. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96147. */
  96148. export class PointerInfoPre extends PointerInfoBase {
  96149. /**
  96150. * Ray from a pointer if availible (eg. 6dof controller)
  96151. */
  96152. ray: Nullable<Ray>;
  96153. /**
  96154. * Defines the local position of the pointer on the canvas.
  96155. */
  96156. localPosition: Vector2;
  96157. /**
  96158. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96159. */
  96160. skipOnPointerObservable: boolean;
  96161. /**
  96162. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96163. * @param type Defines the type of event (PointerEventTypes)
  96164. * @param event Defines the related dom event
  96165. * @param localX Defines the local x coordinates of the pointer when the event occured
  96166. * @param localY Defines the local y coordinates of the pointer when the event occured
  96167. */
  96168. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96169. }
  96170. /**
  96171. * This type contains all the data related to a pointer event in Babylon.js.
  96172. * 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.
  96173. */
  96174. export class PointerInfo extends PointerInfoBase {
  96175. /**
  96176. * Defines the picking info associated to the info (if any)\
  96177. */
  96178. pickInfo: Nullable<PickingInfo>;
  96179. /**
  96180. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96181. * @param type Defines the type of event (PointerEventTypes)
  96182. * @param event Defines the related dom event
  96183. * @param pickInfo Defines the picking info associated to the info (if any)\
  96184. */
  96185. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96186. /**
  96187. * Defines the picking info associated to the info (if any)\
  96188. */
  96189. pickInfo: Nullable<PickingInfo>);
  96190. }
  96191. /**
  96192. * Data relating to a touch event on the screen.
  96193. */
  96194. export interface PointerTouch {
  96195. /**
  96196. * X coordinate of touch.
  96197. */
  96198. x: number;
  96199. /**
  96200. * Y coordinate of touch.
  96201. */
  96202. y: number;
  96203. /**
  96204. * Id of touch. Unique for each finger.
  96205. */
  96206. pointerId: number;
  96207. /**
  96208. * Event type passed from DOM.
  96209. */
  96210. type: any;
  96211. }
  96212. }
  96213. declare module BABYLON {
  96214. /**
  96215. * Manage the mouse inputs to control the movement of a free camera.
  96216. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96217. */
  96218. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96219. /**
  96220. * Define if touch is enabled in the mouse input
  96221. */
  96222. touchEnabled: boolean;
  96223. /**
  96224. * Defines the camera the input is attached to.
  96225. */
  96226. camera: FreeCamera;
  96227. /**
  96228. * Defines the buttons associated with the input to handle camera move.
  96229. */
  96230. buttons: number[];
  96231. /**
  96232. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96233. */
  96234. angularSensibility: number;
  96235. private _pointerInput;
  96236. private _onMouseMove;
  96237. private _observer;
  96238. private previousPosition;
  96239. /**
  96240. * Observable for when a pointer move event occurs containing the move offset
  96241. */
  96242. onPointerMovedObservable: Observable<{
  96243. offsetX: number;
  96244. offsetY: number;
  96245. }>;
  96246. /**
  96247. * @hidden
  96248. * If the camera should be rotated automatically based on pointer movement
  96249. */
  96250. _allowCameraRotation: boolean;
  96251. /**
  96252. * Manage the mouse inputs to control the movement of a free camera.
  96253. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96254. * @param touchEnabled Defines if touch is enabled or not
  96255. */
  96256. constructor(
  96257. /**
  96258. * Define if touch is enabled in the mouse input
  96259. */
  96260. touchEnabled?: boolean);
  96261. /**
  96262. * Attach the input controls to a specific dom element to get the input from.
  96263. * @param element Defines the element the controls should be listened from
  96264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96265. */
  96266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96267. /**
  96268. * Called on JS contextmenu event.
  96269. * Override this method to provide functionality.
  96270. */
  96271. protected onContextMenu(evt: PointerEvent): void;
  96272. /**
  96273. * Detach the current controls from the specified dom element.
  96274. * @param element Defines the element to stop listening the inputs from
  96275. */
  96276. detachControl(element: Nullable<HTMLElement>): void;
  96277. /**
  96278. * Gets the class name of the current intput.
  96279. * @returns the class name
  96280. */
  96281. getClassName(): string;
  96282. /**
  96283. * Get the friendly name associated with the input class.
  96284. * @returns the input friendly name
  96285. */
  96286. getSimpleName(): string;
  96287. }
  96288. }
  96289. declare module BABYLON {
  96290. /**
  96291. * Manage the touch inputs to control the movement of a free camera.
  96292. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96293. */
  96294. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  96295. /**
  96296. * Defines the camera the input is attached to.
  96297. */
  96298. camera: FreeCamera;
  96299. /**
  96300. * Defines the touch sensibility for rotation.
  96301. * The higher the faster.
  96302. */
  96303. touchAngularSensibility: number;
  96304. /**
  96305. * Defines the touch sensibility for move.
  96306. * The higher the faster.
  96307. */
  96308. touchMoveSensibility: number;
  96309. private _offsetX;
  96310. private _offsetY;
  96311. private _pointerPressed;
  96312. private _pointerInput;
  96313. private _observer;
  96314. private _onLostFocus;
  96315. /**
  96316. * Attach the input controls to a specific dom element to get the input from.
  96317. * @param element Defines the element the controls should be listened from
  96318. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96319. */
  96320. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96321. /**
  96322. * Detach the current controls from the specified dom element.
  96323. * @param element Defines the element to stop listening the inputs from
  96324. */
  96325. detachControl(element: Nullable<HTMLElement>): void;
  96326. /**
  96327. * Update the current camera state depending on the inputs that have been used this frame.
  96328. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96329. */
  96330. checkInputs(): void;
  96331. /**
  96332. * Gets the class name of the current intput.
  96333. * @returns the class name
  96334. */
  96335. getClassName(): string;
  96336. /**
  96337. * Get the friendly name associated with the input class.
  96338. * @returns the input friendly name
  96339. */
  96340. getSimpleName(): string;
  96341. }
  96342. }
  96343. declare module BABYLON {
  96344. /**
  96345. * Default Inputs manager for the FreeCamera.
  96346. * It groups all the default supported inputs for ease of use.
  96347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96348. */
  96349. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  96350. /**
  96351. * @hidden
  96352. */
  96353. _mouseInput: Nullable<FreeCameraMouseInput>;
  96354. /**
  96355. * Instantiates a new FreeCameraInputsManager.
  96356. * @param camera Defines the camera the inputs belong to
  96357. */
  96358. constructor(camera: FreeCamera);
  96359. /**
  96360. * Add keyboard input support to the input manager.
  96361. * @returns the current input manager
  96362. */
  96363. addKeyboard(): FreeCameraInputsManager;
  96364. /**
  96365. * Add mouse input support to the input manager.
  96366. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  96367. * @returns the current input manager
  96368. */
  96369. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  96370. /**
  96371. * Removes the mouse input support from the manager
  96372. * @returns the current input manager
  96373. */
  96374. removeMouse(): FreeCameraInputsManager;
  96375. /**
  96376. * Add touch input support to the input manager.
  96377. * @returns the current input manager
  96378. */
  96379. addTouch(): FreeCameraInputsManager;
  96380. /**
  96381. * Remove all attached input methods from a camera
  96382. */
  96383. clear(): void;
  96384. }
  96385. }
  96386. declare module BABYLON {
  96387. /**
  96388. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96389. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  96390. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96391. */
  96392. export class FreeCamera extends TargetCamera {
  96393. /**
  96394. * Define the collision ellipsoid of the camera.
  96395. * This is helpful to simulate a camera body like the player body around the camera
  96396. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  96397. */
  96398. ellipsoid: Vector3;
  96399. /**
  96400. * Define an offset for the position of the ellipsoid around the camera.
  96401. * This can be helpful to determine the center of the body near the gravity center of the body
  96402. * instead of its head.
  96403. */
  96404. ellipsoidOffset: Vector3;
  96405. /**
  96406. * Enable or disable collisions of the camera with the rest of the scene objects.
  96407. */
  96408. checkCollisions: boolean;
  96409. /**
  96410. * Enable or disable gravity on the camera.
  96411. */
  96412. applyGravity: boolean;
  96413. /**
  96414. * Define the input manager associated to the camera.
  96415. */
  96416. inputs: FreeCameraInputsManager;
  96417. /**
  96418. * Gets the input sensibility for a mouse input. (default is 2000.0)
  96419. * Higher values reduce sensitivity.
  96420. */
  96421. get angularSensibility(): number;
  96422. /**
  96423. * Sets the input sensibility for a mouse input. (default is 2000.0)
  96424. * Higher values reduce sensitivity.
  96425. */
  96426. set angularSensibility(value: number);
  96427. /**
  96428. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96429. */
  96430. get keysUp(): number[];
  96431. set keysUp(value: number[]);
  96432. /**
  96433. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96434. */
  96435. get keysUpward(): number[];
  96436. set keysUpward(value: number[]);
  96437. /**
  96438. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96439. */
  96440. get keysDown(): number[];
  96441. set keysDown(value: number[]);
  96442. /**
  96443. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96444. */
  96445. get keysDownward(): number[];
  96446. set keysDownward(value: number[]);
  96447. /**
  96448. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96449. */
  96450. get keysLeft(): number[];
  96451. set keysLeft(value: number[]);
  96452. /**
  96453. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96454. */
  96455. get keysRight(): number[];
  96456. set keysRight(value: number[]);
  96457. /**
  96458. * Event raised when the camera collide with a mesh in the scene.
  96459. */
  96460. onCollide: (collidedMesh: AbstractMesh) => void;
  96461. private _collider;
  96462. private _needMoveForGravity;
  96463. private _oldPosition;
  96464. private _diffPosition;
  96465. private _newPosition;
  96466. /** @hidden */
  96467. _localDirection: Vector3;
  96468. /** @hidden */
  96469. _transformedDirection: Vector3;
  96470. /**
  96471. * Instantiates a Free Camera.
  96472. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  96473. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  96474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96475. * @param name Define the name of the camera in the scene
  96476. * @param position Define the start position of the camera in the scene
  96477. * @param scene Define the scene the camera belongs to
  96478. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96479. */
  96480. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96481. /**
  96482. * Attached controls to the current camera.
  96483. * @param element Defines the element the controls should be listened from
  96484. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96485. */
  96486. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96487. /**
  96488. * Detach the current controls from the camera.
  96489. * The camera will stop reacting to inputs.
  96490. * @param element Defines the element to stop listening the inputs from
  96491. */
  96492. detachControl(element: HTMLElement): void;
  96493. private _collisionMask;
  96494. /**
  96495. * Define a collision mask to limit the list of object the camera can collide with
  96496. */
  96497. get collisionMask(): number;
  96498. set collisionMask(mask: number);
  96499. /** @hidden */
  96500. _collideWithWorld(displacement: Vector3): void;
  96501. private _onCollisionPositionChange;
  96502. /** @hidden */
  96503. _checkInputs(): void;
  96504. /** @hidden */
  96505. _decideIfNeedsToMove(): boolean;
  96506. /** @hidden */
  96507. _updatePosition(): void;
  96508. /**
  96509. * Destroy the camera and release the current resources hold by it.
  96510. */
  96511. dispose(): void;
  96512. /**
  96513. * Gets the current object class name.
  96514. * @return the class name
  96515. */
  96516. getClassName(): string;
  96517. }
  96518. }
  96519. declare module BABYLON {
  96520. /**
  96521. * Represents a gamepad control stick position
  96522. */
  96523. export class StickValues {
  96524. /**
  96525. * The x component of the control stick
  96526. */
  96527. x: number;
  96528. /**
  96529. * The y component of the control stick
  96530. */
  96531. y: number;
  96532. /**
  96533. * Initializes the gamepad x and y control stick values
  96534. * @param x The x component of the gamepad control stick value
  96535. * @param y The y component of the gamepad control stick value
  96536. */
  96537. constructor(
  96538. /**
  96539. * The x component of the control stick
  96540. */
  96541. x: number,
  96542. /**
  96543. * The y component of the control stick
  96544. */
  96545. y: number);
  96546. }
  96547. /**
  96548. * An interface which manages callbacks for gamepad button changes
  96549. */
  96550. export interface GamepadButtonChanges {
  96551. /**
  96552. * Called when a gamepad has been changed
  96553. */
  96554. changed: boolean;
  96555. /**
  96556. * Called when a gamepad press event has been triggered
  96557. */
  96558. pressChanged: boolean;
  96559. /**
  96560. * Called when a touch event has been triggered
  96561. */
  96562. touchChanged: boolean;
  96563. /**
  96564. * Called when a value has changed
  96565. */
  96566. valueChanged: boolean;
  96567. }
  96568. /**
  96569. * Represents a gamepad
  96570. */
  96571. export class Gamepad {
  96572. /**
  96573. * The id of the gamepad
  96574. */
  96575. id: string;
  96576. /**
  96577. * The index of the gamepad
  96578. */
  96579. index: number;
  96580. /**
  96581. * The browser gamepad
  96582. */
  96583. browserGamepad: any;
  96584. /**
  96585. * Specifies what type of gamepad this represents
  96586. */
  96587. type: number;
  96588. private _leftStick;
  96589. private _rightStick;
  96590. /** @hidden */
  96591. _isConnected: boolean;
  96592. private _leftStickAxisX;
  96593. private _leftStickAxisY;
  96594. private _rightStickAxisX;
  96595. private _rightStickAxisY;
  96596. /**
  96597. * Triggered when the left control stick has been changed
  96598. */
  96599. private _onleftstickchanged;
  96600. /**
  96601. * Triggered when the right control stick has been changed
  96602. */
  96603. private _onrightstickchanged;
  96604. /**
  96605. * Represents a gamepad controller
  96606. */
  96607. static GAMEPAD: number;
  96608. /**
  96609. * Represents a generic controller
  96610. */
  96611. static GENERIC: number;
  96612. /**
  96613. * Represents an XBox controller
  96614. */
  96615. static XBOX: number;
  96616. /**
  96617. * Represents a pose-enabled controller
  96618. */
  96619. static POSE_ENABLED: number;
  96620. /**
  96621. * Represents an Dual Shock controller
  96622. */
  96623. static DUALSHOCK: number;
  96624. /**
  96625. * Specifies whether the left control stick should be Y-inverted
  96626. */
  96627. protected _invertLeftStickY: boolean;
  96628. /**
  96629. * Specifies if the gamepad has been connected
  96630. */
  96631. get isConnected(): boolean;
  96632. /**
  96633. * Initializes the gamepad
  96634. * @param id The id of the gamepad
  96635. * @param index The index of the gamepad
  96636. * @param browserGamepad The browser gamepad
  96637. * @param leftStickX The x component of the left joystick
  96638. * @param leftStickY The y component of the left joystick
  96639. * @param rightStickX The x component of the right joystick
  96640. * @param rightStickY The y component of the right joystick
  96641. */
  96642. constructor(
  96643. /**
  96644. * The id of the gamepad
  96645. */
  96646. id: string,
  96647. /**
  96648. * The index of the gamepad
  96649. */
  96650. index: number,
  96651. /**
  96652. * The browser gamepad
  96653. */
  96654. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  96655. /**
  96656. * Callback triggered when the left joystick has changed
  96657. * @param callback
  96658. */
  96659. onleftstickchanged(callback: (values: StickValues) => void): void;
  96660. /**
  96661. * Callback triggered when the right joystick has changed
  96662. * @param callback
  96663. */
  96664. onrightstickchanged(callback: (values: StickValues) => void): void;
  96665. /**
  96666. * Gets the left joystick
  96667. */
  96668. get leftStick(): StickValues;
  96669. /**
  96670. * Sets the left joystick values
  96671. */
  96672. set leftStick(newValues: StickValues);
  96673. /**
  96674. * Gets the right joystick
  96675. */
  96676. get rightStick(): StickValues;
  96677. /**
  96678. * Sets the right joystick value
  96679. */
  96680. set rightStick(newValues: StickValues);
  96681. /**
  96682. * Updates the gamepad joystick positions
  96683. */
  96684. update(): void;
  96685. /**
  96686. * Disposes the gamepad
  96687. */
  96688. dispose(): void;
  96689. }
  96690. /**
  96691. * Represents a generic gamepad
  96692. */
  96693. export class GenericPad extends Gamepad {
  96694. private _buttons;
  96695. private _onbuttondown;
  96696. private _onbuttonup;
  96697. /**
  96698. * Observable triggered when a button has been pressed
  96699. */
  96700. onButtonDownObservable: Observable<number>;
  96701. /**
  96702. * Observable triggered when a button has been released
  96703. */
  96704. onButtonUpObservable: Observable<number>;
  96705. /**
  96706. * Callback triggered when a button has been pressed
  96707. * @param callback Called when a button has been pressed
  96708. */
  96709. onbuttondown(callback: (buttonPressed: number) => void): void;
  96710. /**
  96711. * Callback triggered when a button has been released
  96712. * @param callback Called when a button has been released
  96713. */
  96714. onbuttonup(callback: (buttonReleased: number) => void): void;
  96715. /**
  96716. * Initializes the generic gamepad
  96717. * @param id The id of the generic gamepad
  96718. * @param index The index of the generic gamepad
  96719. * @param browserGamepad The browser gamepad
  96720. */
  96721. constructor(id: string, index: number, browserGamepad: any);
  96722. private _setButtonValue;
  96723. /**
  96724. * Updates the generic gamepad
  96725. */
  96726. update(): void;
  96727. /**
  96728. * Disposes the generic gamepad
  96729. */
  96730. dispose(): void;
  96731. }
  96732. }
  96733. declare module BABYLON {
  96734. /**
  96735. * Defines the types of pose enabled controllers that are supported
  96736. */
  96737. export enum PoseEnabledControllerType {
  96738. /**
  96739. * HTC Vive
  96740. */
  96741. VIVE = 0,
  96742. /**
  96743. * Oculus Rift
  96744. */
  96745. OCULUS = 1,
  96746. /**
  96747. * Windows mixed reality
  96748. */
  96749. WINDOWS = 2,
  96750. /**
  96751. * Samsung gear VR
  96752. */
  96753. GEAR_VR = 3,
  96754. /**
  96755. * Google Daydream
  96756. */
  96757. DAYDREAM = 4,
  96758. /**
  96759. * Generic
  96760. */
  96761. GENERIC = 5
  96762. }
  96763. /**
  96764. * Defines the MutableGamepadButton interface for the state of a gamepad button
  96765. */
  96766. export interface MutableGamepadButton {
  96767. /**
  96768. * Value of the button/trigger
  96769. */
  96770. value: number;
  96771. /**
  96772. * If the button/trigger is currently touched
  96773. */
  96774. touched: boolean;
  96775. /**
  96776. * If the button/trigger is currently pressed
  96777. */
  96778. pressed: boolean;
  96779. }
  96780. /**
  96781. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  96782. * @hidden
  96783. */
  96784. export interface ExtendedGamepadButton extends GamepadButton {
  96785. /**
  96786. * If the button/trigger is currently pressed
  96787. */
  96788. readonly pressed: boolean;
  96789. /**
  96790. * If the button/trigger is currently touched
  96791. */
  96792. readonly touched: boolean;
  96793. /**
  96794. * Value of the button/trigger
  96795. */
  96796. readonly value: number;
  96797. }
  96798. /** @hidden */
  96799. export interface _GamePadFactory {
  96800. /**
  96801. * Returns whether or not the current gamepad can be created for this type of controller.
  96802. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96803. * @returns true if it can be created, otherwise false
  96804. */
  96805. canCreate(gamepadInfo: any): boolean;
  96806. /**
  96807. * Creates a new instance of the Gamepad.
  96808. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  96809. * @returns the new gamepad instance
  96810. */
  96811. create(gamepadInfo: any): Gamepad;
  96812. }
  96813. /**
  96814. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96815. */
  96816. export class PoseEnabledControllerHelper {
  96817. /** @hidden */
  96818. static _ControllerFactories: _GamePadFactory[];
  96819. /** @hidden */
  96820. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  96821. /**
  96822. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  96823. * @param vrGamepad the gamepad to initialized
  96824. * @returns a vr controller of the type the gamepad identified as
  96825. */
  96826. static InitiateController(vrGamepad: any): Gamepad;
  96827. }
  96828. /**
  96829. * Defines the PoseEnabledController object that contains state of a vr capable controller
  96830. */
  96831. export class PoseEnabledController extends Gamepad implements PoseControlled {
  96832. /**
  96833. * If the controller is used in a webXR session
  96834. */
  96835. isXR: boolean;
  96836. private _deviceRoomPosition;
  96837. private _deviceRoomRotationQuaternion;
  96838. /**
  96839. * The device position in babylon space
  96840. */
  96841. devicePosition: Vector3;
  96842. /**
  96843. * The device rotation in babylon space
  96844. */
  96845. deviceRotationQuaternion: Quaternion;
  96846. /**
  96847. * The scale factor of the device in babylon space
  96848. */
  96849. deviceScaleFactor: number;
  96850. /**
  96851. * (Likely devicePosition should be used instead) The device position in its room space
  96852. */
  96853. position: Vector3;
  96854. /**
  96855. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  96856. */
  96857. rotationQuaternion: Quaternion;
  96858. /**
  96859. * The type of controller (Eg. Windows mixed reality)
  96860. */
  96861. controllerType: PoseEnabledControllerType;
  96862. protected _calculatedPosition: Vector3;
  96863. private _calculatedRotation;
  96864. /**
  96865. * The raw pose from the device
  96866. */
  96867. rawPose: DevicePose;
  96868. private _trackPosition;
  96869. private _maxRotationDistFromHeadset;
  96870. private _draggedRoomRotation;
  96871. /**
  96872. * @hidden
  96873. */
  96874. _disableTrackPosition(fixedPosition: Vector3): void;
  96875. /**
  96876. * Internal, the mesh attached to the controller
  96877. * @hidden
  96878. */
  96879. _mesh: Nullable<AbstractMesh>;
  96880. private _poseControlledCamera;
  96881. private _leftHandSystemQuaternion;
  96882. /**
  96883. * Internal, matrix used to convert room space to babylon space
  96884. * @hidden
  96885. */
  96886. _deviceToWorld: Matrix;
  96887. /**
  96888. * Node to be used when casting a ray from the controller
  96889. * @hidden
  96890. */
  96891. _pointingPoseNode: Nullable<TransformNode>;
  96892. /**
  96893. * Name of the child mesh that can be used to cast a ray from the controller
  96894. */
  96895. static readonly POINTING_POSE: string;
  96896. /**
  96897. * Creates a new PoseEnabledController from a gamepad
  96898. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  96899. */
  96900. constructor(browserGamepad: any);
  96901. private _workingMatrix;
  96902. /**
  96903. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  96904. */
  96905. update(): void;
  96906. /**
  96907. * Updates only the pose device and mesh without doing any button event checking
  96908. */
  96909. protected _updatePoseAndMesh(): void;
  96910. /**
  96911. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  96912. * @param poseData raw pose fromthe device
  96913. */
  96914. updateFromDevice(poseData: DevicePose): void;
  96915. /**
  96916. * @hidden
  96917. */
  96918. _meshAttachedObservable: Observable<AbstractMesh>;
  96919. /**
  96920. * Attaches a mesh to the controller
  96921. * @param mesh the mesh to be attached
  96922. */
  96923. attachToMesh(mesh: AbstractMesh): void;
  96924. /**
  96925. * Attaches the controllers mesh to a camera
  96926. * @param camera the camera the mesh should be attached to
  96927. */
  96928. attachToPoseControlledCamera(camera: TargetCamera): void;
  96929. /**
  96930. * Disposes of the controller
  96931. */
  96932. dispose(): void;
  96933. /**
  96934. * The mesh that is attached to the controller
  96935. */
  96936. get mesh(): Nullable<AbstractMesh>;
  96937. /**
  96938. * Gets the ray of the controller in the direction the controller is pointing
  96939. * @param length the length the resulting ray should be
  96940. * @returns a ray in the direction the controller is pointing
  96941. */
  96942. getForwardRay(length?: number): Ray;
  96943. }
  96944. }
  96945. declare module BABYLON {
  96946. /**
  96947. * Defines the WebVRController object that represents controllers tracked in 3D space
  96948. */
  96949. export abstract class WebVRController extends PoseEnabledController {
  96950. /**
  96951. * Internal, the default controller model for the controller
  96952. */
  96953. protected _defaultModel: Nullable<AbstractMesh>;
  96954. /**
  96955. * Fired when the trigger state has changed
  96956. */
  96957. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  96958. /**
  96959. * Fired when the main button state has changed
  96960. */
  96961. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96962. /**
  96963. * Fired when the secondary button state has changed
  96964. */
  96965. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  96966. /**
  96967. * Fired when the pad state has changed
  96968. */
  96969. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  96970. /**
  96971. * Fired when controllers stick values have changed
  96972. */
  96973. onPadValuesChangedObservable: Observable<StickValues>;
  96974. /**
  96975. * Array of button availible on the controller
  96976. */
  96977. protected _buttons: Array<MutableGamepadButton>;
  96978. private _onButtonStateChange;
  96979. /**
  96980. * Fired when a controller button's state has changed
  96981. * @param callback the callback containing the button that was modified
  96982. */
  96983. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  96984. /**
  96985. * X and Y axis corresponding to the controllers joystick
  96986. */
  96987. pad: StickValues;
  96988. /**
  96989. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  96990. */
  96991. hand: string;
  96992. /**
  96993. * The default controller model for the controller
  96994. */
  96995. get defaultModel(): Nullable<AbstractMesh>;
  96996. /**
  96997. * Creates a new WebVRController from a gamepad
  96998. * @param vrGamepad the gamepad that the WebVRController should be created from
  96999. */
  97000. constructor(vrGamepad: any);
  97001. /**
  97002. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97003. */
  97004. update(): void;
  97005. /**
  97006. * Function to be called when a button is modified
  97007. */
  97008. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97009. /**
  97010. * Loads a mesh and attaches it to the controller
  97011. * @param scene the scene the mesh should be added to
  97012. * @param meshLoaded callback for when the mesh has been loaded
  97013. */
  97014. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97015. private _setButtonValue;
  97016. private _changes;
  97017. private _checkChanges;
  97018. /**
  97019. * Disposes of th webVRCOntroller
  97020. */
  97021. dispose(): void;
  97022. }
  97023. }
  97024. declare module BABYLON {
  97025. /**
  97026. * The HemisphericLight simulates the ambient environment light,
  97027. * so the passed direction is the light reflection direction, not the incoming direction.
  97028. */
  97029. export class HemisphericLight extends Light {
  97030. /**
  97031. * The groundColor is the light in the opposite direction to the one specified during creation.
  97032. * 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.
  97033. */
  97034. groundColor: Color3;
  97035. /**
  97036. * The light reflection direction, not the incoming direction.
  97037. */
  97038. direction: Vector3;
  97039. /**
  97040. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97041. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97042. * The HemisphericLight can't cast shadows.
  97043. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97044. * @param name The friendly name of the light
  97045. * @param direction The direction of the light reflection
  97046. * @param scene The scene the light belongs to
  97047. */
  97048. constructor(name: string, direction: Vector3, scene: Scene);
  97049. protected _buildUniformLayout(): void;
  97050. /**
  97051. * Returns the string "HemisphericLight".
  97052. * @return The class name
  97053. */
  97054. getClassName(): string;
  97055. /**
  97056. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97057. * Returns the updated direction.
  97058. * @param target The target the direction should point to
  97059. * @return The computed direction
  97060. */
  97061. setDirectionToTarget(target: Vector3): Vector3;
  97062. /**
  97063. * Returns the shadow generator associated to the light.
  97064. * @returns Always null for hemispheric lights because it does not support shadows.
  97065. */
  97066. getShadowGenerator(): Nullable<IShadowGenerator>;
  97067. /**
  97068. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97069. * @param effect The effect to update
  97070. * @param lightIndex The index of the light in the effect to update
  97071. * @returns The hemispheric light
  97072. */
  97073. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97074. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97075. /**
  97076. * Computes the world matrix of the node
  97077. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97078. * @param useWasUpdatedFlag defines a reserved property
  97079. * @returns the world matrix
  97080. */
  97081. computeWorldMatrix(): Matrix;
  97082. /**
  97083. * Returns the integer 3.
  97084. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97085. */
  97086. getTypeID(): number;
  97087. /**
  97088. * Prepares the list of defines specific to the light type.
  97089. * @param defines the list of defines
  97090. * @param lightIndex defines the index of the light for the effect
  97091. */
  97092. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97093. }
  97094. }
  97095. declare module BABYLON {
  97096. /** @hidden */
  97097. export var vrMultiviewToSingleviewPixelShader: {
  97098. name: string;
  97099. shader: string;
  97100. };
  97101. }
  97102. declare module BABYLON {
  97103. /**
  97104. * Renders to multiple views with a single draw call
  97105. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97106. */
  97107. export class MultiviewRenderTarget extends RenderTargetTexture {
  97108. /**
  97109. * Creates a multiview render target
  97110. * @param scene scene used with the render target
  97111. * @param size the size of the render target (used for each view)
  97112. */
  97113. constructor(scene: Scene, size?: number | {
  97114. width: number;
  97115. height: number;
  97116. } | {
  97117. ratio: number;
  97118. });
  97119. /**
  97120. * @hidden
  97121. * @param faceIndex the face index, if its a cube texture
  97122. */
  97123. _bindFrameBuffer(faceIndex?: number): void;
  97124. /**
  97125. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97126. * @returns the view count
  97127. */
  97128. getViewCount(): number;
  97129. }
  97130. }
  97131. declare module BABYLON {
  97132. interface Engine {
  97133. /**
  97134. * Creates a new multiview render target
  97135. * @param width defines the width of the texture
  97136. * @param height defines the height of the texture
  97137. * @returns the created multiview texture
  97138. */
  97139. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97140. /**
  97141. * Binds a multiview framebuffer to be drawn to
  97142. * @param multiviewTexture texture to bind
  97143. */
  97144. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97145. }
  97146. interface Camera {
  97147. /**
  97148. * @hidden
  97149. * 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)
  97150. */
  97151. _useMultiviewToSingleView: boolean;
  97152. /**
  97153. * @hidden
  97154. * 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)
  97155. */
  97156. _multiviewTexture: Nullable<RenderTargetTexture>;
  97157. /**
  97158. * @hidden
  97159. * ensures the multiview texture of the camera exists and has the specified width/height
  97160. * @param width height to set on the multiview texture
  97161. * @param height width to set on the multiview texture
  97162. */
  97163. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97164. }
  97165. interface Scene {
  97166. /** @hidden */
  97167. _transformMatrixR: Matrix;
  97168. /** @hidden */
  97169. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97170. /** @hidden */
  97171. _createMultiviewUbo(): void;
  97172. /** @hidden */
  97173. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97174. /** @hidden */
  97175. _renderMultiviewToSingleView(camera: Camera): void;
  97176. }
  97177. }
  97178. declare module BABYLON {
  97179. /**
  97180. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97181. * This will not be used for webXR as it supports displaying texture arrays directly
  97182. */
  97183. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97184. /**
  97185. * Initializes a VRMultiviewToSingleview
  97186. * @param name name of the post process
  97187. * @param camera camera to be applied to
  97188. * @param scaleFactor scaling factor to the size of the output texture
  97189. */
  97190. constructor(name: string, camera: Camera, scaleFactor: number);
  97191. }
  97192. }
  97193. declare module BABYLON {
  97194. /**
  97195. * Interface used to define additional presentation attributes
  97196. */
  97197. export interface IVRPresentationAttributes {
  97198. /**
  97199. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97200. */
  97201. highRefreshRate: boolean;
  97202. /**
  97203. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97204. */
  97205. foveationLevel: number;
  97206. }
  97207. interface Engine {
  97208. /** @hidden */
  97209. _vrDisplay: any;
  97210. /** @hidden */
  97211. _vrSupported: boolean;
  97212. /** @hidden */
  97213. _oldSize: Size;
  97214. /** @hidden */
  97215. _oldHardwareScaleFactor: number;
  97216. /** @hidden */
  97217. _vrExclusivePointerMode: boolean;
  97218. /** @hidden */
  97219. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97220. /** @hidden */
  97221. _onVRDisplayPointerRestricted: () => void;
  97222. /** @hidden */
  97223. _onVRDisplayPointerUnrestricted: () => void;
  97224. /** @hidden */
  97225. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97226. /** @hidden */
  97227. _onVrDisplayDisconnect: Nullable<() => void>;
  97228. /** @hidden */
  97229. _onVrDisplayPresentChange: Nullable<() => void>;
  97230. /**
  97231. * Observable signaled when VR display mode changes
  97232. */
  97233. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97234. /**
  97235. * Observable signaled when VR request present is complete
  97236. */
  97237. onVRRequestPresentComplete: Observable<boolean>;
  97238. /**
  97239. * Observable signaled when VR request present starts
  97240. */
  97241. onVRRequestPresentStart: Observable<Engine>;
  97242. /**
  97243. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97244. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97245. */
  97246. isInVRExclusivePointerMode: boolean;
  97247. /**
  97248. * Gets a boolean indicating if a webVR device was detected
  97249. * @returns true if a webVR device was detected
  97250. */
  97251. isVRDevicePresent(): boolean;
  97252. /**
  97253. * Gets the current webVR device
  97254. * @returns the current webVR device (or null)
  97255. */
  97256. getVRDevice(): any;
  97257. /**
  97258. * Initializes a webVR display and starts listening to display change events
  97259. * The onVRDisplayChangedObservable will be notified upon these changes
  97260. * @returns A promise containing a VRDisplay and if vr is supported
  97261. */
  97262. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97263. /** @hidden */
  97264. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97265. /**
  97266. * Gets or sets the presentation attributes used to configure VR rendering
  97267. */
  97268. vrPresentationAttributes?: IVRPresentationAttributes;
  97269. /**
  97270. * Call this function to switch to webVR mode
  97271. * Will do nothing if webVR is not supported or if there is no webVR device
  97272. * @param options the webvr options provided to the camera. mainly used for multiview
  97273. * @see http://doc.babylonjs.com/how_to/webvr_camera
  97274. */
  97275. enableVR(options: WebVROptions): void;
  97276. /** @hidden */
  97277. _onVRFullScreenTriggered(): void;
  97278. }
  97279. }
  97280. declare module BABYLON {
  97281. /**
  97282. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97283. * IMPORTANT!! The data is right-hand data.
  97284. * @export
  97285. * @interface DevicePose
  97286. */
  97287. export interface DevicePose {
  97288. /**
  97289. * The position of the device, values in array are [x,y,z].
  97290. */
  97291. readonly position: Nullable<Float32Array>;
  97292. /**
  97293. * The linearVelocity of the device, values in array are [x,y,z].
  97294. */
  97295. readonly linearVelocity: Nullable<Float32Array>;
  97296. /**
  97297. * The linearAcceleration of the device, values in array are [x,y,z].
  97298. */
  97299. readonly linearAcceleration: Nullable<Float32Array>;
  97300. /**
  97301. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  97302. */
  97303. readonly orientation: Nullable<Float32Array>;
  97304. /**
  97305. * The angularVelocity of the device, values in array are [x,y,z].
  97306. */
  97307. readonly angularVelocity: Nullable<Float32Array>;
  97308. /**
  97309. * The angularAcceleration of the device, values in array are [x,y,z].
  97310. */
  97311. readonly angularAcceleration: Nullable<Float32Array>;
  97312. }
  97313. /**
  97314. * Interface representing a pose controlled object in Babylon.
  97315. * A pose controlled object has both regular pose values as well as pose values
  97316. * from an external device such as a VR head mounted display
  97317. */
  97318. export interface PoseControlled {
  97319. /**
  97320. * The position of the object in babylon space.
  97321. */
  97322. position: Vector3;
  97323. /**
  97324. * The rotation quaternion of the object in babylon space.
  97325. */
  97326. rotationQuaternion: Quaternion;
  97327. /**
  97328. * The position of the device in babylon space.
  97329. */
  97330. devicePosition?: Vector3;
  97331. /**
  97332. * The rotation quaternion of the device in babylon space.
  97333. */
  97334. deviceRotationQuaternion: Quaternion;
  97335. /**
  97336. * The raw pose coming from the device.
  97337. */
  97338. rawPose: Nullable<DevicePose>;
  97339. /**
  97340. * The scale of the device to be used when translating from device space to babylon space.
  97341. */
  97342. deviceScaleFactor: number;
  97343. /**
  97344. * Updates the poseControlled values based on the input device pose.
  97345. * @param poseData the pose data to update the object with
  97346. */
  97347. updateFromDevice(poseData: DevicePose): void;
  97348. }
  97349. /**
  97350. * Set of options to customize the webVRCamera
  97351. */
  97352. export interface WebVROptions {
  97353. /**
  97354. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  97355. */
  97356. trackPosition?: boolean;
  97357. /**
  97358. * Sets the scale of the vrDevice in babylon space. (default: 1)
  97359. */
  97360. positionScale?: number;
  97361. /**
  97362. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  97363. */
  97364. displayName?: string;
  97365. /**
  97366. * Should the native controller meshes be initialized. (default: true)
  97367. */
  97368. controllerMeshes?: boolean;
  97369. /**
  97370. * Creating a default HemiLight only on controllers. (default: true)
  97371. */
  97372. defaultLightingOnControllers?: boolean;
  97373. /**
  97374. * If you don't want to use the default VR button of the helper. (default: false)
  97375. */
  97376. useCustomVRButton?: boolean;
  97377. /**
  97378. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  97379. */
  97380. customVRButton?: HTMLButtonElement;
  97381. /**
  97382. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  97383. */
  97384. rayLength?: number;
  97385. /**
  97386. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  97387. */
  97388. defaultHeight?: number;
  97389. /**
  97390. * If multiview should be used if availible (default: false)
  97391. */
  97392. useMultiview?: boolean;
  97393. }
  97394. /**
  97395. * This represents a WebVR camera.
  97396. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  97397. * @example http://doc.babylonjs.com/how_to/webvr_camera
  97398. */
  97399. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  97400. private webVROptions;
  97401. /**
  97402. * @hidden
  97403. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  97404. */
  97405. _vrDevice: any;
  97406. /**
  97407. * The rawPose of the vrDevice.
  97408. */
  97409. rawPose: Nullable<DevicePose>;
  97410. private _onVREnabled;
  97411. private _specsVersion;
  97412. private _attached;
  97413. private _frameData;
  97414. protected _descendants: Array<Node>;
  97415. private _deviceRoomPosition;
  97416. /** @hidden */
  97417. _deviceRoomRotationQuaternion: Quaternion;
  97418. private _standingMatrix;
  97419. /**
  97420. * Represents device position in babylon space.
  97421. */
  97422. devicePosition: Vector3;
  97423. /**
  97424. * Represents device rotation in babylon space.
  97425. */
  97426. deviceRotationQuaternion: Quaternion;
  97427. /**
  97428. * The scale of the device to be used when translating from device space to babylon space.
  97429. */
  97430. deviceScaleFactor: number;
  97431. private _deviceToWorld;
  97432. private _worldToDevice;
  97433. /**
  97434. * References to the webVR controllers for the vrDevice.
  97435. */
  97436. controllers: Array<WebVRController>;
  97437. /**
  97438. * Emits an event when a controller is attached.
  97439. */
  97440. onControllersAttachedObservable: Observable<WebVRController[]>;
  97441. /**
  97442. * Emits an event when a controller's mesh has been loaded;
  97443. */
  97444. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97445. /**
  97446. * Emits an event when the HMD's pose has been updated.
  97447. */
  97448. onPoseUpdatedFromDeviceObservable: Observable<any>;
  97449. private _poseSet;
  97450. /**
  97451. * If the rig cameras be used as parent instead of this camera.
  97452. */
  97453. rigParenting: boolean;
  97454. private _lightOnControllers;
  97455. private _defaultHeight?;
  97456. /**
  97457. * Instantiates a WebVRFreeCamera.
  97458. * @param name The name of the WebVRFreeCamera
  97459. * @param position The starting anchor position for the camera
  97460. * @param scene The scene the camera belongs to
  97461. * @param webVROptions a set of customizable options for the webVRCamera
  97462. */
  97463. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  97464. /**
  97465. * Gets the device distance from the ground in meters.
  97466. * @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.
  97467. */
  97468. deviceDistanceToRoomGround(): number;
  97469. /**
  97470. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97471. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  97472. */
  97473. useStandingMatrix(callback?: (bool: boolean) => void): void;
  97474. /**
  97475. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  97476. * @returns A promise with a boolean set to if the standing matrix is supported.
  97477. */
  97478. useStandingMatrixAsync(): Promise<boolean>;
  97479. /**
  97480. * Disposes the camera
  97481. */
  97482. dispose(): void;
  97483. /**
  97484. * Gets a vrController by name.
  97485. * @param name The name of the controller to retreive
  97486. * @returns the controller matching the name specified or null if not found
  97487. */
  97488. getControllerByName(name: string): Nullable<WebVRController>;
  97489. private _leftController;
  97490. /**
  97491. * The controller corresponding to the users left hand.
  97492. */
  97493. get leftController(): Nullable<WebVRController>;
  97494. private _rightController;
  97495. /**
  97496. * The controller corresponding to the users right hand.
  97497. */
  97498. get rightController(): Nullable<WebVRController>;
  97499. /**
  97500. * Casts a ray forward from the vrCamera's gaze.
  97501. * @param length Length of the ray (default: 100)
  97502. * @returns the ray corresponding to the gaze
  97503. */
  97504. getForwardRay(length?: number): Ray;
  97505. /**
  97506. * @hidden
  97507. * Updates the camera based on device's frame data
  97508. */
  97509. _checkInputs(): void;
  97510. /**
  97511. * Updates the poseControlled values based on the input device pose.
  97512. * @param poseData Pose coming from the device
  97513. */
  97514. updateFromDevice(poseData: DevicePose): void;
  97515. private _htmlElementAttached;
  97516. private _detachIfAttached;
  97517. /**
  97518. * WebVR's attach control will start broadcasting frames to the device.
  97519. * Note that in certain browsers (chrome for example) this function must be called
  97520. * within a user-interaction callback. Example:
  97521. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  97522. *
  97523. * @param element html element to attach the vrDevice to
  97524. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  97525. */
  97526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97527. /**
  97528. * Detaches the camera from the html element and disables VR
  97529. *
  97530. * @param element html element to detach from
  97531. */
  97532. detachControl(element: HTMLElement): void;
  97533. /**
  97534. * @returns the name of this class
  97535. */
  97536. getClassName(): string;
  97537. /**
  97538. * Calls resetPose on the vrDisplay
  97539. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  97540. */
  97541. resetToCurrentRotation(): void;
  97542. /**
  97543. * @hidden
  97544. * Updates the rig cameras (left and right eye)
  97545. */
  97546. _updateRigCameras(): void;
  97547. private _workingVector;
  97548. private _oneVector;
  97549. private _workingMatrix;
  97550. private updateCacheCalled;
  97551. private _correctPositionIfNotTrackPosition;
  97552. /**
  97553. * @hidden
  97554. * Updates the cached values of the camera
  97555. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  97556. */
  97557. _updateCache(ignoreParentClass?: boolean): void;
  97558. /**
  97559. * @hidden
  97560. * Get current device position in babylon world
  97561. */
  97562. _computeDevicePosition(): void;
  97563. /**
  97564. * Updates the current device position and rotation in the babylon world
  97565. */
  97566. update(): void;
  97567. /**
  97568. * @hidden
  97569. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  97570. * @returns an identity matrix
  97571. */
  97572. _getViewMatrix(): Matrix;
  97573. private _tmpMatrix;
  97574. /**
  97575. * This function is called by the two RIG cameras.
  97576. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  97577. * @hidden
  97578. */
  97579. _getWebVRViewMatrix(): Matrix;
  97580. /** @hidden */
  97581. _getWebVRProjectionMatrix(): Matrix;
  97582. private _onGamepadConnectedObserver;
  97583. private _onGamepadDisconnectedObserver;
  97584. private _updateCacheWhenTrackingDisabledObserver;
  97585. /**
  97586. * Initializes the controllers and their meshes
  97587. */
  97588. initControllers(): void;
  97589. }
  97590. }
  97591. declare module BABYLON {
  97592. /**
  97593. * "Static Class" containing the most commonly used helper while dealing with material for
  97594. * rendering purpose.
  97595. *
  97596. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  97597. *
  97598. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  97599. */
  97600. export class MaterialHelper {
  97601. /**
  97602. * Bind the current view position to an effect.
  97603. * @param effect The effect to be bound
  97604. * @param scene The scene the eyes position is used from
  97605. * @param variableName name of the shader variable that will hold the eye position
  97606. */
  97607. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  97608. /**
  97609. * Helps preparing the defines values about the UVs in used in the effect.
  97610. * UVs are shared as much as we can accross channels in the shaders.
  97611. * @param texture The texture we are preparing the UVs for
  97612. * @param defines The defines to update
  97613. * @param key The channel key "diffuse", "specular"... used in the shader
  97614. */
  97615. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  97616. /**
  97617. * Binds a texture matrix value to its corrsponding uniform
  97618. * @param texture The texture to bind the matrix for
  97619. * @param uniformBuffer The uniform buffer receivin the data
  97620. * @param key The channel key "diffuse", "specular"... used in the shader
  97621. */
  97622. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  97623. /**
  97624. * Gets the current status of the fog (should it be enabled?)
  97625. * @param mesh defines the mesh to evaluate for fog support
  97626. * @param scene defines the hosting scene
  97627. * @returns true if fog must be enabled
  97628. */
  97629. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  97630. /**
  97631. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  97632. * @param mesh defines the current mesh
  97633. * @param scene defines the current scene
  97634. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  97635. * @param pointsCloud defines if point cloud rendering has to be turned on
  97636. * @param fogEnabled defines if fog has to be turned on
  97637. * @param alphaTest defines if alpha testing has to be turned on
  97638. * @param defines defines the current list of defines
  97639. */
  97640. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  97641. /**
  97642. * Helper used to prepare the list of defines associated with frame values for shader compilation
  97643. * @param scene defines the current scene
  97644. * @param engine defines the current engine
  97645. * @param defines specifies the list of active defines
  97646. * @param useInstances defines if instances have to be turned on
  97647. * @param useClipPlane defines if clip plane have to be turned on
  97648. * @param useInstances defines if instances have to be turned on
  97649. * @param useThinInstances defines if thin instances have to be turned on
  97650. */
  97651. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  97652. /**
  97653. * Prepares the defines for bones
  97654. * @param mesh The mesh containing the geometry data we will draw
  97655. * @param defines The defines to update
  97656. */
  97657. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  97658. /**
  97659. * Prepares the defines for morph targets
  97660. * @param mesh The mesh containing the geometry data we will draw
  97661. * @param defines The defines to update
  97662. */
  97663. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  97664. /**
  97665. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  97666. * @param mesh The mesh containing the geometry data we will draw
  97667. * @param defines The defines to update
  97668. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  97669. * @param useBones Precise whether bones should be used or not (override mesh info)
  97670. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  97671. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  97672. * @returns false if defines are considered not dirty and have not been checked
  97673. */
  97674. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  97675. /**
  97676. * Prepares the defines related to multiview
  97677. * @param scene The scene we are intending to draw
  97678. * @param defines The defines to update
  97679. */
  97680. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  97681. /**
  97682. * Prepares the defines related to the light information passed in parameter
  97683. * @param scene The scene we are intending to draw
  97684. * @param mesh The mesh the effect is compiling for
  97685. * @param light The light the effect is compiling for
  97686. * @param lightIndex The index of the light
  97687. * @param defines The defines to update
  97688. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97689. * @param state Defines the current state regarding what is needed (normals, etc...)
  97690. */
  97691. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  97692. needNormals: boolean;
  97693. needRebuild: boolean;
  97694. shadowEnabled: boolean;
  97695. specularEnabled: boolean;
  97696. lightmapMode: boolean;
  97697. }): void;
  97698. /**
  97699. * Prepares the defines related to the light information passed in parameter
  97700. * @param scene The scene we are intending to draw
  97701. * @param mesh The mesh the effect is compiling for
  97702. * @param defines The defines to update
  97703. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  97704. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  97705. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  97706. * @returns true if normals will be required for the rest of the effect
  97707. */
  97708. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  97709. /**
  97710. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  97711. * @param lightIndex defines the light index
  97712. * @param uniformsList The uniform list
  97713. * @param samplersList The sampler list
  97714. * @param projectedLightTexture defines if projected texture must be used
  97715. * @param uniformBuffersList defines an optional list of uniform buffers
  97716. */
  97717. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  97718. /**
  97719. * Prepares the uniforms and samplers list to be used in the effect
  97720. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  97721. * @param samplersList The sampler list
  97722. * @param defines The defines helping in the list generation
  97723. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  97724. */
  97725. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  97726. /**
  97727. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  97728. * @param defines The defines to update while falling back
  97729. * @param fallbacks The authorized effect fallbacks
  97730. * @param maxSimultaneousLights The maximum number of lights allowed
  97731. * @param rank the current rank of the Effect
  97732. * @returns The newly affected rank
  97733. */
  97734. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  97735. private static _TmpMorphInfluencers;
  97736. /**
  97737. * Prepares the list of attributes required for morph targets according to the effect defines.
  97738. * @param attribs The current list of supported attribs
  97739. * @param mesh The mesh to prepare the morph targets attributes for
  97740. * @param influencers The number of influencers
  97741. */
  97742. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  97743. /**
  97744. * Prepares the list of attributes required for morph targets according to the effect defines.
  97745. * @param attribs The current list of supported attribs
  97746. * @param mesh The mesh to prepare the morph targets attributes for
  97747. * @param defines The current Defines of the effect
  97748. */
  97749. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  97750. /**
  97751. * Prepares the list of attributes required for bones according to the effect defines.
  97752. * @param attribs The current list of supported attribs
  97753. * @param mesh The mesh to prepare the bones attributes for
  97754. * @param defines The current Defines of the effect
  97755. * @param fallbacks The current efffect fallback strategy
  97756. */
  97757. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  97758. /**
  97759. * Check and prepare the list of attributes required for instances according to the effect defines.
  97760. * @param attribs The current list of supported attribs
  97761. * @param defines The current MaterialDefines of the effect
  97762. */
  97763. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  97764. /**
  97765. * Add the list of attributes required for instances to the attribs array.
  97766. * @param attribs The current list of supported attribs
  97767. */
  97768. static PushAttributesForInstances(attribs: string[]): void;
  97769. /**
  97770. * Binds the light information to the effect.
  97771. * @param light The light containing the generator
  97772. * @param effect The effect we are binding the data to
  97773. * @param lightIndex The light index in the effect used to render
  97774. */
  97775. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  97776. /**
  97777. * Binds the lights information from the scene to the effect for the given mesh.
  97778. * @param light Light to bind
  97779. * @param lightIndex Light index
  97780. * @param scene The scene where the light belongs to
  97781. * @param effect The effect we are binding the data to
  97782. * @param useSpecular Defines if specular is supported
  97783. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97784. */
  97785. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  97786. /**
  97787. * Binds the lights information from the scene to the effect for the given mesh.
  97788. * @param scene The scene the lights belongs to
  97789. * @param mesh The mesh we are binding the information to render
  97790. * @param effect The effect we are binding the data to
  97791. * @param defines The generated defines for the effect
  97792. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  97793. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  97794. */
  97795. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  97796. private static _tempFogColor;
  97797. /**
  97798. * Binds the fog information from the scene to the effect for the given mesh.
  97799. * @param scene The scene the lights belongs to
  97800. * @param mesh The mesh we are binding the information to render
  97801. * @param effect The effect we are binding the data to
  97802. * @param linearSpace Defines if the fog effect is applied in linear space
  97803. */
  97804. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  97805. /**
  97806. * Binds the bones information from the mesh to the effect.
  97807. * @param mesh The mesh we are binding the information to render
  97808. * @param effect The effect we are binding the data to
  97809. */
  97810. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  97811. /**
  97812. * Binds the morph targets information from the mesh to the effect.
  97813. * @param abstractMesh The mesh we are binding the information to render
  97814. * @param effect The effect we are binding the data to
  97815. */
  97816. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  97817. /**
  97818. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  97819. * @param defines The generated defines used in the effect
  97820. * @param effect The effect we are binding the data to
  97821. * @param scene The scene we are willing to render with logarithmic scale for
  97822. */
  97823. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  97824. /**
  97825. * Binds the clip plane information from the scene to the effect.
  97826. * @param scene The scene the clip plane information are extracted from
  97827. * @param effect The effect we are binding the data to
  97828. */
  97829. static BindClipPlane(effect: Effect, scene: Scene): void;
  97830. }
  97831. }
  97832. declare module BABYLON {
  97833. /**
  97834. * Block used to expose an input value
  97835. */
  97836. export class InputBlock extends NodeMaterialBlock {
  97837. private _mode;
  97838. private _associatedVariableName;
  97839. private _storedValue;
  97840. private _valueCallback;
  97841. private _type;
  97842. private _animationType;
  97843. /** Gets or set a value used to limit the range of float values */
  97844. min: number;
  97845. /** Gets or set a value used to limit the range of float values */
  97846. max: number;
  97847. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  97848. isBoolean: boolean;
  97849. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  97850. matrixMode: number;
  97851. /** @hidden */
  97852. _systemValue: Nullable<NodeMaterialSystemValues>;
  97853. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  97854. visibleInInspector: boolean;
  97855. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  97856. isConstant: boolean;
  97857. /** Gets or sets the group to use to display this block in the Inspector */
  97858. groupInInspector: string;
  97859. /** Gets an observable raised when the value is changed */
  97860. onValueChangedObservable: Observable<InputBlock>;
  97861. /**
  97862. * Gets or sets the connection point type (default is float)
  97863. */
  97864. get type(): NodeMaterialBlockConnectionPointTypes;
  97865. /**
  97866. * Creates a new InputBlock
  97867. * @param name defines the block name
  97868. * @param target defines the target of that block (Vertex by default)
  97869. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  97870. */
  97871. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  97872. /**
  97873. * Gets the output component
  97874. */
  97875. get output(): NodeMaterialConnectionPoint;
  97876. /**
  97877. * Set the source of this connection point to a vertex attribute
  97878. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  97879. * @returns the current connection point
  97880. */
  97881. setAsAttribute(attributeName?: string): InputBlock;
  97882. /**
  97883. * Set the source of this connection point to a system value
  97884. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  97885. * @returns the current connection point
  97886. */
  97887. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  97888. /**
  97889. * Gets or sets the value of that point.
  97890. * Please note that this value will be ignored if valueCallback is defined
  97891. */
  97892. get value(): any;
  97893. set value(value: any);
  97894. /**
  97895. * Gets or sets a callback used to get the value of that point.
  97896. * Please note that setting this value will force the connection point to ignore the value property
  97897. */
  97898. get valueCallback(): () => any;
  97899. set valueCallback(value: () => any);
  97900. /**
  97901. * Gets or sets the associated variable name in the shader
  97902. */
  97903. get associatedVariableName(): string;
  97904. set associatedVariableName(value: string);
  97905. /** Gets or sets the type of animation applied to the input */
  97906. get animationType(): AnimatedInputBlockTypes;
  97907. set animationType(value: AnimatedInputBlockTypes);
  97908. /**
  97909. * Gets a boolean indicating that this connection point not defined yet
  97910. */
  97911. get isUndefined(): boolean;
  97912. /**
  97913. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  97914. * In this case the connection point name must be the name of the uniform to use.
  97915. * Can only be set on inputs
  97916. */
  97917. get isUniform(): boolean;
  97918. set isUniform(value: boolean);
  97919. /**
  97920. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  97921. * In this case the connection point name must be the name of the attribute to use
  97922. * Can only be set on inputs
  97923. */
  97924. get isAttribute(): boolean;
  97925. set isAttribute(value: boolean);
  97926. /**
  97927. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  97928. * Can only be set on exit points
  97929. */
  97930. get isVarying(): boolean;
  97931. set isVarying(value: boolean);
  97932. /**
  97933. * Gets a boolean indicating that the current connection point is a system value
  97934. */
  97935. get isSystemValue(): boolean;
  97936. /**
  97937. * Gets or sets the current well known value or null if not defined as a system value
  97938. */
  97939. get systemValue(): Nullable<NodeMaterialSystemValues>;
  97940. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  97941. /**
  97942. * Gets the current class name
  97943. * @returns the class name
  97944. */
  97945. getClassName(): string;
  97946. /**
  97947. * Animate the input if animationType !== None
  97948. * @param scene defines the rendering scene
  97949. */
  97950. animate(scene: Scene): void;
  97951. private _emitDefine;
  97952. initialize(state: NodeMaterialBuildState): void;
  97953. /**
  97954. * Set the input block to its default value (based on its type)
  97955. */
  97956. setDefaultValue(): void;
  97957. private _emitConstant;
  97958. /** @hidden */
  97959. get _noContextSwitch(): boolean;
  97960. private _emit;
  97961. /** @hidden */
  97962. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  97963. /** @hidden */
  97964. _transmit(effect: Effect, scene: Scene): void;
  97965. protected _buildBlock(state: NodeMaterialBuildState): void;
  97966. protected _dumpPropertiesCode(): string;
  97967. dispose(): void;
  97968. serialize(): any;
  97969. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  97970. }
  97971. }
  97972. declare module BABYLON {
  97973. /**
  97974. * Enum used to define the compatibility state between two connection points
  97975. */
  97976. export enum NodeMaterialConnectionPointCompatibilityStates {
  97977. /** Points are compatibles */
  97978. Compatible = 0,
  97979. /** Points are incompatible because of their types */
  97980. TypeIncompatible = 1,
  97981. /** Points are incompatible because of their targets (vertex vs fragment) */
  97982. TargetIncompatible = 2
  97983. }
  97984. /**
  97985. * Defines the direction of a connection point
  97986. */
  97987. export enum NodeMaterialConnectionPointDirection {
  97988. /** Input */
  97989. Input = 0,
  97990. /** Output */
  97991. Output = 1
  97992. }
  97993. /**
  97994. * Defines a connection point for a block
  97995. */
  97996. export class NodeMaterialConnectionPoint {
  97997. /** @hidden */
  97998. _ownerBlock: NodeMaterialBlock;
  97999. /** @hidden */
  98000. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98001. private _endpoints;
  98002. private _associatedVariableName;
  98003. private _direction;
  98004. /** @hidden */
  98005. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98006. /** @hidden */
  98007. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98008. private _type;
  98009. /** @hidden */
  98010. _enforceAssociatedVariableName: boolean;
  98011. /** Gets the direction of the point */
  98012. get direction(): NodeMaterialConnectionPointDirection;
  98013. /** Indicates that this connection point needs dual validation before being connected to another point */
  98014. needDualDirectionValidation: boolean;
  98015. /**
  98016. * Gets or sets the additional types supported by this connection point
  98017. */
  98018. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98019. /**
  98020. * Gets or sets the additional types excluded by this connection point
  98021. */
  98022. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98023. /**
  98024. * Observable triggered when this point is connected
  98025. */
  98026. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98027. /**
  98028. * Gets or sets the associated variable name in the shader
  98029. */
  98030. get associatedVariableName(): string;
  98031. set associatedVariableName(value: string);
  98032. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98033. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98034. /**
  98035. * Gets or sets the connection point type (default is float)
  98036. */
  98037. get type(): NodeMaterialBlockConnectionPointTypes;
  98038. set type(value: NodeMaterialBlockConnectionPointTypes);
  98039. /**
  98040. * Gets or sets the connection point name
  98041. */
  98042. name: string;
  98043. /**
  98044. * Gets or sets the connection point name
  98045. */
  98046. displayName: string;
  98047. /**
  98048. * Gets or sets a boolean indicating that this connection point can be omitted
  98049. */
  98050. isOptional: boolean;
  98051. /**
  98052. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98053. */
  98054. isExposedOnFrame: boolean;
  98055. /**
  98056. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98057. */
  98058. define: string;
  98059. /** @hidden */
  98060. _prioritizeVertex: boolean;
  98061. private _target;
  98062. /** Gets or sets the target of that connection point */
  98063. get target(): NodeMaterialBlockTargets;
  98064. set target(value: NodeMaterialBlockTargets);
  98065. /**
  98066. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98067. */
  98068. get isConnected(): boolean;
  98069. /**
  98070. * Gets a boolean indicating that the current point is connected to an input block
  98071. */
  98072. get isConnectedToInputBlock(): boolean;
  98073. /**
  98074. * Gets a the connected input block (if any)
  98075. */
  98076. get connectInputBlock(): Nullable<InputBlock>;
  98077. /** Get the other side of the connection (if any) */
  98078. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98079. /** Get the block that owns this connection point */
  98080. get ownerBlock(): NodeMaterialBlock;
  98081. /** Get the block connected on the other side of this connection (if any) */
  98082. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98083. /** Get the block connected on the endpoints of this connection (if any) */
  98084. get connectedBlocks(): Array<NodeMaterialBlock>;
  98085. /** Gets the list of connected endpoints */
  98086. get endpoints(): NodeMaterialConnectionPoint[];
  98087. /** Gets a boolean indicating if that output point is connected to at least one input */
  98088. get hasEndpoints(): boolean;
  98089. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98090. get isConnectedInVertexShader(): boolean;
  98091. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98092. get isConnectedInFragmentShader(): boolean;
  98093. /**
  98094. * Creates a block suitable to be used as an input for this input point.
  98095. * If null is returned, a block based on the point type will be created.
  98096. * @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
  98097. */
  98098. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98099. /**
  98100. * Creates a new connection point
  98101. * @param name defines the connection point name
  98102. * @param ownerBlock defines the block hosting this connection point
  98103. * @param direction defines the direction of the connection point
  98104. */
  98105. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98106. /**
  98107. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98108. * @returns the class name
  98109. */
  98110. getClassName(): string;
  98111. /**
  98112. * Gets a boolean indicating if the current point can be connected to another point
  98113. * @param connectionPoint defines the other connection point
  98114. * @returns a boolean
  98115. */
  98116. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98117. /**
  98118. * Gets a number indicating if the current point can be connected to another point
  98119. * @param connectionPoint defines the other connection point
  98120. * @returns a number defining the compatibility state
  98121. */
  98122. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98123. /**
  98124. * Connect this point to another connection point
  98125. * @param connectionPoint defines the other connection point
  98126. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98127. * @returns the current connection point
  98128. */
  98129. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98130. /**
  98131. * Disconnect this point from one of his endpoint
  98132. * @param endpoint defines the other connection point
  98133. * @returns the current connection point
  98134. */
  98135. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98136. /**
  98137. * Serializes this point in a JSON representation
  98138. * @param isInput defines if the connection point is an input (default is true)
  98139. * @returns the serialized point object
  98140. */
  98141. serialize(isInput?: boolean): any;
  98142. /**
  98143. * Release resources
  98144. */
  98145. dispose(): void;
  98146. }
  98147. }
  98148. declare module BABYLON {
  98149. /**
  98150. * Enum used to define the material modes
  98151. */
  98152. export enum NodeMaterialModes {
  98153. /** Regular material */
  98154. Material = 0,
  98155. /** For post process */
  98156. PostProcess = 1,
  98157. /** For particle system */
  98158. Particle = 2
  98159. }
  98160. }
  98161. declare module BABYLON {
  98162. /**
  98163. * Block used to read a texture from a sampler
  98164. */
  98165. export class TextureBlock extends NodeMaterialBlock {
  98166. private _defineName;
  98167. private _linearDefineName;
  98168. private _gammaDefineName;
  98169. private _tempTextureRead;
  98170. private _samplerName;
  98171. private _transformedUVName;
  98172. private _textureTransformName;
  98173. private _textureInfoName;
  98174. private _mainUVName;
  98175. private _mainUVDefineName;
  98176. private _fragmentOnly;
  98177. /**
  98178. * Gets or sets the texture associated with the node
  98179. */
  98180. texture: Nullable<Texture>;
  98181. /**
  98182. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98183. */
  98184. convertToGammaSpace: boolean;
  98185. /**
  98186. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98187. */
  98188. convertToLinearSpace: boolean;
  98189. /**
  98190. * Create a new TextureBlock
  98191. * @param name defines the block name
  98192. */
  98193. constructor(name: string, fragmentOnly?: boolean);
  98194. /**
  98195. * Gets the current class name
  98196. * @returns the class name
  98197. */
  98198. getClassName(): string;
  98199. /**
  98200. * Gets the uv input component
  98201. */
  98202. get uv(): NodeMaterialConnectionPoint;
  98203. /**
  98204. * Gets the rgba output component
  98205. */
  98206. get rgba(): NodeMaterialConnectionPoint;
  98207. /**
  98208. * Gets the rgb output component
  98209. */
  98210. get rgb(): NodeMaterialConnectionPoint;
  98211. /**
  98212. * Gets the r output component
  98213. */
  98214. get r(): NodeMaterialConnectionPoint;
  98215. /**
  98216. * Gets the g output component
  98217. */
  98218. get g(): NodeMaterialConnectionPoint;
  98219. /**
  98220. * Gets the b output component
  98221. */
  98222. get b(): NodeMaterialConnectionPoint;
  98223. /**
  98224. * Gets the a output component
  98225. */
  98226. get a(): NodeMaterialConnectionPoint;
  98227. get target(): NodeMaterialBlockTargets;
  98228. autoConfigure(material: NodeMaterial): void;
  98229. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98230. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98231. isReady(): boolean;
  98232. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98233. private get _isMixed();
  98234. private _injectVertexCode;
  98235. private _writeTextureRead;
  98236. private _writeOutput;
  98237. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98238. protected _dumpPropertiesCode(): string;
  98239. serialize(): any;
  98240. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98241. }
  98242. }
  98243. declare module BABYLON {
  98244. /** @hidden */
  98245. export var reflectionFunction: {
  98246. name: string;
  98247. shader: string;
  98248. };
  98249. }
  98250. declare module BABYLON {
  98251. /**
  98252. * Base block used to read a reflection texture from a sampler
  98253. */
  98254. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98255. /** @hidden */
  98256. _define3DName: string;
  98257. /** @hidden */
  98258. _defineCubicName: string;
  98259. /** @hidden */
  98260. _defineExplicitName: string;
  98261. /** @hidden */
  98262. _defineProjectionName: string;
  98263. /** @hidden */
  98264. _defineLocalCubicName: string;
  98265. /** @hidden */
  98266. _defineSphericalName: string;
  98267. /** @hidden */
  98268. _definePlanarName: string;
  98269. /** @hidden */
  98270. _defineEquirectangularName: string;
  98271. /** @hidden */
  98272. _defineMirroredEquirectangularFixedName: string;
  98273. /** @hidden */
  98274. _defineEquirectangularFixedName: string;
  98275. /** @hidden */
  98276. _defineSkyboxName: string;
  98277. /** @hidden */
  98278. _defineOppositeZ: string;
  98279. /** @hidden */
  98280. _cubeSamplerName: string;
  98281. /** @hidden */
  98282. _2DSamplerName: string;
  98283. protected _positionUVWName: string;
  98284. protected _directionWName: string;
  98285. protected _reflectionVectorName: string;
  98286. /** @hidden */
  98287. _reflectionCoordsName: string;
  98288. /** @hidden */
  98289. _reflectionMatrixName: string;
  98290. protected _reflectionColorName: string;
  98291. /**
  98292. * Gets or sets the texture associated with the node
  98293. */
  98294. texture: Nullable<BaseTexture>;
  98295. /**
  98296. * Create a new ReflectionTextureBaseBlock
  98297. * @param name defines the block name
  98298. */
  98299. constructor(name: string);
  98300. /**
  98301. * Gets the current class name
  98302. * @returns the class name
  98303. */
  98304. getClassName(): string;
  98305. /**
  98306. * Gets the world position input component
  98307. */
  98308. abstract get position(): NodeMaterialConnectionPoint;
  98309. /**
  98310. * Gets the world position input component
  98311. */
  98312. abstract get worldPosition(): NodeMaterialConnectionPoint;
  98313. /**
  98314. * Gets the world normal input component
  98315. */
  98316. abstract get worldNormal(): NodeMaterialConnectionPoint;
  98317. /**
  98318. * Gets the world input component
  98319. */
  98320. abstract get world(): NodeMaterialConnectionPoint;
  98321. /**
  98322. * Gets the camera (or eye) position component
  98323. */
  98324. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  98325. /**
  98326. * Gets the view input component
  98327. */
  98328. abstract get view(): NodeMaterialConnectionPoint;
  98329. protected _getTexture(): Nullable<BaseTexture>;
  98330. autoConfigure(material: NodeMaterial): void;
  98331. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98332. isReady(): boolean;
  98333. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98334. /**
  98335. * Gets the code to inject in the vertex shader
  98336. * @param state current state of the node material building
  98337. * @returns the shader code
  98338. */
  98339. handleVertexSide(state: NodeMaterialBuildState): string;
  98340. /**
  98341. * Handles the inits for the fragment code path
  98342. * @param state node material build state
  98343. */
  98344. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  98345. /**
  98346. * Generates the reflection coords code for the fragment code path
  98347. * @param worldNormalVarName name of the world normal variable
  98348. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  98349. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  98350. * @returns the shader code
  98351. */
  98352. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  98353. /**
  98354. * Generates the reflection color code for the fragment code path
  98355. * @param lodVarName name of the lod variable
  98356. * @param swizzleLookupTexture swizzle to use for the final color variable
  98357. * @returns the shader code
  98358. */
  98359. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  98360. /**
  98361. * Generates the code corresponding to the connected output points
  98362. * @param state node material build state
  98363. * @param varName name of the variable to output
  98364. * @returns the shader code
  98365. */
  98366. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  98367. protected _buildBlock(state: NodeMaterialBuildState): this;
  98368. protected _dumpPropertiesCode(): string;
  98369. serialize(): any;
  98370. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98371. }
  98372. }
  98373. declare module BABYLON {
  98374. /**
  98375. * Defines a connection point to be used for points with a custom object type
  98376. */
  98377. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  98378. private _blockType;
  98379. private _blockName;
  98380. private _nameForCheking?;
  98381. /**
  98382. * Creates a new connection point
  98383. * @param name defines the connection point name
  98384. * @param ownerBlock defines the block hosting this connection point
  98385. * @param direction defines the direction of the connection point
  98386. */
  98387. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  98388. /**
  98389. * Gets a number indicating if the current point can be connected to another point
  98390. * @param connectionPoint defines the other connection point
  98391. * @returns a number defining the compatibility state
  98392. */
  98393. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98394. /**
  98395. * Creates a block suitable to be used as an input for this input point.
  98396. * If null is returned, a block based on the point type will be created.
  98397. * @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
  98398. */
  98399. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98400. }
  98401. }
  98402. declare module BABYLON {
  98403. /**
  98404. * Enum defining the type of properties that can be edited in the property pages in the NME
  98405. */
  98406. export enum PropertyTypeForEdition {
  98407. /** property is a boolean */
  98408. Boolean = 0,
  98409. /** property is a float */
  98410. Float = 1,
  98411. /** property is a Vector2 */
  98412. Vector2 = 2,
  98413. /** property is a list of values */
  98414. List = 3
  98415. }
  98416. /**
  98417. * Interface that defines an option in a variable of type list
  98418. */
  98419. export interface IEditablePropertyListOption {
  98420. /** label of the option */
  98421. "label": string;
  98422. /** value of the option */
  98423. "value": number;
  98424. }
  98425. /**
  98426. * Interface that defines the options available for an editable property
  98427. */
  98428. export interface IEditablePropertyOption {
  98429. /** min value */
  98430. "min"?: number;
  98431. /** max value */
  98432. "max"?: number;
  98433. /** notifiers: indicates which actions to take when the property is changed */
  98434. "notifiers"?: {
  98435. /** the material should be rebuilt */
  98436. "rebuild"?: boolean;
  98437. /** the preview should be updated */
  98438. "update"?: boolean;
  98439. };
  98440. /** list of the options for a variable of type list */
  98441. "options"?: IEditablePropertyListOption[];
  98442. }
  98443. /**
  98444. * Interface that describes an editable property
  98445. */
  98446. export interface IPropertyDescriptionForEdition {
  98447. /** name of the property */
  98448. "propertyName": string;
  98449. /** display name of the property */
  98450. "displayName": string;
  98451. /** type of the property */
  98452. "type": PropertyTypeForEdition;
  98453. /** group of the property - all properties with the same group value will be displayed in a specific section */
  98454. "groupName": string;
  98455. /** options for the property */
  98456. "options": IEditablePropertyOption;
  98457. }
  98458. /**
  98459. * Decorator that flags a property in a node material block as being editable
  98460. */
  98461. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  98462. }
  98463. declare module BABYLON {
  98464. /**
  98465. * Block used to implement the refraction part of the sub surface module of the PBR material
  98466. */
  98467. export class RefractionBlock extends NodeMaterialBlock {
  98468. /** @hidden */
  98469. _define3DName: string;
  98470. /** @hidden */
  98471. _refractionMatrixName: string;
  98472. /** @hidden */
  98473. _defineLODRefractionAlpha: string;
  98474. /** @hidden */
  98475. _defineLinearSpecularRefraction: string;
  98476. /** @hidden */
  98477. _defineOppositeZ: string;
  98478. /** @hidden */
  98479. _cubeSamplerName: string;
  98480. /** @hidden */
  98481. _2DSamplerName: string;
  98482. /** @hidden */
  98483. _vRefractionMicrosurfaceInfosName: string;
  98484. /** @hidden */
  98485. _vRefractionInfosName: string;
  98486. private _scene;
  98487. /**
  98488. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98489. * Materials half opaque for instance using refraction could benefit from this control.
  98490. */
  98491. linkRefractionWithTransparency: boolean;
  98492. /**
  98493. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98494. */
  98495. invertRefractionY: boolean;
  98496. /**
  98497. * Gets or sets the texture associated with the node
  98498. */
  98499. texture: Nullable<BaseTexture>;
  98500. /**
  98501. * Create a new RefractionBlock
  98502. * @param name defines the block name
  98503. */
  98504. constructor(name: string);
  98505. /**
  98506. * Gets the current class name
  98507. * @returns the class name
  98508. */
  98509. getClassName(): string;
  98510. /**
  98511. * Gets the intensity input component
  98512. */
  98513. get intensity(): NodeMaterialConnectionPoint;
  98514. /**
  98515. * Gets the index of refraction input component
  98516. */
  98517. get indexOfRefraction(): NodeMaterialConnectionPoint;
  98518. /**
  98519. * Gets the tint at distance input component
  98520. */
  98521. get tintAtDistance(): NodeMaterialConnectionPoint;
  98522. /**
  98523. * Gets the view input component
  98524. */
  98525. get view(): NodeMaterialConnectionPoint;
  98526. /**
  98527. * Gets the refraction object output component
  98528. */
  98529. get refraction(): NodeMaterialConnectionPoint;
  98530. /**
  98531. * Returns true if the block has a texture
  98532. */
  98533. get hasTexture(): boolean;
  98534. protected _getTexture(): Nullable<BaseTexture>;
  98535. autoConfigure(material: NodeMaterial): void;
  98536. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98537. isReady(): boolean;
  98538. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  98539. /**
  98540. * Gets the main code of the block (fragment side)
  98541. * @param state current state of the node material building
  98542. * @returns the shader code
  98543. */
  98544. getCode(state: NodeMaterialBuildState): string;
  98545. protected _buildBlock(state: NodeMaterialBuildState): this;
  98546. protected _dumpPropertiesCode(): string;
  98547. serialize(): any;
  98548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98549. }
  98550. }
  98551. declare module BABYLON {
  98552. /**
  98553. * Base block used as input for post process
  98554. */
  98555. export class CurrentScreenBlock extends NodeMaterialBlock {
  98556. private _samplerName;
  98557. private _linearDefineName;
  98558. private _gammaDefineName;
  98559. private _mainUVName;
  98560. private _tempTextureRead;
  98561. /**
  98562. * Gets or sets the texture associated with the node
  98563. */
  98564. texture: Nullable<BaseTexture>;
  98565. /**
  98566. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98567. */
  98568. convertToGammaSpace: boolean;
  98569. /**
  98570. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98571. */
  98572. convertToLinearSpace: boolean;
  98573. /**
  98574. * Create a new CurrentScreenBlock
  98575. * @param name defines the block name
  98576. */
  98577. constructor(name: string);
  98578. /**
  98579. * Gets the current class name
  98580. * @returns the class name
  98581. */
  98582. getClassName(): string;
  98583. /**
  98584. * Gets the uv input component
  98585. */
  98586. get uv(): NodeMaterialConnectionPoint;
  98587. /**
  98588. * Gets the rgba output component
  98589. */
  98590. get rgba(): NodeMaterialConnectionPoint;
  98591. /**
  98592. * Gets the rgb output component
  98593. */
  98594. get rgb(): NodeMaterialConnectionPoint;
  98595. /**
  98596. * Gets the r output component
  98597. */
  98598. get r(): NodeMaterialConnectionPoint;
  98599. /**
  98600. * Gets the g output component
  98601. */
  98602. get g(): NodeMaterialConnectionPoint;
  98603. /**
  98604. * Gets the b output component
  98605. */
  98606. get b(): NodeMaterialConnectionPoint;
  98607. /**
  98608. * Gets the a output component
  98609. */
  98610. get a(): NodeMaterialConnectionPoint;
  98611. /**
  98612. * Initialize the block and prepare the context for build
  98613. * @param state defines the state that will be used for the build
  98614. */
  98615. initialize(state: NodeMaterialBuildState): void;
  98616. get target(): NodeMaterialBlockTargets;
  98617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98618. isReady(): boolean;
  98619. private _injectVertexCode;
  98620. private _writeTextureRead;
  98621. private _writeOutput;
  98622. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98623. serialize(): any;
  98624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98625. }
  98626. }
  98627. declare module BABYLON {
  98628. /**
  98629. * Base block used for the particle texture
  98630. */
  98631. export class ParticleTextureBlock extends NodeMaterialBlock {
  98632. private _samplerName;
  98633. private _linearDefineName;
  98634. private _gammaDefineName;
  98635. private _tempTextureRead;
  98636. /**
  98637. * Gets or sets the texture associated with the node
  98638. */
  98639. texture: Nullable<BaseTexture>;
  98640. /**
  98641. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98642. */
  98643. convertToGammaSpace: boolean;
  98644. /**
  98645. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98646. */
  98647. convertToLinearSpace: boolean;
  98648. /**
  98649. * Create a new ParticleTextureBlock
  98650. * @param name defines the block name
  98651. */
  98652. constructor(name: string);
  98653. /**
  98654. * Gets the current class name
  98655. * @returns the class name
  98656. */
  98657. getClassName(): string;
  98658. /**
  98659. * Gets the uv input component
  98660. */
  98661. get uv(): NodeMaterialConnectionPoint;
  98662. /**
  98663. * Gets the rgba output component
  98664. */
  98665. get rgba(): NodeMaterialConnectionPoint;
  98666. /**
  98667. * Gets the rgb output component
  98668. */
  98669. get rgb(): NodeMaterialConnectionPoint;
  98670. /**
  98671. * Gets the r output component
  98672. */
  98673. get r(): NodeMaterialConnectionPoint;
  98674. /**
  98675. * Gets the g output component
  98676. */
  98677. get g(): NodeMaterialConnectionPoint;
  98678. /**
  98679. * Gets the b output component
  98680. */
  98681. get b(): NodeMaterialConnectionPoint;
  98682. /**
  98683. * Gets the a output component
  98684. */
  98685. get a(): NodeMaterialConnectionPoint;
  98686. /**
  98687. * Initialize the block and prepare the context for build
  98688. * @param state defines the state that will be used for the build
  98689. */
  98690. initialize(state: NodeMaterialBuildState): void;
  98691. autoConfigure(material: NodeMaterial): void;
  98692. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98693. isReady(): boolean;
  98694. private _writeOutput;
  98695. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98696. serialize(): any;
  98697. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98698. }
  98699. }
  98700. declare module BABYLON {
  98701. /**
  98702. * Class used to store shared data between 2 NodeMaterialBuildState
  98703. */
  98704. export class NodeMaterialBuildStateSharedData {
  98705. /**
  98706. * Gets the list of emitted varyings
  98707. */
  98708. temps: string[];
  98709. /**
  98710. * Gets the list of emitted varyings
  98711. */
  98712. varyings: string[];
  98713. /**
  98714. * Gets the varying declaration string
  98715. */
  98716. varyingDeclaration: string;
  98717. /**
  98718. * Input blocks
  98719. */
  98720. inputBlocks: InputBlock[];
  98721. /**
  98722. * Input blocks
  98723. */
  98724. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  98725. /**
  98726. * Bindable blocks (Blocks that need to set data to the effect)
  98727. */
  98728. bindableBlocks: NodeMaterialBlock[];
  98729. /**
  98730. * List of blocks that can provide a compilation fallback
  98731. */
  98732. blocksWithFallbacks: NodeMaterialBlock[];
  98733. /**
  98734. * List of blocks that can provide a define update
  98735. */
  98736. blocksWithDefines: NodeMaterialBlock[];
  98737. /**
  98738. * List of blocks that can provide a repeatable content
  98739. */
  98740. repeatableContentBlocks: NodeMaterialBlock[];
  98741. /**
  98742. * List of blocks that can provide a dynamic list of uniforms
  98743. */
  98744. dynamicUniformBlocks: NodeMaterialBlock[];
  98745. /**
  98746. * List of blocks that can block the isReady function for the material
  98747. */
  98748. blockingBlocks: NodeMaterialBlock[];
  98749. /**
  98750. * Gets the list of animated inputs
  98751. */
  98752. animatedInputs: InputBlock[];
  98753. /**
  98754. * Build Id used to avoid multiple recompilations
  98755. */
  98756. buildId: number;
  98757. /** List of emitted variables */
  98758. variableNames: {
  98759. [key: string]: number;
  98760. };
  98761. /** List of emitted defines */
  98762. defineNames: {
  98763. [key: string]: number;
  98764. };
  98765. /** Should emit comments? */
  98766. emitComments: boolean;
  98767. /** Emit build activity */
  98768. verbose: boolean;
  98769. /** Gets or sets the hosting scene */
  98770. scene: Scene;
  98771. /**
  98772. * Gets the compilation hints emitted at compilation time
  98773. */
  98774. hints: {
  98775. needWorldViewMatrix: boolean;
  98776. needWorldViewProjectionMatrix: boolean;
  98777. needAlphaBlending: boolean;
  98778. needAlphaTesting: boolean;
  98779. };
  98780. /**
  98781. * List of compilation checks
  98782. */
  98783. checks: {
  98784. emitVertex: boolean;
  98785. emitFragment: boolean;
  98786. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  98787. };
  98788. /**
  98789. * Is vertex program allowed to be empty?
  98790. */
  98791. allowEmptyVertexProgram: boolean;
  98792. /** Creates a new shared data */
  98793. constructor();
  98794. /**
  98795. * Emits console errors and exceptions if there is a failing check
  98796. */
  98797. emitErrors(): void;
  98798. }
  98799. }
  98800. declare module BABYLON {
  98801. /**
  98802. * Class used to store node based material build state
  98803. */
  98804. export class NodeMaterialBuildState {
  98805. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  98806. supportUniformBuffers: boolean;
  98807. /**
  98808. * Gets the list of emitted attributes
  98809. */
  98810. attributes: string[];
  98811. /**
  98812. * Gets the list of emitted uniforms
  98813. */
  98814. uniforms: string[];
  98815. /**
  98816. * Gets the list of emitted constants
  98817. */
  98818. constants: string[];
  98819. /**
  98820. * Gets the list of emitted samplers
  98821. */
  98822. samplers: string[];
  98823. /**
  98824. * Gets the list of emitted functions
  98825. */
  98826. functions: {
  98827. [key: string]: string;
  98828. };
  98829. /**
  98830. * Gets the list of emitted extensions
  98831. */
  98832. extensions: {
  98833. [key: string]: string;
  98834. };
  98835. /**
  98836. * Gets the target of the compilation state
  98837. */
  98838. target: NodeMaterialBlockTargets;
  98839. /**
  98840. * Gets the list of emitted counters
  98841. */
  98842. counters: {
  98843. [key: string]: number;
  98844. };
  98845. /**
  98846. * Shared data between multiple NodeMaterialBuildState instances
  98847. */
  98848. sharedData: NodeMaterialBuildStateSharedData;
  98849. /** @hidden */
  98850. _vertexState: NodeMaterialBuildState;
  98851. /** @hidden */
  98852. _attributeDeclaration: string;
  98853. /** @hidden */
  98854. _uniformDeclaration: string;
  98855. /** @hidden */
  98856. _constantDeclaration: string;
  98857. /** @hidden */
  98858. _samplerDeclaration: string;
  98859. /** @hidden */
  98860. _varyingTransfer: string;
  98861. /** @hidden */
  98862. _injectAtEnd: string;
  98863. private _repeatableContentAnchorIndex;
  98864. /** @hidden */
  98865. _builtCompilationString: string;
  98866. /**
  98867. * Gets the emitted compilation strings
  98868. */
  98869. compilationString: string;
  98870. /**
  98871. * Finalize the compilation strings
  98872. * @param state defines the current compilation state
  98873. */
  98874. finalize(state: NodeMaterialBuildState): void;
  98875. /** @hidden */
  98876. get _repeatableContentAnchor(): string;
  98877. /** @hidden */
  98878. _getFreeVariableName(prefix: string): string;
  98879. /** @hidden */
  98880. _getFreeDefineName(prefix: string): string;
  98881. /** @hidden */
  98882. _excludeVariableName(name: string): void;
  98883. /** @hidden */
  98884. _emit2DSampler(name: string): void;
  98885. /** @hidden */
  98886. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  98887. /** @hidden */
  98888. _emitExtension(name: string, extension: string, define?: string): void;
  98889. /** @hidden */
  98890. _emitFunction(name: string, code: string, comments: string): void;
  98891. /** @hidden */
  98892. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  98893. replaceStrings?: {
  98894. search: RegExp;
  98895. replace: string;
  98896. }[];
  98897. repeatKey?: string;
  98898. }): string;
  98899. /** @hidden */
  98900. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  98901. repeatKey?: string;
  98902. removeAttributes?: boolean;
  98903. removeUniforms?: boolean;
  98904. removeVaryings?: boolean;
  98905. removeIfDef?: boolean;
  98906. replaceStrings?: {
  98907. search: RegExp;
  98908. replace: string;
  98909. }[];
  98910. }, storeKey?: string): void;
  98911. /** @hidden */
  98912. _registerTempVariable(name: string): boolean;
  98913. /** @hidden */
  98914. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  98915. /** @hidden */
  98916. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  98917. /** @hidden */
  98918. _emitFloat(value: number): string;
  98919. }
  98920. }
  98921. declare module BABYLON {
  98922. /**
  98923. * Helper class used to generate session unique ID
  98924. */
  98925. export class UniqueIdGenerator {
  98926. private static _UniqueIdCounter;
  98927. /**
  98928. * Gets an unique (relatively to the current scene) Id
  98929. */
  98930. static get UniqueId(): number;
  98931. }
  98932. }
  98933. declare module BABYLON {
  98934. /**
  98935. * Defines a block that can be used inside a node based material
  98936. */
  98937. export class NodeMaterialBlock {
  98938. private _buildId;
  98939. private _buildTarget;
  98940. private _target;
  98941. private _isFinalMerger;
  98942. private _isInput;
  98943. protected _isUnique: boolean;
  98944. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  98945. inputsAreExclusive: boolean;
  98946. /** @hidden */
  98947. _codeVariableName: string;
  98948. /** @hidden */
  98949. _inputs: NodeMaterialConnectionPoint[];
  98950. /** @hidden */
  98951. _outputs: NodeMaterialConnectionPoint[];
  98952. /** @hidden */
  98953. _preparationId: number;
  98954. /**
  98955. * Gets or sets the name of the block
  98956. */
  98957. name: string;
  98958. /**
  98959. * Gets or sets the unique id of the node
  98960. */
  98961. uniqueId: number;
  98962. /**
  98963. * Gets or sets the comments associated with this block
  98964. */
  98965. comments: string;
  98966. /**
  98967. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  98968. */
  98969. get isUnique(): boolean;
  98970. /**
  98971. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  98972. */
  98973. get isFinalMerger(): boolean;
  98974. /**
  98975. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  98976. */
  98977. get isInput(): boolean;
  98978. /**
  98979. * Gets or sets the build Id
  98980. */
  98981. get buildId(): number;
  98982. set buildId(value: number);
  98983. /**
  98984. * Gets or sets the target of the block
  98985. */
  98986. get target(): NodeMaterialBlockTargets;
  98987. set target(value: NodeMaterialBlockTargets);
  98988. /**
  98989. * Gets the list of input points
  98990. */
  98991. get inputs(): NodeMaterialConnectionPoint[];
  98992. /** Gets the list of output points */
  98993. get outputs(): NodeMaterialConnectionPoint[];
  98994. /**
  98995. * Find an input by its name
  98996. * @param name defines the name of the input to look for
  98997. * @returns the input or null if not found
  98998. */
  98999. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99000. /**
  99001. * Find an output by its name
  99002. * @param name defines the name of the outputto look for
  99003. * @returns the output or null if not found
  99004. */
  99005. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99006. /**
  99007. * Creates a new NodeMaterialBlock
  99008. * @param name defines the block name
  99009. * @param target defines the target of that block (Vertex by default)
  99010. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99011. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99012. */
  99013. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99014. /**
  99015. * Initialize the block and prepare the context for build
  99016. * @param state defines the state that will be used for the build
  99017. */
  99018. initialize(state: NodeMaterialBuildState): void;
  99019. /**
  99020. * Bind data to effect. Will only be called for blocks with isBindable === true
  99021. * @param effect defines the effect to bind data to
  99022. * @param nodeMaterial defines the hosting NodeMaterial
  99023. * @param mesh defines the mesh that will be rendered
  99024. * @param subMesh defines the submesh that will be rendered
  99025. */
  99026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99027. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99028. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99029. protected _writeFloat(value: number): string;
  99030. /**
  99031. * Gets the current class name e.g. "NodeMaterialBlock"
  99032. * @returns the class name
  99033. */
  99034. getClassName(): string;
  99035. /**
  99036. * Register a new input. Must be called inside a block constructor
  99037. * @param name defines the connection point name
  99038. * @param type defines the connection point type
  99039. * @param isOptional defines a boolean indicating that this input can be omitted
  99040. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99041. * @param point an already created connection point. If not provided, create a new one
  99042. * @returns the current block
  99043. */
  99044. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99045. /**
  99046. * Register a new output. Must be called inside a block constructor
  99047. * @param name defines the connection point name
  99048. * @param type defines the connection point type
  99049. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99050. * @param point an already created connection point. If not provided, create a new one
  99051. * @returns the current block
  99052. */
  99053. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99054. /**
  99055. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99056. * @param forOutput defines an optional connection point to check compatibility with
  99057. * @returns the first available input or null
  99058. */
  99059. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99060. /**
  99061. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99062. * @param forBlock defines an optional block to check compatibility with
  99063. * @returns the first available input or null
  99064. */
  99065. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99066. /**
  99067. * Gets the sibling of the given output
  99068. * @param current defines the current output
  99069. * @returns the next output in the list or null
  99070. */
  99071. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99072. /**
  99073. * Connect current block with another block
  99074. * @param other defines the block to connect with
  99075. * @param options define the various options to help pick the right connections
  99076. * @returns the current block
  99077. */
  99078. connectTo(other: NodeMaterialBlock, options?: {
  99079. input?: string;
  99080. output?: string;
  99081. outputSwizzle?: string;
  99082. }): this | undefined;
  99083. protected _buildBlock(state: NodeMaterialBuildState): void;
  99084. /**
  99085. * Add uniforms, samplers and uniform buffers at compilation time
  99086. * @param state defines the state to update
  99087. * @param nodeMaterial defines the node material requesting the update
  99088. * @param defines defines the material defines to update
  99089. * @param uniformBuffers defines the list of uniform buffer names
  99090. */
  99091. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99092. /**
  99093. * Add potential fallbacks if shader compilation fails
  99094. * @param mesh defines the mesh to be rendered
  99095. * @param fallbacks defines the current prioritized list of fallbacks
  99096. */
  99097. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99098. /**
  99099. * Initialize defines for shader compilation
  99100. * @param mesh defines the mesh to be rendered
  99101. * @param nodeMaterial defines the node material requesting the update
  99102. * @param defines defines the material defines to update
  99103. * @param useInstances specifies that instances should be used
  99104. */
  99105. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99106. /**
  99107. * Update defines for shader compilation
  99108. * @param mesh defines the mesh to be rendered
  99109. * @param nodeMaterial defines the node material requesting the update
  99110. * @param defines defines the material defines to update
  99111. * @param useInstances specifies that instances should be used
  99112. * @param subMesh defines which submesh to render
  99113. */
  99114. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99115. /**
  99116. * Lets the block try to connect some inputs automatically
  99117. * @param material defines the hosting NodeMaterial
  99118. */
  99119. autoConfigure(material: NodeMaterial): void;
  99120. /**
  99121. * Function called when a block is declared as repeatable content generator
  99122. * @param vertexShaderState defines the current compilation state for the vertex shader
  99123. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99124. * @param mesh defines the mesh to be rendered
  99125. * @param defines defines the material defines to update
  99126. */
  99127. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99128. /**
  99129. * Checks if the block is ready
  99130. * @param mesh defines the mesh to be rendered
  99131. * @param nodeMaterial defines the node material requesting the update
  99132. * @param defines defines the material defines to update
  99133. * @param useInstances specifies that instances should be used
  99134. * @returns true if the block is ready
  99135. */
  99136. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99137. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99138. private _processBuild;
  99139. /**
  99140. * Compile the current node and generate the shader code
  99141. * @param state defines the current compilation state (uniforms, samplers, current string)
  99142. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99143. * @returns true if already built
  99144. */
  99145. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99146. protected _inputRename(name: string): string;
  99147. protected _outputRename(name: string): string;
  99148. protected _dumpPropertiesCode(): string;
  99149. /** @hidden */
  99150. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99151. /** @hidden */
  99152. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99153. /**
  99154. * Clone the current block to a new identical block
  99155. * @param scene defines the hosting scene
  99156. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99157. * @returns a copy of the current block
  99158. */
  99159. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99160. /**
  99161. * Serializes this block in a JSON representation
  99162. * @returns the serialized block object
  99163. */
  99164. serialize(): any;
  99165. /** @hidden */
  99166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99167. private _deserializePortDisplayNamesAndExposedOnFrame;
  99168. /**
  99169. * Release resources
  99170. */
  99171. dispose(): void;
  99172. }
  99173. }
  99174. declare module BABYLON {
  99175. /**
  99176. * Base class of materials working in push mode in babylon JS
  99177. * @hidden
  99178. */
  99179. export class PushMaterial extends Material {
  99180. protected _activeEffect: Effect;
  99181. protected _normalMatrix: Matrix;
  99182. constructor(name: string, scene: Scene);
  99183. getEffect(): Effect;
  99184. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99185. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99186. /**
  99187. * Binds the given world matrix to the active effect
  99188. *
  99189. * @param world the matrix to bind
  99190. */
  99191. bindOnlyWorldMatrix(world: Matrix): void;
  99192. /**
  99193. * Binds the given normal matrix to the active effect
  99194. *
  99195. * @param normalMatrix the matrix to bind
  99196. */
  99197. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99198. bind(world: Matrix, mesh?: Mesh): void;
  99199. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99200. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99201. }
  99202. }
  99203. declare module BABYLON {
  99204. /**
  99205. * Root class for all node material optimizers
  99206. */
  99207. export class NodeMaterialOptimizer {
  99208. /**
  99209. * Function used to optimize a NodeMaterial graph
  99210. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99211. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99212. */
  99213. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99214. }
  99215. }
  99216. declare module BABYLON {
  99217. /**
  99218. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99219. */
  99220. export class TransformBlock extends NodeMaterialBlock {
  99221. /**
  99222. * Defines the value to use to complement W value to transform it to a Vector4
  99223. */
  99224. complementW: number;
  99225. /**
  99226. * Defines the value to use to complement z value to transform it to a Vector4
  99227. */
  99228. complementZ: number;
  99229. /**
  99230. * Creates a new TransformBlock
  99231. * @param name defines the block name
  99232. */
  99233. constructor(name: string);
  99234. /**
  99235. * Gets the current class name
  99236. * @returns the class name
  99237. */
  99238. getClassName(): string;
  99239. /**
  99240. * Gets the vector input
  99241. */
  99242. get vector(): NodeMaterialConnectionPoint;
  99243. /**
  99244. * Gets the output component
  99245. */
  99246. get output(): NodeMaterialConnectionPoint;
  99247. /**
  99248. * Gets the xyz output component
  99249. */
  99250. get xyz(): NodeMaterialConnectionPoint;
  99251. /**
  99252. * Gets the matrix transform input
  99253. */
  99254. get transform(): NodeMaterialConnectionPoint;
  99255. protected _buildBlock(state: NodeMaterialBuildState): this;
  99256. /**
  99257. * Update defines for shader compilation
  99258. * @param mesh defines the mesh to be rendered
  99259. * @param nodeMaterial defines the node material requesting the update
  99260. * @param defines defines the material defines to update
  99261. * @param useInstances specifies that instances should be used
  99262. * @param subMesh defines which submesh to render
  99263. */
  99264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99265. serialize(): any;
  99266. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99267. protected _dumpPropertiesCode(): string;
  99268. }
  99269. }
  99270. declare module BABYLON {
  99271. /**
  99272. * Block used to output the vertex position
  99273. */
  99274. export class VertexOutputBlock extends NodeMaterialBlock {
  99275. /**
  99276. * Creates a new VertexOutputBlock
  99277. * @param name defines the block name
  99278. */
  99279. constructor(name: string);
  99280. /**
  99281. * Gets the current class name
  99282. * @returns the class name
  99283. */
  99284. getClassName(): string;
  99285. /**
  99286. * Gets the vector input component
  99287. */
  99288. get vector(): NodeMaterialConnectionPoint;
  99289. protected _buildBlock(state: NodeMaterialBuildState): this;
  99290. }
  99291. }
  99292. declare module BABYLON {
  99293. /**
  99294. * Block used to output the final color
  99295. */
  99296. export class FragmentOutputBlock extends NodeMaterialBlock {
  99297. /**
  99298. * Create a new FragmentOutputBlock
  99299. * @param name defines the block name
  99300. */
  99301. constructor(name: string);
  99302. /**
  99303. * Gets the current class name
  99304. * @returns the class name
  99305. */
  99306. getClassName(): string;
  99307. /**
  99308. * Gets the rgba input component
  99309. */
  99310. get rgba(): NodeMaterialConnectionPoint;
  99311. /**
  99312. * Gets the rgb input component
  99313. */
  99314. get rgb(): NodeMaterialConnectionPoint;
  99315. /**
  99316. * Gets the a input component
  99317. */
  99318. get a(): NodeMaterialConnectionPoint;
  99319. protected _buildBlock(state: NodeMaterialBuildState): this;
  99320. }
  99321. }
  99322. declare module BABYLON {
  99323. /**
  99324. * Block used for the particle ramp gradient section
  99325. */
  99326. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  99327. /**
  99328. * Create a new ParticleRampGradientBlock
  99329. * @param name defines the block name
  99330. */
  99331. constructor(name: string);
  99332. /**
  99333. * Gets the current class name
  99334. * @returns the class name
  99335. */
  99336. getClassName(): string;
  99337. /**
  99338. * Gets the color input component
  99339. */
  99340. get color(): NodeMaterialConnectionPoint;
  99341. /**
  99342. * Gets the rampColor output component
  99343. */
  99344. get rampColor(): NodeMaterialConnectionPoint;
  99345. /**
  99346. * Initialize the block and prepare the context for build
  99347. * @param state defines the state that will be used for the build
  99348. */
  99349. initialize(state: NodeMaterialBuildState): void;
  99350. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99351. }
  99352. }
  99353. declare module BABYLON {
  99354. /**
  99355. * Block used for the particle blend multiply section
  99356. */
  99357. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  99358. /**
  99359. * Create a new ParticleBlendMultiplyBlock
  99360. * @param name defines the block name
  99361. */
  99362. constructor(name: string);
  99363. /**
  99364. * Gets the current class name
  99365. * @returns the class name
  99366. */
  99367. getClassName(): string;
  99368. /**
  99369. * Gets the color input component
  99370. */
  99371. get color(): NodeMaterialConnectionPoint;
  99372. /**
  99373. * Gets the alphaTexture input component
  99374. */
  99375. get alphaTexture(): NodeMaterialConnectionPoint;
  99376. /**
  99377. * Gets the alphaColor input component
  99378. */
  99379. get alphaColor(): NodeMaterialConnectionPoint;
  99380. /**
  99381. * Gets the blendColor output component
  99382. */
  99383. get blendColor(): NodeMaterialConnectionPoint;
  99384. /**
  99385. * Initialize the block and prepare the context for build
  99386. * @param state defines the state that will be used for the build
  99387. */
  99388. initialize(state: NodeMaterialBuildState): void;
  99389. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99390. }
  99391. }
  99392. declare module BABYLON {
  99393. /**
  99394. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  99395. */
  99396. export class VectorMergerBlock extends NodeMaterialBlock {
  99397. /**
  99398. * Create a new VectorMergerBlock
  99399. * @param name defines the block name
  99400. */
  99401. constructor(name: string);
  99402. /**
  99403. * Gets the current class name
  99404. * @returns the class name
  99405. */
  99406. getClassName(): string;
  99407. /**
  99408. * Gets the xyz component (input)
  99409. */
  99410. get xyzIn(): NodeMaterialConnectionPoint;
  99411. /**
  99412. * Gets the xy component (input)
  99413. */
  99414. get xyIn(): NodeMaterialConnectionPoint;
  99415. /**
  99416. * Gets the x component (input)
  99417. */
  99418. get x(): NodeMaterialConnectionPoint;
  99419. /**
  99420. * Gets the y component (input)
  99421. */
  99422. get y(): NodeMaterialConnectionPoint;
  99423. /**
  99424. * Gets the z component (input)
  99425. */
  99426. get z(): NodeMaterialConnectionPoint;
  99427. /**
  99428. * Gets the w component (input)
  99429. */
  99430. get w(): NodeMaterialConnectionPoint;
  99431. /**
  99432. * Gets the xyzw component (output)
  99433. */
  99434. get xyzw(): NodeMaterialConnectionPoint;
  99435. /**
  99436. * Gets the xyz component (output)
  99437. */
  99438. get xyzOut(): NodeMaterialConnectionPoint;
  99439. /**
  99440. * Gets the xy component (output)
  99441. */
  99442. get xyOut(): NodeMaterialConnectionPoint;
  99443. /**
  99444. * Gets the xy component (output)
  99445. * @deprecated Please use xyOut instead.
  99446. */
  99447. get xy(): NodeMaterialConnectionPoint;
  99448. /**
  99449. * Gets the xyz component (output)
  99450. * @deprecated Please use xyzOut instead.
  99451. */
  99452. get xyz(): NodeMaterialConnectionPoint;
  99453. protected _buildBlock(state: NodeMaterialBuildState): this;
  99454. }
  99455. }
  99456. declare module BABYLON {
  99457. /**
  99458. * Block used to remap a float from a range to a new one
  99459. */
  99460. export class RemapBlock extends NodeMaterialBlock {
  99461. /**
  99462. * Gets or sets the source range
  99463. */
  99464. sourceRange: Vector2;
  99465. /**
  99466. * Gets or sets the target range
  99467. */
  99468. targetRange: Vector2;
  99469. /**
  99470. * Creates a new RemapBlock
  99471. * @param name defines the block name
  99472. */
  99473. constructor(name: string);
  99474. /**
  99475. * Gets the current class name
  99476. * @returns the class name
  99477. */
  99478. getClassName(): string;
  99479. /**
  99480. * Gets the input component
  99481. */
  99482. get input(): NodeMaterialConnectionPoint;
  99483. /**
  99484. * Gets the source min input component
  99485. */
  99486. get sourceMin(): NodeMaterialConnectionPoint;
  99487. /**
  99488. * Gets the source max input component
  99489. */
  99490. get sourceMax(): NodeMaterialConnectionPoint;
  99491. /**
  99492. * Gets the target min input component
  99493. */
  99494. get targetMin(): NodeMaterialConnectionPoint;
  99495. /**
  99496. * Gets the target max input component
  99497. */
  99498. get targetMax(): NodeMaterialConnectionPoint;
  99499. /**
  99500. * Gets the output component
  99501. */
  99502. get output(): NodeMaterialConnectionPoint;
  99503. protected _buildBlock(state: NodeMaterialBuildState): this;
  99504. protected _dumpPropertiesCode(): string;
  99505. serialize(): any;
  99506. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99507. }
  99508. }
  99509. declare module BABYLON {
  99510. /**
  99511. * Block used to multiply 2 values
  99512. */
  99513. export class MultiplyBlock extends NodeMaterialBlock {
  99514. /**
  99515. * Creates a new MultiplyBlock
  99516. * @param name defines the block name
  99517. */
  99518. constructor(name: string);
  99519. /**
  99520. * Gets the current class name
  99521. * @returns the class name
  99522. */
  99523. getClassName(): string;
  99524. /**
  99525. * Gets the left operand input component
  99526. */
  99527. get left(): NodeMaterialConnectionPoint;
  99528. /**
  99529. * Gets the right operand input component
  99530. */
  99531. get right(): NodeMaterialConnectionPoint;
  99532. /**
  99533. * Gets the output component
  99534. */
  99535. get output(): NodeMaterialConnectionPoint;
  99536. protected _buildBlock(state: NodeMaterialBuildState): this;
  99537. }
  99538. }
  99539. declare module BABYLON {
  99540. /**
  99541. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  99542. */
  99543. export class ColorSplitterBlock extends NodeMaterialBlock {
  99544. /**
  99545. * Create a new ColorSplitterBlock
  99546. * @param name defines the block name
  99547. */
  99548. constructor(name: string);
  99549. /**
  99550. * Gets the current class name
  99551. * @returns the class name
  99552. */
  99553. getClassName(): string;
  99554. /**
  99555. * Gets the rgba component (input)
  99556. */
  99557. get rgba(): NodeMaterialConnectionPoint;
  99558. /**
  99559. * Gets the rgb component (input)
  99560. */
  99561. get rgbIn(): NodeMaterialConnectionPoint;
  99562. /**
  99563. * Gets the rgb component (output)
  99564. */
  99565. get rgbOut(): NodeMaterialConnectionPoint;
  99566. /**
  99567. * Gets the r component (output)
  99568. */
  99569. get r(): NodeMaterialConnectionPoint;
  99570. /**
  99571. * Gets the g component (output)
  99572. */
  99573. get g(): NodeMaterialConnectionPoint;
  99574. /**
  99575. * Gets the b component (output)
  99576. */
  99577. get b(): NodeMaterialConnectionPoint;
  99578. /**
  99579. * Gets the a component (output)
  99580. */
  99581. get a(): NodeMaterialConnectionPoint;
  99582. protected _inputRename(name: string): string;
  99583. protected _outputRename(name: string): string;
  99584. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99585. }
  99586. }
  99587. declare module BABYLON {
  99588. /**
  99589. * Interface used to configure the node material editor
  99590. */
  99591. export interface INodeMaterialEditorOptions {
  99592. /** Define the URl to load node editor script */
  99593. editorURL?: string;
  99594. }
  99595. /** @hidden */
  99596. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99597. NORMAL: boolean;
  99598. TANGENT: boolean;
  99599. UV1: boolean;
  99600. /** BONES */
  99601. NUM_BONE_INFLUENCERS: number;
  99602. BonesPerMesh: number;
  99603. BONETEXTURE: boolean;
  99604. /** MORPH TARGETS */
  99605. MORPHTARGETS: boolean;
  99606. MORPHTARGETS_NORMAL: boolean;
  99607. MORPHTARGETS_TANGENT: boolean;
  99608. MORPHTARGETS_UV: boolean;
  99609. NUM_MORPH_INFLUENCERS: number;
  99610. /** IMAGE PROCESSING */
  99611. IMAGEPROCESSING: boolean;
  99612. VIGNETTE: boolean;
  99613. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99614. VIGNETTEBLENDMODEOPAQUE: boolean;
  99615. TONEMAPPING: boolean;
  99616. TONEMAPPING_ACES: boolean;
  99617. CONTRAST: boolean;
  99618. EXPOSURE: boolean;
  99619. COLORCURVES: boolean;
  99620. COLORGRADING: boolean;
  99621. COLORGRADING3D: boolean;
  99622. SAMPLER3DGREENDEPTH: boolean;
  99623. SAMPLER3DBGRMAP: boolean;
  99624. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99625. /** MISC. */
  99626. BUMPDIRECTUV: number;
  99627. constructor();
  99628. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  99629. }
  99630. /**
  99631. * Class used to configure NodeMaterial
  99632. */
  99633. export interface INodeMaterialOptions {
  99634. /**
  99635. * Defines if blocks should emit comments
  99636. */
  99637. emitComments: boolean;
  99638. }
  99639. /**
  99640. * Class used to create a node based material built by assembling shader blocks
  99641. */
  99642. export class NodeMaterial extends PushMaterial {
  99643. private static _BuildIdGenerator;
  99644. private _options;
  99645. private _vertexCompilationState;
  99646. private _fragmentCompilationState;
  99647. private _sharedData;
  99648. private _buildId;
  99649. private _buildWasSuccessful;
  99650. private _cachedWorldViewMatrix;
  99651. private _cachedWorldViewProjectionMatrix;
  99652. private _optimizers;
  99653. private _animationFrame;
  99654. /** Define the Url to load node editor script */
  99655. static EditorURL: string;
  99656. /** Define the Url to load snippets */
  99657. static SnippetUrl: string;
  99658. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  99659. static IgnoreTexturesAtLoadTime: boolean;
  99660. private BJSNODEMATERIALEDITOR;
  99661. /** Get the inspector from bundle or global */
  99662. private _getGlobalNodeMaterialEditor;
  99663. /**
  99664. * Snippet ID if the material was created from the snippet server
  99665. */
  99666. snippetId: string;
  99667. /**
  99668. * Gets or sets data used by visual editor
  99669. * @see https://nme.babylonjs.com
  99670. */
  99671. editorData: any;
  99672. /**
  99673. * 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)
  99674. */
  99675. ignoreAlpha: boolean;
  99676. /**
  99677. * Defines the maximum number of lights that can be used in the material
  99678. */
  99679. maxSimultaneousLights: number;
  99680. /**
  99681. * Observable raised when the material is built
  99682. */
  99683. onBuildObservable: Observable<NodeMaterial>;
  99684. /**
  99685. * Gets or sets the root nodes of the material vertex shader
  99686. */
  99687. _vertexOutputNodes: NodeMaterialBlock[];
  99688. /**
  99689. * Gets or sets the root nodes of the material fragment (pixel) shader
  99690. */
  99691. _fragmentOutputNodes: NodeMaterialBlock[];
  99692. /** Gets or sets options to control the node material overall behavior */
  99693. get options(): INodeMaterialOptions;
  99694. set options(options: INodeMaterialOptions);
  99695. /**
  99696. * Default configuration related to image processing available in the standard Material.
  99697. */
  99698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99699. /**
  99700. * Gets the image processing configuration used either in this material.
  99701. */
  99702. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99703. /**
  99704. * Sets the Default image processing configuration used either in the this material.
  99705. *
  99706. * If sets to null, the scene one is in use.
  99707. */
  99708. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99709. /**
  99710. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  99711. */
  99712. attachedBlocks: NodeMaterialBlock[];
  99713. /**
  99714. * Specifies the mode of the node material
  99715. * @hidden
  99716. */
  99717. _mode: NodeMaterialModes;
  99718. /**
  99719. * Gets the mode property
  99720. */
  99721. get mode(): NodeMaterialModes;
  99722. /**
  99723. * Create a new node based material
  99724. * @param name defines the material name
  99725. * @param scene defines the hosting scene
  99726. * @param options defines creation option
  99727. */
  99728. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  99729. /**
  99730. * Gets the current class name of the material e.g. "NodeMaterial"
  99731. * @returns the class name
  99732. */
  99733. getClassName(): string;
  99734. /**
  99735. * Keep track of the image processing observer to allow dispose and replace.
  99736. */
  99737. private _imageProcessingObserver;
  99738. /**
  99739. * Attaches a new image processing configuration to the Standard Material.
  99740. * @param configuration
  99741. */
  99742. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99743. /**
  99744. * Get a block by its name
  99745. * @param name defines the name of the block to retrieve
  99746. * @returns the required block or null if not found
  99747. */
  99748. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  99749. /**
  99750. * Get a block by its name
  99751. * @param predicate defines the predicate used to find the good candidate
  99752. * @returns the required block or null if not found
  99753. */
  99754. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  99755. /**
  99756. * Get an input block by its name
  99757. * @param predicate defines the predicate used to find the good candidate
  99758. * @returns the required input block or null if not found
  99759. */
  99760. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  99761. /**
  99762. * Gets the list of input blocks attached to this material
  99763. * @returns an array of InputBlocks
  99764. */
  99765. getInputBlocks(): InputBlock[];
  99766. /**
  99767. * Adds a new optimizer to the list of optimizers
  99768. * @param optimizer defines the optimizers to add
  99769. * @returns the current material
  99770. */
  99771. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99772. /**
  99773. * Remove an optimizer from the list of optimizers
  99774. * @param optimizer defines the optimizers to remove
  99775. * @returns the current material
  99776. */
  99777. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99778. /**
  99779. * Add a new block to the list of output nodes
  99780. * @param node defines the node to add
  99781. * @returns the current material
  99782. */
  99783. addOutputNode(node: NodeMaterialBlock): this;
  99784. /**
  99785. * Remove a block from the list of root nodes
  99786. * @param node defines the node to remove
  99787. * @returns the current material
  99788. */
  99789. removeOutputNode(node: NodeMaterialBlock): this;
  99790. private _addVertexOutputNode;
  99791. private _removeVertexOutputNode;
  99792. private _addFragmentOutputNode;
  99793. private _removeFragmentOutputNode;
  99794. /**
  99795. * Specifies if the material will require alpha blending
  99796. * @returns a boolean specifying if alpha blending is needed
  99797. */
  99798. needAlphaBlending(): boolean;
  99799. /**
  99800. * Specifies if this material should be rendered in alpha test mode
  99801. * @returns a boolean specifying if an alpha test is needed.
  99802. */
  99803. needAlphaTesting(): boolean;
  99804. private _initializeBlock;
  99805. private _resetDualBlocks;
  99806. /**
  99807. * Remove a block from the current node material
  99808. * @param block defines the block to remove
  99809. */
  99810. removeBlock(block: NodeMaterialBlock): void;
  99811. /**
  99812. * Build the material and generates the inner effect
  99813. * @param verbose defines if the build should log activity
  99814. */
  99815. build(verbose?: boolean): void;
  99816. /**
  99817. * Runs an otpimization phase to try to improve the shader code
  99818. */
  99819. optimize(): void;
  99820. private _prepareDefinesForAttributes;
  99821. /**
  99822. * Create a post process from the material
  99823. * @param camera The camera to apply the render pass to.
  99824. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99825. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99826. * @param engine The engine which the post process will be applied. (default: current engine)
  99827. * @param reusable If the post process can be reused on the same frame. (default: false)
  99828. * @param textureType Type of textures used when performing the post process. (default: 0)
  99829. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99830. * @returns the post process created
  99831. */
  99832. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  99833. /**
  99834. * Create the post process effect from the material
  99835. * @param postProcess The post process to create the effect for
  99836. */
  99837. createEffectForPostProcess(postProcess: PostProcess): void;
  99838. private _createEffectOrPostProcess;
  99839. private _createEffectForParticles;
  99840. /**
  99841. * Create the effect to be used as the custom effect for a particle system
  99842. * @param particleSystem Particle system to create the effect for
  99843. * @param onCompiled defines a function to call when the effect creation is successful
  99844. * @param onError defines a function to call when the effect creation has failed
  99845. */
  99846. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99847. private _processDefines;
  99848. /**
  99849. * Get if the submesh is ready to be used and all its information available.
  99850. * Child classes can use it to update shaders
  99851. * @param mesh defines the mesh to check
  99852. * @param subMesh defines which submesh to check
  99853. * @param useInstances specifies that instances should be used
  99854. * @returns a boolean indicating that the submesh is ready or not
  99855. */
  99856. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99857. /**
  99858. * Get a string representing the shaders built by the current node graph
  99859. */
  99860. get compiledShaders(): string;
  99861. /**
  99862. * Binds the world matrix to the material
  99863. * @param world defines the world transformation matrix
  99864. */
  99865. bindOnlyWorldMatrix(world: Matrix): void;
  99866. /**
  99867. * Binds the submesh to this material by preparing the effect and shader to draw
  99868. * @param world defines the world transformation matrix
  99869. * @param mesh defines the mesh containing the submesh
  99870. * @param subMesh defines the submesh to bind the material to
  99871. */
  99872. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99873. /**
  99874. * Gets the active textures from the material
  99875. * @returns an array of textures
  99876. */
  99877. getActiveTextures(): BaseTexture[];
  99878. /**
  99879. * Gets the list of texture blocks
  99880. * @returns an array of texture blocks
  99881. */
  99882. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99883. /**
  99884. * Specifies if the material uses a texture
  99885. * @param texture defines the texture to check against the material
  99886. * @returns a boolean specifying if the material uses the texture
  99887. */
  99888. hasTexture(texture: BaseTexture): boolean;
  99889. /**
  99890. * Disposes the material
  99891. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99892. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99893. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99894. */
  99895. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99896. /** Creates the node editor window. */
  99897. private _createNodeEditor;
  99898. /**
  99899. * Launch the node material editor
  99900. * @param config Define the configuration of the editor
  99901. * @return a promise fulfilled when the node editor is visible
  99902. */
  99903. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99904. /**
  99905. * Clear the current material
  99906. */
  99907. clear(): void;
  99908. /**
  99909. * Clear the current material and set it to a default state
  99910. */
  99911. setToDefault(): void;
  99912. /**
  99913. * Clear the current material and set it to a default state for post process
  99914. */
  99915. setToDefaultPostProcess(): void;
  99916. /**
  99917. * Clear the current material and set it to a default state for particle
  99918. */
  99919. setToDefaultParticle(): void;
  99920. /**
  99921. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99922. * @param url defines the url to load from
  99923. * @returns a promise that will fullfil when the material is fully loaded
  99924. */
  99925. loadAsync(url: string): Promise<void>;
  99926. private _gatherBlocks;
  99927. /**
  99928. * Generate a string containing the code declaration required to create an equivalent of this material
  99929. * @returns a string
  99930. */
  99931. generateCode(): string;
  99932. /**
  99933. * Serializes this material in a JSON representation
  99934. * @returns the serialized material object
  99935. */
  99936. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99937. private _restoreConnections;
  99938. /**
  99939. * Clear the current graph and load a new one from a serialization object
  99940. * @param source defines the JSON representation of the material
  99941. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99942. * @param merge defines whether or not the source must be merged or replace the current content
  99943. */
  99944. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  99945. /**
  99946. * Makes a duplicate of the current material.
  99947. * @param name - name to use for the new material.
  99948. */
  99949. clone(name: string): NodeMaterial;
  99950. /**
  99951. * Creates a node material from parsed material data
  99952. * @param source defines the JSON representation of the material
  99953. * @param scene defines the hosting scene
  99954. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99955. * @returns a new node material
  99956. */
  99957. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99958. /**
  99959. * Creates a node material from a snippet saved in a remote file
  99960. * @param name defines the name of the material to create
  99961. * @param url defines the url to load from
  99962. * @param scene defines the hosting scene
  99963. * @returns a promise that will resolve to the new node material
  99964. */
  99965. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99966. /**
  99967. * Creates a node material from a snippet saved by the node material editor
  99968. * @param snippetId defines the snippet to load
  99969. * @param scene defines the hosting scene
  99970. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99971. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99972. * @returns a promise that will resolve to the new node material
  99973. */
  99974. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99975. /**
  99976. * Creates a new node material set to default basic configuration
  99977. * @param name defines the name of the material
  99978. * @param scene defines the hosting scene
  99979. * @returns a new NodeMaterial
  99980. */
  99981. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99982. }
  99983. }
  99984. declare module BABYLON {
  99985. /**
  99986. * Size options for a post process
  99987. */
  99988. export type PostProcessOptions = {
  99989. width: number;
  99990. height: number;
  99991. };
  99992. /**
  99993. * PostProcess can be used to apply a shader to a texture after it has been rendered
  99994. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  99995. */
  99996. export class PostProcess {
  99997. /** Name of the PostProcess. */
  99998. name: string;
  99999. /**
  100000. * Gets or sets the unique id of the post process
  100001. */
  100002. uniqueId: number;
  100003. /**
  100004. * Width of the texture to apply the post process on
  100005. */
  100006. width: number;
  100007. /**
  100008. * Height of the texture to apply the post process on
  100009. */
  100010. height: number;
  100011. /**
  100012. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100013. */
  100014. nodeMaterialSource: Nullable<NodeMaterial>;
  100015. /**
  100016. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100017. * @hidden
  100018. */
  100019. _outputTexture: Nullable<InternalTexture>;
  100020. /**
  100021. * Sampling mode used by the shader
  100022. * See https://doc.babylonjs.com/classes/3.1/texture
  100023. */
  100024. renderTargetSamplingMode: number;
  100025. /**
  100026. * Clear color to use when screen clearing
  100027. */
  100028. clearColor: Color4;
  100029. /**
  100030. * If the buffer needs to be cleared before applying the post process. (default: true)
  100031. * Should be set to false if shader will overwrite all previous pixels.
  100032. */
  100033. autoClear: boolean;
  100034. /**
  100035. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100036. */
  100037. alphaMode: number;
  100038. /**
  100039. * Sets the setAlphaBlendConstants of the babylon engine
  100040. */
  100041. alphaConstants: Color4;
  100042. /**
  100043. * Animations to be used for the post processing
  100044. */
  100045. animations: Animation[];
  100046. /**
  100047. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100048. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100049. */
  100050. enablePixelPerfectMode: boolean;
  100051. /**
  100052. * Force the postprocess to be applied without taking in account viewport
  100053. */
  100054. forceFullscreenViewport: boolean;
  100055. /**
  100056. * List of inspectable custom properties (used by the Inspector)
  100057. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100058. */
  100059. inspectableCustomProperties: IInspectable[];
  100060. /**
  100061. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100062. *
  100063. * | Value | Type | Description |
  100064. * | ----- | ----------------------------------- | ----------- |
  100065. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100066. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100067. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100068. *
  100069. */
  100070. scaleMode: number;
  100071. /**
  100072. * Force textures to be a power of two (default: false)
  100073. */
  100074. alwaysForcePOT: boolean;
  100075. private _samples;
  100076. /**
  100077. * Number of sample textures (default: 1)
  100078. */
  100079. get samples(): number;
  100080. set samples(n: number);
  100081. /**
  100082. * Modify the scale of the post process to be the same as the viewport (default: false)
  100083. */
  100084. adaptScaleToCurrentViewport: boolean;
  100085. private _camera;
  100086. private _scene;
  100087. private _engine;
  100088. private _options;
  100089. private _reusable;
  100090. private _textureType;
  100091. private _textureFormat;
  100092. /**
  100093. * Smart array of input and output textures for the post process.
  100094. * @hidden
  100095. */
  100096. _textures: SmartArray<InternalTexture>;
  100097. /**
  100098. * The index in _textures that corresponds to the output texture.
  100099. * @hidden
  100100. */
  100101. _currentRenderTextureInd: number;
  100102. private _effect;
  100103. private _samplers;
  100104. private _fragmentUrl;
  100105. private _vertexUrl;
  100106. private _parameters;
  100107. private _scaleRatio;
  100108. protected _indexParameters: any;
  100109. private _shareOutputWithPostProcess;
  100110. private _texelSize;
  100111. private _forcedOutputTexture;
  100112. /**
  100113. * Returns the fragment url or shader name used in the post process.
  100114. * @returns the fragment url or name in the shader store.
  100115. */
  100116. getEffectName(): string;
  100117. /**
  100118. * An event triggered when the postprocess is activated.
  100119. */
  100120. onActivateObservable: Observable<Camera>;
  100121. private _onActivateObserver;
  100122. /**
  100123. * A function that is added to the onActivateObservable
  100124. */
  100125. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100126. /**
  100127. * An event triggered when the postprocess changes its size.
  100128. */
  100129. onSizeChangedObservable: Observable<PostProcess>;
  100130. private _onSizeChangedObserver;
  100131. /**
  100132. * A function that is added to the onSizeChangedObservable
  100133. */
  100134. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100135. /**
  100136. * An event triggered when the postprocess applies its effect.
  100137. */
  100138. onApplyObservable: Observable<Effect>;
  100139. private _onApplyObserver;
  100140. /**
  100141. * A function that is added to the onApplyObservable
  100142. */
  100143. set onApply(callback: (effect: Effect) => void);
  100144. /**
  100145. * An event triggered before rendering the postprocess
  100146. */
  100147. onBeforeRenderObservable: Observable<Effect>;
  100148. private _onBeforeRenderObserver;
  100149. /**
  100150. * A function that is added to the onBeforeRenderObservable
  100151. */
  100152. set onBeforeRender(callback: (effect: Effect) => void);
  100153. /**
  100154. * An event triggered after rendering the postprocess
  100155. */
  100156. onAfterRenderObservable: Observable<Effect>;
  100157. private _onAfterRenderObserver;
  100158. /**
  100159. * A function that is added to the onAfterRenderObservable
  100160. */
  100161. set onAfterRender(callback: (efect: Effect) => void);
  100162. /**
  100163. * 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
  100164. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100165. */
  100166. get inputTexture(): InternalTexture;
  100167. set inputTexture(value: InternalTexture);
  100168. /**
  100169. * Gets the camera which post process is applied to.
  100170. * @returns The camera the post process is applied to.
  100171. */
  100172. getCamera(): Camera;
  100173. /**
  100174. * Gets the texel size of the postprocess.
  100175. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100176. */
  100177. get texelSize(): Vector2;
  100178. /**
  100179. * Creates a new instance PostProcess
  100180. * @param name The name of the PostProcess.
  100181. * @param fragmentUrl The url of the fragment shader to be used.
  100182. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100183. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100184. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100185. * @param camera The camera to apply the render pass to.
  100186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100187. * @param engine The engine which the post process will be applied. (default: current engine)
  100188. * @param reusable If the post process can be reused on the same frame. (default: false)
  100189. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100190. * @param textureType Type of textures used when performing the post process. (default: 0)
  100191. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100192. * @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
  100193. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100194. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100195. */
  100196. constructor(
  100197. /** Name of the PostProcess. */
  100198. 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);
  100199. /**
  100200. * Gets a string idenfifying the name of the class
  100201. * @returns "PostProcess" string
  100202. */
  100203. getClassName(): string;
  100204. /**
  100205. * Gets the engine which this post process belongs to.
  100206. * @returns The engine the post process was enabled with.
  100207. */
  100208. getEngine(): Engine;
  100209. /**
  100210. * The effect that is created when initializing the post process.
  100211. * @returns The created effect corresponding the the postprocess.
  100212. */
  100213. getEffect(): Effect;
  100214. /**
  100215. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100216. * @param postProcess The post process to share the output with.
  100217. * @returns This post process.
  100218. */
  100219. shareOutputWith(postProcess: PostProcess): PostProcess;
  100220. /**
  100221. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100222. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100223. */
  100224. useOwnOutput(): void;
  100225. /**
  100226. * Updates the effect with the current post process compile time values and recompiles the shader.
  100227. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100228. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100229. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100230. * @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
  100231. * @param onCompiled Called when the shader has been compiled.
  100232. * @param onError Called if there is an error when compiling a shader.
  100233. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100234. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100235. */
  100236. 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;
  100237. /**
  100238. * The post process is reusable if it can be used multiple times within one frame.
  100239. * @returns If the post process is reusable
  100240. */
  100241. isReusable(): boolean;
  100242. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100243. markTextureDirty(): void;
  100244. /**
  100245. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100246. * 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.
  100247. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100248. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100249. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100250. * @returns The target texture that was bound to be written to.
  100251. */
  100252. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100253. /**
  100254. * If the post process is supported.
  100255. */
  100256. get isSupported(): boolean;
  100257. /**
  100258. * The aspect ratio of the output texture.
  100259. */
  100260. get aspectRatio(): number;
  100261. /**
  100262. * Get a value indicating if the post-process is ready to be used
  100263. * @returns true if the post-process is ready (shader is compiled)
  100264. */
  100265. isReady(): boolean;
  100266. /**
  100267. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100268. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100269. */
  100270. apply(): Nullable<Effect>;
  100271. private _disposeTextures;
  100272. /**
  100273. * Disposes the post process.
  100274. * @param camera The camera to dispose the post process on.
  100275. */
  100276. dispose(camera?: Camera): void;
  100277. }
  100278. }
  100279. declare module BABYLON {
  100280. /** @hidden */
  100281. export var kernelBlurVaryingDeclaration: {
  100282. name: string;
  100283. shader: string;
  100284. };
  100285. }
  100286. declare module BABYLON {
  100287. /** @hidden */
  100288. export var kernelBlurFragment: {
  100289. name: string;
  100290. shader: string;
  100291. };
  100292. }
  100293. declare module BABYLON {
  100294. /** @hidden */
  100295. export var kernelBlurFragment2: {
  100296. name: string;
  100297. shader: string;
  100298. };
  100299. }
  100300. declare module BABYLON {
  100301. /** @hidden */
  100302. export var kernelBlurPixelShader: {
  100303. name: string;
  100304. shader: string;
  100305. };
  100306. }
  100307. declare module BABYLON {
  100308. /** @hidden */
  100309. export var kernelBlurVertex: {
  100310. name: string;
  100311. shader: string;
  100312. };
  100313. }
  100314. declare module BABYLON {
  100315. /** @hidden */
  100316. export var kernelBlurVertexShader: {
  100317. name: string;
  100318. shader: string;
  100319. };
  100320. }
  100321. declare module BABYLON {
  100322. /**
  100323. * The Blur Post Process which blurs an image based on a kernel and direction.
  100324. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  100325. */
  100326. export class BlurPostProcess extends PostProcess {
  100327. /** The direction in which to blur the image. */
  100328. direction: Vector2;
  100329. private blockCompilation;
  100330. protected _kernel: number;
  100331. protected _idealKernel: number;
  100332. protected _packedFloat: boolean;
  100333. private _staticDefines;
  100334. /**
  100335. * Sets the length in pixels of the blur sample region
  100336. */
  100337. set kernel(v: number);
  100338. /**
  100339. * Gets the length in pixels of the blur sample region
  100340. */
  100341. get kernel(): number;
  100342. /**
  100343. * Sets wether or not the blur needs to unpack/repack floats
  100344. */
  100345. set packedFloat(v: boolean);
  100346. /**
  100347. * Gets wether or not the blur is unpacking/repacking floats
  100348. */
  100349. get packedFloat(): boolean;
  100350. /**
  100351. * Creates a new instance BlurPostProcess
  100352. * @param name The name of the effect.
  100353. * @param direction The direction in which to blur the image.
  100354. * @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.
  100355. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100356. * @param camera The camera to apply the render pass to.
  100357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100358. * @param engine The engine which the post process will be applied. (default: current engine)
  100359. * @param reusable If the post process can be reused on the same frame. (default: false)
  100360. * @param textureType Type of textures used when performing the post process. (default: 0)
  100361. * @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)
  100362. */
  100363. constructor(name: string,
  100364. /** The direction in which to blur the image. */
  100365. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  100366. /**
  100367. * Updates the effect with the current post process compile time values and recompiles the shader.
  100368. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100369. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100370. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100371. * @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
  100372. * @param onCompiled Called when the shader has been compiled.
  100373. * @param onError Called if there is an error when compiling a shader.
  100374. */
  100375. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100376. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100377. /**
  100378. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  100379. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  100380. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  100381. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  100382. * The gaps between physical kernels are compensated for in the weighting of the samples
  100383. * @param idealKernel Ideal blur kernel.
  100384. * @return Nearest best kernel.
  100385. */
  100386. protected _nearestBestKernel(idealKernel: number): number;
  100387. /**
  100388. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  100389. * @param x The point on the Gaussian distribution to sample.
  100390. * @return the value of the Gaussian function at x.
  100391. */
  100392. protected _gaussianWeight(x: number): number;
  100393. /**
  100394. * Generates a string that can be used as a floating point number in GLSL.
  100395. * @param x Value to print.
  100396. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  100397. * @return GLSL float string.
  100398. */
  100399. protected _glslFloat(x: number, decimalFigures?: number): string;
  100400. }
  100401. }
  100402. declare module BABYLON {
  100403. /**
  100404. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100405. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100406. * You can then easily use it as a reflectionTexture on a flat surface.
  100407. * In case the surface is not a plane, please consider relying on reflection probes.
  100408. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100409. */
  100410. export class MirrorTexture extends RenderTargetTexture {
  100411. private scene;
  100412. /**
  100413. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  100414. * 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.
  100415. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100416. */
  100417. mirrorPlane: Plane;
  100418. /**
  100419. * Define the blur ratio used to blur the reflection if needed.
  100420. */
  100421. set blurRatio(value: number);
  100422. get blurRatio(): number;
  100423. /**
  100424. * Define the adaptive blur kernel used to blur the reflection if needed.
  100425. * This will autocompute the closest best match for the `blurKernel`
  100426. */
  100427. set adaptiveBlurKernel(value: number);
  100428. /**
  100429. * Define the blur kernel used to blur the reflection if needed.
  100430. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100431. */
  100432. set blurKernel(value: number);
  100433. /**
  100434. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  100435. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100436. */
  100437. set blurKernelX(value: number);
  100438. get blurKernelX(): number;
  100439. /**
  100440. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  100441. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  100442. */
  100443. set blurKernelY(value: number);
  100444. get blurKernelY(): number;
  100445. private _autoComputeBlurKernel;
  100446. protected _onRatioRescale(): void;
  100447. private _updateGammaSpace;
  100448. private _imageProcessingConfigChangeObserver;
  100449. private _transformMatrix;
  100450. private _mirrorMatrix;
  100451. private _savedViewMatrix;
  100452. private _blurX;
  100453. private _blurY;
  100454. private _adaptiveBlurKernel;
  100455. private _blurKernelX;
  100456. private _blurKernelY;
  100457. private _blurRatio;
  100458. /**
  100459. * Instantiates a Mirror Texture.
  100460. * Mirror texture can be used to simulate the view from a mirror in a scene.
  100461. * It will dynamically be rendered every frame to adapt to the camera point of view.
  100462. * You can then easily use it as a reflectionTexture on a flat surface.
  100463. * In case the surface is not a plane, please consider relying on reflection probes.
  100464. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  100465. * @param name
  100466. * @param size
  100467. * @param scene
  100468. * @param generateMipMaps
  100469. * @param type
  100470. * @param samplingMode
  100471. * @param generateDepthBuffer
  100472. */
  100473. constructor(name: string, size: number | {
  100474. width: number;
  100475. height: number;
  100476. } | {
  100477. ratio: number;
  100478. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  100479. private _preparePostProcesses;
  100480. /**
  100481. * Clone the mirror texture.
  100482. * @returns the cloned texture
  100483. */
  100484. clone(): MirrorTexture;
  100485. /**
  100486. * Serialize the texture to a JSON representation you could use in Parse later on
  100487. * @returns the serialized JSON representation
  100488. */
  100489. serialize(): any;
  100490. /**
  100491. * Dispose the texture and release its associated resources.
  100492. */
  100493. dispose(): void;
  100494. }
  100495. }
  100496. declare module BABYLON {
  100497. /**
  100498. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100499. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100500. */
  100501. export class Texture extends BaseTexture {
  100502. /**
  100503. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  100504. */
  100505. static SerializeBuffers: boolean;
  100506. /** @hidden */
  100507. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  100508. /** @hidden */
  100509. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  100510. /** @hidden */
  100511. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  100512. /** nearest is mag = nearest and min = nearest and mip = linear */
  100513. static readonly NEAREST_SAMPLINGMODE: number;
  100514. /** nearest is mag = nearest and min = nearest and mip = linear */
  100515. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  100516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100517. static readonly BILINEAR_SAMPLINGMODE: number;
  100518. /** Bilinear is mag = linear and min = linear and mip = nearest */
  100519. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  100520. /** Trilinear is mag = linear and min = linear and mip = linear */
  100521. static readonly TRILINEAR_SAMPLINGMODE: number;
  100522. /** Trilinear is mag = linear and min = linear and mip = linear */
  100523. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  100524. /** mag = nearest and min = nearest and mip = nearest */
  100525. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  100526. /** mag = nearest and min = linear and mip = nearest */
  100527. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  100528. /** mag = nearest and min = linear and mip = linear */
  100529. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  100530. /** mag = nearest and min = linear and mip = none */
  100531. static readonly NEAREST_LINEAR: number;
  100532. /** mag = nearest and min = nearest and mip = none */
  100533. static readonly NEAREST_NEAREST: number;
  100534. /** mag = linear and min = nearest and mip = nearest */
  100535. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  100536. /** mag = linear and min = nearest and mip = linear */
  100537. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  100538. /** mag = linear and min = linear and mip = none */
  100539. static readonly LINEAR_LINEAR: number;
  100540. /** mag = linear and min = nearest and mip = none */
  100541. static readonly LINEAR_NEAREST: number;
  100542. /** Explicit coordinates mode */
  100543. static readonly EXPLICIT_MODE: number;
  100544. /** Spherical coordinates mode */
  100545. static readonly SPHERICAL_MODE: number;
  100546. /** Planar coordinates mode */
  100547. static readonly PLANAR_MODE: number;
  100548. /** Cubic coordinates mode */
  100549. static readonly CUBIC_MODE: number;
  100550. /** Projection coordinates mode */
  100551. static readonly PROJECTION_MODE: number;
  100552. /** Inverse Cubic coordinates mode */
  100553. static readonly SKYBOX_MODE: number;
  100554. /** Inverse Cubic coordinates mode */
  100555. static readonly INVCUBIC_MODE: number;
  100556. /** Equirectangular coordinates mode */
  100557. static readonly EQUIRECTANGULAR_MODE: number;
  100558. /** Equirectangular Fixed coordinates mode */
  100559. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  100560. /** Equirectangular Fixed Mirrored coordinates mode */
  100561. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  100562. /** Texture is not repeating outside of 0..1 UVs */
  100563. static readonly CLAMP_ADDRESSMODE: number;
  100564. /** Texture is repeating outside of 0..1 UVs */
  100565. static readonly WRAP_ADDRESSMODE: number;
  100566. /** Texture is repeating and mirrored */
  100567. static readonly MIRROR_ADDRESSMODE: number;
  100568. /**
  100569. * 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
  100570. */
  100571. static UseSerializedUrlIfAny: boolean;
  100572. /**
  100573. * Define the url of the texture.
  100574. */
  100575. url: Nullable<string>;
  100576. /**
  100577. * Define an offset on the texture to offset the u coordinates of the UVs
  100578. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100579. */
  100580. uOffset: number;
  100581. /**
  100582. * Define an offset on the texture to offset the v coordinates of the UVs
  100583. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  100584. */
  100585. vOffset: number;
  100586. /**
  100587. * Define an offset on the texture to scale the u coordinates of the UVs
  100588. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100589. */
  100590. uScale: number;
  100591. /**
  100592. * Define an offset on the texture to scale the v coordinates of the UVs
  100593. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  100594. */
  100595. vScale: number;
  100596. /**
  100597. * Define an offset on the texture to rotate around the u coordinates of the UVs
  100598. * @see http://doc.babylonjs.com/how_to/more_materials
  100599. */
  100600. uAng: number;
  100601. /**
  100602. * Define an offset on the texture to rotate around the v coordinates of the UVs
  100603. * @see http://doc.babylonjs.com/how_to/more_materials
  100604. */
  100605. vAng: number;
  100606. /**
  100607. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  100608. * @see http://doc.babylonjs.com/how_to/more_materials
  100609. */
  100610. wAng: number;
  100611. /**
  100612. * Defines the center of rotation (U)
  100613. */
  100614. uRotationCenter: number;
  100615. /**
  100616. * Defines the center of rotation (V)
  100617. */
  100618. vRotationCenter: number;
  100619. /**
  100620. * Defines the center of rotation (W)
  100621. */
  100622. wRotationCenter: number;
  100623. /**
  100624. * Are mip maps generated for this texture or not.
  100625. */
  100626. get noMipmap(): boolean;
  100627. /**
  100628. * List of inspectable custom properties (used by the Inspector)
  100629. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100630. */
  100631. inspectableCustomProperties: Nullable<IInspectable[]>;
  100632. private _noMipmap;
  100633. /** @hidden */
  100634. _invertY: boolean;
  100635. private _rowGenerationMatrix;
  100636. private _cachedTextureMatrix;
  100637. private _projectionModeMatrix;
  100638. private _t0;
  100639. private _t1;
  100640. private _t2;
  100641. private _cachedUOffset;
  100642. private _cachedVOffset;
  100643. private _cachedUScale;
  100644. private _cachedVScale;
  100645. private _cachedUAng;
  100646. private _cachedVAng;
  100647. private _cachedWAng;
  100648. private _cachedProjectionMatrixId;
  100649. private _cachedCoordinatesMode;
  100650. /** @hidden */
  100651. protected _initialSamplingMode: number;
  100652. /** @hidden */
  100653. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  100654. private _deleteBuffer;
  100655. protected _format: Nullable<number>;
  100656. private _delayedOnLoad;
  100657. private _delayedOnError;
  100658. private _mimeType?;
  100659. /**
  100660. * Observable triggered once the texture has been loaded.
  100661. */
  100662. onLoadObservable: Observable<Texture>;
  100663. protected _isBlocking: boolean;
  100664. /**
  100665. * Is the texture preventing material to render while loading.
  100666. * If false, a default texture will be used instead of the loading one during the preparation step.
  100667. */
  100668. set isBlocking(value: boolean);
  100669. get isBlocking(): boolean;
  100670. /**
  100671. * Get the current sampling mode associated with the texture.
  100672. */
  100673. get samplingMode(): number;
  100674. /**
  100675. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  100676. */
  100677. get invertY(): boolean;
  100678. /**
  100679. * Instantiates a new texture.
  100680. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  100681. * @see http://doc.babylonjs.com/babylon101/materials#texture
  100682. * @param url defines the url of the picture to load as a texture
  100683. * @param sceneOrEngine defines the scene or engine the texture will belong to
  100684. * @param noMipmap defines if the texture will require mip maps or not
  100685. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  100686. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100687. * @param onLoad defines a callback triggered when the texture has been loaded
  100688. * @param onError defines a callback triggered when an error occurred during the loading session
  100689. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  100690. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  100691. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100692. * @param mimeType defines an optional mime type information
  100693. */
  100694. 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);
  100695. /**
  100696. * Update the url (and optional buffer) of this texture if url was null during construction.
  100697. * @param url the url of the texture
  100698. * @param buffer the buffer of the texture (defaults to null)
  100699. * @param onLoad callback called when the texture is loaded (defaults to null)
  100700. */
  100701. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  100702. /**
  100703. * Finish the loading sequence of a texture flagged as delayed load.
  100704. * @hidden
  100705. */
  100706. delayLoad(): void;
  100707. private _prepareRowForTextureGeneration;
  100708. /**
  100709. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  100710. * @returns the transform matrix of the texture.
  100711. */
  100712. getTextureMatrix(uBase?: number): Matrix;
  100713. /**
  100714. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  100715. * @returns The reflection texture transform
  100716. */
  100717. getReflectionTextureMatrix(): Matrix;
  100718. /**
  100719. * Clones the texture.
  100720. * @returns the cloned texture
  100721. */
  100722. clone(): Texture;
  100723. /**
  100724. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  100725. * @returns The JSON representation of the texture
  100726. */
  100727. serialize(): any;
  100728. /**
  100729. * Get the current class name of the texture useful for serialization or dynamic coding.
  100730. * @returns "Texture"
  100731. */
  100732. getClassName(): string;
  100733. /**
  100734. * Dispose the texture and release its associated resources.
  100735. */
  100736. dispose(): void;
  100737. /**
  100738. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  100739. * @param parsedTexture Define the JSON representation of the texture
  100740. * @param scene Define the scene the parsed texture should be instantiated in
  100741. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  100742. * @returns The parsed texture if successful
  100743. */
  100744. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  100745. /**
  100746. * Creates a texture from its base 64 representation.
  100747. * @param data Define the base64 payload without the data: prefix
  100748. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100749. * @param scene Define the scene the texture should belong to
  100750. * @param noMipmap Forces the texture to not create mip map information if true
  100751. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100752. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100753. * @param onLoad define a callback triggered when the texture has been loaded
  100754. * @param onError define a callback triggered when an error occurred during the loading session
  100755. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100756. * @returns the created texture
  100757. */
  100758. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  100759. /**
  100760. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  100761. * @param data Define the base64 payload without the data: prefix
  100762. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  100763. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  100764. * @param scene Define the scene the texture should belong to
  100765. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  100766. * @param noMipmap Forces the texture to not create mip map information if true
  100767. * @param invertY define if the texture needs to be inverted on the y axis during loading
  100768. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  100769. * @param onLoad define a callback triggered when the texture has been loaded
  100770. * @param onError define a callback triggered when an error occurred during the loading session
  100771. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  100772. * @returns the created texture
  100773. */
  100774. 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;
  100775. }
  100776. }
  100777. declare module BABYLON {
  100778. /**
  100779. * PostProcessManager is used to manage one or more post processes or post process pipelines
  100780. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100781. */
  100782. export class PostProcessManager {
  100783. private _scene;
  100784. private _indexBuffer;
  100785. private _vertexBuffers;
  100786. /**
  100787. * Creates a new instance PostProcess
  100788. * @param scene The scene that the post process is associated with.
  100789. */
  100790. constructor(scene: Scene);
  100791. private _prepareBuffers;
  100792. private _buildIndexBuffer;
  100793. /**
  100794. * Rebuilds the vertex buffers of the manager.
  100795. * @hidden
  100796. */
  100797. _rebuild(): void;
  100798. /**
  100799. * Prepares a frame to be run through a post process.
  100800. * @param sourceTexture The input texture to the post procesess. (default: null)
  100801. * @param postProcesses An array of post processes to be run. (default: null)
  100802. * @returns True if the post processes were able to be run.
  100803. * @hidden
  100804. */
  100805. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  100806. /**
  100807. * Manually render a set of post processes to a texture.
  100808. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  100809. * @param postProcesses An array of post processes to be run.
  100810. * @param targetTexture The target texture to render to.
  100811. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  100812. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  100813. * @param lodLevel defines which lod of the texture to render to
  100814. */
  100815. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  100816. /**
  100817. * Finalize the result of the output of the postprocesses.
  100818. * @param doNotPresent If true the result will not be displayed to the screen.
  100819. * @param targetTexture The target texture to render to.
  100820. * @param faceIndex The index of the face to bind the target texture to.
  100821. * @param postProcesses The array of post processes to render.
  100822. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  100823. * @hidden
  100824. */
  100825. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  100826. /**
  100827. * Disposes of the post process manager.
  100828. */
  100829. dispose(): void;
  100830. }
  100831. }
  100832. declare module BABYLON {
  100833. /**
  100834. * This Helps creating a texture that will be created from a camera in your scene.
  100835. * It is basically a dynamic texture that could be used to create special effects for instance.
  100836. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  100837. */
  100838. export class RenderTargetTexture extends Texture {
  100839. isCube: boolean;
  100840. /**
  100841. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  100842. */
  100843. static readonly REFRESHRATE_RENDER_ONCE: number;
  100844. /**
  100845. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  100846. */
  100847. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  100848. /**
  100849. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  100850. * the central point of your effect and can save a lot of performances.
  100851. */
  100852. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  100853. /**
  100854. * Use this predicate to dynamically define the list of mesh you want to render.
  100855. * If set, the renderList property will be overwritten.
  100856. */
  100857. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  100858. private _renderList;
  100859. /**
  100860. * Use this list to define the list of mesh you want to render.
  100861. */
  100862. get renderList(): Nullable<Array<AbstractMesh>>;
  100863. set renderList(value: Nullable<Array<AbstractMesh>>);
  100864. /**
  100865. * Use this function to overload the renderList array at rendering time.
  100866. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  100867. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  100868. * the cube (if the RTT is a cube, else layerOrFace=0).
  100869. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  100870. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  100871. * hold dummy elements!
  100872. */
  100873. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  100874. private _hookArray;
  100875. /**
  100876. * Define if particles should be rendered in your texture.
  100877. */
  100878. renderParticles: boolean;
  100879. /**
  100880. * Define if sprites should be rendered in your texture.
  100881. */
  100882. renderSprites: boolean;
  100883. /**
  100884. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  100885. */
  100886. coordinatesMode: number;
  100887. /**
  100888. * Define the camera used to render the texture.
  100889. */
  100890. activeCamera: Nullable<Camera>;
  100891. /**
  100892. * Override the mesh isReady function with your own one.
  100893. */
  100894. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  100895. /**
  100896. * Override the render function of the texture with your own one.
  100897. */
  100898. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  100899. /**
  100900. * Define if camera post processes should be use while rendering the texture.
  100901. */
  100902. useCameraPostProcesses: boolean;
  100903. /**
  100904. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  100905. */
  100906. ignoreCameraViewport: boolean;
  100907. private _postProcessManager;
  100908. private _postProcesses;
  100909. private _resizeObserver;
  100910. /**
  100911. * An event triggered when the texture is unbind.
  100912. */
  100913. onBeforeBindObservable: Observable<RenderTargetTexture>;
  100914. /**
  100915. * An event triggered when the texture is unbind.
  100916. */
  100917. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  100918. private _onAfterUnbindObserver;
  100919. /**
  100920. * Set a after unbind callback in the texture.
  100921. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  100922. */
  100923. set onAfterUnbind(callback: () => void);
  100924. /**
  100925. * An event triggered before rendering the texture
  100926. */
  100927. onBeforeRenderObservable: Observable<number>;
  100928. private _onBeforeRenderObserver;
  100929. /**
  100930. * Set a before render callback in the texture.
  100931. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  100932. */
  100933. set onBeforeRender(callback: (faceIndex: number) => void);
  100934. /**
  100935. * An event triggered after rendering the texture
  100936. */
  100937. onAfterRenderObservable: Observable<number>;
  100938. private _onAfterRenderObserver;
  100939. /**
  100940. * Set a after render callback in the texture.
  100941. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  100942. */
  100943. set onAfterRender(callback: (faceIndex: number) => void);
  100944. /**
  100945. * An event triggered after the texture clear
  100946. */
  100947. onClearObservable: Observable<Engine>;
  100948. private _onClearObserver;
  100949. /**
  100950. * Set a clear callback in the texture.
  100951. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  100952. */
  100953. set onClear(callback: (Engine: Engine) => void);
  100954. /**
  100955. * An event triggered when the texture is resized.
  100956. */
  100957. onResizeObservable: Observable<RenderTargetTexture>;
  100958. /**
  100959. * Define the clear color of the Render Target if it should be different from the scene.
  100960. */
  100961. clearColor: Color4;
  100962. protected _size: number | {
  100963. width: number;
  100964. height: number;
  100965. layers?: number;
  100966. };
  100967. protected _initialSizeParameter: number | {
  100968. width: number;
  100969. height: number;
  100970. } | {
  100971. ratio: number;
  100972. };
  100973. protected _sizeRatio: Nullable<number>;
  100974. /** @hidden */
  100975. _generateMipMaps: boolean;
  100976. protected _renderingManager: RenderingManager;
  100977. /** @hidden */
  100978. _waitingRenderList: string[];
  100979. protected _doNotChangeAspectRatio: boolean;
  100980. protected _currentRefreshId: number;
  100981. protected _refreshRate: number;
  100982. protected _textureMatrix: Matrix;
  100983. protected _samples: number;
  100984. protected _renderTargetOptions: RenderTargetCreationOptions;
  100985. /**
  100986. * Gets render target creation options that were used.
  100987. */
  100988. get renderTargetOptions(): RenderTargetCreationOptions;
  100989. protected _onRatioRescale(): void;
  100990. /**
  100991. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  100992. * It must define where the camera used to render the texture is set
  100993. */
  100994. boundingBoxPosition: Vector3;
  100995. private _boundingBoxSize;
  100996. /**
  100997. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  100998. * When defined, the cubemap will switch to local mode
  100999. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101000. * @example https://www.babylonjs-playground.com/#RNASML
  101001. */
  101002. set boundingBoxSize(value: Vector3);
  101003. get boundingBoxSize(): Vector3;
  101004. /**
  101005. * In case the RTT has been created with a depth texture, get the associated
  101006. * depth texture.
  101007. * Otherwise, return null.
  101008. */
  101009. get depthStencilTexture(): Nullable<InternalTexture>;
  101010. /**
  101011. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101012. * or used a shadow, depth texture...
  101013. * @param name The friendly name of the texture
  101014. * @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)
  101015. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101016. * @param generateMipMaps True if mip maps need to be generated after render.
  101017. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101018. * @param type The type of the buffer in the RTT (int, half float, float...)
  101019. * @param isCube True if a cube texture needs to be created
  101020. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101021. * @param generateDepthBuffer True to generate a depth buffer
  101022. * @param generateStencilBuffer True to generate a stencil buffer
  101023. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101024. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101025. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101026. */
  101027. constructor(name: string, size: number | {
  101028. width: number;
  101029. height: number;
  101030. layers?: number;
  101031. } | {
  101032. ratio: number;
  101033. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101034. /**
  101035. * Creates a depth stencil texture.
  101036. * This is only available in WebGL 2 or with the depth texture extension available.
  101037. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101038. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101039. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101040. */
  101041. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101042. private _processSizeParameter;
  101043. /**
  101044. * Define the number of samples to use in case of MSAA.
  101045. * It defaults to one meaning no MSAA has been enabled.
  101046. */
  101047. get samples(): number;
  101048. set samples(value: number);
  101049. /**
  101050. * Resets the refresh counter of the texture and start bak from scratch.
  101051. * Could be useful to regenerate the texture if it is setup to render only once.
  101052. */
  101053. resetRefreshCounter(): void;
  101054. /**
  101055. * Define the refresh rate of the texture or the rendering frequency.
  101056. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101057. */
  101058. get refreshRate(): number;
  101059. set refreshRate(value: number);
  101060. /**
  101061. * Adds a post process to the render target rendering passes.
  101062. * @param postProcess define the post process to add
  101063. */
  101064. addPostProcess(postProcess: PostProcess): void;
  101065. /**
  101066. * Clear all the post processes attached to the render target
  101067. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101068. */
  101069. clearPostProcesses(dispose?: boolean): void;
  101070. /**
  101071. * Remove one of the post process from the list of attached post processes to the texture
  101072. * @param postProcess define the post process to remove from the list
  101073. */
  101074. removePostProcess(postProcess: PostProcess): void;
  101075. /** @hidden */
  101076. _shouldRender(): boolean;
  101077. /**
  101078. * Gets the actual render size of the texture.
  101079. * @returns the width of the render size
  101080. */
  101081. getRenderSize(): number;
  101082. /**
  101083. * Gets the actual render width of the texture.
  101084. * @returns the width of the render size
  101085. */
  101086. getRenderWidth(): number;
  101087. /**
  101088. * Gets the actual render height of the texture.
  101089. * @returns the height of the render size
  101090. */
  101091. getRenderHeight(): number;
  101092. /**
  101093. * Gets the actual number of layers of the texture.
  101094. * @returns the number of layers
  101095. */
  101096. getRenderLayers(): number;
  101097. /**
  101098. * Get if the texture can be rescaled or not.
  101099. */
  101100. get canRescale(): boolean;
  101101. /**
  101102. * Resize the texture using a ratio.
  101103. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101104. */
  101105. scale(ratio: number): void;
  101106. /**
  101107. * Get the texture reflection matrix used to rotate/transform the reflection.
  101108. * @returns the reflection matrix
  101109. */
  101110. getReflectionTextureMatrix(): Matrix;
  101111. /**
  101112. * Resize the texture to a new desired size.
  101113. * Be carrefull as it will recreate all the data in the new texture.
  101114. * @param size Define the new size. It can be:
  101115. * - a number for squared texture,
  101116. * - an object containing { width: number, height: number }
  101117. * - or an object containing a ratio { ratio: number }
  101118. */
  101119. resize(size: number | {
  101120. width: number;
  101121. height: number;
  101122. } | {
  101123. ratio: number;
  101124. }): void;
  101125. private _defaultRenderListPrepared;
  101126. /**
  101127. * Renders all the objects from the render list into the texture.
  101128. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101129. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101130. */
  101131. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101132. private _bestReflectionRenderTargetDimension;
  101133. private _prepareRenderingManager;
  101134. /**
  101135. * @hidden
  101136. * @param faceIndex face index to bind to if this is a cubetexture
  101137. * @param layer defines the index of the texture to bind in the array
  101138. */
  101139. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101140. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101141. private renderToTarget;
  101142. /**
  101143. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101144. * This allowed control for front to back rendering or reversly depending of the special needs.
  101145. *
  101146. * @param renderingGroupId The rendering group id corresponding to its index
  101147. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101148. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101149. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101150. */
  101151. 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;
  101152. /**
  101153. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101154. *
  101155. * @param renderingGroupId The rendering group id corresponding to its index
  101156. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101157. */
  101158. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101159. /**
  101160. * Clones the texture.
  101161. * @returns the cloned texture
  101162. */
  101163. clone(): RenderTargetTexture;
  101164. /**
  101165. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101166. * @returns The JSON representation of the texture
  101167. */
  101168. serialize(): any;
  101169. /**
  101170. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101171. */
  101172. disposeFramebufferObjects(): void;
  101173. /**
  101174. * Dispose the texture and release its associated resources.
  101175. */
  101176. dispose(): void;
  101177. /** @hidden */
  101178. _rebuild(): void;
  101179. /**
  101180. * Clear the info related to rendering groups preventing retention point in material dispose.
  101181. */
  101182. freeRenderingGroups(): void;
  101183. /**
  101184. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101185. * @returns the view count
  101186. */
  101187. getViewCount(): number;
  101188. }
  101189. }
  101190. declare module BABYLON {
  101191. /**
  101192. * Class used to manipulate GUIDs
  101193. */
  101194. export class GUID {
  101195. /**
  101196. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101197. * Be aware Math.random() could cause collisions, but:
  101198. * "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"
  101199. * @returns a pseudo random id
  101200. */
  101201. static RandomId(): string;
  101202. }
  101203. }
  101204. declare module BABYLON {
  101205. /**
  101206. * Options to be used when creating a shadow depth material
  101207. */
  101208. export interface IIOptionShadowDepthMaterial {
  101209. /** Variables in the vertex shader code that need to have their names remapped.
  101210. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101211. * "var_name" should be either: worldPos or vNormalW
  101212. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101213. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101214. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101215. */
  101216. remappedVariables?: string[];
  101217. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101218. standalone?: boolean;
  101219. }
  101220. /**
  101221. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101222. */
  101223. export class ShadowDepthWrapper {
  101224. private _scene;
  101225. private _options?;
  101226. private _baseMaterial;
  101227. private _onEffectCreatedObserver;
  101228. private _subMeshToEffect;
  101229. private _subMeshToDepthEffect;
  101230. private _meshes;
  101231. /** @hidden */
  101232. _matriceNames: any;
  101233. /** Gets the standalone status of the wrapper */
  101234. get standalone(): boolean;
  101235. /** Gets the base material the wrapper is built upon */
  101236. get baseMaterial(): Material;
  101237. /**
  101238. * Instantiate a new shadow depth wrapper.
  101239. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101240. * generate the shadow depth map. For more information, please refer to the documentation:
  101241. * https://doc.babylonjs.com/babylon101/shadows
  101242. * @param baseMaterial Material to wrap
  101243. * @param scene Define the scene the material belongs to
  101244. * @param options Options used to create the wrapper
  101245. */
  101246. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101247. /**
  101248. * Gets the effect to use to generate the depth map
  101249. * @param subMesh subMesh to get the effect for
  101250. * @param shadowGenerator shadow generator to get the effect for
  101251. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101252. */
  101253. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101254. /**
  101255. * Specifies that the submesh is ready to be used for depth rendering
  101256. * @param subMesh submesh to check
  101257. * @param defines the list of defines to take into account when checking the effect
  101258. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101259. * @param useInstances specifies that instances should be used
  101260. * @returns a boolean indicating that the submesh is ready or not
  101261. */
  101262. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101263. /**
  101264. * Disposes the resources
  101265. */
  101266. dispose(): void;
  101267. private _makeEffect;
  101268. }
  101269. }
  101270. declare module BABYLON {
  101271. /**
  101272. * Options for compiling materials.
  101273. */
  101274. export interface IMaterialCompilationOptions {
  101275. /**
  101276. * Defines whether clip planes are enabled.
  101277. */
  101278. clipPlane: boolean;
  101279. /**
  101280. * Defines whether instances are enabled.
  101281. */
  101282. useInstances: boolean;
  101283. }
  101284. /**
  101285. * Options passed when calling customShaderNameResolve
  101286. */
  101287. export interface ICustomShaderNameResolveOptions {
  101288. /**
  101289. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  101290. */
  101291. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  101292. }
  101293. /**
  101294. * Base class for the main features of a material in Babylon.js
  101295. */
  101296. export class Material implements IAnimatable {
  101297. /**
  101298. * Returns the triangle fill mode
  101299. */
  101300. static readonly TriangleFillMode: number;
  101301. /**
  101302. * Returns the wireframe mode
  101303. */
  101304. static readonly WireFrameFillMode: number;
  101305. /**
  101306. * Returns the point fill mode
  101307. */
  101308. static readonly PointFillMode: number;
  101309. /**
  101310. * Returns the point list draw mode
  101311. */
  101312. static readonly PointListDrawMode: number;
  101313. /**
  101314. * Returns the line list draw mode
  101315. */
  101316. static readonly LineListDrawMode: number;
  101317. /**
  101318. * Returns the line loop draw mode
  101319. */
  101320. static readonly LineLoopDrawMode: number;
  101321. /**
  101322. * Returns the line strip draw mode
  101323. */
  101324. static readonly LineStripDrawMode: number;
  101325. /**
  101326. * Returns the triangle strip draw mode
  101327. */
  101328. static readonly TriangleStripDrawMode: number;
  101329. /**
  101330. * Returns the triangle fan draw mode
  101331. */
  101332. static readonly TriangleFanDrawMode: number;
  101333. /**
  101334. * Stores the clock-wise side orientation
  101335. */
  101336. static readonly ClockWiseSideOrientation: number;
  101337. /**
  101338. * Stores the counter clock-wise side orientation
  101339. */
  101340. static readonly CounterClockWiseSideOrientation: number;
  101341. /**
  101342. * The dirty texture flag value
  101343. */
  101344. static readonly TextureDirtyFlag: number;
  101345. /**
  101346. * The dirty light flag value
  101347. */
  101348. static readonly LightDirtyFlag: number;
  101349. /**
  101350. * The dirty fresnel flag value
  101351. */
  101352. static readonly FresnelDirtyFlag: number;
  101353. /**
  101354. * The dirty attribute flag value
  101355. */
  101356. static readonly AttributesDirtyFlag: number;
  101357. /**
  101358. * The dirty misc flag value
  101359. */
  101360. static readonly MiscDirtyFlag: number;
  101361. /**
  101362. * The all dirty flag value
  101363. */
  101364. static readonly AllDirtyFlag: number;
  101365. /**
  101366. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101367. */
  101368. static readonly MATERIAL_OPAQUE: number;
  101369. /**
  101370. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101371. */
  101372. static readonly MATERIAL_ALPHATEST: number;
  101373. /**
  101374. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101375. */
  101376. static readonly MATERIAL_ALPHABLEND: number;
  101377. /**
  101378. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101379. * They are also discarded below the alpha cutoff threshold to improve performances.
  101380. */
  101381. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  101382. /**
  101383. * The Whiteout method is used to blend normals.
  101384. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101385. */
  101386. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  101387. /**
  101388. * The Reoriented Normal Mapping method is used to blend normals.
  101389. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  101390. */
  101391. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  101392. /**
  101393. * Custom callback helping to override the default shader used in the material.
  101394. */
  101395. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  101396. /**
  101397. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  101398. */
  101399. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  101400. /**
  101401. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  101402. * This means that the material can keep using a previous shader while a new one is being compiled.
  101403. * This is mostly used when shader parallel compilation is supported (true by default)
  101404. */
  101405. allowShaderHotSwapping: boolean;
  101406. /**
  101407. * The ID of the material
  101408. */
  101409. id: string;
  101410. /**
  101411. * Gets or sets the unique id of the material
  101412. */
  101413. uniqueId: number;
  101414. /**
  101415. * The name of the material
  101416. */
  101417. name: string;
  101418. /**
  101419. * Gets or sets user defined metadata
  101420. */
  101421. metadata: any;
  101422. /**
  101423. * For internal use only. Please do not use.
  101424. */
  101425. reservedDataStore: any;
  101426. /**
  101427. * Specifies if the ready state should be checked on each call
  101428. */
  101429. checkReadyOnEveryCall: boolean;
  101430. /**
  101431. * Specifies if the ready state should be checked once
  101432. */
  101433. checkReadyOnlyOnce: boolean;
  101434. /**
  101435. * The state of the material
  101436. */
  101437. state: string;
  101438. /**
  101439. * The alpha value of the material
  101440. */
  101441. protected _alpha: number;
  101442. /**
  101443. * List of inspectable custom properties (used by the Inspector)
  101444. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101445. */
  101446. inspectableCustomProperties: IInspectable[];
  101447. /**
  101448. * Sets the alpha value of the material
  101449. */
  101450. set alpha(value: number);
  101451. /**
  101452. * Gets the alpha value of the material
  101453. */
  101454. get alpha(): number;
  101455. /**
  101456. * Specifies if back face culling is enabled
  101457. */
  101458. protected _backFaceCulling: boolean;
  101459. /**
  101460. * Sets the back-face culling state
  101461. */
  101462. set backFaceCulling(value: boolean);
  101463. /**
  101464. * Gets the back-face culling state
  101465. */
  101466. get backFaceCulling(): boolean;
  101467. /**
  101468. * Stores the value for side orientation
  101469. */
  101470. sideOrientation: number;
  101471. /**
  101472. * Callback triggered when the material is compiled
  101473. */
  101474. onCompiled: Nullable<(effect: Effect) => void>;
  101475. /**
  101476. * Callback triggered when an error occurs
  101477. */
  101478. onError: Nullable<(effect: Effect, errors: string) => void>;
  101479. /**
  101480. * Callback triggered to get the render target textures
  101481. */
  101482. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  101483. /**
  101484. * Gets a boolean indicating that current material needs to register RTT
  101485. */
  101486. get hasRenderTargetTextures(): boolean;
  101487. /**
  101488. * Specifies if the material should be serialized
  101489. */
  101490. doNotSerialize: boolean;
  101491. /**
  101492. * @hidden
  101493. */
  101494. _storeEffectOnSubMeshes: boolean;
  101495. /**
  101496. * Stores the animations for the material
  101497. */
  101498. animations: Nullable<Array<Animation>>;
  101499. /**
  101500. * An event triggered when the material is disposed
  101501. */
  101502. onDisposeObservable: Observable<Material>;
  101503. /**
  101504. * An observer which watches for dispose events
  101505. */
  101506. private _onDisposeObserver;
  101507. private _onUnBindObservable;
  101508. /**
  101509. * Called during a dispose event
  101510. */
  101511. set onDispose(callback: () => void);
  101512. private _onBindObservable;
  101513. /**
  101514. * An event triggered when the material is bound
  101515. */
  101516. get onBindObservable(): Observable<AbstractMesh>;
  101517. /**
  101518. * An observer which watches for bind events
  101519. */
  101520. private _onBindObserver;
  101521. /**
  101522. * Called during a bind event
  101523. */
  101524. set onBind(callback: (Mesh: AbstractMesh) => void);
  101525. /**
  101526. * An event triggered when the material is unbound
  101527. */
  101528. get onUnBindObservable(): Observable<Material>;
  101529. protected _onEffectCreatedObservable: Nullable<Observable<{
  101530. effect: Effect;
  101531. subMesh: Nullable<SubMesh>;
  101532. }>>;
  101533. /**
  101534. * An event triggered when the effect is (re)created
  101535. */
  101536. get onEffectCreatedObservable(): Observable<{
  101537. effect: Effect;
  101538. subMesh: Nullable<SubMesh>;
  101539. }>;
  101540. /**
  101541. * Stores the value of the alpha mode
  101542. */
  101543. private _alphaMode;
  101544. /**
  101545. * Sets the value of the alpha mode.
  101546. *
  101547. * | Value | Type | Description |
  101548. * | --- | --- | --- |
  101549. * | 0 | ALPHA_DISABLE | |
  101550. * | 1 | ALPHA_ADD | |
  101551. * | 2 | ALPHA_COMBINE | |
  101552. * | 3 | ALPHA_SUBTRACT | |
  101553. * | 4 | ALPHA_MULTIPLY | |
  101554. * | 5 | ALPHA_MAXIMIZED | |
  101555. * | 6 | ALPHA_ONEONE | |
  101556. * | 7 | ALPHA_PREMULTIPLIED | |
  101557. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  101558. * | 9 | ALPHA_INTERPOLATE | |
  101559. * | 10 | ALPHA_SCREENMODE | |
  101560. *
  101561. */
  101562. set alphaMode(value: number);
  101563. /**
  101564. * Gets the value of the alpha mode
  101565. */
  101566. get alphaMode(): number;
  101567. /**
  101568. * Stores the state of the need depth pre-pass value
  101569. */
  101570. private _needDepthPrePass;
  101571. /**
  101572. * Sets the need depth pre-pass value
  101573. */
  101574. set needDepthPrePass(value: boolean);
  101575. /**
  101576. * Gets the depth pre-pass value
  101577. */
  101578. get needDepthPrePass(): boolean;
  101579. /**
  101580. * Specifies if depth writing should be disabled
  101581. */
  101582. disableDepthWrite: boolean;
  101583. /**
  101584. * Specifies if color writing should be disabled
  101585. */
  101586. disableColorWrite: boolean;
  101587. /**
  101588. * Specifies if depth writing should be forced
  101589. */
  101590. forceDepthWrite: boolean;
  101591. /**
  101592. * Specifies the depth function that should be used. 0 means the default engine function
  101593. */
  101594. depthFunction: number;
  101595. /**
  101596. * Specifies if there should be a separate pass for culling
  101597. */
  101598. separateCullingPass: boolean;
  101599. /**
  101600. * Stores the state specifing if fog should be enabled
  101601. */
  101602. private _fogEnabled;
  101603. /**
  101604. * Sets the state for enabling fog
  101605. */
  101606. set fogEnabled(value: boolean);
  101607. /**
  101608. * Gets the value of the fog enabled state
  101609. */
  101610. get fogEnabled(): boolean;
  101611. /**
  101612. * Stores the size of points
  101613. */
  101614. pointSize: number;
  101615. /**
  101616. * Stores the z offset value
  101617. */
  101618. zOffset: number;
  101619. get wireframe(): boolean;
  101620. /**
  101621. * Sets the state of wireframe mode
  101622. */
  101623. set wireframe(value: boolean);
  101624. /**
  101625. * Gets the value specifying if point clouds are enabled
  101626. */
  101627. get pointsCloud(): boolean;
  101628. /**
  101629. * Sets the state of point cloud mode
  101630. */
  101631. set pointsCloud(value: boolean);
  101632. /**
  101633. * Gets the material fill mode
  101634. */
  101635. get fillMode(): number;
  101636. /**
  101637. * Sets the material fill mode
  101638. */
  101639. set fillMode(value: number);
  101640. /**
  101641. * @hidden
  101642. * Stores the effects for the material
  101643. */
  101644. _effect: Nullable<Effect>;
  101645. /**
  101646. * Specifies if uniform buffers should be used
  101647. */
  101648. private _useUBO;
  101649. /**
  101650. * Stores a reference to the scene
  101651. */
  101652. private _scene;
  101653. /**
  101654. * Stores the fill mode state
  101655. */
  101656. private _fillMode;
  101657. /**
  101658. * Specifies if the depth write state should be cached
  101659. */
  101660. private _cachedDepthWriteState;
  101661. /**
  101662. * Specifies if the color write state should be cached
  101663. */
  101664. private _cachedColorWriteState;
  101665. /**
  101666. * Specifies if the depth function state should be cached
  101667. */
  101668. private _cachedDepthFunctionState;
  101669. /**
  101670. * Stores the uniform buffer
  101671. */
  101672. protected _uniformBuffer: UniformBuffer;
  101673. /** @hidden */
  101674. _indexInSceneMaterialArray: number;
  101675. /** @hidden */
  101676. meshMap: Nullable<{
  101677. [id: string]: AbstractMesh | undefined;
  101678. }>;
  101679. /**
  101680. * Creates a material instance
  101681. * @param name defines the name of the material
  101682. * @param scene defines the scene to reference
  101683. * @param doNotAdd specifies if the material should be added to the scene
  101684. */
  101685. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  101686. /**
  101687. * Returns a string representation of the current material
  101688. * @param fullDetails defines a boolean indicating which levels of logging is desired
  101689. * @returns a string with material information
  101690. */
  101691. toString(fullDetails?: boolean): string;
  101692. /**
  101693. * Gets the class name of the material
  101694. * @returns a string with the class name of the material
  101695. */
  101696. getClassName(): string;
  101697. /**
  101698. * Specifies if updates for the material been locked
  101699. */
  101700. get isFrozen(): boolean;
  101701. /**
  101702. * Locks updates for the material
  101703. */
  101704. freeze(): void;
  101705. /**
  101706. * Unlocks updates for the material
  101707. */
  101708. unfreeze(): void;
  101709. /**
  101710. * Specifies if the material is ready to be used
  101711. * @param mesh defines the mesh to check
  101712. * @param useInstances specifies if instances should be used
  101713. * @returns a boolean indicating if the material is ready to be used
  101714. */
  101715. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101716. /**
  101717. * Specifies that the submesh is ready to be used
  101718. * @param mesh defines the mesh to check
  101719. * @param subMesh defines which submesh to check
  101720. * @param useInstances specifies that instances should be used
  101721. * @returns a boolean indicating that the submesh is ready or not
  101722. */
  101723. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101724. /**
  101725. * Returns the material effect
  101726. * @returns the effect associated with the material
  101727. */
  101728. getEffect(): Nullable<Effect>;
  101729. /**
  101730. * Returns the current scene
  101731. * @returns a Scene
  101732. */
  101733. getScene(): Scene;
  101734. /**
  101735. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  101736. */
  101737. protected _forceAlphaTest: boolean;
  101738. /**
  101739. * The transparency mode of the material.
  101740. */
  101741. protected _transparencyMode: Nullable<number>;
  101742. /**
  101743. * Gets the current transparency mode.
  101744. */
  101745. get transparencyMode(): Nullable<number>;
  101746. /**
  101747. * Sets the transparency mode of the material.
  101748. *
  101749. * | Value | Type | Description |
  101750. * | ----- | ----------------------------------- | ----------- |
  101751. * | 0 | OPAQUE | |
  101752. * | 1 | ALPHATEST | |
  101753. * | 2 | ALPHABLEND | |
  101754. * | 3 | ALPHATESTANDBLEND | |
  101755. *
  101756. */
  101757. set transparencyMode(value: Nullable<number>);
  101758. /**
  101759. * Returns true if alpha blending should be disabled.
  101760. */
  101761. protected get _disableAlphaBlending(): boolean;
  101762. /**
  101763. * Specifies whether or not this material should be rendered in alpha blend mode.
  101764. * @returns a boolean specifying if alpha blending is needed
  101765. */
  101766. needAlphaBlending(): boolean;
  101767. /**
  101768. * Specifies if the mesh will require alpha blending
  101769. * @param mesh defines the mesh to check
  101770. * @returns a boolean specifying if alpha blending is needed for the mesh
  101771. */
  101772. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  101773. /**
  101774. * Specifies whether or not this material should be rendered in alpha test mode.
  101775. * @returns a boolean specifying if an alpha test is needed.
  101776. */
  101777. needAlphaTesting(): boolean;
  101778. /**
  101779. * Specifies if material alpha testing should be turned on for the mesh
  101780. * @param mesh defines the mesh to check
  101781. */
  101782. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  101783. /**
  101784. * Gets the texture used for the alpha test
  101785. * @returns the texture to use for alpha testing
  101786. */
  101787. getAlphaTestTexture(): Nullable<BaseTexture>;
  101788. /**
  101789. * Marks the material to indicate that it needs to be re-calculated
  101790. */
  101791. markDirty(): void;
  101792. /** @hidden */
  101793. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  101794. /**
  101795. * Binds the material to the mesh
  101796. * @param world defines the world transformation matrix
  101797. * @param mesh defines the mesh to bind the material to
  101798. */
  101799. bind(world: Matrix, mesh?: Mesh): void;
  101800. /**
  101801. * Binds the submesh to the material
  101802. * @param world defines the world transformation matrix
  101803. * @param mesh defines the mesh containing the submesh
  101804. * @param subMesh defines the submesh to bind the material to
  101805. */
  101806. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101807. /**
  101808. * Binds the world matrix to the material
  101809. * @param world defines the world transformation matrix
  101810. */
  101811. bindOnlyWorldMatrix(world: Matrix): void;
  101812. /**
  101813. * Binds the scene's uniform buffer to the effect.
  101814. * @param effect defines the effect to bind to the scene uniform buffer
  101815. * @param sceneUbo defines the uniform buffer storing scene data
  101816. */
  101817. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  101818. /**
  101819. * Binds the view matrix to the effect
  101820. * @param effect defines the effect to bind the view matrix to
  101821. */
  101822. bindView(effect: Effect): void;
  101823. /**
  101824. * Binds the view projection matrix to the effect
  101825. * @param effect defines the effect to bind the view projection matrix to
  101826. */
  101827. bindViewProjection(effect: Effect): void;
  101828. /**
  101829. * Processes to execute after binding the material to a mesh
  101830. * @param mesh defines the rendered mesh
  101831. */
  101832. protected _afterBind(mesh?: Mesh): void;
  101833. /**
  101834. * Unbinds the material from the mesh
  101835. */
  101836. unbind(): void;
  101837. /**
  101838. * Gets the active textures from the material
  101839. * @returns an array of textures
  101840. */
  101841. getActiveTextures(): BaseTexture[];
  101842. /**
  101843. * Specifies if the material uses a texture
  101844. * @param texture defines the texture to check against the material
  101845. * @returns a boolean specifying if the material uses the texture
  101846. */
  101847. hasTexture(texture: BaseTexture): boolean;
  101848. /**
  101849. * Makes a duplicate of the material, and gives it a new name
  101850. * @param name defines the new name for the duplicated material
  101851. * @returns the cloned material
  101852. */
  101853. clone(name: string): Nullable<Material>;
  101854. /**
  101855. * Gets the meshes bound to the material
  101856. * @returns an array of meshes bound to the material
  101857. */
  101858. getBindedMeshes(): AbstractMesh[];
  101859. /**
  101860. * Force shader compilation
  101861. * @param mesh defines the mesh associated with this material
  101862. * @param onCompiled defines a function to execute once the material is compiled
  101863. * @param options defines the options to configure the compilation
  101864. * @param onError defines a function to execute if the material fails compiling
  101865. */
  101866. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  101867. /**
  101868. * Force shader compilation
  101869. * @param mesh defines the mesh that will use this material
  101870. * @param options defines additional options for compiling the shaders
  101871. * @returns a promise that resolves when the compilation completes
  101872. */
  101873. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  101874. private static readonly _AllDirtyCallBack;
  101875. private static readonly _ImageProcessingDirtyCallBack;
  101876. private static readonly _TextureDirtyCallBack;
  101877. private static readonly _FresnelDirtyCallBack;
  101878. private static readonly _MiscDirtyCallBack;
  101879. private static readonly _LightsDirtyCallBack;
  101880. private static readonly _AttributeDirtyCallBack;
  101881. private static _FresnelAndMiscDirtyCallBack;
  101882. private static _TextureAndMiscDirtyCallBack;
  101883. private static readonly _DirtyCallbackArray;
  101884. private static readonly _RunDirtyCallBacks;
  101885. /**
  101886. * Marks a define in the material to indicate that it needs to be re-computed
  101887. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  101888. */
  101889. markAsDirty(flag: number): void;
  101890. /**
  101891. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  101892. * @param func defines a function which checks material defines against the submeshes
  101893. */
  101894. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  101895. /**
  101896. * Indicates that we need to re-calculated for all submeshes
  101897. */
  101898. protected _markAllSubMeshesAsAllDirty(): void;
  101899. /**
  101900. * Indicates that image processing needs to be re-calculated for all submeshes
  101901. */
  101902. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  101903. /**
  101904. * Indicates that textures need to be re-calculated for all submeshes
  101905. */
  101906. protected _markAllSubMeshesAsTexturesDirty(): void;
  101907. /**
  101908. * Indicates that fresnel needs to be re-calculated for all submeshes
  101909. */
  101910. protected _markAllSubMeshesAsFresnelDirty(): void;
  101911. /**
  101912. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  101913. */
  101914. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  101915. /**
  101916. * Indicates that lights need to be re-calculated for all submeshes
  101917. */
  101918. protected _markAllSubMeshesAsLightsDirty(): void;
  101919. /**
  101920. * Indicates that attributes need to be re-calculated for all submeshes
  101921. */
  101922. protected _markAllSubMeshesAsAttributesDirty(): void;
  101923. /**
  101924. * Indicates that misc needs to be re-calculated for all submeshes
  101925. */
  101926. protected _markAllSubMeshesAsMiscDirty(): void;
  101927. /**
  101928. * Indicates that textures and misc need to be re-calculated for all submeshes
  101929. */
  101930. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  101931. /**
  101932. * Disposes the material
  101933. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101934. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101935. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  101936. */
  101937. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  101938. /** @hidden */
  101939. private releaseVertexArrayObject;
  101940. /**
  101941. * Serializes this material
  101942. * @returns the serialized material object
  101943. */
  101944. serialize(): any;
  101945. /**
  101946. * Creates a material from parsed material data
  101947. * @param parsedMaterial defines parsed material data
  101948. * @param scene defines the hosting scene
  101949. * @param rootUrl defines the root URL to use to load textures
  101950. * @returns a new material
  101951. */
  101952. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  101953. }
  101954. }
  101955. declare module BABYLON {
  101956. /**
  101957. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101958. * separate meshes. This can be use to improve performances.
  101959. * @see http://doc.babylonjs.com/how_to/multi_materials
  101960. */
  101961. export class MultiMaterial extends Material {
  101962. private _subMaterials;
  101963. /**
  101964. * Gets or Sets the list of Materials used within the multi material.
  101965. * They need to be ordered according to the submeshes order in the associated mesh
  101966. */
  101967. get subMaterials(): Nullable<Material>[];
  101968. set subMaterials(value: Nullable<Material>[]);
  101969. /**
  101970. * Function used to align with Node.getChildren()
  101971. * @returns the list of Materials used within the multi material
  101972. */
  101973. getChildren(): Nullable<Material>[];
  101974. /**
  101975. * Instantiates a new Multi Material
  101976. * A multi-material is used to apply different materials to different parts of the same object without the need of
  101977. * separate meshes. This can be use to improve performances.
  101978. * @see http://doc.babylonjs.com/how_to/multi_materials
  101979. * @param name Define the name in the scene
  101980. * @param scene Define the scene the material belongs to
  101981. */
  101982. constructor(name: string, scene: Scene);
  101983. private _hookArray;
  101984. /**
  101985. * Get one of the submaterial by its index in the submaterials array
  101986. * @param index The index to look the sub material at
  101987. * @returns The Material if the index has been defined
  101988. */
  101989. getSubMaterial(index: number): Nullable<Material>;
  101990. /**
  101991. * Get the list of active textures for the whole sub materials list.
  101992. * @returns All the textures that will be used during the rendering
  101993. */
  101994. getActiveTextures(): BaseTexture[];
  101995. /**
  101996. * Gets the current class name of the material e.g. "MultiMaterial"
  101997. * Mainly use in serialization.
  101998. * @returns the class name
  101999. */
  102000. getClassName(): string;
  102001. /**
  102002. * Checks if the material is ready to render the requested sub mesh
  102003. * @param mesh Define the mesh the submesh belongs to
  102004. * @param subMesh Define the sub mesh to look readyness for
  102005. * @param useInstances Define whether or not the material is used with instances
  102006. * @returns true if ready, otherwise false
  102007. */
  102008. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102009. /**
  102010. * Clones the current material and its related sub materials
  102011. * @param name Define the name of the newly cloned material
  102012. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102013. * @returns the cloned material
  102014. */
  102015. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102016. /**
  102017. * Serializes the materials into a JSON representation.
  102018. * @returns the JSON representation
  102019. */
  102020. serialize(): any;
  102021. /**
  102022. * Dispose the material and release its associated resources
  102023. * @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)
  102024. * @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)
  102025. * @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)
  102026. */
  102027. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102028. /**
  102029. * Creates a MultiMaterial from parsed MultiMaterial data.
  102030. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102031. * @param scene defines the hosting scene
  102032. * @returns a new MultiMaterial
  102033. */
  102034. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102035. }
  102036. }
  102037. declare module BABYLON {
  102038. /**
  102039. * Defines a subdivision inside a mesh
  102040. */
  102041. export class SubMesh implements ICullable {
  102042. /** the material index to use */
  102043. materialIndex: number;
  102044. /** vertex index start */
  102045. verticesStart: number;
  102046. /** vertices count */
  102047. verticesCount: number;
  102048. /** index start */
  102049. indexStart: number;
  102050. /** indices count */
  102051. indexCount: number;
  102052. /** @hidden */
  102053. _materialDefines: Nullable<MaterialDefines>;
  102054. /** @hidden */
  102055. _materialEffect: Nullable<Effect>;
  102056. /** @hidden */
  102057. _effectOverride: Nullable<Effect>;
  102058. /**
  102059. * Gets material defines used by the effect associated to the sub mesh
  102060. */
  102061. get materialDefines(): Nullable<MaterialDefines>;
  102062. /**
  102063. * Sets material defines used by the effect associated to the sub mesh
  102064. */
  102065. set materialDefines(defines: Nullable<MaterialDefines>);
  102066. /**
  102067. * Gets associated effect
  102068. */
  102069. get effect(): Nullable<Effect>;
  102070. /**
  102071. * Sets associated effect (effect used to render this submesh)
  102072. * @param effect defines the effect to associate with
  102073. * @param defines defines the set of defines used to compile this effect
  102074. */
  102075. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102076. /** @hidden */
  102077. _linesIndexCount: number;
  102078. private _mesh;
  102079. private _renderingMesh;
  102080. private _boundingInfo;
  102081. private _linesIndexBuffer;
  102082. /** @hidden */
  102083. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102084. /** @hidden */
  102085. _trianglePlanes: Plane[];
  102086. /** @hidden */
  102087. _lastColliderTransformMatrix: Nullable<Matrix>;
  102088. /** @hidden */
  102089. _renderId: number;
  102090. /** @hidden */
  102091. _alphaIndex: number;
  102092. /** @hidden */
  102093. _distanceToCamera: number;
  102094. /** @hidden */
  102095. _id: number;
  102096. private _currentMaterial;
  102097. /**
  102098. * Add a new submesh to a mesh
  102099. * @param materialIndex defines the material index to use
  102100. * @param verticesStart defines vertex index start
  102101. * @param verticesCount defines vertices count
  102102. * @param indexStart defines index start
  102103. * @param indexCount defines indices count
  102104. * @param mesh defines the parent mesh
  102105. * @param renderingMesh defines an optional rendering mesh
  102106. * @param createBoundingBox defines if bounding box should be created for this submesh
  102107. * @returns the new submesh
  102108. */
  102109. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102110. /**
  102111. * Creates a new submesh
  102112. * @param materialIndex defines the material index to use
  102113. * @param verticesStart defines vertex index start
  102114. * @param verticesCount defines vertices count
  102115. * @param indexStart defines index start
  102116. * @param indexCount defines indices count
  102117. * @param mesh defines the parent mesh
  102118. * @param renderingMesh defines an optional rendering mesh
  102119. * @param createBoundingBox defines if bounding box should be created for this submesh
  102120. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102121. */
  102122. constructor(
  102123. /** the material index to use */
  102124. materialIndex: number,
  102125. /** vertex index start */
  102126. verticesStart: number,
  102127. /** vertices count */
  102128. verticesCount: number,
  102129. /** index start */
  102130. indexStart: number,
  102131. /** indices count */
  102132. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102133. /**
  102134. * Returns true if this submesh covers the entire parent mesh
  102135. * @ignorenaming
  102136. */
  102137. get IsGlobal(): boolean;
  102138. /**
  102139. * Returns the submesh BoudingInfo object
  102140. * @returns current bounding info (or mesh's one if the submesh is global)
  102141. */
  102142. getBoundingInfo(): BoundingInfo;
  102143. /**
  102144. * Sets the submesh BoundingInfo
  102145. * @param boundingInfo defines the new bounding info to use
  102146. * @returns the SubMesh
  102147. */
  102148. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102149. /**
  102150. * Returns the mesh of the current submesh
  102151. * @return the parent mesh
  102152. */
  102153. getMesh(): AbstractMesh;
  102154. /**
  102155. * Returns the rendering mesh of the submesh
  102156. * @returns the rendering mesh (could be different from parent mesh)
  102157. */
  102158. getRenderingMesh(): Mesh;
  102159. /**
  102160. * Returns the replacement mesh of the submesh
  102161. * @returns the replacement mesh (could be different from parent mesh)
  102162. */
  102163. getReplacementMesh(): Nullable<AbstractMesh>;
  102164. /**
  102165. * Returns the effective mesh of the submesh
  102166. * @returns the effective mesh (could be different from parent mesh)
  102167. */
  102168. getEffectiveMesh(): AbstractMesh;
  102169. /**
  102170. * Returns the submesh material
  102171. * @returns null or the current material
  102172. */
  102173. getMaterial(): Nullable<Material>;
  102174. private _IsMultiMaterial;
  102175. /**
  102176. * Sets a new updated BoundingInfo object to the submesh
  102177. * @param data defines an optional position array to use to determine the bounding info
  102178. * @returns the SubMesh
  102179. */
  102180. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102181. /** @hidden */
  102182. _checkCollision(collider: Collider): boolean;
  102183. /**
  102184. * Updates the submesh BoundingInfo
  102185. * @param world defines the world matrix to use to update the bounding info
  102186. * @returns the submesh
  102187. */
  102188. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102189. /**
  102190. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102191. * @param frustumPlanes defines the frustum planes
  102192. * @returns true if the submesh is intersecting with the frustum
  102193. */
  102194. isInFrustum(frustumPlanes: Plane[]): boolean;
  102195. /**
  102196. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102197. * @param frustumPlanes defines the frustum planes
  102198. * @returns true if the submesh is inside the frustum
  102199. */
  102200. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102201. /**
  102202. * Renders the submesh
  102203. * @param enableAlphaMode defines if alpha needs to be used
  102204. * @returns the submesh
  102205. */
  102206. render(enableAlphaMode: boolean): SubMesh;
  102207. /**
  102208. * @hidden
  102209. */
  102210. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102211. /**
  102212. * Checks if the submesh intersects with a ray
  102213. * @param ray defines the ray to test
  102214. * @returns true is the passed ray intersects the submesh bounding box
  102215. */
  102216. canIntersects(ray: Ray): boolean;
  102217. /**
  102218. * Intersects current submesh with a ray
  102219. * @param ray defines the ray to test
  102220. * @param positions defines mesh's positions array
  102221. * @param indices defines mesh's indices array
  102222. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102223. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102224. * @returns intersection info or null if no intersection
  102225. */
  102226. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102227. /** @hidden */
  102228. private _intersectLines;
  102229. /** @hidden */
  102230. private _intersectUnIndexedLines;
  102231. /** @hidden */
  102232. private _intersectTriangles;
  102233. /** @hidden */
  102234. private _intersectUnIndexedTriangles;
  102235. /** @hidden */
  102236. _rebuild(): void;
  102237. /**
  102238. * Creates a new submesh from the passed mesh
  102239. * @param newMesh defines the new hosting mesh
  102240. * @param newRenderingMesh defines an optional rendering mesh
  102241. * @returns the new submesh
  102242. */
  102243. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102244. /**
  102245. * Release associated resources
  102246. */
  102247. dispose(): void;
  102248. /**
  102249. * Gets the class name
  102250. * @returns the string "SubMesh".
  102251. */
  102252. getClassName(): string;
  102253. /**
  102254. * Creates a new submesh from indices data
  102255. * @param materialIndex the index of the main mesh material
  102256. * @param startIndex the index where to start the copy in the mesh indices array
  102257. * @param indexCount the number of indices to copy then from the startIndex
  102258. * @param mesh the main mesh to create the submesh from
  102259. * @param renderingMesh the optional rendering mesh
  102260. * @returns a new submesh
  102261. */
  102262. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102263. }
  102264. }
  102265. declare module BABYLON {
  102266. /**
  102267. * Class used to represent data loading progression
  102268. */
  102269. export class SceneLoaderFlags {
  102270. private static _ForceFullSceneLoadingForIncremental;
  102271. private static _ShowLoadingScreen;
  102272. private static _CleanBoneMatrixWeights;
  102273. private static _loggingLevel;
  102274. /**
  102275. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  102276. */
  102277. static get ForceFullSceneLoadingForIncremental(): boolean;
  102278. static set ForceFullSceneLoadingForIncremental(value: boolean);
  102279. /**
  102280. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  102281. */
  102282. static get ShowLoadingScreen(): boolean;
  102283. static set ShowLoadingScreen(value: boolean);
  102284. /**
  102285. * Defines the current logging level (while loading the scene)
  102286. * @ignorenaming
  102287. */
  102288. static get loggingLevel(): number;
  102289. static set loggingLevel(value: number);
  102290. /**
  102291. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  102292. */
  102293. static get CleanBoneMatrixWeights(): boolean;
  102294. static set CleanBoneMatrixWeights(value: boolean);
  102295. }
  102296. }
  102297. declare module BABYLON {
  102298. /**
  102299. * Class used to store geometry data (vertex buffers + index buffer)
  102300. */
  102301. export class Geometry implements IGetSetVerticesData {
  102302. /**
  102303. * Gets or sets the ID of the geometry
  102304. */
  102305. id: string;
  102306. /**
  102307. * Gets or sets the unique ID of the geometry
  102308. */
  102309. uniqueId: number;
  102310. /**
  102311. * Gets the delay loading state of the geometry (none by default which means not delayed)
  102312. */
  102313. delayLoadState: number;
  102314. /**
  102315. * Gets the file containing the data to load when running in delay load state
  102316. */
  102317. delayLoadingFile: Nullable<string>;
  102318. /**
  102319. * Callback called when the geometry is updated
  102320. */
  102321. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  102322. private _scene;
  102323. private _engine;
  102324. private _meshes;
  102325. private _totalVertices;
  102326. /** @hidden */
  102327. _indices: IndicesArray;
  102328. /** @hidden */
  102329. _vertexBuffers: {
  102330. [key: string]: VertexBuffer;
  102331. };
  102332. private _isDisposed;
  102333. private _extend;
  102334. private _boundingBias;
  102335. /** @hidden */
  102336. _delayInfo: Array<string>;
  102337. private _indexBuffer;
  102338. private _indexBufferIsUpdatable;
  102339. /** @hidden */
  102340. _boundingInfo: Nullable<BoundingInfo>;
  102341. /** @hidden */
  102342. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  102343. /** @hidden */
  102344. _softwareSkinningFrameId: number;
  102345. private _vertexArrayObjects;
  102346. private _updatable;
  102347. /** @hidden */
  102348. _positions: Nullable<Vector3[]>;
  102349. /**
  102350. * 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
  102351. */
  102352. get boundingBias(): Vector2;
  102353. /**
  102354. * 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
  102355. */
  102356. set boundingBias(value: Vector2);
  102357. /**
  102358. * Static function used to attach a new empty geometry to a mesh
  102359. * @param mesh defines the mesh to attach the geometry to
  102360. * @returns the new Geometry
  102361. */
  102362. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  102363. /** Get the list of meshes using this geometry */
  102364. get meshes(): Mesh[];
  102365. /**
  102366. * Creates a new geometry
  102367. * @param id defines the unique ID
  102368. * @param scene defines the hosting scene
  102369. * @param vertexData defines the VertexData used to get geometry data
  102370. * @param updatable defines if geometry must be updatable (false by default)
  102371. * @param mesh defines the mesh that will be associated with the geometry
  102372. */
  102373. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  102374. /**
  102375. * Gets the current extend of the geometry
  102376. */
  102377. get extend(): {
  102378. minimum: Vector3;
  102379. maximum: Vector3;
  102380. };
  102381. /**
  102382. * Gets the hosting scene
  102383. * @returns the hosting Scene
  102384. */
  102385. getScene(): Scene;
  102386. /**
  102387. * Gets the hosting engine
  102388. * @returns the hosting Engine
  102389. */
  102390. getEngine(): Engine;
  102391. /**
  102392. * Defines if the geometry is ready to use
  102393. * @returns true if the geometry is ready to be used
  102394. */
  102395. isReady(): boolean;
  102396. /**
  102397. * Gets a value indicating that the geometry should not be serialized
  102398. */
  102399. get doNotSerialize(): boolean;
  102400. /** @hidden */
  102401. _rebuild(): void;
  102402. /**
  102403. * Affects all geometry data in one call
  102404. * @param vertexData defines the geometry data
  102405. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  102406. */
  102407. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  102408. /**
  102409. * Set specific vertex data
  102410. * @param kind defines the data kind (Position, normal, etc...)
  102411. * @param data defines the vertex data to use
  102412. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102413. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102414. */
  102415. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  102416. /**
  102417. * Removes a specific vertex data
  102418. * @param kind defines the data kind (Position, normal, etc...)
  102419. */
  102420. removeVerticesData(kind: string): void;
  102421. /**
  102422. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  102423. * @param buffer defines the vertex buffer to use
  102424. * @param totalVertices defines the total number of vertices for position kind (could be null)
  102425. */
  102426. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  102427. /**
  102428. * Update a specific vertex buffer
  102429. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  102430. * It will do nothing if the buffer is not updatable
  102431. * @param kind defines the data kind (Position, normal, etc...)
  102432. * @param data defines the data to use
  102433. * @param offset defines the offset in the target buffer where to store the data
  102434. * @param useBytes set to true if the offset is in bytes
  102435. */
  102436. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  102437. /**
  102438. * Update a specific vertex buffer
  102439. * This function will create a new buffer if the current one is not updatable
  102440. * @param kind defines the data kind (Position, normal, etc...)
  102441. * @param data defines the data to use
  102442. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  102443. */
  102444. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  102445. private _updateBoundingInfo;
  102446. /** @hidden */
  102447. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  102448. /**
  102449. * Gets total number of vertices
  102450. * @returns the total number of vertices
  102451. */
  102452. getTotalVertices(): number;
  102453. /**
  102454. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102455. * @param kind defines the data kind (Position, normal, etc...)
  102456. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102458. * @returns a float array containing vertex data
  102459. */
  102460. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102461. /**
  102462. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  102463. * @param kind defines the data kind (Position, normal, etc...)
  102464. * @returns true if the vertex buffer with the specified kind is updatable
  102465. */
  102466. isVertexBufferUpdatable(kind: string): boolean;
  102467. /**
  102468. * Gets a specific vertex buffer
  102469. * @param kind defines the data kind (Position, normal, etc...)
  102470. * @returns a VertexBuffer
  102471. */
  102472. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  102473. /**
  102474. * Returns all vertex buffers
  102475. * @return an object holding all vertex buffers indexed by kind
  102476. */
  102477. getVertexBuffers(): Nullable<{
  102478. [key: string]: VertexBuffer;
  102479. }>;
  102480. /**
  102481. * Gets a boolean indicating if specific vertex buffer is present
  102482. * @param kind defines the data kind (Position, normal, etc...)
  102483. * @returns true if data is present
  102484. */
  102485. isVerticesDataPresent(kind: string): boolean;
  102486. /**
  102487. * Gets a list of all attached data kinds (Position, normal, etc...)
  102488. * @returns a list of string containing all kinds
  102489. */
  102490. getVerticesDataKinds(): string[];
  102491. /**
  102492. * Update index buffer
  102493. * @param indices defines the indices to store in the index buffer
  102494. * @param offset defines the offset in the target buffer where to store the data
  102495. * @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)
  102496. */
  102497. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  102498. /**
  102499. * Creates a new index buffer
  102500. * @param indices defines the indices to store in the index buffer
  102501. * @param totalVertices defines the total number of vertices (could be null)
  102502. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102503. */
  102504. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  102505. /**
  102506. * Return the total number of indices
  102507. * @returns the total number of indices
  102508. */
  102509. getTotalIndices(): number;
  102510. /**
  102511. * Gets the index buffer array
  102512. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102513. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102514. * @returns the index buffer array
  102515. */
  102516. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102517. /**
  102518. * Gets the index buffer
  102519. * @return the index buffer
  102520. */
  102521. getIndexBuffer(): Nullable<DataBuffer>;
  102522. /** @hidden */
  102523. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  102524. /**
  102525. * Release the associated resources for a specific mesh
  102526. * @param mesh defines the source mesh
  102527. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  102528. */
  102529. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  102530. /**
  102531. * Apply current geometry to a given mesh
  102532. * @param mesh defines the mesh to apply geometry to
  102533. */
  102534. applyToMesh(mesh: Mesh): void;
  102535. private _updateExtend;
  102536. private _applyToMesh;
  102537. private notifyUpdate;
  102538. /**
  102539. * Load the geometry if it was flagged as delay loaded
  102540. * @param scene defines the hosting scene
  102541. * @param onLoaded defines a callback called when the geometry is loaded
  102542. */
  102543. load(scene: Scene, onLoaded?: () => void): void;
  102544. private _queueLoad;
  102545. /**
  102546. * Invert the geometry to move from a right handed system to a left handed one.
  102547. */
  102548. toLeftHanded(): void;
  102549. /** @hidden */
  102550. _resetPointsArrayCache(): void;
  102551. /** @hidden */
  102552. _generatePointsArray(): boolean;
  102553. /**
  102554. * Gets a value indicating if the geometry is disposed
  102555. * @returns true if the geometry was disposed
  102556. */
  102557. isDisposed(): boolean;
  102558. private _disposeVertexArrayObjects;
  102559. /**
  102560. * Free all associated resources
  102561. */
  102562. dispose(): void;
  102563. /**
  102564. * Clone the current geometry into a new geometry
  102565. * @param id defines the unique ID of the new geometry
  102566. * @returns a new geometry object
  102567. */
  102568. copy(id: string): Geometry;
  102569. /**
  102570. * Serialize the current geometry info (and not the vertices data) into a JSON object
  102571. * @return a JSON representation of the current geometry data (without the vertices data)
  102572. */
  102573. serialize(): any;
  102574. private toNumberArray;
  102575. /**
  102576. * Serialize all vertices data into a JSON oject
  102577. * @returns a JSON representation of the current geometry data
  102578. */
  102579. serializeVerticeData(): any;
  102580. /**
  102581. * Extracts a clone of a mesh geometry
  102582. * @param mesh defines the source mesh
  102583. * @param id defines the unique ID of the new geometry object
  102584. * @returns the new geometry object
  102585. */
  102586. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  102587. /**
  102588. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  102589. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102590. * Be aware Math.random() could cause collisions, but:
  102591. * "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"
  102592. * @returns a string containing a new GUID
  102593. */
  102594. static RandomId(): string;
  102595. /** @hidden */
  102596. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  102597. private static _CleanMatricesWeights;
  102598. /**
  102599. * Create a new geometry from persisted data (Using .babylon file format)
  102600. * @param parsedVertexData defines the persisted data
  102601. * @param scene defines the hosting scene
  102602. * @param rootUrl defines the root url to use to load assets (like delayed data)
  102603. * @returns the new geometry object
  102604. */
  102605. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  102606. }
  102607. }
  102608. declare module BABYLON {
  102609. /**
  102610. * Define an interface for all classes that will get and set the data on vertices
  102611. */
  102612. export interface IGetSetVerticesData {
  102613. /**
  102614. * Gets a boolean indicating if specific vertex data is present
  102615. * @param kind defines the vertex data kind to use
  102616. * @returns true is data kind is present
  102617. */
  102618. isVerticesDataPresent(kind: string): boolean;
  102619. /**
  102620. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  102621. * @param kind defines the data kind (Position, normal, etc...)
  102622. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  102623. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102624. * @returns a float array containing vertex data
  102625. */
  102626. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  102627. /**
  102628. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  102629. * @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.
  102630. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  102631. * @returns the indices array or an empty array if the mesh has no geometry
  102632. */
  102633. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  102634. /**
  102635. * Set specific vertex data
  102636. * @param kind defines the data kind (Position, normal, etc...)
  102637. * @param data defines the vertex data to use
  102638. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  102639. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  102640. */
  102641. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  102642. /**
  102643. * Update a specific associated vertex buffer
  102644. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  102645. * - VertexBuffer.PositionKind
  102646. * - VertexBuffer.UVKind
  102647. * - VertexBuffer.UV2Kind
  102648. * - VertexBuffer.UV3Kind
  102649. * - VertexBuffer.UV4Kind
  102650. * - VertexBuffer.UV5Kind
  102651. * - VertexBuffer.UV6Kind
  102652. * - VertexBuffer.ColorKind
  102653. * - VertexBuffer.MatricesIndicesKind
  102654. * - VertexBuffer.MatricesIndicesExtraKind
  102655. * - VertexBuffer.MatricesWeightsKind
  102656. * - VertexBuffer.MatricesWeightsExtraKind
  102657. * @param data defines the data source
  102658. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  102659. * @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)
  102660. */
  102661. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  102662. /**
  102663. * Creates a new index buffer
  102664. * @param indices defines the indices to store in the index buffer
  102665. * @param totalVertices defines the total number of vertices (could be null)
  102666. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  102667. */
  102668. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  102669. }
  102670. /**
  102671. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  102672. */
  102673. export class VertexData {
  102674. /**
  102675. * Mesh side orientation : usually the external or front surface
  102676. */
  102677. static readonly FRONTSIDE: number;
  102678. /**
  102679. * Mesh side orientation : usually the internal or back surface
  102680. */
  102681. static readonly BACKSIDE: number;
  102682. /**
  102683. * Mesh side orientation : both internal and external or front and back surfaces
  102684. */
  102685. static readonly DOUBLESIDE: number;
  102686. /**
  102687. * Mesh side orientation : by default, `FRONTSIDE`
  102688. */
  102689. static readonly DEFAULTSIDE: number;
  102690. /**
  102691. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  102692. */
  102693. positions: Nullable<FloatArray>;
  102694. /**
  102695. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  102696. */
  102697. normals: Nullable<FloatArray>;
  102698. /**
  102699. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  102700. */
  102701. tangents: Nullable<FloatArray>;
  102702. /**
  102703. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102704. */
  102705. uvs: Nullable<FloatArray>;
  102706. /**
  102707. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102708. */
  102709. uvs2: Nullable<FloatArray>;
  102710. /**
  102711. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102712. */
  102713. uvs3: Nullable<FloatArray>;
  102714. /**
  102715. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102716. */
  102717. uvs4: Nullable<FloatArray>;
  102718. /**
  102719. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102720. */
  102721. uvs5: Nullable<FloatArray>;
  102722. /**
  102723. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  102724. */
  102725. uvs6: Nullable<FloatArray>;
  102726. /**
  102727. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  102728. */
  102729. colors: Nullable<FloatArray>;
  102730. /**
  102731. * 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).
  102732. */
  102733. matricesIndices: Nullable<FloatArray>;
  102734. /**
  102735. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  102736. */
  102737. matricesWeights: Nullable<FloatArray>;
  102738. /**
  102739. * An array extending the number of possible indices
  102740. */
  102741. matricesIndicesExtra: Nullable<FloatArray>;
  102742. /**
  102743. * An array extending the number of possible weights when the number of indices is extended
  102744. */
  102745. matricesWeightsExtra: Nullable<FloatArray>;
  102746. /**
  102747. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  102748. */
  102749. indices: Nullable<IndicesArray>;
  102750. /**
  102751. * Uses the passed data array to set the set the values for the specified kind of data
  102752. * @param data a linear array of floating numbers
  102753. * @param kind the type of data that is being set, eg positions, colors etc
  102754. */
  102755. set(data: FloatArray, kind: string): void;
  102756. /**
  102757. * Associates the vertexData to the passed Mesh.
  102758. * Sets it as updatable or not (default `false`)
  102759. * @param mesh the mesh the vertexData is applied to
  102760. * @param updatable when used and having the value true allows new data to update the vertexData
  102761. * @returns the VertexData
  102762. */
  102763. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  102764. /**
  102765. * Associates the vertexData to the passed Geometry.
  102766. * Sets it as updatable or not (default `false`)
  102767. * @param geometry the geometry the vertexData is applied to
  102768. * @param updatable when used and having the value true allows new data to update the vertexData
  102769. * @returns VertexData
  102770. */
  102771. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  102772. /**
  102773. * Updates the associated mesh
  102774. * @param mesh the mesh to be updated
  102775. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102776. * @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
  102777. * @returns VertexData
  102778. */
  102779. updateMesh(mesh: Mesh): VertexData;
  102780. /**
  102781. * Updates the associated geometry
  102782. * @param geometry the geometry to be updated
  102783. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  102784. * @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
  102785. * @returns VertexData.
  102786. */
  102787. updateGeometry(geometry: Geometry): VertexData;
  102788. private _applyTo;
  102789. private _update;
  102790. /**
  102791. * Transforms each position and each normal of the vertexData according to the passed Matrix
  102792. * @param matrix the transforming matrix
  102793. * @returns the VertexData
  102794. */
  102795. transform(matrix: Matrix): VertexData;
  102796. /**
  102797. * Merges the passed VertexData into the current one
  102798. * @param other the VertexData to be merged into the current one
  102799. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  102800. * @returns the modified VertexData
  102801. */
  102802. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  102803. private _mergeElement;
  102804. private _validate;
  102805. /**
  102806. * Serializes the VertexData
  102807. * @returns a serialized object
  102808. */
  102809. serialize(): any;
  102810. /**
  102811. * Extracts the vertexData from a mesh
  102812. * @param mesh the mesh from which to extract the VertexData
  102813. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  102814. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102815. * @returns the object VertexData associated to the passed mesh
  102816. */
  102817. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102818. /**
  102819. * Extracts the vertexData from the geometry
  102820. * @param geometry the geometry from which to extract the VertexData
  102821. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  102822. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  102823. * @returns the object VertexData associated to the passed mesh
  102824. */
  102825. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  102826. private static _ExtractFrom;
  102827. /**
  102828. * Creates the VertexData for a Ribbon
  102829. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  102830. * * pathArray array of paths, each of which an array of successive Vector3
  102831. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  102832. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  102833. * * 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
  102834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102835. * * 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)
  102836. * * 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)
  102837. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  102838. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  102839. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  102840. * @returns the VertexData of the ribbon
  102841. */
  102842. static CreateRibbon(options: {
  102843. pathArray: Vector3[][];
  102844. closeArray?: boolean;
  102845. closePath?: boolean;
  102846. offset?: number;
  102847. sideOrientation?: number;
  102848. frontUVs?: Vector4;
  102849. backUVs?: Vector4;
  102850. invertUV?: boolean;
  102851. uvs?: Vector2[];
  102852. colors?: Color4[];
  102853. }): VertexData;
  102854. /**
  102855. * Creates the VertexData for a box
  102856. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102857. * * size sets the width, height and depth of the box to the value of size, optional default 1
  102858. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  102859. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  102860. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  102861. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102862. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102863. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102864. * * 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)
  102865. * * 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)
  102866. * @returns the VertexData of the box
  102867. */
  102868. static CreateBox(options: {
  102869. size?: number;
  102870. width?: number;
  102871. height?: number;
  102872. depth?: number;
  102873. faceUV?: Vector4[];
  102874. faceColors?: Color4[];
  102875. sideOrientation?: number;
  102876. frontUVs?: Vector4;
  102877. backUVs?: Vector4;
  102878. }): VertexData;
  102879. /**
  102880. * Creates the VertexData for a tiled box
  102881. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102882. * * faceTiles sets the pattern, tile size and number of tiles for a face
  102883. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  102884. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  102885. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102886. * @returns the VertexData of the box
  102887. */
  102888. static CreateTiledBox(options: {
  102889. pattern?: number;
  102890. width?: number;
  102891. height?: number;
  102892. depth?: number;
  102893. tileSize?: number;
  102894. tileWidth?: number;
  102895. tileHeight?: number;
  102896. alignHorizontal?: number;
  102897. alignVertical?: number;
  102898. faceUV?: Vector4[];
  102899. faceColors?: Color4[];
  102900. sideOrientation?: number;
  102901. }): VertexData;
  102902. /**
  102903. * Creates the VertexData for a tiled plane
  102904. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102905. * * pattern a limited pattern arrangement depending on the number
  102906. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  102907. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  102908. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  102909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102910. * * 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)
  102911. * * 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)
  102912. * @returns the VertexData of the tiled plane
  102913. */
  102914. static CreateTiledPlane(options: {
  102915. pattern?: number;
  102916. tileSize?: number;
  102917. tileWidth?: number;
  102918. tileHeight?: number;
  102919. size?: number;
  102920. width?: number;
  102921. height?: number;
  102922. alignHorizontal?: number;
  102923. alignVertical?: number;
  102924. sideOrientation?: number;
  102925. frontUVs?: Vector4;
  102926. backUVs?: Vector4;
  102927. }): VertexData;
  102928. /**
  102929. * Creates the VertexData for an ellipsoid, defaults to a sphere
  102930. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102931. * * segments sets the number of horizontal strips optional, default 32
  102932. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  102933. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  102934. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  102935. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  102936. * * 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
  102937. * * 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
  102938. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102939. * * 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)
  102940. * * 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)
  102941. * @returns the VertexData of the ellipsoid
  102942. */
  102943. static CreateSphere(options: {
  102944. segments?: number;
  102945. diameter?: number;
  102946. diameterX?: number;
  102947. diameterY?: number;
  102948. diameterZ?: number;
  102949. arc?: number;
  102950. slice?: number;
  102951. sideOrientation?: number;
  102952. frontUVs?: Vector4;
  102953. backUVs?: Vector4;
  102954. }): VertexData;
  102955. /**
  102956. * Creates the VertexData for a cylinder, cone or prism
  102957. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102958. * * height sets the height (y direction) of the cylinder, optional, default 2
  102959. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  102960. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  102961. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  102962. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102963. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  102964. * * 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
  102965. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  102966. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  102967. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  102968. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  102969. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102970. * * 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)
  102971. * * 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)
  102972. * @returns the VertexData of the cylinder, cone or prism
  102973. */
  102974. static CreateCylinder(options: {
  102975. height?: number;
  102976. diameterTop?: number;
  102977. diameterBottom?: number;
  102978. diameter?: number;
  102979. tessellation?: number;
  102980. subdivisions?: number;
  102981. arc?: number;
  102982. faceColors?: Color4[];
  102983. faceUV?: Vector4[];
  102984. hasRings?: boolean;
  102985. enclose?: boolean;
  102986. sideOrientation?: number;
  102987. frontUVs?: Vector4;
  102988. backUVs?: Vector4;
  102989. }): VertexData;
  102990. /**
  102991. * Creates the VertexData for a torus
  102992. * @param options an object used to set the following optional parameters for the box, required but can be empty
  102993. * * diameter the diameter of the torus, optional default 1
  102994. * * thickness the diameter of the tube forming the torus, optional default 0.5
  102995. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  102996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  102997. * * 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)
  102998. * * 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)
  102999. * @returns the VertexData of the torus
  103000. */
  103001. static CreateTorus(options: {
  103002. diameter?: number;
  103003. thickness?: number;
  103004. tessellation?: number;
  103005. sideOrientation?: number;
  103006. frontUVs?: Vector4;
  103007. backUVs?: Vector4;
  103008. }): VertexData;
  103009. /**
  103010. * Creates the VertexData of the LineSystem
  103011. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103012. * - lines an array of lines, each line being an array of successive Vector3
  103013. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103014. * @returns the VertexData of the LineSystem
  103015. */
  103016. static CreateLineSystem(options: {
  103017. lines: Vector3[][];
  103018. colors?: Nullable<Color4[][]>;
  103019. }): VertexData;
  103020. /**
  103021. * Create the VertexData for a DashedLines
  103022. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103023. * - points an array successive Vector3
  103024. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103025. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103026. * - dashNb the intended total number of dashes, optional, default 200
  103027. * @returns the VertexData for the DashedLines
  103028. */
  103029. static CreateDashedLines(options: {
  103030. points: Vector3[];
  103031. dashSize?: number;
  103032. gapSize?: number;
  103033. dashNb?: number;
  103034. }): VertexData;
  103035. /**
  103036. * Creates the VertexData for a Ground
  103037. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103038. * - width the width (x direction) of the ground, optional, default 1
  103039. * - height the height (z direction) of the ground, optional, default 1
  103040. * - subdivisions the number of subdivisions per side, optional, default 1
  103041. * @returns the VertexData of the Ground
  103042. */
  103043. static CreateGround(options: {
  103044. width?: number;
  103045. height?: number;
  103046. subdivisions?: number;
  103047. subdivisionsX?: number;
  103048. subdivisionsY?: number;
  103049. }): VertexData;
  103050. /**
  103051. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103052. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103053. * * xmin the ground minimum X coordinate, optional, default -1
  103054. * * zmin the ground minimum Z coordinate, optional, default -1
  103055. * * xmax the ground maximum X coordinate, optional, default 1
  103056. * * zmax the ground maximum Z coordinate, optional, default 1
  103057. * * 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}
  103058. * * 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}
  103059. * @returns the VertexData of the TiledGround
  103060. */
  103061. static CreateTiledGround(options: {
  103062. xmin: number;
  103063. zmin: number;
  103064. xmax: number;
  103065. zmax: number;
  103066. subdivisions?: {
  103067. w: number;
  103068. h: number;
  103069. };
  103070. precision?: {
  103071. w: number;
  103072. h: number;
  103073. };
  103074. }): VertexData;
  103075. /**
  103076. * Creates the VertexData of the Ground designed from a heightmap
  103077. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103078. * * width the width (x direction) of the ground
  103079. * * height the height (z direction) of the ground
  103080. * * subdivisions the number of subdivisions per side
  103081. * * minHeight the minimum altitude on the ground, optional, default 0
  103082. * * maxHeight the maximum altitude on the ground, optional default 1
  103083. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103084. * * buffer the array holding the image color data
  103085. * * bufferWidth the width of image
  103086. * * bufferHeight the height of image
  103087. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103088. * @returns the VertexData of the Ground designed from a heightmap
  103089. */
  103090. static CreateGroundFromHeightMap(options: {
  103091. width: number;
  103092. height: number;
  103093. subdivisions: number;
  103094. minHeight: number;
  103095. maxHeight: number;
  103096. colorFilter: Color3;
  103097. buffer: Uint8Array;
  103098. bufferWidth: number;
  103099. bufferHeight: number;
  103100. alphaFilter: number;
  103101. }): VertexData;
  103102. /**
  103103. * Creates the VertexData for a Plane
  103104. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103105. * * size sets the width and height of the plane to the value of size, optional default 1
  103106. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103107. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103108. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103109. * * 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)
  103110. * * 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)
  103111. * @returns the VertexData of the box
  103112. */
  103113. static CreatePlane(options: {
  103114. size?: number;
  103115. width?: number;
  103116. height?: number;
  103117. sideOrientation?: number;
  103118. frontUVs?: Vector4;
  103119. backUVs?: Vector4;
  103120. }): VertexData;
  103121. /**
  103122. * Creates the VertexData of the Disc or regular Polygon
  103123. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103124. * * radius the radius of the disc, optional default 0.5
  103125. * * tessellation the number of polygon sides, optional, default 64
  103126. * * 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
  103127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103128. * * 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)
  103129. * * 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)
  103130. * @returns the VertexData of the box
  103131. */
  103132. static CreateDisc(options: {
  103133. radius?: number;
  103134. tessellation?: number;
  103135. arc?: number;
  103136. sideOrientation?: number;
  103137. frontUVs?: Vector4;
  103138. backUVs?: Vector4;
  103139. }): VertexData;
  103140. /**
  103141. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103142. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103143. * @param polygon a mesh built from polygonTriangulation.build()
  103144. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103145. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103146. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103147. * @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)
  103148. * @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)
  103149. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103150. * @returns the VertexData of the Polygon
  103151. */
  103152. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103153. /**
  103154. * Creates the VertexData of the IcoSphere
  103155. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103156. * * radius the radius of the IcoSphere, optional default 1
  103157. * * radiusX allows stretching in the x direction, optional, default radius
  103158. * * radiusY allows stretching in the y direction, optional, default radius
  103159. * * radiusZ allows stretching in the z direction, optional, default radius
  103160. * * flat when true creates a flat shaded mesh, optional, default true
  103161. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103163. * * 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)
  103164. * * 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)
  103165. * @returns the VertexData of the IcoSphere
  103166. */
  103167. static CreateIcoSphere(options: {
  103168. radius?: number;
  103169. radiusX?: number;
  103170. radiusY?: number;
  103171. radiusZ?: number;
  103172. flat?: boolean;
  103173. subdivisions?: number;
  103174. sideOrientation?: number;
  103175. frontUVs?: Vector4;
  103176. backUVs?: Vector4;
  103177. }): VertexData;
  103178. /**
  103179. * Creates the VertexData for a Polyhedron
  103180. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103181. * * type provided types are:
  103182. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103183. * * 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)
  103184. * * size the size of the IcoSphere, optional default 1
  103185. * * sizeX allows stretching in the x direction, optional, default size
  103186. * * sizeY allows stretching in the y direction, optional, default size
  103187. * * sizeZ allows stretching in the z direction, optional, default size
  103188. * * 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
  103189. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103190. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103191. * * flat when true creates a flat shaded mesh, optional, default true
  103192. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103194. * * 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)
  103195. * * 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)
  103196. * @returns the VertexData of the Polyhedron
  103197. */
  103198. static CreatePolyhedron(options: {
  103199. type?: number;
  103200. size?: number;
  103201. sizeX?: number;
  103202. sizeY?: number;
  103203. sizeZ?: number;
  103204. custom?: any;
  103205. faceUV?: Vector4[];
  103206. faceColors?: Color4[];
  103207. flat?: boolean;
  103208. sideOrientation?: number;
  103209. frontUVs?: Vector4;
  103210. backUVs?: Vector4;
  103211. }): VertexData;
  103212. /**
  103213. * Creates the VertexData for a TorusKnot
  103214. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103215. * * radius the radius of the torus knot, optional, default 2
  103216. * * tube the thickness of the tube, optional, default 0.5
  103217. * * radialSegments the number of sides on each tube segments, optional, default 32
  103218. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103219. * * p the number of windings around the z axis, optional, default 2
  103220. * * q the number of windings around the x axis, optional, default 3
  103221. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103222. * * 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)
  103223. * * 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)
  103224. * @returns the VertexData of the Torus Knot
  103225. */
  103226. static CreateTorusKnot(options: {
  103227. radius?: number;
  103228. tube?: number;
  103229. radialSegments?: number;
  103230. tubularSegments?: number;
  103231. p?: number;
  103232. q?: number;
  103233. sideOrientation?: number;
  103234. frontUVs?: Vector4;
  103235. backUVs?: Vector4;
  103236. }): VertexData;
  103237. /**
  103238. * Compute normals for given positions and indices
  103239. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103240. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103241. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103242. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103243. * * facetNormals : optional array of facet normals (vector3)
  103244. * * facetPositions : optional array of facet positions (vector3)
  103245. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103246. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103247. * * bInfo : optional bounding info, required for facetPartitioning computation
  103248. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103249. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103250. * * useRightHandedSystem: optional boolean to for right handed system computation
  103251. * * depthSort : optional boolean to enable the facet depth sort computation
  103252. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103253. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103254. */
  103255. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103256. facetNormals?: any;
  103257. facetPositions?: any;
  103258. facetPartitioning?: any;
  103259. ratio?: number;
  103260. bInfo?: any;
  103261. bbSize?: Vector3;
  103262. subDiv?: any;
  103263. useRightHandedSystem?: boolean;
  103264. depthSort?: boolean;
  103265. distanceTo?: Vector3;
  103266. depthSortedFacets?: any;
  103267. }): void;
  103268. /** @hidden */
  103269. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  103270. /**
  103271. * Applies VertexData created from the imported parameters to the geometry
  103272. * @param parsedVertexData the parsed data from an imported file
  103273. * @param geometry the geometry to apply the VertexData to
  103274. */
  103275. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  103276. }
  103277. }
  103278. declare module BABYLON {
  103279. /**
  103280. * Defines a target to use with MorphTargetManager
  103281. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103282. */
  103283. export class MorphTarget implements IAnimatable {
  103284. /** defines the name of the target */
  103285. name: string;
  103286. /**
  103287. * Gets or sets the list of animations
  103288. */
  103289. animations: Animation[];
  103290. private _scene;
  103291. private _positions;
  103292. private _normals;
  103293. private _tangents;
  103294. private _uvs;
  103295. private _influence;
  103296. private _uniqueId;
  103297. /**
  103298. * Observable raised when the influence changes
  103299. */
  103300. onInfluenceChanged: Observable<boolean>;
  103301. /** @hidden */
  103302. _onDataLayoutChanged: Observable<void>;
  103303. /**
  103304. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  103305. */
  103306. get influence(): number;
  103307. set influence(influence: number);
  103308. /**
  103309. * Gets or sets the id of the morph Target
  103310. */
  103311. id: string;
  103312. private _animationPropertiesOverride;
  103313. /**
  103314. * Gets or sets the animation properties override
  103315. */
  103316. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103317. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103318. /**
  103319. * Creates a new MorphTarget
  103320. * @param name defines the name of the target
  103321. * @param influence defines the influence to use
  103322. * @param scene defines the scene the morphtarget belongs to
  103323. */
  103324. constructor(
  103325. /** defines the name of the target */
  103326. name: string, influence?: number, scene?: Nullable<Scene>);
  103327. /**
  103328. * Gets the unique ID of this manager
  103329. */
  103330. get uniqueId(): number;
  103331. /**
  103332. * Gets a boolean defining if the target contains position data
  103333. */
  103334. get hasPositions(): boolean;
  103335. /**
  103336. * Gets a boolean defining if the target contains normal data
  103337. */
  103338. get hasNormals(): boolean;
  103339. /**
  103340. * Gets a boolean defining if the target contains tangent data
  103341. */
  103342. get hasTangents(): boolean;
  103343. /**
  103344. * Gets a boolean defining if the target contains texture coordinates data
  103345. */
  103346. get hasUVs(): boolean;
  103347. /**
  103348. * Affects position data to this target
  103349. * @param data defines the position data to use
  103350. */
  103351. setPositions(data: Nullable<FloatArray>): void;
  103352. /**
  103353. * Gets the position data stored in this target
  103354. * @returns a FloatArray containing the position data (or null if not present)
  103355. */
  103356. getPositions(): Nullable<FloatArray>;
  103357. /**
  103358. * Affects normal data to this target
  103359. * @param data defines the normal data to use
  103360. */
  103361. setNormals(data: Nullable<FloatArray>): void;
  103362. /**
  103363. * Gets the normal data stored in this target
  103364. * @returns a FloatArray containing the normal data (or null if not present)
  103365. */
  103366. getNormals(): Nullable<FloatArray>;
  103367. /**
  103368. * Affects tangent data to this target
  103369. * @param data defines the tangent data to use
  103370. */
  103371. setTangents(data: Nullable<FloatArray>): void;
  103372. /**
  103373. * Gets the tangent data stored in this target
  103374. * @returns a FloatArray containing the tangent data (or null if not present)
  103375. */
  103376. getTangents(): Nullable<FloatArray>;
  103377. /**
  103378. * Affects texture coordinates data to this target
  103379. * @param data defines the texture coordinates data to use
  103380. */
  103381. setUVs(data: Nullable<FloatArray>): void;
  103382. /**
  103383. * Gets the texture coordinates data stored in this target
  103384. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  103385. */
  103386. getUVs(): Nullable<FloatArray>;
  103387. /**
  103388. * Clone the current target
  103389. * @returns a new MorphTarget
  103390. */
  103391. clone(): MorphTarget;
  103392. /**
  103393. * Serializes the current target into a Serialization object
  103394. * @returns the serialized object
  103395. */
  103396. serialize(): any;
  103397. /**
  103398. * Returns the string "MorphTarget"
  103399. * @returns "MorphTarget"
  103400. */
  103401. getClassName(): string;
  103402. /**
  103403. * Creates a new target from serialized data
  103404. * @param serializationObject defines the serialized data to use
  103405. * @returns a new MorphTarget
  103406. */
  103407. static Parse(serializationObject: any): MorphTarget;
  103408. /**
  103409. * Creates a MorphTarget from mesh data
  103410. * @param mesh defines the source mesh
  103411. * @param name defines the name to use for the new target
  103412. * @param influence defines the influence to attach to the target
  103413. * @returns a new MorphTarget
  103414. */
  103415. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  103416. }
  103417. }
  103418. declare module BABYLON {
  103419. /**
  103420. * This class is used to deform meshes using morphing between different targets
  103421. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  103422. */
  103423. export class MorphTargetManager {
  103424. private _targets;
  103425. private _targetInfluenceChangedObservers;
  103426. private _targetDataLayoutChangedObservers;
  103427. private _activeTargets;
  103428. private _scene;
  103429. private _influences;
  103430. private _supportsNormals;
  103431. private _supportsTangents;
  103432. private _supportsUVs;
  103433. private _vertexCount;
  103434. private _uniqueId;
  103435. private _tempInfluences;
  103436. /**
  103437. * Gets or sets a boolean indicating if normals must be morphed
  103438. */
  103439. enableNormalMorphing: boolean;
  103440. /**
  103441. * Gets or sets a boolean indicating if tangents must be morphed
  103442. */
  103443. enableTangentMorphing: boolean;
  103444. /**
  103445. * Gets or sets a boolean indicating if UV must be morphed
  103446. */
  103447. enableUVMorphing: boolean;
  103448. /**
  103449. * Creates a new MorphTargetManager
  103450. * @param scene defines the current scene
  103451. */
  103452. constructor(scene?: Nullable<Scene>);
  103453. /**
  103454. * Gets the unique ID of this manager
  103455. */
  103456. get uniqueId(): number;
  103457. /**
  103458. * Gets the number of vertices handled by this manager
  103459. */
  103460. get vertexCount(): number;
  103461. /**
  103462. * Gets a boolean indicating if this manager supports morphing of normals
  103463. */
  103464. get supportsNormals(): boolean;
  103465. /**
  103466. * Gets a boolean indicating if this manager supports morphing of tangents
  103467. */
  103468. get supportsTangents(): boolean;
  103469. /**
  103470. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  103471. */
  103472. get supportsUVs(): boolean;
  103473. /**
  103474. * Gets the number of targets stored in this manager
  103475. */
  103476. get numTargets(): number;
  103477. /**
  103478. * Gets the number of influencers (ie. the number of targets with influences > 0)
  103479. */
  103480. get numInfluencers(): number;
  103481. /**
  103482. * Gets the list of influences (one per target)
  103483. */
  103484. get influences(): Float32Array;
  103485. /**
  103486. * Gets the active target at specified index. An active target is a target with an influence > 0
  103487. * @param index defines the index to check
  103488. * @returns the requested target
  103489. */
  103490. getActiveTarget(index: number): MorphTarget;
  103491. /**
  103492. * Gets the target at specified index
  103493. * @param index defines the index to check
  103494. * @returns the requested target
  103495. */
  103496. getTarget(index: number): MorphTarget;
  103497. /**
  103498. * Add a new target to this manager
  103499. * @param target defines the target to add
  103500. */
  103501. addTarget(target: MorphTarget): void;
  103502. /**
  103503. * Removes a target from the manager
  103504. * @param target defines the target to remove
  103505. */
  103506. removeTarget(target: MorphTarget): void;
  103507. /**
  103508. * Clone the current manager
  103509. * @returns a new MorphTargetManager
  103510. */
  103511. clone(): MorphTargetManager;
  103512. /**
  103513. * Serializes the current manager into a Serialization object
  103514. * @returns the serialized object
  103515. */
  103516. serialize(): any;
  103517. private _syncActiveTargets;
  103518. /**
  103519. * Syncrhonize the targets with all the meshes using this morph target manager
  103520. */
  103521. synchronize(): void;
  103522. /**
  103523. * Creates a new MorphTargetManager from serialized data
  103524. * @param serializationObject defines the serialized data
  103525. * @param scene defines the hosting scene
  103526. * @returns the new MorphTargetManager
  103527. */
  103528. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  103529. }
  103530. }
  103531. declare module BABYLON {
  103532. /**
  103533. * Class used to represent a specific level of detail of a mesh
  103534. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  103535. */
  103536. export class MeshLODLevel {
  103537. /** Defines the distance where this level should start being displayed */
  103538. distance: number;
  103539. /** Defines the mesh to use to render this level */
  103540. mesh: Nullable<Mesh>;
  103541. /**
  103542. * Creates a new LOD level
  103543. * @param distance defines the distance where this level should star being displayed
  103544. * @param mesh defines the mesh to use to render this level
  103545. */
  103546. constructor(
  103547. /** Defines the distance where this level should start being displayed */
  103548. distance: number,
  103549. /** Defines the mesh to use to render this level */
  103550. mesh: Nullable<Mesh>);
  103551. }
  103552. }
  103553. declare module BABYLON {
  103554. /**
  103555. * Helper class used to generate a canvas to manipulate images
  103556. */
  103557. export class CanvasGenerator {
  103558. /**
  103559. * Create a new canvas (or offscreen canvas depending on the context)
  103560. * @param width defines the expected width
  103561. * @param height defines the expected height
  103562. * @return a new canvas or offscreen canvas
  103563. */
  103564. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  103565. }
  103566. }
  103567. declare module BABYLON {
  103568. /**
  103569. * Mesh representing the gorund
  103570. */
  103571. export class GroundMesh extends Mesh {
  103572. /** If octree should be generated */
  103573. generateOctree: boolean;
  103574. private _heightQuads;
  103575. /** @hidden */
  103576. _subdivisionsX: number;
  103577. /** @hidden */
  103578. _subdivisionsY: number;
  103579. /** @hidden */
  103580. _width: number;
  103581. /** @hidden */
  103582. _height: number;
  103583. /** @hidden */
  103584. _minX: number;
  103585. /** @hidden */
  103586. _maxX: number;
  103587. /** @hidden */
  103588. _minZ: number;
  103589. /** @hidden */
  103590. _maxZ: number;
  103591. constructor(name: string, scene: Scene);
  103592. /**
  103593. * "GroundMesh"
  103594. * @returns "GroundMesh"
  103595. */
  103596. getClassName(): string;
  103597. /**
  103598. * The minimum of x and y subdivisions
  103599. */
  103600. get subdivisions(): number;
  103601. /**
  103602. * X subdivisions
  103603. */
  103604. get subdivisionsX(): number;
  103605. /**
  103606. * Y subdivisions
  103607. */
  103608. get subdivisionsY(): number;
  103609. /**
  103610. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  103611. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103612. * @param chunksCount the number of subdivisions for x and y
  103613. * @param octreeBlocksSize (Default: 32)
  103614. */
  103615. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  103616. /**
  103617. * Returns a height (y) value in the Worl system :
  103618. * the ground altitude at the coordinates (x, z) expressed in the World system.
  103619. * @param x x coordinate
  103620. * @param z z coordinate
  103621. * @returns the ground y position if (x, z) are outside the ground surface.
  103622. */
  103623. getHeightAtCoordinates(x: number, z: number): number;
  103624. /**
  103625. * Returns a normalized vector (Vector3) orthogonal to the ground
  103626. * at the ground coordinates (x, z) expressed in the World system.
  103627. * @param x x coordinate
  103628. * @param z z coordinate
  103629. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  103630. */
  103631. getNormalAtCoordinates(x: number, z: number): Vector3;
  103632. /**
  103633. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  103634. * at the ground coordinates (x, z) expressed in the World system.
  103635. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  103636. * @param x x coordinate
  103637. * @param z z coordinate
  103638. * @param ref vector to store the result
  103639. * @returns the GroundMesh.
  103640. */
  103641. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  103642. /**
  103643. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  103644. * if the ground has been updated.
  103645. * This can be used in the render loop.
  103646. * @returns the GroundMesh.
  103647. */
  103648. updateCoordinateHeights(): GroundMesh;
  103649. private _getFacetAt;
  103650. private _initHeightQuads;
  103651. private _computeHeightQuads;
  103652. /**
  103653. * Serializes this ground mesh
  103654. * @param serializationObject object to write serialization to
  103655. */
  103656. serialize(serializationObject: any): void;
  103657. /**
  103658. * Parses a serialized ground mesh
  103659. * @param parsedMesh the serialized mesh
  103660. * @param scene the scene to create the ground mesh in
  103661. * @returns the created ground mesh
  103662. */
  103663. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  103664. }
  103665. }
  103666. declare module BABYLON {
  103667. /**
  103668. * Interface for Physics-Joint data
  103669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103670. */
  103671. export interface PhysicsJointData {
  103672. /**
  103673. * The main pivot of the joint
  103674. */
  103675. mainPivot?: Vector3;
  103676. /**
  103677. * The connected pivot of the joint
  103678. */
  103679. connectedPivot?: Vector3;
  103680. /**
  103681. * The main axis of the joint
  103682. */
  103683. mainAxis?: Vector3;
  103684. /**
  103685. * The connected axis of the joint
  103686. */
  103687. connectedAxis?: Vector3;
  103688. /**
  103689. * The collision of the joint
  103690. */
  103691. collision?: boolean;
  103692. /**
  103693. * Native Oimo/Cannon/Energy data
  103694. */
  103695. nativeParams?: any;
  103696. }
  103697. /**
  103698. * This is a holder class for the physics joint created by the physics plugin
  103699. * It holds a set of functions to control the underlying joint
  103700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103701. */
  103702. export class PhysicsJoint {
  103703. /**
  103704. * The type of the physics joint
  103705. */
  103706. type: number;
  103707. /**
  103708. * The data for the physics joint
  103709. */
  103710. jointData: PhysicsJointData;
  103711. private _physicsJoint;
  103712. protected _physicsPlugin: IPhysicsEnginePlugin;
  103713. /**
  103714. * Initializes the physics joint
  103715. * @param type The type of the physics joint
  103716. * @param jointData The data for the physics joint
  103717. */
  103718. constructor(
  103719. /**
  103720. * The type of the physics joint
  103721. */
  103722. type: number,
  103723. /**
  103724. * The data for the physics joint
  103725. */
  103726. jointData: PhysicsJointData);
  103727. /**
  103728. * Gets the physics joint
  103729. */
  103730. get physicsJoint(): any;
  103731. /**
  103732. * Sets the physics joint
  103733. */
  103734. set physicsJoint(newJoint: any);
  103735. /**
  103736. * Sets the physics plugin
  103737. */
  103738. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  103739. /**
  103740. * Execute a function that is physics-plugin specific.
  103741. * @param {Function} func the function that will be executed.
  103742. * It accepts two parameters: the physics world and the physics joint
  103743. */
  103744. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  103745. /**
  103746. * Distance-Joint type
  103747. */
  103748. static DistanceJoint: number;
  103749. /**
  103750. * Hinge-Joint type
  103751. */
  103752. static HingeJoint: number;
  103753. /**
  103754. * Ball-and-Socket joint type
  103755. */
  103756. static BallAndSocketJoint: number;
  103757. /**
  103758. * Wheel-Joint type
  103759. */
  103760. static WheelJoint: number;
  103761. /**
  103762. * Slider-Joint type
  103763. */
  103764. static SliderJoint: number;
  103765. /**
  103766. * Prismatic-Joint type
  103767. */
  103768. static PrismaticJoint: number;
  103769. /**
  103770. * Universal-Joint type
  103771. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  103772. */
  103773. static UniversalJoint: number;
  103774. /**
  103775. * Hinge-Joint 2 type
  103776. */
  103777. static Hinge2Joint: number;
  103778. /**
  103779. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  103780. */
  103781. static PointToPointJoint: number;
  103782. /**
  103783. * Spring-Joint type
  103784. */
  103785. static SpringJoint: number;
  103786. /**
  103787. * Lock-Joint type
  103788. */
  103789. static LockJoint: number;
  103790. }
  103791. /**
  103792. * A class representing a physics distance joint
  103793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103794. */
  103795. export class DistanceJoint extends PhysicsJoint {
  103796. /**
  103797. *
  103798. * @param jointData The data for the Distance-Joint
  103799. */
  103800. constructor(jointData: DistanceJointData);
  103801. /**
  103802. * Update the predefined distance.
  103803. * @param maxDistance The maximum preferred distance
  103804. * @param minDistance The minimum preferred distance
  103805. */
  103806. updateDistance(maxDistance: number, minDistance?: number): void;
  103807. }
  103808. /**
  103809. * Represents a Motor-Enabled Joint
  103810. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103811. */
  103812. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  103813. /**
  103814. * Initializes the Motor-Enabled Joint
  103815. * @param type The type of the joint
  103816. * @param jointData The physica joint data for the joint
  103817. */
  103818. constructor(type: number, jointData: PhysicsJointData);
  103819. /**
  103820. * Set the motor values.
  103821. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103822. * @param force the force to apply
  103823. * @param maxForce max force for this motor.
  103824. */
  103825. setMotor(force?: number, maxForce?: number): void;
  103826. /**
  103827. * Set the motor's limits.
  103828. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103829. * @param upperLimit The upper limit of the motor
  103830. * @param lowerLimit The lower limit of the motor
  103831. */
  103832. setLimit(upperLimit: number, lowerLimit?: number): void;
  103833. }
  103834. /**
  103835. * This class represents a single physics Hinge-Joint
  103836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103837. */
  103838. export class HingeJoint extends MotorEnabledJoint {
  103839. /**
  103840. * Initializes the Hinge-Joint
  103841. * @param jointData The joint data for the Hinge-Joint
  103842. */
  103843. constructor(jointData: PhysicsJointData);
  103844. /**
  103845. * Set the motor values.
  103846. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103847. * @param {number} force the force to apply
  103848. * @param {number} maxForce max force for this motor.
  103849. */
  103850. setMotor(force?: number, maxForce?: number): void;
  103851. /**
  103852. * Set the motor's limits.
  103853. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103854. * @param upperLimit The upper limit of the motor
  103855. * @param lowerLimit The lower limit of the motor
  103856. */
  103857. setLimit(upperLimit: number, lowerLimit?: number): void;
  103858. }
  103859. /**
  103860. * This class represents a dual hinge physics joint (same as wheel joint)
  103861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103862. */
  103863. export class Hinge2Joint extends MotorEnabledJoint {
  103864. /**
  103865. * Initializes the Hinge2-Joint
  103866. * @param jointData The joint data for the Hinge2-Joint
  103867. */
  103868. constructor(jointData: PhysicsJointData);
  103869. /**
  103870. * Set the motor values.
  103871. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103872. * @param {number} targetSpeed the speed the motor is to reach
  103873. * @param {number} maxForce max force for this motor.
  103874. * @param {motorIndex} the motor's index, 0 or 1.
  103875. */
  103876. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  103877. /**
  103878. * Set the motor limits.
  103879. * Attention, this function is plugin specific. Engines won't react 100% the same.
  103880. * @param {number} upperLimit the upper limit
  103881. * @param {number} lowerLimit lower limit
  103882. * @param {motorIndex} the motor's index, 0 or 1.
  103883. */
  103884. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103885. }
  103886. /**
  103887. * Interface for a motor enabled joint
  103888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103889. */
  103890. export interface IMotorEnabledJoint {
  103891. /**
  103892. * Physics joint
  103893. */
  103894. physicsJoint: any;
  103895. /**
  103896. * Sets the motor of the motor-enabled joint
  103897. * @param force The force of the motor
  103898. * @param maxForce The maximum force of the motor
  103899. * @param motorIndex The index of the motor
  103900. */
  103901. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  103902. /**
  103903. * Sets the limit of the motor
  103904. * @param upperLimit The upper limit of the motor
  103905. * @param lowerLimit The lower limit of the motor
  103906. * @param motorIndex The index of the motor
  103907. */
  103908. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  103909. }
  103910. /**
  103911. * Joint data for a Distance-Joint
  103912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103913. */
  103914. export interface DistanceJointData extends PhysicsJointData {
  103915. /**
  103916. * Max distance the 2 joint objects can be apart
  103917. */
  103918. maxDistance: number;
  103919. }
  103920. /**
  103921. * Joint data from a spring joint
  103922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103923. */
  103924. export interface SpringJointData extends PhysicsJointData {
  103925. /**
  103926. * Length of the spring
  103927. */
  103928. length: number;
  103929. /**
  103930. * Stiffness of the spring
  103931. */
  103932. stiffness: number;
  103933. /**
  103934. * Damping of the spring
  103935. */
  103936. damping: number;
  103937. /** this callback will be called when applying the force to the impostors. */
  103938. forceApplicationCallback: () => void;
  103939. }
  103940. }
  103941. declare module BABYLON {
  103942. /**
  103943. * Holds the data for the raycast result
  103944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  103945. */
  103946. export class PhysicsRaycastResult {
  103947. private _hasHit;
  103948. private _hitDistance;
  103949. private _hitNormalWorld;
  103950. private _hitPointWorld;
  103951. private _rayFromWorld;
  103952. private _rayToWorld;
  103953. /**
  103954. * Gets if there was a hit
  103955. */
  103956. get hasHit(): boolean;
  103957. /**
  103958. * Gets the distance from the hit
  103959. */
  103960. get hitDistance(): number;
  103961. /**
  103962. * Gets the hit normal/direction in the world
  103963. */
  103964. get hitNormalWorld(): Vector3;
  103965. /**
  103966. * Gets the hit point in the world
  103967. */
  103968. get hitPointWorld(): Vector3;
  103969. /**
  103970. * Gets the ray "start point" of the ray in the world
  103971. */
  103972. get rayFromWorld(): Vector3;
  103973. /**
  103974. * Gets the ray "end point" of the ray in the world
  103975. */
  103976. get rayToWorld(): Vector3;
  103977. /**
  103978. * Sets the hit data (normal & point in world space)
  103979. * @param hitNormalWorld defines the normal in world space
  103980. * @param hitPointWorld defines the point in world space
  103981. */
  103982. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  103983. /**
  103984. * Sets the distance from the start point to the hit point
  103985. * @param distance
  103986. */
  103987. setHitDistance(distance: number): void;
  103988. /**
  103989. * Calculates the distance manually
  103990. */
  103991. calculateHitDistance(): void;
  103992. /**
  103993. * Resets all the values to default
  103994. * @param from The from point on world space
  103995. * @param to The to point on world space
  103996. */
  103997. reset(from?: Vector3, to?: Vector3): void;
  103998. }
  103999. /**
  104000. * Interface for the size containing width and height
  104001. */
  104002. interface IXYZ {
  104003. /**
  104004. * X
  104005. */
  104006. x: number;
  104007. /**
  104008. * Y
  104009. */
  104010. y: number;
  104011. /**
  104012. * Z
  104013. */
  104014. z: number;
  104015. }
  104016. }
  104017. declare module BABYLON {
  104018. /**
  104019. * Interface used to describe a physics joint
  104020. */
  104021. export interface PhysicsImpostorJoint {
  104022. /** Defines the main impostor to which the joint is linked */
  104023. mainImpostor: PhysicsImpostor;
  104024. /** Defines the impostor that is connected to the main impostor using this joint */
  104025. connectedImpostor: PhysicsImpostor;
  104026. /** Defines the joint itself */
  104027. joint: PhysicsJoint;
  104028. }
  104029. /** @hidden */
  104030. export interface IPhysicsEnginePlugin {
  104031. world: any;
  104032. name: string;
  104033. setGravity(gravity: Vector3): void;
  104034. setTimeStep(timeStep: number): void;
  104035. getTimeStep(): number;
  104036. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104037. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104038. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104039. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104040. removePhysicsBody(impostor: PhysicsImpostor): void;
  104041. generateJoint(joint: PhysicsImpostorJoint): void;
  104042. removeJoint(joint: PhysicsImpostorJoint): void;
  104043. isSupported(): boolean;
  104044. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104045. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104046. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104047. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104048. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104049. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104050. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104051. getBodyMass(impostor: PhysicsImpostor): number;
  104052. getBodyFriction(impostor: PhysicsImpostor): number;
  104053. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104054. getBodyRestitution(impostor: PhysicsImpostor): number;
  104055. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104056. getBodyPressure?(impostor: PhysicsImpostor): number;
  104057. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104058. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104059. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104060. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104061. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104062. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104063. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104064. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104065. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104066. sleepBody(impostor: PhysicsImpostor): void;
  104067. wakeUpBody(impostor: PhysicsImpostor): void;
  104068. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104069. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104070. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104071. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104072. getRadius(impostor: PhysicsImpostor): number;
  104073. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104074. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104075. dispose(): void;
  104076. }
  104077. /**
  104078. * Interface used to define a physics engine
  104079. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104080. */
  104081. export interface IPhysicsEngine {
  104082. /**
  104083. * Gets the gravity vector used by the simulation
  104084. */
  104085. gravity: Vector3;
  104086. /**
  104087. * Sets the gravity vector used by the simulation
  104088. * @param gravity defines the gravity vector to use
  104089. */
  104090. setGravity(gravity: Vector3): void;
  104091. /**
  104092. * Set the time step of the physics engine.
  104093. * Default is 1/60.
  104094. * To slow it down, enter 1/600 for example.
  104095. * To speed it up, 1/30
  104096. * @param newTimeStep the new timestep to apply to this world.
  104097. */
  104098. setTimeStep(newTimeStep: number): void;
  104099. /**
  104100. * Get the time step of the physics engine.
  104101. * @returns the current time step
  104102. */
  104103. getTimeStep(): number;
  104104. /**
  104105. * Set the sub time step of the physics engine.
  104106. * Default is 0 meaning there is no sub steps
  104107. * To increase physics resolution precision, set a small value (like 1 ms)
  104108. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104109. */
  104110. setSubTimeStep(subTimeStep: number): void;
  104111. /**
  104112. * Get the sub time step of the physics engine.
  104113. * @returns the current sub time step
  104114. */
  104115. getSubTimeStep(): number;
  104116. /**
  104117. * Release all resources
  104118. */
  104119. dispose(): void;
  104120. /**
  104121. * Gets the name of the current physics plugin
  104122. * @returns the name of the plugin
  104123. */
  104124. getPhysicsPluginName(): string;
  104125. /**
  104126. * Adding a new impostor for the impostor tracking.
  104127. * This will be done by the impostor itself.
  104128. * @param impostor the impostor to add
  104129. */
  104130. addImpostor(impostor: PhysicsImpostor): void;
  104131. /**
  104132. * Remove an impostor from the engine.
  104133. * This impostor and its mesh will not longer be updated by the physics engine.
  104134. * @param impostor the impostor to remove
  104135. */
  104136. removeImpostor(impostor: PhysicsImpostor): void;
  104137. /**
  104138. * Add a joint to the physics engine
  104139. * @param mainImpostor defines the main impostor to which the joint is added.
  104140. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104141. * @param joint defines the joint that will connect both impostors.
  104142. */
  104143. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104144. /**
  104145. * Removes a joint from the simulation
  104146. * @param mainImpostor defines the impostor used with the joint
  104147. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104148. * @param joint defines the joint to remove
  104149. */
  104150. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104151. /**
  104152. * Gets the current plugin used to run the simulation
  104153. * @returns current plugin
  104154. */
  104155. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104156. /**
  104157. * Gets the list of physic impostors
  104158. * @returns an array of PhysicsImpostor
  104159. */
  104160. getImpostors(): Array<PhysicsImpostor>;
  104161. /**
  104162. * Gets the impostor for a physics enabled object
  104163. * @param object defines the object impersonated by the impostor
  104164. * @returns the PhysicsImpostor or null if not found
  104165. */
  104166. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104167. /**
  104168. * Gets the impostor for a physics body object
  104169. * @param body defines physics body used by the impostor
  104170. * @returns the PhysicsImpostor or null if not found
  104171. */
  104172. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104173. /**
  104174. * Does a raycast in the physics world
  104175. * @param from when should the ray start?
  104176. * @param to when should the ray end?
  104177. * @returns PhysicsRaycastResult
  104178. */
  104179. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104180. /**
  104181. * Called by the scene. No need to call it.
  104182. * @param delta defines the timespam between frames
  104183. */
  104184. _step(delta: number): void;
  104185. }
  104186. }
  104187. declare module BABYLON {
  104188. /**
  104189. * The interface for the physics imposter parameters
  104190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104191. */
  104192. export interface PhysicsImpostorParameters {
  104193. /**
  104194. * The mass of the physics imposter
  104195. */
  104196. mass: number;
  104197. /**
  104198. * The friction of the physics imposter
  104199. */
  104200. friction?: number;
  104201. /**
  104202. * The coefficient of restitution of the physics imposter
  104203. */
  104204. restitution?: number;
  104205. /**
  104206. * The native options of the physics imposter
  104207. */
  104208. nativeOptions?: any;
  104209. /**
  104210. * Specifies if the parent should be ignored
  104211. */
  104212. ignoreParent?: boolean;
  104213. /**
  104214. * Specifies if bi-directional transformations should be disabled
  104215. */
  104216. disableBidirectionalTransformation?: boolean;
  104217. /**
  104218. * The pressure inside the physics imposter, soft object only
  104219. */
  104220. pressure?: number;
  104221. /**
  104222. * The stiffness the physics imposter, soft object only
  104223. */
  104224. stiffness?: number;
  104225. /**
  104226. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104227. */
  104228. velocityIterations?: number;
  104229. /**
  104230. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104231. */
  104232. positionIterations?: number;
  104233. /**
  104234. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104235. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104236. * Add to fix multiple points
  104237. */
  104238. fixedPoints?: number;
  104239. /**
  104240. * The collision margin around a soft object
  104241. */
  104242. margin?: number;
  104243. /**
  104244. * The collision margin around a soft object
  104245. */
  104246. damping?: number;
  104247. /**
  104248. * The path for a rope based on an extrusion
  104249. */
  104250. path?: any;
  104251. /**
  104252. * The shape of an extrusion used for a rope based on an extrusion
  104253. */
  104254. shape?: any;
  104255. }
  104256. /**
  104257. * Interface for a physics-enabled object
  104258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104259. */
  104260. export interface IPhysicsEnabledObject {
  104261. /**
  104262. * The position of the physics-enabled object
  104263. */
  104264. position: Vector3;
  104265. /**
  104266. * The rotation of the physics-enabled object
  104267. */
  104268. rotationQuaternion: Nullable<Quaternion>;
  104269. /**
  104270. * The scale of the physics-enabled object
  104271. */
  104272. scaling: Vector3;
  104273. /**
  104274. * The rotation of the physics-enabled object
  104275. */
  104276. rotation?: Vector3;
  104277. /**
  104278. * The parent of the physics-enabled object
  104279. */
  104280. parent?: any;
  104281. /**
  104282. * The bounding info of the physics-enabled object
  104283. * @returns The bounding info of the physics-enabled object
  104284. */
  104285. getBoundingInfo(): BoundingInfo;
  104286. /**
  104287. * Computes the world matrix
  104288. * @param force Specifies if the world matrix should be computed by force
  104289. * @returns A world matrix
  104290. */
  104291. computeWorldMatrix(force: boolean): Matrix;
  104292. /**
  104293. * Gets the world matrix
  104294. * @returns A world matrix
  104295. */
  104296. getWorldMatrix?(): Matrix;
  104297. /**
  104298. * Gets the child meshes
  104299. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  104300. * @returns An array of abstract meshes
  104301. */
  104302. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  104303. /**
  104304. * Gets the vertex data
  104305. * @param kind The type of vertex data
  104306. * @returns A nullable array of numbers, or a float32 array
  104307. */
  104308. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  104309. /**
  104310. * Gets the indices from the mesh
  104311. * @returns A nullable array of index arrays
  104312. */
  104313. getIndices?(): Nullable<IndicesArray>;
  104314. /**
  104315. * Gets the scene from the mesh
  104316. * @returns the indices array or null
  104317. */
  104318. getScene?(): Scene;
  104319. /**
  104320. * Gets the absolute position from the mesh
  104321. * @returns the absolute position
  104322. */
  104323. getAbsolutePosition(): Vector3;
  104324. /**
  104325. * Gets the absolute pivot point from the mesh
  104326. * @returns the absolute pivot point
  104327. */
  104328. getAbsolutePivotPoint(): Vector3;
  104329. /**
  104330. * Rotates the mesh
  104331. * @param axis The axis of rotation
  104332. * @param amount The amount of rotation
  104333. * @param space The space of the rotation
  104334. * @returns The rotation transform node
  104335. */
  104336. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  104337. /**
  104338. * Translates the mesh
  104339. * @param axis The axis of translation
  104340. * @param distance The distance of translation
  104341. * @param space The space of the translation
  104342. * @returns The transform node
  104343. */
  104344. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  104345. /**
  104346. * Sets the absolute position of the mesh
  104347. * @param absolutePosition The absolute position of the mesh
  104348. * @returns The transform node
  104349. */
  104350. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  104351. /**
  104352. * Gets the class name of the mesh
  104353. * @returns The class name
  104354. */
  104355. getClassName(): string;
  104356. }
  104357. /**
  104358. * Represents a physics imposter
  104359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104360. */
  104361. export class PhysicsImpostor {
  104362. /**
  104363. * The physics-enabled object used as the physics imposter
  104364. */
  104365. object: IPhysicsEnabledObject;
  104366. /**
  104367. * The type of the physics imposter
  104368. */
  104369. type: number;
  104370. private _options;
  104371. private _scene?;
  104372. /**
  104373. * The default object size of the imposter
  104374. */
  104375. static DEFAULT_OBJECT_SIZE: Vector3;
  104376. /**
  104377. * The identity quaternion of the imposter
  104378. */
  104379. static IDENTITY_QUATERNION: Quaternion;
  104380. /** @hidden */
  104381. _pluginData: any;
  104382. private _physicsEngine;
  104383. private _physicsBody;
  104384. private _bodyUpdateRequired;
  104385. private _onBeforePhysicsStepCallbacks;
  104386. private _onAfterPhysicsStepCallbacks;
  104387. /** @hidden */
  104388. _onPhysicsCollideCallbacks: Array<{
  104389. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  104390. otherImpostors: Array<PhysicsImpostor>;
  104391. }>;
  104392. private _deltaPosition;
  104393. private _deltaRotation;
  104394. private _deltaRotationConjugated;
  104395. /** @hidden */
  104396. _isFromLine: boolean;
  104397. private _parent;
  104398. private _isDisposed;
  104399. private static _tmpVecs;
  104400. private static _tmpQuat;
  104401. /**
  104402. * Specifies if the physics imposter is disposed
  104403. */
  104404. get isDisposed(): boolean;
  104405. /**
  104406. * Gets the mass of the physics imposter
  104407. */
  104408. get mass(): number;
  104409. set mass(value: number);
  104410. /**
  104411. * Gets the coefficient of friction
  104412. */
  104413. get friction(): number;
  104414. /**
  104415. * Sets the coefficient of friction
  104416. */
  104417. set friction(value: number);
  104418. /**
  104419. * Gets the coefficient of restitution
  104420. */
  104421. get restitution(): number;
  104422. /**
  104423. * Sets the coefficient of restitution
  104424. */
  104425. set restitution(value: number);
  104426. /**
  104427. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  104428. */
  104429. get pressure(): number;
  104430. /**
  104431. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  104432. */
  104433. set pressure(value: number);
  104434. /**
  104435. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104436. */
  104437. get stiffness(): number;
  104438. /**
  104439. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  104440. */
  104441. set stiffness(value: number);
  104442. /**
  104443. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104444. */
  104445. get velocityIterations(): number;
  104446. /**
  104447. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  104448. */
  104449. set velocityIterations(value: number);
  104450. /**
  104451. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104452. */
  104453. get positionIterations(): number;
  104454. /**
  104455. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  104456. */
  104457. set positionIterations(value: number);
  104458. /**
  104459. * The unique id of the physics imposter
  104460. * set by the physics engine when adding this impostor to the array
  104461. */
  104462. uniqueId: number;
  104463. /**
  104464. * @hidden
  104465. */
  104466. soft: boolean;
  104467. /**
  104468. * @hidden
  104469. */
  104470. segments: number;
  104471. private _joints;
  104472. /**
  104473. * Initializes the physics imposter
  104474. * @param object The physics-enabled object used as the physics imposter
  104475. * @param type The type of the physics imposter
  104476. * @param _options The options for the physics imposter
  104477. * @param _scene The Babylon scene
  104478. */
  104479. constructor(
  104480. /**
  104481. * The physics-enabled object used as the physics imposter
  104482. */
  104483. object: IPhysicsEnabledObject,
  104484. /**
  104485. * The type of the physics imposter
  104486. */
  104487. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  104488. /**
  104489. * This function will completly initialize this impostor.
  104490. * It will create a new body - but only if this mesh has no parent.
  104491. * If it has, this impostor will not be used other than to define the impostor
  104492. * of the child mesh.
  104493. * @hidden
  104494. */
  104495. _init(): void;
  104496. private _getPhysicsParent;
  104497. /**
  104498. * Should a new body be generated.
  104499. * @returns boolean specifying if body initialization is required
  104500. */
  104501. isBodyInitRequired(): boolean;
  104502. /**
  104503. * Sets the updated scaling
  104504. * @param updated Specifies if the scaling is updated
  104505. */
  104506. setScalingUpdated(): void;
  104507. /**
  104508. * Force a regeneration of this or the parent's impostor's body.
  104509. * Use under cautious - This will remove all joints already implemented.
  104510. */
  104511. forceUpdate(): void;
  104512. /**
  104513. * Gets the body that holds this impostor. Either its own, or its parent.
  104514. */
  104515. get physicsBody(): any;
  104516. /**
  104517. * Get the parent of the physics imposter
  104518. * @returns Physics imposter or null
  104519. */
  104520. get parent(): Nullable<PhysicsImpostor>;
  104521. /**
  104522. * Sets the parent of the physics imposter
  104523. */
  104524. set parent(value: Nullable<PhysicsImpostor>);
  104525. /**
  104526. * Set the physics body. Used mainly by the physics engine/plugin
  104527. */
  104528. set physicsBody(physicsBody: any);
  104529. /**
  104530. * Resets the update flags
  104531. */
  104532. resetUpdateFlags(): void;
  104533. /**
  104534. * Gets the object extend size
  104535. * @returns the object extend size
  104536. */
  104537. getObjectExtendSize(): Vector3;
  104538. /**
  104539. * Gets the object center
  104540. * @returns The object center
  104541. */
  104542. getObjectCenter(): Vector3;
  104543. /**
  104544. * Get a specific parameter from the options parameters
  104545. * @param paramName The object parameter name
  104546. * @returns The object parameter
  104547. */
  104548. getParam(paramName: string): any;
  104549. /**
  104550. * Sets a specific parameter in the options given to the physics plugin
  104551. * @param paramName The parameter name
  104552. * @param value The value of the parameter
  104553. */
  104554. setParam(paramName: string, value: number): void;
  104555. /**
  104556. * Specifically change the body's mass option. Won't recreate the physics body object
  104557. * @param mass The mass of the physics imposter
  104558. */
  104559. setMass(mass: number): void;
  104560. /**
  104561. * Gets the linear velocity
  104562. * @returns linear velocity or null
  104563. */
  104564. getLinearVelocity(): Nullable<Vector3>;
  104565. /**
  104566. * Sets the linear velocity
  104567. * @param velocity linear velocity or null
  104568. */
  104569. setLinearVelocity(velocity: Nullable<Vector3>): void;
  104570. /**
  104571. * Gets the angular velocity
  104572. * @returns angular velocity or null
  104573. */
  104574. getAngularVelocity(): Nullable<Vector3>;
  104575. /**
  104576. * Sets the angular velocity
  104577. * @param velocity The velocity or null
  104578. */
  104579. setAngularVelocity(velocity: Nullable<Vector3>): void;
  104580. /**
  104581. * Execute a function with the physics plugin native code
  104582. * Provide a function the will have two variables - the world object and the physics body object
  104583. * @param func The function to execute with the physics plugin native code
  104584. */
  104585. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  104586. /**
  104587. * Register a function that will be executed before the physics world is stepping forward
  104588. * @param func The function to execute before the physics world is stepped forward
  104589. */
  104590. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104591. /**
  104592. * Unregister a function that will be executed before the physics world is stepping forward
  104593. * @param func The function to execute before the physics world is stepped forward
  104594. */
  104595. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104596. /**
  104597. * Register a function that will be executed after the physics step
  104598. * @param func The function to execute after physics step
  104599. */
  104600. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104601. /**
  104602. * Unregisters a function that will be executed after the physics step
  104603. * @param func The function to execute after physics step
  104604. */
  104605. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  104606. /**
  104607. * register a function that will be executed when this impostor collides against a different body
  104608. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  104609. * @param func Callback that is executed on collision
  104610. */
  104611. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  104612. /**
  104613. * Unregisters the physics imposter on contact
  104614. * @param collideAgainst The physics object to collide against
  104615. * @param func Callback to execute on collision
  104616. */
  104617. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  104618. private _tmpQuat;
  104619. private _tmpQuat2;
  104620. /**
  104621. * Get the parent rotation
  104622. * @returns The parent rotation
  104623. */
  104624. getParentsRotation(): Quaternion;
  104625. /**
  104626. * this function is executed by the physics engine.
  104627. */
  104628. beforeStep: () => void;
  104629. /**
  104630. * this function is executed by the physics engine
  104631. */
  104632. afterStep: () => void;
  104633. /**
  104634. * Legacy collision detection event support
  104635. */
  104636. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  104637. /**
  104638. * event and body object due to cannon's event-based architecture.
  104639. */
  104640. onCollide: (e: {
  104641. body: any;
  104642. }) => void;
  104643. /**
  104644. * Apply a force
  104645. * @param force The force to apply
  104646. * @param contactPoint The contact point for the force
  104647. * @returns The physics imposter
  104648. */
  104649. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104650. /**
  104651. * Apply an impulse
  104652. * @param force The impulse force
  104653. * @param contactPoint The contact point for the impulse force
  104654. * @returns The physics imposter
  104655. */
  104656. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  104657. /**
  104658. * A help function to create a joint
  104659. * @param otherImpostor A physics imposter used to create a joint
  104660. * @param jointType The type of joint
  104661. * @param jointData The data for the joint
  104662. * @returns The physics imposter
  104663. */
  104664. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  104665. /**
  104666. * Add a joint to this impostor with a different impostor
  104667. * @param otherImpostor A physics imposter used to add a joint
  104668. * @param joint The joint to add
  104669. * @returns The physics imposter
  104670. */
  104671. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  104672. /**
  104673. * Add an anchor to a cloth impostor
  104674. * @param otherImpostor rigid impostor to anchor to
  104675. * @param width ratio across width from 0 to 1
  104676. * @param height ratio up height from 0 to 1
  104677. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  104678. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  104679. * @returns impostor the soft imposter
  104680. */
  104681. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104682. /**
  104683. * Add a hook to a rope impostor
  104684. * @param otherImpostor rigid impostor to anchor to
  104685. * @param length ratio across rope from 0 to 1
  104686. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  104687. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  104688. * @returns impostor the rope imposter
  104689. */
  104690. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  104691. /**
  104692. * Will keep this body still, in a sleep mode.
  104693. * @returns the physics imposter
  104694. */
  104695. sleep(): PhysicsImpostor;
  104696. /**
  104697. * Wake the body up.
  104698. * @returns The physics imposter
  104699. */
  104700. wakeUp(): PhysicsImpostor;
  104701. /**
  104702. * Clones the physics imposter
  104703. * @param newObject The physics imposter clones to this physics-enabled object
  104704. * @returns A nullable physics imposter
  104705. */
  104706. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104707. /**
  104708. * Disposes the physics imposter
  104709. */
  104710. dispose(): void;
  104711. /**
  104712. * Sets the delta position
  104713. * @param position The delta position amount
  104714. */
  104715. setDeltaPosition(position: Vector3): void;
  104716. /**
  104717. * Sets the delta rotation
  104718. * @param rotation The delta rotation amount
  104719. */
  104720. setDeltaRotation(rotation: Quaternion): void;
  104721. /**
  104722. * Gets the box size of the physics imposter and stores the result in the input parameter
  104723. * @param result Stores the box size
  104724. * @returns The physics imposter
  104725. */
  104726. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  104727. /**
  104728. * Gets the radius of the physics imposter
  104729. * @returns Radius of the physics imposter
  104730. */
  104731. getRadius(): number;
  104732. /**
  104733. * Sync a bone with this impostor
  104734. * @param bone The bone to sync to the impostor.
  104735. * @param boneMesh The mesh that the bone is influencing.
  104736. * @param jointPivot The pivot of the joint / bone in local space.
  104737. * @param distToJoint Optional distance from the impostor to the joint.
  104738. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104739. */
  104740. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  104741. /**
  104742. * Sync impostor to a bone
  104743. * @param bone The bone that the impostor will be synced to.
  104744. * @param boneMesh The mesh that the bone is influencing.
  104745. * @param jointPivot The pivot of the joint / bone in local space.
  104746. * @param distToJoint Optional distance from the impostor to the joint.
  104747. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  104748. * @param boneAxis Optional vector3 axis the bone is aligned with
  104749. */
  104750. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  104751. /**
  104752. * No-Imposter type
  104753. */
  104754. static NoImpostor: number;
  104755. /**
  104756. * Sphere-Imposter type
  104757. */
  104758. static SphereImpostor: number;
  104759. /**
  104760. * Box-Imposter type
  104761. */
  104762. static BoxImpostor: number;
  104763. /**
  104764. * Plane-Imposter type
  104765. */
  104766. static PlaneImpostor: number;
  104767. /**
  104768. * Mesh-imposter type
  104769. */
  104770. static MeshImpostor: number;
  104771. /**
  104772. * Capsule-Impostor type (Ammo.js plugin only)
  104773. */
  104774. static CapsuleImpostor: number;
  104775. /**
  104776. * Cylinder-Imposter type
  104777. */
  104778. static CylinderImpostor: number;
  104779. /**
  104780. * Particle-Imposter type
  104781. */
  104782. static ParticleImpostor: number;
  104783. /**
  104784. * Heightmap-Imposter type
  104785. */
  104786. static HeightmapImpostor: number;
  104787. /**
  104788. * ConvexHull-Impostor type (Ammo.js plugin only)
  104789. */
  104790. static ConvexHullImpostor: number;
  104791. /**
  104792. * Custom-Imposter type (Ammo.js plugin only)
  104793. */
  104794. static CustomImpostor: number;
  104795. /**
  104796. * Rope-Imposter type
  104797. */
  104798. static RopeImpostor: number;
  104799. /**
  104800. * Cloth-Imposter type
  104801. */
  104802. static ClothImpostor: number;
  104803. /**
  104804. * Softbody-Imposter type
  104805. */
  104806. static SoftbodyImpostor: number;
  104807. }
  104808. }
  104809. declare module BABYLON {
  104810. /**
  104811. * @hidden
  104812. **/
  104813. export class _CreationDataStorage {
  104814. closePath?: boolean;
  104815. closeArray?: boolean;
  104816. idx: number[];
  104817. dashSize: number;
  104818. gapSize: number;
  104819. path3D: Path3D;
  104820. pathArray: Vector3[][];
  104821. arc: number;
  104822. radius: number;
  104823. cap: number;
  104824. tessellation: number;
  104825. }
  104826. /**
  104827. * @hidden
  104828. **/
  104829. class _InstanceDataStorage {
  104830. visibleInstances: any;
  104831. batchCache: _InstancesBatch;
  104832. instancesBufferSize: number;
  104833. instancesBuffer: Nullable<Buffer>;
  104834. instancesData: Float32Array;
  104835. overridenInstanceCount: number;
  104836. isFrozen: boolean;
  104837. previousBatch: Nullable<_InstancesBatch>;
  104838. hardwareInstancedRendering: boolean;
  104839. sideOrientation: number;
  104840. manualUpdate: boolean;
  104841. }
  104842. /**
  104843. * @hidden
  104844. **/
  104845. export class _InstancesBatch {
  104846. mustReturn: boolean;
  104847. visibleInstances: Nullable<InstancedMesh[]>[];
  104848. renderSelf: boolean[];
  104849. hardwareInstancedRendering: boolean[];
  104850. }
  104851. /**
  104852. * @hidden
  104853. **/
  104854. class _ThinInstanceDataStorage {
  104855. instancesCount: number;
  104856. matrixBuffer: Nullable<Buffer>;
  104857. matrixBufferSize: number;
  104858. matrixData: Nullable<Float32Array>;
  104859. boundingVectors: Array<Vector3>;
  104860. }
  104861. /**
  104862. * Class used to represent renderable models
  104863. */
  104864. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  104865. /**
  104866. * Mesh side orientation : usually the external or front surface
  104867. */
  104868. static readonly FRONTSIDE: number;
  104869. /**
  104870. * Mesh side orientation : usually the internal or back surface
  104871. */
  104872. static readonly BACKSIDE: number;
  104873. /**
  104874. * Mesh side orientation : both internal and external or front and back surfaces
  104875. */
  104876. static readonly DOUBLESIDE: number;
  104877. /**
  104878. * Mesh side orientation : by default, `FRONTSIDE`
  104879. */
  104880. static readonly DEFAULTSIDE: number;
  104881. /**
  104882. * Mesh cap setting : no cap
  104883. */
  104884. static readonly NO_CAP: number;
  104885. /**
  104886. * Mesh cap setting : one cap at the beginning of the mesh
  104887. */
  104888. static readonly CAP_START: number;
  104889. /**
  104890. * Mesh cap setting : one cap at the end of the mesh
  104891. */
  104892. static readonly CAP_END: number;
  104893. /**
  104894. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  104895. */
  104896. static readonly CAP_ALL: number;
  104897. /**
  104898. * Mesh pattern setting : no flip or rotate
  104899. */
  104900. static readonly NO_FLIP: number;
  104901. /**
  104902. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  104903. */
  104904. static readonly FLIP_TILE: number;
  104905. /**
  104906. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  104907. */
  104908. static readonly ROTATE_TILE: number;
  104909. /**
  104910. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  104911. */
  104912. static readonly FLIP_ROW: number;
  104913. /**
  104914. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  104915. */
  104916. static readonly ROTATE_ROW: number;
  104917. /**
  104918. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  104919. */
  104920. static readonly FLIP_N_ROTATE_TILE: number;
  104921. /**
  104922. * Mesh pattern setting : rotate pattern and rotate
  104923. */
  104924. static readonly FLIP_N_ROTATE_ROW: number;
  104925. /**
  104926. * Mesh tile positioning : part tiles same on left/right or top/bottom
  104927. */
  104928. static readonly CENTER: number;
  104929. /**
  104930. * Mesh tile positioning : part tiles on left
  104931. */
  104932. static readonly LEFT: number;
  104933. /**
  104934. * Mesh tile positioning : part tiles on right
  104935. */
  104936. static readonly RIGHT: number;
  104937. /**
  104938. * Mesh tile positioning : part tiles on top
  104939. */
  104940. static readonly TOP: number;
  104941. /**
  104942. * Mesh tile positioning : part tiles on bottom
  104943. */
  104944. static readonly BOTTOM: number;
  104945. /**
  104946. * Gets the default side orientation.
  104947. * @param orientation the orientation to value to attempt to get
  104948. * @returns the default orientation
  104949. * @hidden
  104950. */
  104951. static _GetDefaultSideOrientation(orientation?: number): number;
  104952. private _internalMeshDataInfo;
  104953. /**
  104954. * An event triggered before rendering the mesh
  104955. */
  104956. get onBeforeRenderObservable(): Observable<Mesh>;
  104957. /**
  104958. * An event triggered before binding the mesh
  104959. */
  104960. get onBeforeBindObservable(): Observable<Mesh>;
  104961. /**
  104962. * An event triggered after rendering the mesh
  104963. */
  104964. get onAfterRenderObservable(): Observable<Mesh>;
  104965. /**
  104966. * An event triggered before drawing the mesh
  104967. */
  104968. get onBeforeDrawObservable(): Observable<Mesh>;
  104969. private _onBeforeDrawObserver;
  104970. /**
  104971. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  104972. */
  104973. set onBeforeDraw(callback: () => void);
  104974. get hasInstances(): boolean;
  104975. get hasThinInstances(): boolean;
  104976. /**
  104977. * Gets the delay loading state of the mesh (when delay loading is turned on)
  104978. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  104979. */
  104980. delayLoadState: number;
  104981. /**
  104982. * Gets the list of instances created from this mesh
  104983. * it is not supposed to be modified manually.
  104984. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  104985. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  104986. */
  104987. instances: InstancedMesh[];
  104988. /**
  104989. * Gets the file containing delay loading data for this mesh
  104990. */
  104991. delayLoadingFile: string;
  104992. /** @hidden */
  104993. _binaryInfo: any;
  104994. /**
  104995. * User defined function used to change how LOD level selection is done
  104996. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  104997. */
  104998. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  104999. /**
  105000. * Gets or sets the morph target manager
  105001. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105002. */
  105003. get morphTargetManager(): Nullable<MorphTargetManager>;
  105004. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105005. /** @hidden */
  105006. _creationDataStorage: Nullable<_CreationDataStorage>;
  105007. /** @hidden */
  105008. _geometry: Nullable<Geometry>;
  105009. /** @hidden */
  105010. _delayInfo: Array<string>;
  105011. /** @hidden */
  105012. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105013. /** @hidden */
  105014. _instanceDataStorage: _InstanceDataStorage;
  105015. /** @hidden */
  105016. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105017. private _effectiveMaterial;
  105018. /** @hidden */
  105019. _shouldGenerateFlatShading: boolean;
  105020. /** @hidden */
  105021. _originalBuilderSideOrientation: number;
  105022. /**
  105023. * Use this property to change the original side orientation defined at construction time
  105024. */
  105025. overrideMaterialSideOrientation: Nullable<number>;
  105026. /**
  105027. * Gets the source mesh (the one used to clone this one from)
  105028. */
  105029. get source(): Nullable<Mesh>;
  105030. /**
  105031. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105032. */
  105033. get isUnIndexed(): boolean;
  105034. set isUnIndexed(value: boolean);
  105035. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105036. get worldMatrixInstancedBuffer(): Float32Array;
  105037. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105038. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105039. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105040. /**
  105041. * @constructor
  105042. * @param name The value used by scene.getMeshByName() to do a lookup.
  105043. * @param scene The scene to add this mesh to.
  105044. * @param parent The parent of this mesh, if it has one
  105045. * @param source An optional Mesh from which geometry is shared, cloned.
  105046. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105047. * When false, achieved by calling a clone(), also passing False.
  105048. * This will make creation of children, recursive.
  105049. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105050. */
  105051. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105052. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105053. doNotInstantiate: boolean;
  105054. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105055. /**
  105056. * Gets the class name
  105057. * @returns the string "Mesh".
  105058. */
  105059. getClassName(): string;
  105060. /** @hidden */
  105061. get _isMesh(): boolean;
  105062. /**
  105063. * Returns a description of this mesh
  105064. * @param fullDetails define if full details about this mesh must be used
  105065. * @returns a descriptive string representing this mesh
  105066. */
  105067. toString(fullDetails?: boolean): string;
  105068. /** @hidden */
  105069. _unBindEffect(): void;
  105070. /**
  105071. * Gets a boolean indicating if this mesh has LOD
  105072. */
  105073. get hasLODLevels(): boolean;
  105074. /**
  105075. * Gets the list of MeshLODLevel associated with the current mesh
  105076. * @returns an array of MeshLODLevel
  105077. */
  105078. getLODLevels(): MeshLODLevel[];
  105079. private _sortLODLevels;
  105080. /**
  105081. * Add a mesh as LOD level triggered at the given distance.
  105082. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105083. * @param distance The distance from the center of the object to show this level
  105084. * @param mesh The mesh to be added as LOD level (can be null)
  105085. * @return This mesh (for chaining)
  105086. */
  105087. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105088. /**
  105089. * Returns the LOD level mesh at the passed distance or null if not found.
  105090. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105091. * @param distance The distance from the center of the object to show this level
  105092. * @returns a Mesh or `null`
  105093. */
  105094. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105095. /**
  105096. * Remove a mesh from the LOD array
  105097. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105098. * @param mesh defines the mesh to be removed
  105099. * @return This mesh (for chaining)
  105100. */
  105101. removeLODLevel(mesh: Mesh): Mesh;
  105102. /**
  105103. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105104. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105105. * @param camera defines the camera to use to compute distance
  105106. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105107. * @return This mesh (for chaining)
  105108. */
  105109. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105110. /**
  105111. * Gets the mesh internal Geometry object
  105112. */
  105113. get geometry(): Nullable<Geometry>;
  105114. /**
  105115. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105116. * @returns the total number of vertices
  105117. */
  105118. getTotalVertices(): number;
  105119. /**
  105120. * Returns the content of an associated vertex buffer
  105121. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105122. * - VertexBuffer.PositionKind
  105123. * - VertexBuffer.UVKind
  105124. * - VertexBuffer.UV2Kind
  105125. * - VertexBuffer.UV3Kind
  105126. * - VertexBuffer.UV4Kind
  105127. * - VertexBuffer.UV5Kind
  105128. * - VertexBuffer.UV6Kind
  105129. * - VertexBuffer.ColorKind
  105130. * - VertexBuffer.MatricesIndicesKind
  105131. * - VertexBuffer.MatricesIndicesExtraKind
  105132. * - VertexBuffer.MatricesWeightsKind
  105133. * - VertexBuffer.MatricesWeightsExtraKind
  105134. * @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
  105135. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105136. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105137. */
  105138. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105139. /**
  105140. * Returns the mesh VertexBuffer object from the requested `kind`
  105141. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105142. * - VertexBuffer.PositionKind
  105143. * - VertexBuffer.NormalKind
  105144. * - VertexBuffer.UVKind
  105145. * - VertexBuffer.UV2Kind
  105146. * - VertexBuffer.UV3Kind
  105147. * - VertexBuffer.UV4Kind
  105148. * - VertexBuffer.UV5Kind
  105149. * - VertexBuffer.UV6Kind
  105150. * - VertexBuffer.ColorKind
  105151. * - VertexBuffer.MatricesIndicesKind
  105152. * - VertexBuffer.MatricesIndicesExtraKind
  105153. * - VertexBuffer.MatricesWeightsKind
  105154. * - VertexBuffer.MatricesWeightsExtraKind
  105155. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105156. */
  105157. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105158. /**
  105159. * Tests if a specific vertex buffer is associated with this mesh
  105160. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105161. * - VertexBuffer.PositionKind
  105162. * - VertexBuffer.NormalKind
  105163. * - VertexBuffer.UVKind
  105164. * - VertexBuffer.UV2Kind
  105165. * - VertexBuffer.UV3Kind
  105166. * - VertexBuffer.UV4Kind
  105167. * - VertexBuffer.UV5Kind
  105168. * - VertexBuffer.UV6Kind
  105169. * - VertexBuffer.ColorKind
  105170. * - VertexBuffer.MatricesIndicesKind
  105171. * - VertexBuffer.MatricesIndicesExtraKind
  105172. * - VertexBuffer.MatricesWeightsKind
  105173. * - VertexBuffer.MatricesWeightsExtraKind
  105174. * @returns a boolean
  105175. */
  105176. isVerticesDataPresent(kind: string): boolean;
  105177. /**
  105178. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105179. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105180. * - VertexBuffer.PositionKind
  105181. * - VertexBuffer.UVKind
  105182. * - VertexBuffer.UV2Kind
  105183. * - VertexBuffer.UV3Kind
  105184. * - VertexBuffer.UV4Kind
  105185. * - VertexBuffer.UV5Kind
  105186. * - VertexBuffer.UV6Kind
  105187. * - VertexBuffer.ColorKind
  105188. * - VertexBuffer.MatricesIndicesKind
  105189. * - VertexBuffer.MatricesIndicesExtraKind
  105190. * - VertexBuffer.MatricesWeightsKind
  105191. * - VertexBuffer.MatricesWeightsExtraKind
  105192. * @returns a boolean
  105193. */
  105194. isVertexBufferUpdatable(kind: string): boolean;
  105195. /**
  105196. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105197. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105198. * - VertexBuffer.PositionKind
  105199. * - VertexBuffer.NormalKind
  105200. * - VertexBuffer.UVKind
  105201. * - VertexBuffer.UV2Kind
  105202. * - VertexBuffer.UV3Kind
  105203. * - VertexBuffer.UV4Kind
  105204. * - VertexBuffer.UV5Kind
  105205. * - VertexBuffer.UV6Kind
  105206. * - VertexBuffer.ColorKind
  105207. * - VertexBuffer.MatricesIndicesKind
  105208. * - VertexBuffer.MatricesIndicesExtraKind
  105209. * - VertexBuffer.MatricesWeightsKind
  105210. * - VertexBuffer.MatricesWeightsExtraKind
  105211. * @returns an array of strings
  105212. */
  105213. getVerticesDataKinds(): string[];
  105214. /**
  105215. * Returns a positive integer : the total number of indices in this mesh geometry.
  105216. * @returns the numner of indices or zero if the mesh has no geometry.
  105217. */
  105218. getTotalIndices(): number;
  105219. /**
  105220. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105221. * @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.
  105222. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105223. * @returns the indices array or an empty array if the mesh has no geometry
  105224. */
  105225. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105226. get isBlocked(): boolean;
  105227. /**
  105228. * Determine if the current mesh is ready to be rendered
  105229. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105230. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105231. * @returns true if all associated assets are ready (material, textures, shaders)
  105232. */
  105233. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105234. /**
  105235. * 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.
  105236. */
  105237. get areNormalsFrozen(): boolean;
  105238. /**
  105239. * 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.
  105240. * @returns the current mesh
  105241. */
  105242. freezeNormals(): Mesh;
  105243. /**
  105244. * 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
  105245. * @returns the current mesh
  105246. */
  105247. unfreezeNormals(): Mesh;
  105248. /**
  105249. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105250. */
  105251. set overridenInstanceCount(count: number);
  105252. /** @hidden */
  105253. _preActivate(): Mesh;
  105254. /** @hidden */
  105255. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105256. /** @hidden */
  105257. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105258. protected _afterComputeWorldMatrix(): void;
  105259. /** @hidden */
  105260. _postActivate(): void;
  105261. /**
  105262. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  105263. * This means the mesh underlying bounding box and sphere are recomputed.
  105264. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  105265. * @returns the current mesh
  105266. */
  105267. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  105268. /** @hidden */
  105269. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  105270. /**
  105271. * This function will subdivide the mesh into multiple submeshes
  105272. * @param count defines the expected number of submeshes
  105273. */
  105274. subdivide(count: number): void;
  105275. /**
  105276. * Copy a FloatArray into a specific associated vertex buffer
  105277. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105278. * - VertexBuffer.PositionKind
  105279. * - VertexBuffer.UVKind
  105280. * - VertexBuffer.UV2Kind
  105281. * - VertexBuffer.UV3Kind
  105282. * - VertexBuffer.UV4Kind
  105283. * - VertexBuffer.UV5Kind
  105284. * - VertexBuffer.UV6Kind
  105285. * - VertexBuffer.ColorKind
  105286. * - VertexBuffer.MatricesIndicesKind
  105287. * - VertexBuffer.MatricesIndicesExtraKind
  105288. * - VertexBuffer.MatricesWeightsKind
  105289. * - VertexBuffer.MatricesWeightsExtraKind
  105290. * @param data defines the data source
  105291. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105292. * @param stride defines the data stride size (can be null)
  105293. * @returns the current mesh
  105294. */
  105295. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  105296. /**
  105297. * Delete a vertex buffer associated with this mesh
  105298. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  105299. * - VertexBuffer.PositionKind
  105300. * - VertexBuffer.UVKind
  105301. * - VertexBuffer.UV2Kind
  105302. * - VertexBuffer.UV3Kind
  105303. * - VertexBuffer.UV4Kind
  105304. * - VertexBuffer.UV5Kind
  105305. * - VertexBuffer.UV6Kind
  105306. * - VertexBuffer.ColorKind
  105307. * - VertexBuffer.MatricesIndicesKind
  105308. * - VertexBuffer.MatricesIndicesExtraKind
  105309. * - VertexBuffer.MatricesWeightsKind
  105310. * - VertexBuffer.MatricesWeightsExtraKind
  105311. */
  105312. removeVerticesData(kind: string): void;
  105313. /**
  105314. * Flags an associated vertex buffer as updatable
  105315. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  105316. * - VertexBuffer.PositionKind
  105317. * - VertexBuffer.UVKind
  105318. * - VertexBuffer.UV2Kind
  105319. * - VertexBuffer.UV3Kind
  105320. * - VertexBuffer.UV4Kind
  105321. * - VertexBuffer.UV5Kind
  105322. * - VertexBuffer.UV6Kind
  105323. * - VertexBuffer.ColorKind
  105324. * - VertexBuffer.MatricesIndicesKind
  105325. * - VertexBuffer.MatricesIndicesExtraKind
  105326. * - VertexBuffer.MatricesWeightsKind
  105327. * - VertexBuffer.MatricesWeightsExtraKind
  105328. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  105329. */
  105330. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  105331. /**
  105332. * Sets the mesh global Vertex Buffer
  105333. * @param buffer defines the buffer to use
  105334. * @returns the current mesh
  105335. */
  105336. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  105337. /**
  105338. * Update a specific associated vertex buffer
  105339. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  105340. * - VertexBuffer.PositionKind
  105341. * - VertexBuffer.UVKind
  105342. * - VertexBuffer.UV2Kind
  105343. * - VertexBuffer.UV3Kind
  105344. * - VertexBuffer.UV4Kind
  105345. * - VertexBuffer.UV5Kind
  105346. * - VertexBuffer.UV6Kind
  105347. * - VertexBuffer.ColorKind
  105348. * - VertexBuffer.MatricesIndicesKind
  105349. * - VertexBuffer.MatricesIndicesExtraKind
  105350. * - VertexBuffer.MatricesWeightsKind
  105351. * - VertexBuffer.MatricesWeightsExtraKind
  105352. * @param data defines the data source
  105353. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  105354. * @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)
  105355. * @returns the current mesh
  105356. */
  105357. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  105358. /**
  105359. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  105360. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  105361. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  105362. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  105363. * @returns the current mesh
  105364. */
  105365. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  105366. /**
  105367. * Creates a un-shared specific occurence of the geometry for the mesh.
  105368. * @returns the current mesh
  105369. */
  105370. makeGeometryUnique(): Mesh;
  105371. /**
  105372. * Set the index buffer of this mesh
  105373. * @param indices defines the source data
  105374. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  105375. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  105376. * @returns the current mesh
  105377. */
  105378. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  105379. /**
  105380. * Update the current index buffer
  105381. * @param indices defines the source data
  105382. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  105383. * @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)
  105384. * @returns the current mesh
  105385. */
  105386. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  105387. /**
  105388. * Invert the geometry to move from a right handed system to a left handed one.
  105389. * @returns the current mesh
  105390. */
  105391. toLeftHanded(): Mesh;
  105392. /** @hidden */
  105393. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  105394. /** @hidden */
  105395. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  105396. /**
  105397. * Registers for this mesh a javascript function called just before the rendering process
  105398. * @param func defines the function to call before rendering this mesh
  105399. * @returns the current mesh
  105400. */
  105401. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105402. /**
  105403. * Disposes a previously registered javascript function called before the rendering
  105404. * @param func defines the function to remove
  105405. * @returns the current mesh
  105406. */
  105407. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  105408. /**
  105409. * Registers for this mesh a javascript function called just after the rendering is complete
  105410. * @param func defines the function to call after rendering this mesh
  105411. * @returns the current mesh
  105412. */
  105413. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105414. /**
  105415. * Disposes a previously registered javascript function called after the rendering.
  105416. * @param func defines the function to remove
  105417. * @returns the current mesh
  105418. */
  105419. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  105420. /** @hidden */
  105421. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  105422. /** @hidden */
  105423. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  105424. /** @hidden */
  105425. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  105426. /** @hidden */
  105427. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  105428. /** @hidden */
  105429. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  105430. /** @hidden */
  105431. _rebuild(): void;
  105432. /** @hidden */
  105433. _freeze(): void;
  105434. /** @hidden */
  105435. _unFreeze(): void;
  105436. /**
  105437. * 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
  105438. * @param subMesh defines the subMesh to render
  105439. * @param enableAlphaMode defines if alpha mode can be changed
  105440. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  105441. * @returns the current mesh
  105442. */
  105443. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  105444. private _onBeforeDraw;
  105445. /**
  105446. * Renormalize the mesh and patch it up if there are no weights
  105447. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  105448. * However in the case of zero weights then we set just a single influence to 1.
  105449. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  105450. */
  105451. cleanMatrixWeights(): void;
  105452. private normalizeSkinFourWeights;
  105453. private normalizeSkinWeightsAndExtra;
  105454. /**
  105455. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  105456. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  105457. * the user know there was an issue with importing the mesh
  105458. * @returns a validation object with skinned, valid and report string
  105459. */
  105460. validateSkinning(): {
  105461. skinned: boolean;
  105462. valid: boolean;
  105463. report: string;
  105464. };
  105465. /** @hidden */
  105466. _checkDelayState(): Mesh;
  105467. private _queueLoad;
  105468. /**
  105469. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  105470. * A mesh is in the frustum if its bounding box intersects the frustum
  105471. * @param frustumPlanes defines the frustum to test
  105472. * @returns true if the mesh is in the frustum planes
  105473. */
  105474. isInFrustum(frustumPlanes: Plane[]): boolean;
  105475. /**
  105476. * Sets the mesh material by the material or multiMaterial `id` property
  105477. * @param id is a string identifying the material or the multiMaterial
  105478. * @returns the current mesh
  105479. */
  105480. setMaterialByID(id: string): Mesh;
  105481. /**
  105482. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  105483. * @returns an array of IAnimatable
  105484. */
  105485. getAnimatables(): IAnimatable[];
  105486. /**
  105487. * Modifies the mesh geometry according to the passed transformation matrix.
  105488. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  105489. * The mesh normals are modified using the same transformation.
  105490. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105491. * @param transform defines the transform matrix to use
  105492. * @see http://doc.babylonjs.com/resources/baking_transformations
  105493. * @returns the current mesh
  105494. */
  105495. bakeTransformIntoVertices(transform: Matrix): Mesh;
  105496. /**
  105497. * Modifies the mesh geometry according to its own current World Matrix.
  105498. * The mesh World Matrix is then reset.
  105499. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  105500. * Note that, under the hood, this method sets a new VertexBuffer each call.
  105501. * @see http://doc.babylonjs.com/resources/baking_transformations
  105502. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  105503. * @returns the current mesh
  105504. */
  105505. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  105506. /** @hidden */
  105507. get _positions(): Nullable<Vector3[]>;
  105508. /** @hidden */
  105509. _resetPointsArrayCache(): Mesh;
  105510. /** @hidden */
  105511. _generatePointsArray(): boolean;
  105512. /**
  105513. * Returns a new Mesh object generated from the current mesh properties.
  105514. * This method must not get confused with createInstance()
  105515. * @param name is a string, the name given to the new mesh
  105516. * @param newParent can be any Node object (default `null`)
  105517. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  105518. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  105519. * @returns a new mesh
  105520. */
  105521. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  105522. /**
  105523. * Releases resources associated with this mesh.
  105524. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105525. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105526. */
  105527. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105528. /** @hidden */
  105529. _disposeInstanceSpecificData(): void;
  105530. /** @hidden */
  105531. _disposeThinInstanceSpecificData(): void;
  105532. /**
  105533. * Modifies the mesh geometry according to a displacement map.
  105534. * 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.
  105535. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105536. * @param url is a string, the URL from the image file is to be downloaded.
  105537. * @param minHeight is the lower limit of the displacement.
  105538. * @param maxHeight is the upper limit of the displacement.
  105539. * @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.
  105540. * @param uvOffset is an optional vector2 used to offset UV.
  105541. * @param uvScale is an optional vector2 used to scale UV.
  105542. * @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.
  105543. * @returns the Mesh.
  105544. */
  105545. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105546. /**
  105547. * Modifies the mesh geometry according to a displacementMap buffer.
  105548. * 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.
  105549. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  105550. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  105551. * @param heightMapWidth is the width of the buffer image.
  105552. * @param heightMapHeight is the height of the buffer image.
  105553. * @param minHeight is the lower limit of the displacement.
  105554. * @param maxHeight is the upper limit of the displacement.
  105555. * @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.
  105556. * @param uvOffset is an optional vector2 used to offset UV.
  105557. * @param uvScale is an optional vector2 used to scale UV.
  105558. * @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.
  105559. * @returns the Mesh.
  105560. */
  105561. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  105562. /**
  105563. * Modify the mesh to get a flat shading rendering.
  105564. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  105565. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  105566. * @returns current mesh
  105567. */
  105568. convertToFlatShadedMesh(): Mesh;
  105569. /**
  105570. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  105571. * In other words, more vertices, no more indices and a single bigger VBO.
  105572. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  105573. * @returns current mesh
  105574. */
  105575. convertToUnIndexedMesh(): Mesh;
  105576. /**
  105577. * Inverses facet orientations.
  105578. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105579. * @param flipNormals will also inverts the normals
  105580. * @returns current mesh
  105581. */
  105582. flipFaces(flipNormals?: boolean): Mesh;
  105583. /**
  105584. * Increase the number of facets and hence vertices in a mesh
  105585. * Vertex normals are interpolated from existing vertex normals
  105586. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105587. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  105588. */
  105589. increaseVertices(numberPerEdge: number): void;
  105590. /**
  105591. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  105592. * This will undo any application of covertToFlatShadedMesh
  105593. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  105594. */
  105595. forceSharedVertices(): void;
  105596. /** @hidden */
  105597. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  105598. /** @hidden */
  105599. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  105600. /**
  105601. * Creates a new InstancedMesh object from the mesh model.
  105602. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  105603. * @param name defines the name of the new instance
  105604. * @returns a new InstancedMesh
  105605. */
  105606. createInstance(name: string): InstancedMesh;
  105607. /**
  105608. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  105609. * After this call, all the mesh instances have the same submeshes than the current mesh.
  105610. * @returns the current mesh
  105611. */
  105612. synchronizeInstances(): Mesh;
  105613. /**
  105614. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  105615. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  105616. * This should be used together with the simplification to avoid disappearing triangles.
  105617. * @param successCallback an optional success callback to be called after the optimization finished.
  105618. * @returns the current mesh
  105619. */
  105620. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  105621. /**
  105622. * Serialize current mesh
  105623. * @param serializationObject defines the object which will receive the serialization data
  105624. */
  105625. serialize(serializationObject: any): void;
  105626. /** @hidden */
  105627. _syncGeometryWithMorphTargetManager(): void;
  105628. /** @hidden */
  105629. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  105630. /**
  105631. * Returns a new Mesh object parsed from the source provided.
  105632. * @param parsedMesh is the source
  105633. * @param scene defines the hosting scene
  105634. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  105635. * @returns a new Mesh
  105636. */
  105637. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  105638. /**
  105639. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  105640. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105641. * @param name defines the name of the mesh to create
  105642. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  105643. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  105644. * @param closePath creates a seam between the first and the last points of each path of the path array
  105645. * @param offset is taken in account only if the `pathArray` is containing a single path
  105646. * @param scene defines the hosting scene
  105647. * @param updatable defines if the mesh must be flagged as updatable
  105648. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105649. * @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)
  105650. * @returns a new Mesh
  105651. */
  105652. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105653. /**
  105654. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  105655. * @param name defines the name of the mesh to create
  105656. * @param radius sets the radius size (float) of the polygon (default 0.5)
  105657. * @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
  105658. * @param scene defines the hosting scene
  105659. * @param updatable defines if the mesh must be flagged as updatable
  105660. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105661. * @returns a new Mesh
  105662. */
  105663. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105664. /**
  105665. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  105666. * @param name defines the name of the mesh to create
  105667. * @param size sets the size (float) of each box side (default 1)
  105668. * @param scene defines the hosting scene
  105669. * @param updatable defines if the mesh must be flagged as updatable
  105670. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105671. * @returns a new Mesh
  105672. */
  105673. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  105674. /**
  105675. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  105676. * @param name defines the name of the mesh to create
  105677. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105678. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105679. * @param scene defines the hosting scene
  105680. * @param updatable defines if the mesh must be flagged as updatable
  105681. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105682. * @returns a new Mesh
  105683. */
  105684. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105685. /**
  105686. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  105687. * @param name defines the name of the mesh to create
  105688. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  105689. * @param diameter sets the diameter size (float) of the sphere (default 1)
  105690. * @param scene defines the hosting scene
  105691. * @returns a new Mesh
  105692. */
  105693. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  105694. /**
  105695. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  105696. * @param name defines the name of the mesh to create
  105697. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  105698. * @param diameterTop set the top cap diameter (floats, default 1)
  105699. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  105700. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  105701. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  105702. * @param scene defines the hosting scene
  105703. * @param updatable defines if the mesh must be flagged as updatable
  105704. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105705. * @returns a new Mesh
  105706. */
  105707. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  105708. /**
  105709. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  105710. * @param name defines the name of the mesh to create
  105711. * @param diameter sets the diameter size (float) of the torus (default 1)
  105712. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  105713. * @param tessellation sets the number of torus sides (postive integer, default 16)
  105714. * @param scene defines the hosting scene
  105715. * @param updatable defines if the mesh must be flagged as updatable
  105716. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105717. * @returns a new Mesh
  105718. */
  105719. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105720. /**
  105721. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  105722. * @param name defines the name of the mesh to create
  105723. * @param radius sets the global radius size (float) of the torus knot (default 2)
  105724. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  105725. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  105726. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  105727. * @param p the number of windings on X axis (positive integers, default 2)
  105728. * @param q the number of windings on Y axis (positive integers, default 3)
  105729. * @param scene defines the hosting scene
  105730. * @param updatable defines if the mesh must be flagged as updatable
  105731. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105732. * @returns a new Mesh
  105733. */
  105734. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105735. /**
  105736. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  105737. * @param name defines the name of the mesh to create
  105738. * @param points is an array successive Vector3
  105739. * @param scene defines the hosting scene
  105740. * @param updatable defines if the mesh must be flagged as updatable
  105741. * @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).
  105742. * @returns a new Mesh
  105743. */
  105744. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  105745. /**
  105746. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  105747. * @param name defines the name of the mesh to create
  105748. * @param points is an array successive Vector3
  105749. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  105750. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  105751. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  105752. * @param scene defines the hosting scene
  105753. * @param updatable defines if the mesh must be flagged as updatable
  105754. * @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)
  105755. * @returns a new Mesh
  105756. */
  105757. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  105758. /**
  105759. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  105760. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  105761. * 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.
  105762. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105763. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  105764. * Remember you can only change the shape positions, not their number when updating a polygon.
  105765. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  105766. * @param name defines the name of the mesh to create
  105767. * @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
  105768. * @param scene defines the hosting scene
  105769. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105770. * @param updatable defines if the mesh must be flagged as updatable
  105771. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105772. * @param earcutInjection can be used to inject your own earcut reference
  105773. * @returns a new Mesh
  105774. */
  105775. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105776. /**
  105777. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  105778. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  105779. * @param name defines the name of the mesh to create
  105780. * @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
  105781. * @param depth defines the height of extrusion
  105782. * @param scene defines the hosting scene
  105783. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  105784. * @param updatable defines if the mesh must be flagged as updatable
  105785. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105786. * @param earcutInjection can be used to inject your own earcut reference
  105787. * @returns a new Mesh
  105788. */
  105789. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  105790. /**
  105791. * Creates an extruded shape mesh.
  105792. * 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
  105793. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105794. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105795. * @param name defines the name of the mesh to create
  105796. * @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
  105797. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105798. * @param scale is the value to scale the shape
  105799. * @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
  105800. * @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
  105801. * @param scene defines the hosting scene
  105802. * @param updatable defines if the mesh must be flagged as updatable
  105803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105804. * @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)
  105805. * @returns a new Mesh
  105806. */
  105807. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105808. /**
  105809. * Creates an custom extruded shape mesh.
  105810. * The custom extrusion is a parametric shape.
  105811. * It has no predefined shape. Its final shape will depend on the input parameters.
  105812. * Please consider using the same method from the MeshBuilder class instead
  105813. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  105814. * @param name defines the name of the mesh to create
  105815. * @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
  105816. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  105817. * @param scaleFunction is a custom Javascript function called on each path point
  105818. * @param rotationFunction is a custom Javascript function called on each path point
  105819. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  105820. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  105821. * @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
  105822. * @param scene defines the hosting scene
  105823. * @param updatable defines if the mesh must be flagged as updatable
  105824. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105825. * @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)
  105826. * @returns a new Mesh
  105827. */
  105828. 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;
  105829. /**
  105830. * Creates lathe mesh.
  105831. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  105832. * Please consider using the same method from the MeshBuilder class instead
  105833. * @param name defines the name of the mesh to create
  105834. * @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
  105835. * @param radius is the radius value of the lathe
  105836. * @param tessellation is the side number of the lathe.
  105837. * @param scene defines the hosting scene
  105838. * @param updatable defines if the mesh must be flagged as updatable
  105839. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105840. * @returns a new Mesh
  105841. */
  105842. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105843. /**
  105844. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  105845. * @param name defines the name of the mesh to create
  105846. * @param size sets the size (float) of both sides of the plane at once (default 1)
  105847. * @param scene defines the hosting scene
  105848. * @param updatable defines if the mesh must be flagged as updatable
  105849. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105850. * @returns a new Mesh
  105851. */
  105852. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  105853. /**
  105854. * Creates a ground mesh.
  105855. * Please consider using the same method from the MeshBuilder class instead
  105856. * @param name defines the name of the mesh to create
  105857. * @param width set the width of the ground
  105858. * @param height set the height of the ground
  105859. * @param subdivisions sets the number of subdivisions per side
  105860. * @param scene defines the hosting scene
  105861. * @param updatable defines if the mesh must be flagged as updatable
  105862. * @returns a new Mesh
  105863. */
  105864. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  105865. /**
  105866. * Creates a tiled ground mesh.
  105867. * Please consider using the same method from the MeshBuilder class instead
  105868. * @param name defines the name of the mesh to create
  105869. * @param xmin set the ground minimum X coordinate
  105870. * @param zmin set the ground minimum Y coordinate
  105871. * @param xmax set the ground maximum X coordinate
  105872. * @param zmax set the ground maximum Z coordinate
  105873. * @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
  105874. * @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
  105875. * @param scene defines the hosting scene
  105876. * @param updatable defines if the mesh must be flagged as updatable
  105877. * @returns a new Mesh
  105878. */
  105879. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  105880. w: number;
  105881. h: number;
  105882. }, precision: {
  105883. w: number;
  105884. h: number;
  105885. }, scene: Scene, updatable?: boolean): Mesh;
  105886. /**
  105887. * Creates a ground mesh from a height map.
  105888. * Please consider using the same method from the MeshBuilder class instead
  105889. * @see http://doc.babylonjs.com/babylon101/height_map
  105890. * @param name defines the name of the mesh to create
  105891. * @param url sets the URL of the height map image resource
  105892. * @param width set the ground width size
  105893. * @param height set the ground height size
  105894. * @param subdivisions sets the number of subdivision per side
  105895. * @param minHeight is the minimum altitude on the ground
  105896. * @param maxHeight is the maximum altitude on the ground
  105897. * @param scene defines the hosting scene
  105898. * @param updatable defines if the mesh must be flagged as updatable
  105899. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  105900. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  105901. * @returns a new Mesh
  105902. */
  105903. 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;
  105904. /**
  105905. * Creates a tube mesh.
  105906. * The tube is a parametric shape.
  105907. * It has no predefined shape. Its final shape will depend on the input parameters.
  105908. * Please consider using the same method from the MeshBuilder class instead
  105909. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  105910. * @param name defines the name of the mesh to create
  105911. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  105912. * @param radius sets the tube radius size
  105913. * @param tessellation is the number of sides on the tubular surface
  105914. * @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
  105915. * @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
  105916. * @param scene defines the hosting scene
  105917. * @param updatable defines if the mesh must be flagged as updatable
  105918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  105919. * @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)
  105920. * @returns a new Mesh
  105921. */
  105922. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  105923. (i: number, distance: number): number;
  105924. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  105925. /**
  105926. * Creates a polyhedron mesh.
  105927. * Please consider using the same method from the MeshBuilder class instead.
  105928. * * 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
  105929. * * The parameter `size` (positive float, default 1) sets the polygon size
  105930. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105931. * * 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`
  105932. * * 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
  105933. * * 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)`)
  105934. * * 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
  105935. * * 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
  105936. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105937. * * If you create a double-sided mesh, you can choose what parts of 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
  105938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105939. * @param name defines the name of the mesh to create
  105940. * @param options defines the options used to create the mesh
  105941. * @param scene defines the hosting scene
  105942. * @returns a new Mesh
  105943. */
  105944. static CreatePolyhedron(name: string, options: {
  105945. type?: number;
  105946. size?: number;
  105947. sizeX?: number;
  105948. sizeY?: number;
  105949. sizeZ?: number;
  105950. custom?: any;
  105951. faceUV?: Vector4[];
  105952. faceColors?: Color4[];
  105953. updatable?: boolean;
  105954. sideOrientation?: number;
  105955. }, scene: Scene): Mesh;
  105956. /**
  105957. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  105958. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  105959. * * 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`)
  105960. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  105961. * * 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
  105962. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  105963. * * If you create a double-sided mesh, you can choose what parts of 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
  105964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105965. * @param name defines the name of the mesh
  105966. * @param options defines the options used to create the mesh
  105967. * @param scene defines the hosting scene
  105968. * @returns a new Mesh
  105969. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  105970. */
  105971. static CreateIcoSphere(name: string, options: {
  105972. radius?: number;
  105973. flat?: boolean;
  105974. subdivisions?: number;
  105975. sideOrientation?: number;
  105976. updatable?: boolean;
  105977. }, scene: Scene): Mesh;
  105978. /**
  105979. * Creates a decal mesh.
  105980. * Please consider using the same method from the MeshBuilder class instead.
  105981. * A decal is a mesh usually applied as a model onto the surface of another mesh
  105982. * @param name defines the name of the mesh
  105983. * @param sourceMesh defines the mesh receiving the decal
  105984. * @param position sets the position of the decal in world coordinates
  105985. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  105986. * @param size sets the decal scaling
  105987. * @param angle sets the angle to rotate the decal
  105988. * @returns a new Mesh
  105989. */
  105990. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  105991. /**
  105992. * Prepare internal position array for software CPU skinning
  105993. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  105994. */
  105995. setPositionsForCPUSkinning(): Float32Array;
  105996. /**
  105997. * Prepare internal normal array for software CPU skinning
  105998. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  105999. */
  106000. setNormalsForCPUSkinning(): Float32Array;
  106001. /**
  106002. * Updates the vertex buffer by applying transformation from the bones
  106003. * @param skeleton defines the skeleton to apply to current mesh
  106004. * @returns the current mesh
  106005. */
  106006. applySkeleton(skeleton: Skeleton): Mesh;
  106007. /**
  106008. * 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
  106009. * @param meshes defines the list of meshes to scan
  106010. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106011. */
  106012. static MinMax(meshes: AbstractMesh[]): {
  106013. min: Vector3;
  106014. max: Vector3;
  106015. };
  106016. /**
  106017. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106018. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106019. * @returns a vector3
  106020. */
  106021. static Center(meshesOrMinMaxVector: {
  106022. min: Vector3;
  106023. max: Vector3;
  106024. } | AbstractMesh[]): Vector3;
  106025. /**
  106026. * Merge the array of meshes into a single mesh for performance reasons.
  106027. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106028. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106029. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106030. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106031. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106032. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106033. * @returns a new mesh
  106034. */
  106035. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106036. /** @hidden */
  106037. addInstance(instance: InstancedMesh): void;
  106038. /** @hidden */
  106039. removeInstance(instance: InstancedMesh): void;
  106040. }
  106041. }
  106042. declare module BABYLON {
  106043. /**
  106044. * This is the base class of all the camera used in the application.
  106045. * @see http://doc.babylonjs.com/features/cameras
  106046. */
  106047. export class Camera extends Node {
  106048. /** @hidden */
  106049. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106050. /**
  106051. * This is the default projection mode used by the cameras.
  106052. * It helps recreating a feeling of perspective and better appreciate depth.
  106053. * This is the best way to simulate real life cameras.
  106054. */
  106055. static readonly PERSPECTIVE_CAMERA: number;
  106056. /**
  106057. * This helps creating camera with an orthographic mode.
  106058. * 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.
  106059. */
  106060. static readonly ORTHOGRAPHIC_CAMERA: number;
  106061. /**
  106062. * This is the default FOV mode for perspective cameras.
  106063. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106064. */
  106065. static readonly FOVMODE_VERTICAL_FIXED: number;
  106066. /**
  106067. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106068. */
  106069. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106070. /**
  106071. * This specifies ther is no need for a camera rig.
  106072. * Basically only one eye is rendered corresponding to the camera.
  106073. */
  106074. static readonly RIG_MODE_NONE: number;
  106075. /**
  106076. * Simulates a camera Rig with one blue eye and one red eye.
  106077. * This can be use with 3d blue and red glasses.
  106078. */
  106079. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106080. /**
  106081. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106082. */
  106083. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106084. /**
  106085. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106086. */
  106087. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106088. /**
  106089. * Defines that both eyes of the camera will be rendered over under each other.
  106090. */
  106091. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106092. /**
  106093. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106094. */
  106095. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106096. /**
  106097. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106098. */
  106099. static readonly RIG_MODE_VR: number;
  106100. /**
  106101. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106102. */
  106103. static readonly RIG_MODE_WEBVR: number;
  106104. /**
  106105. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106106. */
  106107. static readonly RIG_MODE_CUSTOM: number;
  106108. /**
  106109. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106110. */
  106111. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106112. /**
  106113. * Define the input manager associated with the camera.
  106114. */
  106115. inputs: CameraInputsManager<Camera>;
  106116. /** @hidden */
  106117. _position: Vector3;
  106118. /**
  106119. * Define the current local position of the camera in the scene
  106120. */
  106121. get position(): Vector3;
  106122. set position(newPosition: Vector3);
  106123. /**
  106124. * The vector the camera should consider as up.
  106125. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106126. */
  106127. upVector: Vector3;
  106128. /**
  106129. * Define the current limit on the left side for an orthographic camera
  106130. * In scene unit
  106131. */
  106132. orthoLeft: Nullable<number>;
  106133. /**
  106134. * Define the current limit on the right side for an orthographic camera
  106135. * In scene unit
  106136. */
  106137. orthoRight: Nullable<number>;
  106138. /**
  106139. * Define the current limit on the bottom side for an orthographic camera
  106140. * In scene unit
  106141. */
  106142. orthoBottom: Nullable<number>;
  106143. /**
  106144. * Define the current limit on the top side for an orthographic camera
  106145. * In scene unit
  106146. */
  106147. orthoTop: Nullable<number>;
  106148. /**
  106149. * Field Of View is set in Radians. (default is 0.8)
  106150. */
  106151. fov: number;
  106152. /**
  106153. * Define the minimum distance the camera can see from.
  106154. * This is important to note that the depth buffer are not infinite and the closer it starts
  106155. * the more your scene might encounter depth fighting issue.
  106156. */
  106157. minZ: number;
  106158. /**
  106159. * Define the maximum distance the camera can see to.
  106160. * This is important to note that the depth buffer are not infinite and the further it end
  106161. * the more your scene might encounter depth fighting issue.
  106162. */
  106163. maxZ: number;
  106164. /**
  106165. * Define the default inertia of the camera.
  106166. * This helps giving a smooth feeling to the camera movement.
  106167. */
  106168. inertia: number;
  106169. /**
  106170. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106171. */
  106172. mode: number;
  106173. /**
  106174. * Define whether the camera is intermediate.
  106175. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106176. */
  106177. isIntermediate: boolean;
  106178. /**
  106179. * Define the viewport of the camera.
  106180. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106181. */
  106182. viewport: Viewport;
  106183. /**
  106184. * Restricts the camera to viewing objects with the same layerMask.
  106185. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106186. */
  106187. layerMask: number;
  106188. /**
  106189. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106190. */
  106191. fovMode: number;
  106192. /**
  106193. * Rig mode of the camera.
  106194. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106195. * This is normally controlled byt the camera themselves as internal use.
  106196. */
  106197. cameraRigMode: number;
  106198. /**
  106199. * Defines the distance between both "eyes" in case of a RIG
  106200. */
  106201. interaxialDistance: number;
  106202. /**
  106203. * Defines if stereoscopic rendering is done side by side or over under.
  106204. */
  106205. isStereoscopicSideBySide: boolean;
  106206. /**
  106207. * 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
  106208. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106209. * else in the scene. (Eg. security camera)
  106210. *
  106211. * 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)
  106212. */
  106213. customRenderTargets: RenderTargetTexture[];
  106214. /**
  106215. * When set, the camera will render to this render target instead of the default canvas
  106216. *
  106217. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106218. */
  106219. outputRenderTarget: Nullable<RenderTargetTexture>;
  106220. /**
  106221. * Observable triggered when the camera view matrix has changed.
  106222. */
  106223. onViewMatrixChangedObservable: Observable<Camera>;
  106224. /**
  106225. * Observable triggered when the camera Projection matrix has changed.
  106226. */
  106227. onProjectionMatrixChangedObservable: Observable<Camera>;
  106228. /**
  106229. * Observable triggered when the inputs have been processed.
  106230. */
  106231. onAfterCheckInputsObservable: Observable<Camera>;
  106232. /**
  106233. * Observable triggered when reset has been called and applied to the camera.
  106234. */
  106235. onRestoreStateObservable: Observable<Camera>;
  106236. /**
  106237. * Is this camera a part of a rig system?
  106238. */
  106239. isRigCamera: boolean;
  106240. /**
  106241. * If isRigCamera set to true this will be set with the parent camera.
  106242. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106243. */
  106244. rigParent?: Camera;
  106245. /** @hidden */
  106246. _cameraRigParams: any;
  106247. /** @hidden */
  106248. _rigCameras: Camera[];
  106249. /** @hidden */
  106250. _rigPostProcess: Nullable<PostProcess>;
  106251. protected _webvrViewMatrix: Matrix;
  106252. /** @hidden */
  106253. _skipRendering: boolean;
  106254. /** @hidden */
  106255. _projectionMatrix: Matrix;
  106256. /** @hidden */
  106257. _postProcesses: Nullable<PostProcess>[];
  106258. /** @hidden */
  106259. _activeMeshes: SmartArray<AbstractMesh>;
  106260. protected _globalPosition: Vector3;
  106261. /** @hidden */
  106262. _computedViewMatrix: Matrix;
  106263. private _doNotComputeProjectionMatrix;
  106264. private _transformMatrix;
  106265. private _frustumPlanes;
  106266. private _refreshFrustumPlanes;
  106267. private _storedFov;
  106268. private _stateStored;
  106269. /**
  106270. * Instantiates a new camera object.
  106271. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  106272. * @see http://doc.babylonjs.com/features/cameras
  106273. * @param name Defines the name of the camera in the scene
  106274. * @param position Defines the position of the camera
  106275. * @param scene Defines the scene the camera belongs too
  106276. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  106277. */
  106278. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106279. /**
  106280. * Store current camera state (fov, position, etc..)
  106281. * @returns the camera
  106282. */
  106283. storeState(): Camera;
  106284. /**
  106285. * Restores the camera state values if it has been stored. You must call storeState() first
  106286. */
  106287. protected _restoreStateValues(): boolean;
  106288. /**
  106289. * Restored camera state. You must call storeState() first.
  106290. * @returns true if restored and false otherwise
  106291. */
  106292. restoreState(): boolean;
  106293. /**
  106294. * Gets the class name of the camera.
  106295. * @returns the class name
  106296. */
  106297. getClassName(): string;
  106298. /** @hidden */
  106299. readonly _isCamera: boolean;
  106300. /**
  106301. * Gets a string representation of the camera useful for debug purpose.
  106302. * @param fullDetails Defines that a more verboe level of logging is required
  106303. * @returns the string representation
  106304. */
  106305. toString(fullDetails?: boolean): string;
  106306. /**
  106307. * Gets the current world space position of the camera.
  106308. */
  106309. get globalPosition(): Vector3;
  106310. /**
  106311. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  106312. * @returns the active meshe list
  106313. */
  106314. getActiveMeshes(): SmartArray<AbstractMesh>;
  106315. /**
  106316. * Check whether a mesh is part of the current active mesh list of the camera
  106317. * @param mesh Defines the mesh to check
  106318. * @returns true if active, false otherwise
  106319. */
  106320. isActiveMesh(mesh: Mesh): boolean;
  106321. /**
  106322. * Is this camera ready to be used/rendered
  106323. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  106324. * @return true if the camera is ready
  106325. */
  106326. isReady(completeCheck?: boolean): boolean;
  106327. /** @hidden */
  106328. _initCache(): void;
  106329. /** @hidden */
  106330. _updateCache(ignoreParentClass?: boolean): void;
  106331. /** @hidden */
  106332. _isSynchronized(): boolean;
  106333. /** @hidden */
  106334. _isSynchronizedViewMatrix(): boolean;
  106335. /** @hidden */
  106336. _isSynchronizedProjectionMatrix(): boolean;
  106337. /**
  106338. * Attach the input controls to a specific dom element to get the input from.
  106339. * @param element Defines the element the controls should be listened from
  106340. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106341. */
  106342. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  106343. /**
  106344. * Detach the current controls from the specified dom element.
  106345. * @param element Defines the element to stop listening the inputs from
  106346. */
  106347. detachControl(element: HTMLElement): void;
  106348. /**
  106349. * Update the camera state according to the different inputs gathered during the frame.
  106350. */
  106351. update(): void;
  106352. /** @hidden */
  106353. _checkInputs(): void;
  106354. /** @hidden */
  106355. get rigCameras(): Camera[];
  106356. /**
  106357. * Gets the post process used by the rig cameras
  106358. */
  106359. get rigPostProcess(): Nullable<PostProcess>;
  106360. /**
  106361. * Internal, gets the first post proces.
  106362. * @returns the first post process to be run on this camera.
  106363. */
  106364. _getFirstPostProcess(): Nullable<PostProcess>;
  106365. private _cascadePostProcessesToRigCams;
  106366. /**
  106367. * Attach a post process to the camera.
  106368. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106369. * @param postProcess The post process to attach to the camera
  106370. * @param insertAt The position of the post process in case several of them are in use in the scene
  106371. * @returns the position the post process has been inserted at
  106372. */
  106373. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  106374. /**
  106375. * Detach a post process to the camera.
  106376. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  106377. * @param postProcess The post process to detach from the camera
  106378. */
  106379. detachPostProcess(postProcess: PostProcess): void;
  106380. /**
  106381. * Gets the current world matrix of the camera
  106382. */
  106383. getWorldMatrix(): Matrix;
  106384. /** @hidden */
  106385. _getViewMatrix(): Matrix;
  106386. /**
  106387. * Gets the current view matrix of the camera.
  106388. * @param force forces the camera to recompute the matrix without looking at the cached state
  106389. * @returns the view matrix
  106390. */
  106391. getViewMatrix(force?: boolean): Matrix;
  106392. /**
  106393. * Freeze the projection matrix.
  106394. * It will prevent the cache check of the camera projection compute and can speed up perf
  106395. * if no parameter of the camera are meant to change
  106396. * @param projection Defines manually a projection if necessary
  106397. */
  106398. freezeProjectionMatrix(projection?: Matrix): void;
  106399. /**
  106400. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  106401. */
  106402. unfreezeProjectionMatrix(): void;
  106403. /**
  106404. * Gets the current projection matrix of the camera.
  106405. * @param force forces the camera to recompute the matrix without looking at the cached state
  106406. * @returns the projection matrix
  106407. */
  106408. getProjectionMatrix(force?: boolean): Matrix;
  106409. /**
  106410. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  106411. * @returns a Matrix
  106412. */
  106413. getTransformationMatrix(): Matrix;
  106414. private _updateFrustumPlanes;
  106415. /**
  106416. * Checks if a cullable object (mesh...) is in the camera frustum
  106417. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  106418. * @param target The object to check
  106419. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  106420. * @returns true if the object is in frustum otherwise false
  106421. */
  106422. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  106423. /**
  106424. * Checks if a cullable object (mesh...) is in the camera frustum
  106425. * Unlike isInFrustum this cheks the full bounding box
  106426. * @param target The object to check
  106427. * @returns true if the object is in frustum otherwise false
  106428. */
  106429. isCompletelyInFrustum(target: ICullable): boolean;
  106430. /**
  106431. * Gets a ray in the forward direction from the camera.
  106432. * @param length Defines the length of the ray to create
  106433. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  106434. * @param origin Defines the start point of the ray which defaults to the camera position
  106435. * @returns the forward ray
  106436. */
  106437. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  106438. /**
  106439. * Releases resources associated with this node.
  106440. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106441. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106442. */
  106443. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106444. /** @hidden */
  106445. _isLeftCamera: boolean;
  106446. /**
  106447. * Gets the left camera of a rig setup in case of Rigged Camera
  106448. */
  106449. get isLeftCamera(): boolean;
  106450. /** @hidden */
  106451. _isRightCamera: boolean;
  106452. /**
  106453. * Gets the right camera of a rig setup in case of Rigged Camera
  106454. */
  106455. get isRightCamera(): boolean;
  106456. /**
  106457. * Gets the left camera of a rig setup in case of Rigged Camera
  106458. */
  106459. get leftCamera(): Nullable<FreeCamera>;
  106460. /**
  106461. * Gets the right camera of a rig setup in case of Rigged Camera
  106462. */
  106463. get rightCamera(): Nullable<FreeCamera>;
  106464. /**
  106465. * Gets the left camera target of a rig setup in case of Rigged Camera
  106466. * @returns the target position
  106467. */
  106468. getLeftTarget(): Nullable<Vector3>;
  106469. /**
  106470. * Gets the right camera target of a rig setup in case of Rigged Camera
  106471. * @returns the target position
  106472. */
  106473. getRightTarget(): Nullable<Vector3>;
  106474. /**
  106475. * @hidden
  106476. */
  106477. setCameraRigMode(mode: number, rigParams: any): void;
  106478. /** @hidden */
  106479. static _setStereoscopicRigMode(camera: Camera): void;
  106480. /** @hidden */
  106481. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  106482. /** @hidden */
  106483. static _setVRRigMode(camera: Camera, rigParams: any): void;
  106484. /** @hidden */
  106485. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  106486. /** @hidden */
  106487. _getVRProjectionMatrix(): Matrix;
  106488. protected _updateCameraRotationMatrix(): void;
  106489. protected _updateWebVRCameraRotationMatrix(): void;
  106490. /**
  106491. * This function MUST be overwritten by the different WebVR cameras available.
  106492. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106493. * @hidden
  106494. */
  106495. _getWebVRProjectionMatrix(): Matrix;
  106496. /**
  106497. * This function MUST be overwritten by the different WebVR cameras available.
  106498. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  106499. * @hidden
  106500. */
  106501. _getWebVRViewMatrix(): Matrix;
  106502. /** @hidden */
  106503. setCameraRigParameter(name: string, value: any): void;
  106504. /**
  106505. * needs to be overridden by children so sub has required properties to be copied
  106506. * @hidden
  106507. */
  106508. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  106509. /**
  106510. * May need to be overridden by children
  106511. * @hidden
  106512. */
  106513. _updateRigCameras(): void;
  106514. /** @hidden */
  106515. _setupInputs(): void;
  106516. /**
  106517. * Serialiaze the camera setup to a json represention
  106518. * @returns the JSON representation
  106519. */
  106520. serialize(): any;
  106521. /**
  106522. * Clones the current camera.
  106523. * @param name The cloned camera name
  106524. * @returns the cloned camera
  106525. */
  106526. clone(name: string): Camera;
  106527. /**
  106528. * Gets the direction of the camera relative to a given local axis.
  106529. * @param localAxis Defines the reference axis to provide a relative direction.
  106530. * @return the direction
  106531. */
  106532. getDirection(localAxis: Vector3): Vector3;
  106533. /**
  106534. * Returns the current camera absolute rotation
  106535. */
  106536. get absoluteRotation(): Quaternion;
  106537. /**
  106538. * Gets the direction of the camera relative to a given local axis into a passed vector.
  106539. * @param localAxis Defines the reference axis to provide a relative direction.
  106540. * @param result Defines the vector to store the result in
  106541. */
  106542. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  106543. /**
  106544. * Gets a camera constructor for a given camera type
  106545. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  106546. * @param name The name of the camera the result will be able to instantiate
  106547. * @param scene The scene the result will construct the camera in
  106548. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  106549. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  106550. * @returns a factory method to construc the camera
  106551. */
  106552. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  106553. /**
  106554. * Compute the world matrix of the camera.
  106555. * @returns the camera world matrix
  106556. */
  106557. computeWorldMatrix(): Matrix;
  106558. /**
  106559. * Parse a JSON and creates the camera from the parsed information
  106560. * @param parsedCamera The JSON to parse
  106561. * @param scene The scene to instantiate the camera in
  106562. * @returns the newly constructed camera
  106563. */
  106564. static Parse(parsedCamera: any, scene: Scene): Camera;
  106565. }
  106566. }
  106567. declare module BABYLON {
  106568. /**
  106569. * Class containing static functions to help procedurally build meshes
  106570. */
  106571. export class DiscBuilder {
  106572. /**
  106573. * Creates a plane polygonal mesh. By default, this is a disc
  106574. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  106575. * * 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
  106576. * * 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
  106577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106580. * @param name defines the name of the mesh
  106581. * @param options defines the options used to create the mesh
  106582. * @param scene defines the hosting scene
  106583. * @returns the plane polygonal mesh
  106584. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  106585. */
  106586. static CreateDisc(name: string, options: {
  106587. radius?: number;
  106588. tessellation?: number;
  106589. arc?: number;
  106590. updatable?: boolean;
  106591. sideOrientation?: number;
  106592. frontUVs?: Vector4;
  106593. backUVs?: Vector4;
  106594. }, scene?: Nullable<Scene>): Mesh;
  106595. }
  106596. }
  106597. declare module BABYLON {
  106598. /**
  106599. * Options to be used when creating a FresnelParameters.
  106600. */
  106601. export type IFresnelParametersCreationOptions = {
  106602. /**
  106603. * Define the color used on edges (grazing angle)
  106604. */
  106605. leftColor?: Color3;
  106606. /**
  106607. * Define the color used on center
  106608. */
  106609. rightColor?: Color3;
  106610. /**
  106611. * Define bias applied to computed fresnel term
  106612. */
  106613. bias?: number;
  106614. /**
  106615. * Defined the power exponent applied to fresnel term
  106616. */
  106617. power?: number;
  106618. /**
  106619. * Define if the fresnel effect is enable or not.
  106620. */
  106621. isEnabled?: boolean;
  106622. };
  106623. /**
  106624. * Serialized format for FresnelParameters.
  106625. */
  106626. export type IFresnelParametersSerialized = {
  106627. /**
  106628. * Define the color used on edges (grazing angle) [as an array]
  106629. */
  106630. leftColor: number[];
  106631. /**
  106632. * Define the color used on center [as an array]
  106633. */
  106634. rightColor: number[];
  106635. /**
  106636. * Define bias applied to computed fresnel term
  106637. */
  106638. bias: number;
  106639. /**
  106640. * Defined the power exponent applied to fresnel term
  106641. */
  106642. power?: number;
  106643. /**
  106644. * Define if the fresnel effect is enable or not.
  106645. */
  106646. isEnabled: boolean;
  106647. };
  106648. /**
  106649. * This represents all the required information to add a fresnel effect on a material:
  106650. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106651. */
  106652. export class FresnelParameters {
  106653. private _isEnabled;
  106654. /**
  106655. * Define if the fresnel effect is enable or not.
  106656. */
  106657. get isEnabled(): boolean;
  106658. set isEnabled(value: boolean);
  106659. /**
  106660. * Define the color used on edges (grazing angle)
  106661. */
  106662. leftColor: Color3;
  106663. /**
  106664. * Define the color used on center
  106665. */
  106666. rightColor: Color3;
  106667. /**
  106668. * Define bias applied to computed fresnel term
  106669. */
  106670. bias: number;
  106671. /**
  106672. * Defined the power exponent applied to fresnel term
  106673. */
  106674. power: number;
  106675. /**
  106676. * Creates a new FresnelParameters object.
  106677. *
  106678. * @param options provide your own settings to optionally to override defaults
  106679. */
  106680. constructor(options?: IFresnelParametersCreationOptions);
  106681. /**
  106682. * Clones the current fresnel and its valuues
  106683. * @returns a clone fresnel configuration
  106684. */
  106685. clone(): FresnelParameters;
  106686. /**
  106687. * Determines equality between FresnelParameters objects
  106688. * @param otherFresnelParameters defines the second operand
  106689. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  106690. */
  106691. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  106692. /**
  106693. * Serializes the current fresnel parameters to a JSON representation.
  106694. * @return the JSON serialization
  106695. */
  106696. serialize(): IFresnelParametersSerialized;
  106697. /**
  106698. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  106699. * @param parsedFresnelParameters Define the JSON representation
  106700. * @returns the parsed parameters
  106701. */
  106702. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  106703. }
  106704. }
  106705. declare module BABYLON {
  106706. /**
  106707. * This groups all the flags used to control the materials channel.
  106708. */
  106709. export class MaterialFlags {
  106710. private static _DiffuseTextureEnabled;
  106711. /**
  106712. * Are diffuse textures enabled in the application.
  106713. */
  106714. static get DiffuseTextureEnabled(): boolean;
  106715. static set DiffuseTextureEnabled(value: boolean);
  106716. private static _DetailTextureEnabled;
  106717. /**
  106718. * Are detail textures enabled in the application.
  106719. */
  106720. static get DetailTextureEnabled(): boolean;
  106721. static set DetailTextureEnabled(value: boolean);
  106722. private static _AmbientTextureEnabled;
  106723. /**
  106724. * Are ambient textures enabled in the application.
  106725. */
  106726. static get AmbientTextureEnabled(): boolean;
  106727. static set AmbientTextureEnabled(value: boolean);
  106728. private static _OpacityTextureEnabled;
  106729. /**
  106730. * Are opacity textures enabled in the application.
  106731. */
  106732. static get OpacityTextureEnabled(): boolean;
  106733. static set OpacityTextureEnabled(value: boolean);
  106734. private static _ReflectionTextureEnabled;
  106735. /**
  106736. * Are reflection textures enabled in the application.
  106737. */
  106738. static get ReflectionTextureEnabled(): boolean;
  106739. static set ReflectionTextureEnabled(value: boolean);
  106740. private static _EmissiveTextureEnabled;
  106741. /**
  106742. * Are emissive textures enabled in the application.
  106743. */
  106744. static get EmissiveTextureEnabled(): boolean;
  106745. static set EmissiveTextureEnabled(value: boolean);
  106746. private static _SpecularTextureEnabled;
  106747. /**
  106748. * Are specular textures enabled in the application.
  106749. */
  106750. static get SpecularTextureEnabled(): boolean;
  106751. static set SpecularTextureEnabled(value: boolean);
  106752. private static _BumpTextureEnabled;
  106753. /**
  106754. * Are bump textures enabled in the application.
  106755. */
  106756. static get BumpTextureEnabled(): boolean;
  106757. static set BumpTextureEnabled(value: boolean);
  106758. private static _LightmapTextureEnabled;
  106759. /**
  106760. * Are lightmap textures enabled in the application.
  106761. */
  106762. static get LightmapTextureEnabled(): boolean;
  106763. static set LightmapTextureEnabled(value: boolean);
  106764. private static _RefractionTextureEnabled;
  106765. /**
  106766. * Are refraction textures enabled in the application.
  106767. */
  106768. static get RefractionTextureEnabled(): boolean;
  106769. static set RefractionTextureEnabled(value: boolean);
  106770. private static _ColorGradingTextureEnabled;
  106771. /**
  106772. * Are color grading textures enabled in the application.
  106773. */
  106774. static get ColorGradingTextureEnabled(): boolean;
  106775. static set ColorGradingTextureEnabled(value: boolean);
  106776. private static _FresnelEnabled;
  106777. /**
  106778. * Are fresnels enabled in the application.
  106779. */
  106780. static get FresnelEnabled(): boolean;
  106781. static set FresnelEnabled(value: boolean);
  106782. private static _ClearCoatTextureEnabled;
  106783. /**
  106784. * Are clear coat textures enabled in the application.
  106785. */
  106786. static get ClearCoatTextureEnabled(): boolean;
  106787. static set ClearCoatTextureEnabled(value: boolean);
  106788. private static _ClearCoatBumpTextureEnabled;
  106789. /**
  106790. * Are clear coat bump textures enabled in the application.
  106791. */
  106792. static get ClearCoatBumpTextureEnabled(): boolean;
  106793. static set ClearCoatBumpTextureEnabled(value: boolean);
  106794. private static _ClearCoatTintTextureEnabled;
  106795. /**
  106796. * Are clear coat tint textures enabled in the application.
  106797. */
  106798. static get ClearCoatTintTextureEnabled(): boolean;
  106799. static set ClearCoatTintTextureEnabled(value: boolean);
  106800. private static _SheenTextureEnabled;
  106801. /**
  106802. * Are sheen textures enabled in the application.
  106803. */
  106804. static get SheenTextureEnabled(): boolean;
  106805. static set SheenTextureEnabled(value: boolean);
  106806. private static _AnisotropicTextureEnabled;
  106807. /**
  106808. * Are anisotropic textures enabled in the application.
  106809. */
  106810. static get AnisotropicTextureEnabled(): boolean;
  106811. static set AnisotropicTextureEnabled(value: boolean);
  106812. private static _ThicknessTextureEnabled;
  106813. /**
  106814. * Are thickness textures enabled in the application.
  106815. */
  106816. static get ThicknessTextureEnabled(): boolean;
  106817. static set ThicknessTextureEnabled(value: boolean);
  106818. }
  106819. }
  106820. declare module BABYLON {
  106821. /** @hidden */
  106822. export var defaultFragmentDeclaration: {
  106823. name: string;
  106824. shader: string;
  106825. };
  106826. }
  106827. declare module BABYLON {
  106828. /** @hidden */
  106829. export var defaultUboDeclaration: {
  106830. name: string;
  106831. shader: string;
  106832. };
  106833. }
  106834. declare module BABYLON {
  106835. /** @hidden */
  106836. export var lightFragmentDeclaration: {
  106837. name: string;
  106838. shader: string;
  106839. };
  106840. }
  106841. declare module BABYLON {
  106842. /** @hidden */
  106843. export var lightUboDeclaration: {
  106844. name: string;
  106845. shader: string;
  106846. };
  106847. }
  106848. declare module BABYLON {
  106849. /** @hidden */
  106850. export var lightsFragmentFunctions: {
  106851. name: string;
  106852. shader: string;
  106853. };
  106854. }
  106855. declare module BABYLON {
  106856. /** @hidden */
  106857. export var shadowsFragmentFunctions: {
  106858. name: string;
  106859. shader: string;
  106860. };
  106861. }
  106862. declare module BABYLON {
  106863. /** @hidden */
  106864. export var fresnelFunction: {
  106865. name: string;
  106866. shader: string;
  106867. };
  106868. }
  106869. declare module BABYLON {
  106870. /** @hidden */
  106871. export var bumpFragmentMainFunctions: {
  106872. name: string;
  106873. shader: string;
  106874. };
  106875. }
  106876. declare module BABYLON {
  106877. /** @hidden */
  106878. export var bumpFragmentFunctions: {
  106879. name: string;
  106880. shader: string;
  106881. };
  106882. }
  106883. declare module BABYLON {
  106884. /** @hidden */
  106885. export var logDepthDeclaration: {
  106886. name: string;
  106887. shader: string;
  106888. };
  106889. }
  106890. declare module BABYLON {
  106891. /** @hidden */
  106892. export var bumpFragment: {
  106893. name: string;
  106894. shader: string;
  106895. };
  106896. }
  106897. declare module BABYLON {
  106898. /** @hidden */
  106899. export var depthPrePass: {
  106900. name: string;
  106901. shader: string;
  106902. };
  106903. }
  106904. declare module BABYLON {
  106905. /** @hidden */
  106906. export var lightFragment: {
  106907. name: string;
  106908. shader: string;
  106909. };
  106910. }
  106911. declare module BABYLON {
  106912. /** @hidden */
  106913. export var logDepthFragment: {
  106914. name: string;
  106915. shader: string;
  106916. };
  106917. }
  106918. declare module BABYLON {
  106919. /** @hidden */
  106920. export var defaultPixelShader: {
  106921. name: string;
  106922. shader: string;
  106923. };
  106924. }
  106925. declare module BABYLON {
  106926. /** @hidden */
  106927. export var defaultVertexDeclaration: {
  106928. name: string;
  106929. shader: string;
  106930. };
  106931. }
  106932. declare module BABYLON {
  106933. /** @hidden */
  106934. export var bumpVertexDeclaration: {
  106935. name: string;
  106936. shader: string;
  106937. };
  106938. }
  106939. declare module BABYLON {
  106940. /** @hidden */
  106941. export var bumpVertex: {
  106942. name: string;
  106943. shader: string;
  106944. };
  106945. }
  106946. declare module BABYLON {
  106947. /** @hidden */
  106948. export var fogVertex: {
  106949. name: string;
  106950. shader: string;
  106951. };
  106952. }
  106953. declare module BABYLON {
  106954. /** @hidden */
  106955. export var shadowsVertex: {
  106956. name: string;
  106957. shader: string;
  106958. };
  106959. }
  106960. declare module BABYLON {
  106961. /** @hidden */
  106962. export var pointCloudVertex: {
  106963. name: string;
  106964. shader: string;
  106965. };
  106966. }
  106967. declare module BABYLON {
  106968. /** @hidden */
  106969. export var logDepthVertex: {
  106970. name: string;
  106971. shader: string;
  106972. };
  106973. }
  106974. declare module BABYLON {
  106975. /** @hidden */
  106976. export var defaultVertexShader: {
  106977. name: string;
  106978. shader: string;
  106979. };
  106980. }
  106981. declare module BABYLON {
  106982. /**
  106983. * @hidden
  106984. */
  106985. export interface IMaterialDetailMapDefines {
  106986. DETAIL: boolean;
  106987. DETAILDIRECTUV: number;
  106988. DETAIL_NORMALBLENDMETHOD: number;
  106989. /** @hidden */
  106990. _areTexturesDirty: boolean;
  106991. }
  106992. /**
  106993. * Define the code related to the detail map parameters of a material
  106994. *
  106995. * Inspired from:
  106996. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  106997. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  106998. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  106999. */
  107000. export class DetailMapConfiguration {
  107001. private _texture;
  107002. /**
  107003. * The detail texture of the material.
  107004. */
  107005. texture: Nullable<BaseTexture>;
  107006. /**
  107007. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107008. * Bigger values mean stronger blending
  107009. */
  107010. diffuseBlendLevel: number;
  107011. /**
  107012. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107013. * Bigger values mean stronger blending. Only used with PBR materials
  107014. */
  107015. roughnessBlendLevel: number;
  107016. /**
  107017. * Defines how strong the bump effect from the detail map is
  107018. * Bigger values mean stronger effect
  107019. */
  107020. bumpLevel: number;
  107021. private _normalBlendMethod;
  107022. /**
  107023. * The method used to blend the bump and detail normals together
  107024. */
  107025. normalBlendMethod: number;
  107026. private _isEnabled;
  107027. /**
  107028. * Enable or disable the detail map on this material
  107029. */
  107030. isEnabled: boolean;
  107031. /** @hidden */
  107032. private _internalMarkAllSubMeshesAsTexturesDirty;
  107033. /** @hidden */
  107034. _markAllSubMeshesAsTexturesDirty(): void;
  107035. /**
  107036. * Instantiate a new detail map
  107037. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107038. */
  107039. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107040. /**
  107041. * Gets whether the submesh is ready to be used or not.
  107042. * @param defines the list of "defines" to update.
  107043. * @param scene defines the scene the material belongs to.
  107044. * @returns - boolean indicating that the submesh is ready or not.
  107045. */
  107046. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107047. /**
  107048. * Update the defines for detail map usage
  107049. * @param defines the list of "defines" to update.
  107050. * @param scene defines the scene the material belongs to.
  107051. */
  107052. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107053. /**
  107054. * Binds the material data.
  107055. * @param uniformBuffer defines the Uniform buffer to fill in.
  107056. * @param scene defines the scene the material belongs to.
  107057. * @param isFrozen defines whether the material is frozen or not.
  107058. */
  107059. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107060. /**
  107061. * Checks to see if a texture is used in the material.
  107062. * @param texture - Base texture to use.
  107063. * @returns - Boolean specifying if a texture is used in the material.
  107064. */
  107065. hasTexture(texture: BaseTexture): boolean;
  107066. /**
  107067. * Returns an array of the actively used textures.
  107068. * @param activeTextures Array of BaseTextures
  107069. */
  107070. getActiveTextures(activeTextures: BaseTexture[]): void;
  107071. /**
  107072. * Returns the animatable textures.
  107073. * @param animatables Array of animatable textures.
  107074. */
  107075. getAnimatables(animatables: IAnimatable[]): void;
  107076. /**
  107077. * Disposes the resources of the material.
  107078. * @param forceDisposeTextures - Forces the disposal of all textures.
  107079. */
  107080. dispose(forceDisposeTextures?: boolean): void;
  107081. /**
  107082. * Get the current class name useful for serialization or dynamic coding.
  107083. * @returns "DetailMap"
  107084. */
  107085. getClassName(): string;
  107086. /**
  107087. * Add the required uniforms to the current list.
  107088. * @param uniforms defines the current uniform list.
  107089. */
  107090. static AddUniforms(uniforms: string[]): void;
  107091. /**
  107092. * Add the required samplers to the current list.
  107093. * @param samplers defines the current sampler list.
  107094. */
  107095. static AddSamplers(samplers: string[]): void;
  107096. /**
  107097. * Add the required uniforms to the current buffer.
  107098. * @param uniformBuffer defines the current uniform buffer.
  107099. */
  107100. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107101. /**
  107102. * Makes a duplicate of the current instance into another one.
  107103. * @param detailMap define the instance where to copy the info
  107104. */
  107105. copyTo(detailMap: DetailMapConfiguration): void;
  107106. /**
  107107. * Serializes this detail map instance
  107108. * @returns - An object with the serialized instance.
  107109. */
  107110. serialize(): any;
  107111. /**
  107112. * Parses a detail map setting from a serialized object.
  107113. * @param source - Serialized object.
  107114. * @param scene Defines the scene we are parsing for
  107115. * @param rootUrl Defines the rootUrl to load from
  107116. */
  107117. parse(source: any, scene: Scene, rootUrl: string): void;
  107118. }
  107119. }
  107120. declare module BABYLON {
  107121. /** @hidden */
  107122. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107123. MAINUV1: boolean;
  107124. MAINUV2: boolean;
  107125. DIFFUSE: boolean;
  107126. DIFFUSEDIRECTUV: number;
  107127. DETAIL: boolean;
  107128. DETAILDIRECTUV: number;
  107129. DETAIL_NORMALBLENDMETHOD: number;
  107130. AMBIENT: boolean;
  107131. AMBIENTDIRECTUV: number;
  107132. OPACITY: boolean;
  107133. OPACITYDIRECTUV: number;
  107134. OPACITYRGB: boolean;
  107135. REFLECTION: boolean;
  107136. EMISSIVE: boolean;
  107137. EMISSIVEDIRECTUV: number;
  107138. SPECULAR: boolean;
  107139. SPECULARDIRECTUV: number;
  107140. BUMP: boolean;
  107141. BUMPDIRECTUV: number;
  107142. PARALLAX: boolean;
  107143. PARALLAXOCCLUSION: boolean;
  107144. SPECULAROVERALPHA: boolean;
  107145. CLIPPLANE: boolean;
  107146. CLIPPLANE2: boolean;
  107147. CLIPPLANE3: boolean;
  107148. CLIPPLANE4: boolean;
  107149. CLIPPLANE5: boolean;
  107150. CLIPPLANE6: boolean;
  107151. ALPHATEST: boolean;
  107152. DEPTHPREPASS: boolean;
  107153. ALPHAFROMDIFFUSE: boolean;
  107154. POINTSIZE: boolean;
  107155. FOG: boolean;
  107156. SPECULARTERM: boolean;
  107157. DIFFUSEFRESNEL: boolean;
  107158. OPACITYFRESNEL: boolean;
  107159. REFLECTIONFRESNEL: boolean;
  107160. REFRACTIONFRESNEL: boolean;
  107161. EMISSIVEFRESNEL: boolean;
  107162. FRESNEL: boolean;
  107163. NORMAL: boolean;
  107164. UV1: boolean;
  107165. UV2: boolean;
  107166. VERTEXCOLOR: boolean;
  107167. VERTEXALPHA: boolean;
  107168. NUM_BONE_INFLUENCERS: number;
  107169. BonesPerMesh: number;
  107170. BONETEXTURE: boolean;
  107171. INSTANCES: boolean;
  107172. THIN_INSTANCES: boolean;
  107173. GLOSSINESS: boolean;
  107174. ROUGHNESS: boolean;
  107175. EMISSIVEASILLUMINATION: boolean;
  107176. LINKEMISSIVEWITHDIFFUSE: boolean;
  107177. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107178. LIGHTMAP: boolean;
  107179. LIGHTMAPDIRECTUV: number;
  107180. OBJECTSPACE_NORMALMAP: boolean;
  107181. USELIGHTMAPASSHADOWMAP: boolean;
  107182. REFLECTIONMAP_3D: boolean;
  107183. REFLECTIONMAP_SPHERICAL: boolean;
  107184. REFLECTIONMAP_PLANAR: boolean;
  107185. REFLECTIONMAP_CUBIC: boolean;
  107186. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107187. REFLECTIONMAP_PROJECTION: boolean;
  107188. REFLECTIONMAP_SKYBOX: boolean;
  107189. REFLECTIONMAP_EXPLICIT: boolean;
  107190. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107191. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107192. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107193. INVERTCUBICMAP: boolean;
  107194. LOGARITHMICDEPTH: boolean;
  107195. REFRACTION: boolean;
  107196. REFRACTIONMAP_3D: boolean;
  107197. REFLECTIONOVERALPHA: boolean;
  107198. TWOSIDEDLIGHTING: boolean;
  107199. SHADOWFLOAT: boolean;
  107200. MORPHTARGETS: boolean;
  107201. MORPHTARGETS_NORMAL: boolean;
  107202. MORPHTARGETS_TANGENT: boolean;
  107203. MORPHTARGETS_UV: boolean;
  107204. NUM_MORPH_INFLUENCERS: number;
  107205. NONUNIFORMSCALING: boolean;
  107206. PREMULTIPLYALPHA: boolean;
  107207. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107208. ALPHABLEND: boolean;
  107209. RGBDLIGHTMAP: boolean;
  107210. RGBDREFLECTION: boolean;
  107211. RGBDREFRACTION: boolean;
  107212. IMAGEPROCESSING: boolean;
  107213. VIGNETTE: boolean;
  107214. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107215. VIGNETTEBLENDMODEOPAQUE: boolean;
  107216. TONEMAPPING: boolean;
  107217. TONEMAPPING_ACES: boolean;
  107218. CONTRAST: boolean;
  107219. COLORCURVES: boolean;
  107220. COLORGRADING: boolean;
  107221. COLORGRADING3D: boolean;
  107222. SAMPLER3DGREENDEPTH: boolean;
  107223. SAMPLER3DBGRMAP: boolean;
  107224. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107225. MULTIVIEW: boolean;
  107226. /**
  107227. * If the reflection texture on this material is in linear color space
  107228. * @hidden
  107229. */
  107230. IS_REFLECTION_LINEAR: boolean;
  107231. /**
  107232. * If the refraction texture on this material is in linear color space
  107233. * @hidden
  107234. */
  107235. IS_REFRACTION_LINEAR: boolean;
  107236. EXPOSURE: boolean;
  107237. constructor();
  107238. setReflectionMode(modeToEnable: string): void;
  107239. }
  107240. /**
  107241. * This is the default material used in Babylon. It is the best trade off between quality
  107242. * and performances.
  107243. * @see http://doc.babylonjs.com/babylon101/materials
  107244. */
  107245. export class StandardMaterial extends PushMaterial {
  107246. private _diffuseTexture;
  107247. /**
  107248. * The basic texture of the material as viewed under a light.
  107249. */
  107250. diffuseTexture: Nullable<BaseTexture>;
  107251. private _ambientTexture;
  107252. /**
  107253. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107254. */
  107255. ambientTexture: Nullable<BaseTexture>;
  107256. private _opacityTexture;
  107257. /**
  107258. * Define the transparency of the material from a texture.
  107259. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107260. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107261. */
  107262. opacityTexture: Nullable<BaseTexture>;
  107263. private _reflectionTexture;
  107264. /**
  107265. * Define the texture used to display the reflection.
  107266. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107267. */
  107268. reflectionTexture: Nullable<BaseTexture>;
  107269. private _emissiveTexture;
  107270. /**
  107271. * Define texture of the material as if self lit.
  107272. * This will be mixed in the final result even in the absence of light.
  107273. */
  107274. emissiveTexture: Nullable<BaseTexture>;
  107275. private _specularTexture;
  107276. /**
  107277. * Define how the color and intensity of the highlight given by the light in the material.
  107278. */
  107279. specularTexture: Nullable<BaseTexture>;
  107280. private _bumpTexture;
  107281. /**
  107282. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107283. * 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.
  107284. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107285. */
  107286. bumpTexture: Nullable<BaseTexture>;
  107287. private _lightmapTexture;
  107288. /**
  107289. * Complex lighting can be computationally expensive to compute at runtime.
  107290. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107291. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107292. */
  107293. lightmapTexture: Nullable<BaseTexture>;
  107294. private _refractionTexture;
  107295. /**
  107296. * Define the texture used to display the refraction.
  107297. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107298. */
  107299. refractionTexture: Nullable<BaseTexture>;
  107300. /**
  107301. * The color of the material lit by the environmental background lighting.
  107302. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107303. */
  107304. ambientColor: Color3;
  107305. /**
  107306. * The basic color of the material as viewed under a light.
  107307. */
  107308. diffuseColor: Color3;
  107309. /**
  107310. * Define how the color and intensity of the highlight given by the light in the material.
  107311. */
  107312. specularColor: Color3;
  107313. /**
  107314. * Define the color of the material as if self lit.
  107315. * This will be mixed in the final result even in the absence of light.
  107316. */
  107317. emissiveColor: Color3;
  107318. /**
  107319. * Defines how sharp are the highlights in the material.
  107320. * The bigger the value the sharper giving a more glossy feeling to the result.
  107321. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107322. */
  107323. specularPower: number;
  107324. private _useAlphaFromDiffuseTexture;
  107325. /**
  107326. * Does the transparency come from the diffuse texture alpha channel.
  107327. */
  107328. useAlphaFromDiffuseTexture: boolean;
  107329. private _useEmissiveAsIllumination;
  107330. /**
  107331. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107332. */
  107333. useEmissiveAsIllumination: boolean;
  107334. private _linkEmissiveWithDiffuse;
  107335. /**
  107336. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107337. * the emissive level when the final color is close to one.
  107338. */
  107339. linkEmissiveWithDiffuse: boolean;
  107340. private _useSpecularOverAlpha;
  107341. /**
  107342. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107343. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107344. */
  107345. useSpecularOverAlpha: boolean;
  107346. private _useReflectionOverAlpha;
  107347. /**
  107348. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107349. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107350. */
  107351. useReflectionOverAlpha: boolean;
  107352. private _disableLighting;
  107353. /**
  107354. * Does lights from the scene impacts this material.
  107355. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107356. */
  107357. disableLighting: boolean;
  107358. private _useObjectSpaceNormalMap;
  107359. /**
  107360. * Allows using an object space normal map (instead of tangent space).
  107361. */
  107362. useObjectSpaceNormalMap: boolean;
  107363. private _useParallax;
  107364. /**
  107365. * Is parallax enabled or not.
  107366. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107367. */
  107368. useParallax: boolean;
  107369. private _useParallaxOcclusion;
  107370. /**
  107371. * Is parallax occlusion enabled or not.
  107372. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107373. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107374. */
  107375. useParallaxOcclusion: boolean;
  107376. /**
  107377. * 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.
  107378. */
  107379. parallaxScaleBias: number;
  107380. private _roughness;
  107381. /**
  107382. * Helps to define how blurry the reflections should appears in the material.
  107383. */
  107384. roughness: number;
  107385. /**
  107386. * In case of refraction, define the value of the index of refraction.
  107387. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107388. */
  107389. indexOfRefraction: number;
  107390. /**
  107391. * Invert the refraction texture alongside the y axis.
  107392. * It can be useful with procedural textures or probe for instance.
  107393. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107394. */
  107395. invertRefractionY: boolean;
  107396. /**
  107397. * Defines the alpha limits in alpha test mode.
  107398. */
  107399. alphaCutOff: number;
  107400. private _useLightmapAsShadowmap;
  107401. /**
  107402. * In case of light mapping, define whether the map contains light or shadow informations.
  107403. */
  107404. useLightmapAsShadowmap: boolean;
  107405. private _diffuseFresnelParameters;
  107406. /**
  107407. * Define the diffuse fresnel parameters of the material.
  107408. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107409. */
  107410. diffuseFresnelParameters: FresnelParameters;
  107411. private _opacityFresnelParameters;
  107412. /**
  107413. * Define the opacity fresnel parameters of the material.
  107414. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107415. */
  107416. opacityFresnelParameters: FresnelParameters;
  107417. private _reflectionFresnelParameters;
  107418. /**
  107419. * Define the reflection fresnel parameters of the material.
  107420. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107421. */
  107422. reflectionFresnelParameters: FresnelParameters;
  107423. private _refractionFresnelParameters;
  107424. /**
  107425. * Define the refraction fresnel parameters of the material.
  107426. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107427. */
  107428. refractionFresnelParameters: FresnelParameters;
  107429. private _emissiveFresnelParameters;
  107430. /**
  107431. * Define the emissive fresnel parameters of the material.
  107432. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107433. */
  107434. emissiveFresnelParameters: FresnelParameters;
  107435. private _useReflectionFresnelFromSpecular;
  107436. /**
  107437. * If true automatically deducts the fresnels values from the material specularity.
  107438. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107439. */
  107440. useReflectionFresnelFromSpecular: boolean;
  107441. private _useGlossinessFromSpecularMapAlpha;
  107442. /**
  107443. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107444. */
  107445. useGlossinessFromSpecularMapAlpha: boolean;
  107446. private _maxSimultaneousLights;
  107447. /**
  107448. * Defines the maximum number of lights that can be used in the material
  107449. */
  107450. maxSimultaneousLights: number;
  107451. private _invertNormalMapX;
  107452. /**
  107453. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107454. */
  107455. invertNormalMapX: boolean;
  107456. private _invertNormalMapY;
  107457. /**
  107458. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107459. */
  107460. invertNormalMapY: boolean;
  107461. private _twoSidedLighting;
  107462. /**
  107463. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107464. */
  107465. twoSidedLighting: boolean;
  107466. /**
  107467. * Default configuration related to image processing available in the standard Material.
  107468. */
  107469. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107470. /**
  107471. * Gets the image processing configuration used either in this material.
  107472. */
  107473. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  107474. /**
  107475. * Sets the Default image processing configuration used either in the this material.
  107476. *
  107477. * If sets to null, the scene one is in use.
  107478. */
  107479. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  107480. /**
  107481. * Keep track of the image processing observer to allow dispose and replace.
  107482. */
  107483. private _imageProcessingObserver;
  107484. /**
  107485. * Attaches a new image processing configuration to the Standard Material.
  107486. * @param configuration
  107487. */
  107488. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107489. /**
  107490. * Gets wether the color curves effect is enabled.
  107491. */
  107492. get cameraColorCurvesEnabled(): boolean;
  107493. /**
  107494. * Sets wether the color curves effect is enabled.
  107495. */
  107496. set cameraColorCurvesEnabled(value: boolean);
  107497. /**
  107498. * Gets wether the color grading effect is enabled.
  107499. */
  107500. get cameraColorGradingEnabled(): boolean;
  107501. /**
  107502. * Gets wether the color grading effect is enabled.
  107503. */
  107504. set cameraColorGradingEnabled(value: boolean);
  107505. /**
  107506. * Gets wether tonemapping is enabled or not.
  107507. */
  107508. get cameraToneMappingEnabled(): boolean;
  107509. /**
  107510. * Sets wether tonemapping is enabled or not
  107511. */
  107512. set cameraToneMappingEnabled(value: boolean);
  107513. /**
  107514. * The camera exposure used on this material.
  107515. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107516. * This corresponds to a photographic exposure.
  107517. */
  107518. get cameraExposure(): number;
  107519. /**
  107520. * The camera exposure used on this material.
  107521. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107522. * This corresponds to a photographic exposure.
  107523. */
  107524. set cameraExposure(value: number);
  107525. /**
  107526. * Gets The camera contrast used on this material.
  107527. */
  107528. get cameraContrast(): number;
  107529. /**
  107530. * Sets The camera contrast used on this material.
  107531. */
  107532. set cameraContrast(value: number);
  107533. /**
  107534. * Gets the Color Grading 2D Lookup Texture.
  107535. */
  107536. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  107537. /**
  107538. * Sets the Color Grading 2D Lookup Texture.
  107539. */
  107540. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  107541. /**
  107542. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107543. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107544. * 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;
  107545. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107546. */
  107547. get cameraColorCurves(): Nullable<ColorCurves>;
  107548. /**
  107549. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107550. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107551. * 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;
  107552. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107553. */
  107554. set cameraColorCurves(value: Nullable<ColorCurves>);
  107555. /**
  107556. * Defines the detail map parameters for the material.
  107557. */
  107558. readonly detailMap: DetailMapConfiguration;
  107559. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107560. protected _worldViewProjectionMatrix: Matrix;
  107561. protected _globalAmbientColor: Color3;
  107562. protected _useLogarithmicDepth: boolean;
  107563. protected _rebuildInParallel: boolean;
  107564. /**
  107565. * Instantiates a new standard material.
  107566. * This is the default material used in Babylon. It is the best trade off between quality
  107567. * and performances.
  107568. * @see http://doc.babylonjs.com/babylon101/materials
  107569. * @param name Define the name of the material in the scene
  107570. * @param scene Define the scene the material belong to
  107571. */
  107572. constructor(name: string, scene: Scene);
  107573. /**
  107574. * Gets a boolean indicating that current material needs to register RTT
  107575. */
  107576. get hasRenderTargetTextures(): boolean;
  107577. /**
  107578. * Gets the current class name of the material e.g. "StandardMaterial"
  107579. * Mainly use in serialization.
  107580. * @returns the class name
  107581. */
  107582. getClassName(): string;
  107583. /**
  107584. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107585. * You can try switching to logarithmic depth.
  107586. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107587. */
  107588. get useLogarithmicDepth(): boolean;
  107589. set useLogarithmicDepth(value: boolean);
  107590. /**
  107591. * Specifies if the material will require alpha blending
  107592. * @returns a boolean specifying if alpha blending is needed
  107593. */
  107594. needAlphaBlending(): boolean;
  107595. /**
  107596. * Specifies if this material should be rendered in alpha test mode
  107597. * @returns a boolean specifying if an alpha test is needed.
  107598. */
  107599. needAlphaTesting(): boolean;
  107600. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107601. /**
  107602. * Get the texture used for alpha test purpose.
  107603. * @returns the diffuse texture in case of the standard material.
  107604. */
  107605. getAlphaTestTexture(): Nullable<BaseTexture>;
  107606. /**
  107607. * Get if the submesh is ready to be used and all its information available.
  107608. * Child classes can use it to update shaders
  107609. * @param mesh defines the mesh to check
  107610. * @param subMesh defines which submesh to check
  107611. * @param useInstances specifies that instances should be used
  107612. * @returns a boolean indicating that the submesh is ready or not
  107613. */
  107614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107615. /**
  107616. * Builds the material UBO layouts.
  107617. * Used internally during the effect preparation.
  107618. */
  107619. buildUniformLayout(): void;
  107620. /**
  107621. * Unbinds the material from the mesh
  107622. */
  107623. unbind(): void;
  107624. /**
  107625. * Binds the submesh to this material by preparing the effect and shader to draw
  107626. * @param world defines the world transformation matrix
  107627. * @param mesh defines the mesh containing the submesh
  107628. * @param subMesh defines the submesh to bind the material to
  107629. */
  107630. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107631. /**
  107632. * Get the list of animatables in the material.
  107633. * @returns the list of animatables object used in the material
  107634. */
  107635. getAnimatables(): IAnimatable[];
  107636. /**
  107637. * Gets the active textures from the material
  107638. * @returns an array of textures
  107639. */
  107640. getActiveTextures(): BaseTexture[];
  107641. /**
  107642. * Specifies if the material uses a texture
  107643. * @param texture defines the texture to check against the material
  107644. * @returns a boolean specifying if the material uses the texture
  107645. */
  107646. hasTexture(texture: BaseTexture): boolean;
  107647. /**
  107648. * Disposes the material
  107649. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107650. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107651. */
  107652. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107653. /**
  107654. * Makes a duplicate of the material, and gives it a new name
  107655. * @param name defines the new name for the duplicated material
  107656. * @returns the cloned material
  107657. */
  107658. clone(name: string): StandardMaterial;
  107659. /**
  107660. * Serializes this material in a JSON representation
  107661. * @returns the serialized material object
  107662. */
  107663. serialize(): any;
  107664. /**
  107665. * Creates a standard material from parsed material data
  107666. * @param source defines the JSON representation of the material
  107667. * @param scene defines the hosting scene
  107668. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107669. * @returns a new standard material
  107670. */
  107671. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107672. /**
  107673. * Are diffuse textures enabled in the application.
  107674. */
  107675. static get DiffuseTextureEnabled(): boolean;
  107676. static set DiffuseTextureEnabled(value: boolean);
  107677. /**
  107678. * Are detail textures enabled in the application.
  107679. */
  107680. static get DetailTextureEnabled(): boolean;
  107681. static set DetailTextureEnabled(value: boolean);
  107682. /**
  107683. * Are ambient textures enabled in the application.
  107684. */
  107685. static get AmbientTextureEnabled(): boolean;
  107686. static set AmbientTextureEnabled(value: boolean);
  107687. /**
  107688. * Are opacity textures enabled in the application.
  107689. */
  107690. static get OpacityTextureEnabled(): boolean;
  107691. static set OpacityTextureEnabled(value: boolean);
  107692. /**
  107693. * Are reflection textures enabled in the application.
  107694. */
  107695. static get ReflectionTextureEnabled(): boolean;
  107696. static set ReflectionTextureEnabled(value: boolean);
  107697. /**
  107698. * Are emissive textures enabled in the application.
  107699. */
  107700. static get EmissiveTextureEnabled(): boolean;
  107701. static set EmissiveTextureEnabled(value: boolean);
  107702. /**
  107703. * Are specular textures enabled in the application.
  107704. */
  107705. static get SpecularTextureEnabled(): boolean;
  107706. static set SpecularTextureEnabled(value: boolean);
  107707. /**
  107708. * Are bump textures enabled in the application.
  107709. */
  107710. static get BumpTextureEnabled(): boolean;
  107711. static set BumpTextureEnabled(value: boolean);
  107712. /**
  107713. * Are lightmap textures enabled in the application.
  107714. */
  107715. static get LightmapTextureEnabled(): boolean;
  107716. static set LightmapTextureEnabled(value: boolean);
  107717. /**
  107718. * Are refraction textures enabled in the application.
  107719. */
  107720. static get RefractionTextureEnabled(): boolean;
  107721. static set RefractionTextureEnabled(value: boolean);
  107722. /**
  107723. * Are color grading textures enabled in the application.
  107724. */
  107725. static get ColorGradingTextureEnabled(): boolean;
  107726. static set ColorGradingTextureEnabled(value: boolean);
  107727. /**
  107728. * Are fresnels enabled in the application.
  107729. */
  107730. static get FresnelEnabled(): boolean;
  107731. static set FresnelEnabled(value: boolean);
  107732. }
  107733. }
  107734. declare module BABYLON {
  107735. /**
  107736. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  107737. *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.
  107738. * The SPS is also a particle system. It provides some methods to manage the particles.
  107739. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  107740. *
  107741. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  107742. */
  107743. export class SolidParticleSystem implements IDisposable {
  107744. /**
  107745. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  107746. * Example : var p = SPS.particles[i];
  107747. */
  107748. particles: SolidParticle[];
  107749. /**
  107750. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  107751. */
  107752. nbParticles: number;
  107753. /**
  107754. * If the particles must ever face the camera (default false). Useful for planar particles.
  107755. */
  107756. billboard: boolean;
  107757. /**
  107758. * Recompute normals when adding a shape
  107759. */
  107760. recomputeNormals: boolean;
  107761. /**
  107762. * This a counter ofr your own usage. It's not set by any SPS functions.
  107763. */
  107764. counter: number;
  107765. /**
  107766. * The SPS name. This name is also given to the underlying mesh.
  107767. */
  107768. name: string;
  107769. /**
  107770. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  107771. */
  107772. mesh: Mesh;
  107773. /**
  107774. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  107775. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  107776. */
  107777. vars: any;
  107778. /**
  107779. * This array is populated when the SPS is set as 'pickable'.
  107780. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  107781. * Each element of this array is an object `{idx: int, faceId: int}`.
  107782. * `idx` is the picked particle index in the `SPS.particles` array
  107783. * `faceId` is the picked face index counted within this particle.
  107784. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  107785. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  107786. * Use the method SPS.pickedParticle(pickingInfo) instead.
  107787. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107788. */
  107789. pickedParticles: {
  107790. idx: number;
  107791. faceId: number;
  107792. }[];
  107793. /**
  107794. * This array is populated when the SPS is set as 'pickable'
  107795. * Each key of this array is a submesh index.
  107796. * Each element of this array is a second array defined like this :
  107797. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  107798. * Each element of this second array is an object `{idx: int, faceId: int}`.
  107799. * `idx` is the picked particle index in the `SPS.particles` array
  107800. * `faceId` is the picked face index counted within this particle.
  107801. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  107802. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  107803. */
  107804. pickedBySubMesh: {
  107805. idx: number;
  107806. faceId: number;
  107807. }[][];
  107808. /**
  107809. * This array is populated when `enableDepthSort` is set to true.
  107810. * Each element of this array is an instance of the class DepthSortedParticle.
  107811. */
  107812. depthSortedParticles: DepthSortedParticle[];
  107813. /**
  107814. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  107815. * @hidden
  107816. */
  107817. _bSphereOnly: boolean;
  107818. /**
  107819. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  107820. * @hidden
  107821. */
  107822. _bSphereRadiusFactor: number;
  107823. private _scene;
  107824. private _positions;
  107825. private _indices;
  107826. private _normals;
  107827. private _colors;
  107828. private _uvs;
  107829. private _indices32;
  107830. private _positions32;
  107831. private _normals32;
  107832. private _fixedNormal32;
  107833. private _colors32;
  107834. private _uvs32;
  107835. private _index;
  107836. private _updatable;
  107837. private _pickable;
  107838. private _isVisibilityBoxLocked;
  107839. private _alwaysVisible;
  107840. private _depthSort;
  107841. private _expandable;
  107842. private _shapeCounter;
  107843. private _copy;
  107844. private _color;
  107845. private _computeParticleColor;
  107846. private _computeParticleTexture;
  107847. private _computeParticleRotation;
  107848. private _computeParticleVertex;
  107849. private _computeBoundingBox;
  107850. private _depthSortParticles;
  107851. private _camera;
  107852. private _mustUnrotateFixedNormals;
  107853. private _particlesIntersect;
  107854. private _needs32Bits;
  107855. private _isNotBuilt;
  107856. private _lastParticleId;
  107857. private _idxOfId;
  107858. private _multimaterialEnabled;
  107859. private _useModelMaterial;
  107860. private _indicesByMaterial;
  107861. private _materialIndexes;
  107862. private _depthSortFunction;
  107863. private _materialSortFunction;
  107864. private _materials;
  107865. private _multimaterial;
  107866. private _materialIndexesById;
  107867. private _defaultMaterial;
  107868. private _autoUpdateSubMeshes;
  107869. private _tmpVertex;
  107870. /**
  107871. * Creates a SPS (Solid Particle System) object.
  107872. * @param name (String) is the SPS name, this will be the underlying mesh name.
  107873. * @param scene (Scene) is the scene in which the SPS is added.
  107874. * @param options defines the options of the sps e.g.
  107875. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  107876. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  107877. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  107878. * * 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.
  107879. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  107880. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  107881. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  107882. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  107883. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  107884. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  107885. */
  107886. constructor(name: string, scene: Scene, options?: {
  107887. updatable?: boolean;
  107888. isPickable?: boolean;
  107889. enableDepthSort?: boolean;
  107890. particleIntersection?: boolean;
  107891. boundingSphereOnly?: boolean;
  107892. bSphereRadiusFactor?: number;
  107893. expandable?: boolean;
  107894. useModelMaterial?: boolean;
  107895. enableMultiMaterial?: boolean;
  107896. });
  107897. /**
  107898. * Builds the SPS underlying mesh. Returns a standard Mesh.
  107899. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  107900. * @returns the created mesh
  107901. */
  107902. buildMesh(): Mesh;
  107903. /**
  107904. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  107905. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  107906. * Thus the particles generated from `digest()` have their property `position` set yet.
  107907. * @param mesh ( Mesh ) is the mesh to be digested
  107908. * @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
  107909. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  107910. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  107911. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107912. * @returns the current SPS
  107913. */
  107914. digest(mesh: Mesh, options?: {
  107915. facetNb?: number;
  107916. number?: number;
  107917. delta?: number;
  107918. storage?: [];
  107919. }): SolidParticleSystem;
  107920. /**
  107921. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  107922. * @hidden
  107923. */
  107924. private _unrotateFixedNormals;
  107925. /**
  107926. * Resets the temporary working copy particle
  107927. * @hidden
  107928. */
  107929. private _resetCopy;
  107930. /**
  107931. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  107932. * @param p the current index in the positions array to be updated
  107933. * @param ind the current index in the indices array
  107934. * @param shape a Vector3 array, the shape geometry
  107935. * @param positions the positions array to be updated
  107936. * @param meshInd the shape indices array
  107937. * @param indices the indices array to be updated
  107938. * @param meshUV the shape uv array
  107939. * @param uvs the uv array to be updated
  107940. * @param meshCol the shape color array
  107941. * @param colors the color array to be updated
  107942. * @param meshNor the shape normals array
  107943. * @param normals the normals array to be updated
  107944. * @param idx the particle index
  107945. * @param idxInShape the particle index in its shape
  107946. * @param options the addShape() method passed options
  107947. * @model the particle model
  107948. * @hidden
  107949. */
  107950. private _meshBuilder;
  107951. /**
  107952. * Returns a shape Vector3 array from positions float array
  107953. * @param positions float array
  107954. * @returns a vector3 array
  107955. * @hidden
  107956. */
  107957. private _posToShape;
  107958. /**
  107959. * Returns a shapeUV array from a float uvs (array deep copy)
  107960. * @param uvs as a float array
  107961. * @returns a shapeUV array
  107962. * @hidden
  107963. */
  107964. private _uvsToShapeUV;
  107965. /**
  107966. * Adds a new particle object in the particles array
  107967. * @param idx particle index in particles array
  107968. * @param id particle id
  107969. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  107970. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  107971. * @param model particle ModelShape object
  107972. * @param shapeId model shape identifier
  107973. * @param idxInShape index of the particle in the current model
  107974. * @param bInfo model bounding info object
  107975. * @param storage target storage array, if any
  107976. * @hidden
  107977. */
  107978. private _addParticle;
  107979. /**
  107980. * Adds some particles to the SPS from the model shape. Returns the shape id.
  107981. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  107982. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  107983. * @param nb (positive integer) the number of particles to be created from this model
  107984. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  107985. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  107986. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  107987. * @returns the number of shapes in the system
  107988. */
  107989. addShape(mesh: Mesh, nb: number, options?: {
  107990. positionFunction?: any;
  107991. vertexFunction?: any;
  107992. storage?: [];
  107993. }): number;
  107994. /**
  107995. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  107996. * @hidden
  107997. */
  107998. private _rebuildParticle;
  107999. /**
  108000. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108001. * @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.
  108002. * @returns the SPS.
  108003. */
  108004. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108005. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108006. * Returns an array with the removed particles.
  108007. * 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.
  108008. * The SPS can't be empty so at least one particle needs to remain in place.
  108009. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108010. * @param start index of the first particle to remove
  108011. * @param end index of the last particle to remove (included)
  108012. * @returns an array populated with the removed particles
  108013. */
  108014. removeParticles(start: number, end: number): SolidParticle[];
  108015. /**
  108016. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108017. * @param solidParticleArray an array populated with Solid Particles objects
  108018. * @returns the SPS
  108019. */
  108020. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108021. /**
  108022. * Creates a new particle and modifies the SPS mesh geometry :
  108023. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108024. * - calls _addParticle() to populate the particle array
  108025. * factorized code from addShape() and insertParticlesFromArray()
  108026. * @param idx particle index in the particles array
  108027. * @param i particle index in its shape
  108028. * @param modelShape particle ModelShape object
  108029. * @param shape shape vertex array
  108030. * @param meshInd shape indices array
  108031. * @param meshUV shape uv array
  108032. * @param meshCol shape color array
  108033. * @param meshNor shape normals array
  108034. * @param bbInfo shape bounding info
  108035. * @param storage target particle storage
  108036. * @options addShape() passed options
  108037. * @hidden
  108038. */
  108039. private _insertNewParticle;
  108040. /**
  108041. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108042. * This method calls `updateParticle()` for each particle of the SPS.
  108043. * For an animated SPS, it is usually called within the render loop.
  108044. * 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.
  108045. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108046. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108047. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108048. * @returns the SPS.
  108049. */
  108050. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108051. /**
  108052. * Disposes the SPS.
  108053. */
  108054. dispose(): void;
  108055. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108056. * idx is the particle index in the SPS
  108057. * faceId is the picked face index counted within this particle.
  108058. * Returns null if the pickInfo can't identify a picked particle.
  108059. * @param pickingInfo (PickingInfo object)
  108060. * @returns {idx: number, faceId: number} or null
  108061. */
  108062. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108063. idx: number;
  108064. faceId: number;
  108065. }>;
  108066. /**
  108067. * Returns a SolidParticle object from its identifier : particle.id
  108068. * @param id (integer) the particle Id
  108069. * @returns the searched particle or null if not found in the SPS.
  108070. */
  108071. getParticleById(id: number): Nullable<SolidParticle>;
  108072. /**
  108073. * Returns a new array populated with the particles having the passed shapeId.
  108074. * @param shapeId (integer) the shape identifier
  108075. * @returns a new solid particle array
  108076. */
  108077. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108078. /**
  108079. * Populates the passed array "ref" with the particles having the passed shapeId.
  108080. * @param shapeId the shape identifier
  108081. * @returns the SPS
  108082. * @param ref
  108083. */
  108084. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108085. /**
  108086. * Computes the required SubMeshes according the materials assigned to the particles.
  108087. * @returns the solid particle system.
  108088. * Does nothing if called before the SPS mesh is built.
  108089. */
  108090. computeSubMeshes(): SolidParticleSystem;
  108091. /**
  108092. * Sorts the solid particles by material when MultiMaterial is enabled.
  108093. * Updates the indices32 array.
  108094. * Updates the indicesByMaterial array.
  108095. * Updates the mesh indices array.
  108096. * @returns the SPS
  108097. * @hidden
  108098. */
  108099. private _sortParticlesByMaterial;
  108100. /**
  108101. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108102. * @hidden
  108103. */
  108104. private _setMaterialIndexesById;
  108105. /**
  108106. * Returns an array with unique values of Materials from the passed array
  108107. * @param array the material array to be checked and filtered
  108108. * @hidden
  108109. */
  108110. private _filterUniqueMaterialId;
  108111. /**
  108112. * Sets a new Standard Material as _defaultMaterial if not already set.
  108113. * @hidden
  108114. */
  108115. private _setDefaultMaterial;
  108116. /**
  108117. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108118. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108119. * @returns the SPS.
  108120. */
  108121. refreshVisibleSize(): SolidParticleSystem;
  108122. /**
  108123. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108124. * @param size the size (float) of the visibility box
  108125. * note : this doesn't lock the SPS mesh bounding box.
  108126. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108127. */
  108128. setVisibilityBox(size: number): void;
  108129. /**
  108130. * Gets whether the SPS as always visible or not
  108131. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108132. */
  108133. get isAlwaysVisible(): boolean;
  108134. /**
  108135. * Sets the SPS as always visible or not
  108136. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108137. */
  108138. set isAlwaysVisible(val: boolean);
  108139. /**
  108140. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108141. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108142. */
  108143. set isVisibilityBoxLocked(val: boolean);
  108144. /**
  108145. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108146. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108147. */
  108148. get isVisibilityBoxLocked(): boolean;
  108149. /**
  108150. * Tells to `setParticles()` to compute the particle rotations or not.
  108151. * Default value : true. The SPS is faster when it's set to false.
  108152. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108153. */
  108154. set computeParticleRotation(val: boolean);
  108155. /**
  108156. * Tells to `setParticles()` to compute the particle colors or not.
  108157. * Default value : true. The SPS is faster when it's set to false.
  108158. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108159. */
  108160. set computeParticleColor(val: boolean);
  108161. set computeParticleTexture(val: boolean);
  108162. /**
  108163. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108164. * Default value : false. The SPS is faster when it's set to false.
  108165. * Note : the particle custom vertex positions aren't stored values.
  108166. */
  108167. set computeParticleVertex(val: boolean);
  108168. /**
  108169. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108170. */
  108171. set computeBoundingBox(val: boolean);
  108172. /**
  108173. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108174. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108175. * Default : `true`
  108176. */
  108177. set depthSortParticles(val: boolean);
  108178. /**
  108179. * Gets if `setParticles()` computes the particle rotations or not.
  108180. * Default value : true. The SPS is faster when it's set to false.
  108181. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108182. */
  108183. get computeParticleRotation(): boolean;
  108184. /**
  108185. * Gets if `setParticles()` computes the particle colors or not.
  108186. * Default value : true. The SPS is faster when it's set to false.
  108187. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108188. */
  108189. get computeParticleColor(): boolean;
  108190. /**
  108191. * Gets if `setParticles()` computes the particle textures or not.
  108192. * Default value : true. The SPS is faster when it's set to false.
  108193. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108194. */
  108195. get computeParticleTexture(): boolean;
  108196. /**
  108197. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108198. * Default value : false. The SPS is faster when it's set to false.
  108199. * Note : the particle custom vertex positions aren't stored values.
  108200. */
  108201. get computeParticleVertex(): boolean;
  108202. /**
  108203. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108204. */
  108205. get computeBoundingBox(): boolean;
  108206. /**
  108207. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108208. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108209. * Default : `true`
  108210. */
  108211. get depthSortParticles(): boolean;
  108212. /**
  108213. * Gets if the SPS is created as expandable at construction time.
  108214. * Default : `false`
  108215. */
  108216. get expandable(): boolean;
  108217. /**
  108218. * Gets if the SPS supports the Multi Materials
  108219. */
  108220. get multimaterialEnabled(): boolean;
  108221. /**
  108222. * Gets if the SPS uses the model materials for its own multimaterial.
  108223. */
  108224. get useModelMaterial(): boolean;
  108225. /**
  108226. * The SPS used material array.
  108227. */
  108228. get materials(): Material[];
  108229. /**
  108230. * Sets the SPS MultiMaterial from the passed materials.
  108231. * Note : the passed array is internally copied and not used then by reference.
  108232. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108233. */
  108234. setMultiMaterial(materials: Material[]): void;
  108235. /**
  108236. * The SPS computed multimaterial object
  108237. */
  108238. get multimaterial(): MultiMaterial;
  108239. set multimaterial(mm: MultiMaterial);
  108240. /**
  108241. * If the subMeshes must be updated on the next call to setParticles()
  108242. */
  108243. get autoUpdateSubMeshes(): boolean;
  108244. set autoUpdateSubMeshes(val: boolean);
  108245. /**
  108246. * This function does nothing. It may be overwritten to set all the particle first values.
  108247. * The SPS doesn't call this function, you may have to call it by your own.
  108248. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108249. */
  108250. initParticles(): void;
  108251. /**
  108252. * This function does nothing. It may be overwritten to recycle a particle.
  108253. * The SPS doesn't call this function, you may have to call it by your own.
  108254. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108255. * @param particle The particle to recycle
  108256. * @returns the recycled particle
  108257. */
  108258. recycleParticle(particle: SolidParticle): SolidParticle;
  108259. /**
  108260. * Updates a particle : this function should be overwritten by the user.
  108261. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  108262. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  108263. * @example : just set a particle position or velocity and recycle conditions
  108264. * @param particle The particle to update
  108265. * @returns the updated particle
  108266. */
  108267. updateParticle(particle: SolidParticle): SolidParticle;
  108268. /**
  108269. * Updates a vertex of a particle : it can be overwritten by the user.
  108270. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  108271. * @param particle the current particle
  108272. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  108273. * @param pt the index of the current vertex in the particle shape
  108274. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  108275. * @example : just set a vertex particle position or color
  108276. * @returns the sps
  108277. */
  108278. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  108279. /**
  108280. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  108281. * This does nothing and may be overwritten by the user.
  108282. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108283. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108284. * @param update the boolean update value actually passed to setParticles()
  108285. */
  108286. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108287. /**
  108288. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  108289. * This will be passed three parameters.
  108290. * This does nothing and may be overwritten by the user.
  108291. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108292. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  108293. * @param update the boolean update value actually passed to setParticles()
  108294. */
  108295. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  108296. }
  108297. }
  108298. declare module BABYLON {
  108299. /**
  108300. * Represents one particle of a solid particle system.
  108301. */
  108302. export class SolidParticle {
  108303. /**
  108304. * particle global index
  108305. */
  108306. idx: number;
  108307. /**
  108308. * particle identifier
  108309. */
  108310. id: number;
  108311. /**
  108312. * The color of the particle
  108313. */
  108314. color: Nullable<Color4>;
  108315. /**
  108316. * The world space position of the particle.
  108317. */
  108318. position: Vector3;
  108319. /**
  108320. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108321. */
  108322. rotation: Vector3;
  108323. /**
  108324. * The world space rotation quaternion of the particle.
  108325. */
  108326. rotationQuaternion: Nullable<Quaternion>;
  108327. /**
  108328. * The scaling of the particle.
  108329. */
  108330. scaling: Vector3;
  108331. /**
  108332. * The uvs of the particle.
  108333. */
  108334. uvs: Vector4;
  108335. /**
  108336. * The current speed of the particle.
  108337. */
  108338. velocity: Vector3;
  108339. /**
  108340. * The pivot point in the particle local space.
  108341. */
  108342. pivot: Vector3;
  108343. /**
  108344. * Must the particle be translated from its pivot point in its local space ?
  108345. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108346. * Default : false
  108347. */
  108348. translateFromPivot: boolean;
  108349. /**
  108350. * Is the particle active or not ?
  108351. */
  108352. alive: boolean;
  108353. /**
  108354. * Is the particle visible or not ?
  108355. */
  108356. isVisible: boolean;
  108357. /**
  108358. * Index of this particle in the global "positions" array (Internal use)
  108359. * @hidden
  108360. */
  108361. _pos: number;
  108362. /**
  108363. * @hidden Index of this particle in the global "indices" array (Internal use)
  108364. */
  108365. _ind: number;
  108366. /**
  108367. * @hidden ModelShape of this particle (Internal use)
  108368. */
  108369. _model: ModelShape;
  108370. /**
  108371. * ModelShape id of this particle
  108372. */
  108373. shapeId: number;
  108374. /**
  108375. * Index of the particle in its shape id
  108376. */
  108377. idxInShape: number;
  108378. /**
  108379. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  108380. */
  108381. _modelBoundingInfo: BoundingInfo;
  108382. /**
  108383. * @hidden Particle BoundingInfo object (Internal use)
  108384. */
  108385. _boundingInfo: BoundingInfo;
  108386. /**
  108387. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  108388. */
  108389. _sps: SolidParticleSystem;
  108390. /**
  108391. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108392. */
  108393. _stillInvisible: boolean;
  108394. /**
  108395. * @hidden Last computed particle rotation matrix
  108396. */
  108397. _rotationMatrix: number[];
  108398. /**
  108399. * Parent particle Id, if any.
  108400. * Default null.
  108401. */
  108402. parentId: Nullable<number>;
  108403. /**
  108404. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  108405. */
  108406. materialIndex: Nullable<number>;
  108407. /**
  108408. * Custom object or properties.
  108409. */
  108410. props: Nullable<any>;
  108411. /**
  108412. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108413. * The possible values are :
  108414. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108415. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108416. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108417. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108418. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108419. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108420. * */
  108421. cullingStrategy: number;
  108422. /**
  108423. * @hidden Internal global position in the SPS.
  108424. */
  108425. _globalPosition: Vector3;
  108426. /**
  108427. * Creates a Solid Particle object.
  108428. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108429. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  108430. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  108431. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108432. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108433. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108434. * @param shapeId (integer) is the model shape identifier in the SPS.
  108435. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108436. * @param sps defines the sps it is associated to
  108437. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108438. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  108439. */
  108440. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  108441. /**
  108442. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  108443. * @param target the particle target
  108444. * @returns the current particle
  108445. */
  108446. copyToRef(target: SolidParticle): SolidParticle;
  108447. /**
  108448. * Legacy support, changed scale to scaling
  108449. */
  108450. get scale(): Vector3;
  108451. /**
  108452. * Legacy support, changed scale to scaling
  108453. */
  108454. set scale(scale: Vector3);
  108455. /**
  108456. * Legacy support, changed quaternion to rotationQuaternion
  108457. */
  108458. get quaternion(): Nullable<Quaternion>;
  108459. /**
  108460. * Legacy support, changed quaternion to rotationQuaternion
  108461. */
  108462. set quaternion(q: Nullable<Quaternion>);
  108463. /**
  108464. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  108465. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  108466. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  108467. * @returns true if it intersects
  108468. */
  108469. intersectsMesh(target: Mesh | SolidParticle): boolean;
  108470. /**
  108471. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  108472. * A particle is in the frustum if its bounding box intersects the frustum
  108473. * @param frustumPlanes defines the frustum to test
  108474. * @returns true if the particle is in the frustum planes
  108475. */
  108476. isInFrustum(frustumPlanes: Plane[]): boolean;
  108477. /**
  108478. * get the rotation matrix of the particle
  108479. * @hidden
  108480. */
  108481. getRotationMatrix(m: Matrix): void;
  108482. }
  108483. /**
  108484. * Represents the shape of the model used by one particle of a solid particle system.
  108485. * SPS internal tool, don't use it manually.
  108486. */
  108487. export class ModelShape {
  108488. /**
  108489. * The shape id
  108490. * @hidden
  108491. */
  108492. shapeID: number;
  108493. /**
  108494. * flat array of model positions (internal use)
  108495. * @hidden
  108496. */
  108497. _shape: Vector3[];
  108498. /**
  108499. * flat array of model UVs (internal use)
  108500. * @hidden
  108501. */
  108502. _shapeUV: number[];
  108503. /**
  108504. * color array of the model
  108505. * @hidden
  108506. */
  108507. _shapeColors: number[];
  108508. /**
  108509. * indices array of the model
  108510. * @hidden
  108511. */
  108512. _indices: number[];
  108513. /**
  108514. * normals array of the model
  108515. * @hidden
  108516. */
  108517. _normals: number[];
  108518. /**
  108519. * length of the shape in the model indices array (internal use)
  108520. * @hidden
  108521. */
  108522. _indicesLength: number;
  108523. /**
  108524. * Custom position function (internal use)
  108525. * @hidden
  108526. */
  108527. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  108528. /**
  108529. * Custom vertex function (internal use)
  108530. * @hidden
  108531. */
  108532. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  108533. /**
  108534. * Model material (internal use)
  108535. * @hidden
  108536. */
  108537. _material: Nullable<Material>;
  108538. /**
  108539. * 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.
  108540. * SPS internal tool, don't use it manually.
  108541. * @hidden
  108542. */
  108543. 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>);
  108544. }
  108545. /**
  108546. * Represents a Depth Sorted Particle in the solid particle system.
  108547. * @hidden
  108548. */
  108549. export class DepthSortedParticle {
  108550. /**
  108551. * Particle index
  108552. */
  108553. idx: number;
  108554. /**
  108555. * Index of the particle in the "indices" array
  108556. */
  108557. ind: number;
  108558. /**
  108559. * Length of the particle shape in the "indices" array
  108560. */
  108561. indicesLength: number;
  108562. /**
  108563. * Squared distance from the particle to the camera
  108564. */
  108565. sqDistance: number;
  108566. /**
  108567. * Material index when used with MultiMaterials
  108568. */
  108569. materialIndex: number;
  108570. /**
  108571. * Creates a new sorted particle
  108572. * @param materialIndex
  108573. */
  108574. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  108575. }
  108576. /**
  108577. * Represents a solid particle vertex
  108578. */
  108579. export class SolidParticleVertex {
  108580. /**
  108581. * Vertex position
  108582. */
  108583. position: Vector3;
  108584. /**
  108585. * Vertex color
  108586. */
  108587. color: Color4;
  108588. /**
  108589. * Vertex UV
  108590. */
  108591. uv: Vector2;
  108592. /**
  108593. * Creates a new solid particle vertex
  108594. */
  108595. constructor();
  108596. /** Vertex x coordinate */
  108597. get x(): number;
  108598. set x(val: number);
  108599. /** Vertex y coordinate */
  108600. get y(): number;
  108601. set y(val: number);
  108602. /** Vertex z coordinate */
  108603. get z(): number;
  108604. set z(val: number);
  108605. }
  108606. }
  108607. declare module BABYLON {
  108608. /**
  108609. * @hidden
  108610. */
  108611. export class _MeshCollisionData {
  108612. _checkCollisions: boolean;
  108613. _collisionMask: number;
  108614. _collisionGroup: number;
  108615. _surroundingMeshes: Nullable<AbstractMesh[]>;
  108616. _collider: Nullable<Collider>;
  108617. _oldPositionForCollisions: Vector3;
  108618. _diffPositionForCollisions: Vector3;
  108619. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  108620. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  108621. }
  108622. }
  108623. declare module BABYLON {
  108624. /** @hidden */
  108625. class _FacetDataStorage {
  108626. facetPositions: Vector3[];
  108627. facetNormals: Vector3[];
  108628. facetPartitioning: number[][];
  108629. facetNb: number;
  108630. partitioningSubdivisions: number;
  108631. partitioningBBoxRatio: number;
  108632. facetDataEnabled: boolean;
  108633. facetParameters: any;
  108634. bbSize: Vector3;
  108635. subDiv: {
  108636. max: number;
  108637. X: number;
  108638. Y: number;
  108639. Z: number;
  108640. };
  108641. facetDepthSort: boolean;
  108642. facetDepthSortEnabled: boolean;
  108643. depthSortedIndices: IndicesArray;
  108644. depthSortedFacets: {
  108645. ind: number;
  108646. sqDistance: number;
  108647. }[];
  108648. facetDepthSortFunction: (f1: {
  108649. ind: number;
  108650. sqDistance: number;
  108651. }, f2: {
  108652. ind: number;
  108653. sqDistance: number;
  108654. }) => number;
  108655. facetDepthSortFrom: Vector3;
  108656. facetDepthSortOrigin: Vector3;
  108657. invertedMatrix: Matrix;
  108658. }
  108659. /**
  108660. * @hidden
  108661. **/
  108662. class _InternalAbstractMeshDataInfo {
  108663. _hasVertexAlpha: boolean;
  108664. _useVertexColors: boolean;
  108665. _numBoneInfluencers: number;
  108666. _applyFog: boolean;
  108667. _receiveShadows: boolean;
  108668. _facetData: _FacetDataStorage;
  108669. _visibility: number;
  108670. _skeleton: Nullable<Skeleton>;
  108671. _layerMask: number;
  108672. _computeBonesUsingShaders: boolean;
  108673. _isActive: boolean;
  108674. _onlyForInstances: boolean;
  108675. _isActiveIntermediate: boolean;
  108676. _onlyForInstancesIntermediate: boolean;
  108677. _actAsRegularMesh: boolean;
  108678. }
  108679. /**
  108680. * Class used to store all common mesh properties
  108681. */
  108682. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  108683. /** No occlusion */
  108684. static OCCLUSION_TYPE_NONE: number;
  108685. /** Occlusion set to optimisitic */
  108686. static OCCLUSION_TYPE_OPTIMISTIC: number;
  108687. /** Occlusion set to strict */
  108688. static OCCLUSION_TYPE_STRICT: number;
  108689. /** Use an accurante occlusion algorithm */
  108690. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  108691. /** Use a conservative occlusion algorithm */
  108692. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  108693. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  108694. * Test order :
  108695. * Is the bounding sphere outside the frustum ?
  108696. * If not, are the bounding box vertices outside the frustum ?
  108697. * It not, then the cullable object is in the frustum.
  108698. */
  108699. static readonly CULLINGSTRATEGY_STANDARD: number;
  108700. /** Culling strategy : Bounding Sphere Only.
  108701. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  108702. * It's also less accurate than the standard because some not visible objects can still be selected.
  108703. * Test : is the bounding sphere outside the frustum ?
  108704. * If not, then the cullable object is in the frustum.
  108705. */
  108706. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  108707. /** Culling strategy : Optimistic Inclusion.
  108708. * This in an inclusion test first, then the standard exclusion test.
  108709. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  108710. * 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.
  108711. * Anyway, it's as accurate as the standard strategy.
  108712. * Test :
  108713. * Is the cullable object bounding sphere center in the frustum ?
  108714. * If not, apply the default culling strategy.
  108715. */
  108716. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  108717. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  108718. * This in an inclusion test first, then the bounding sphere only exclusion test.
  108719. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  108720. * 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.
  108721. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  108722. * Test :
  108723. * Is the cullable object bounding sphere center in the frustum ?
  108724. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  108725. */
  108726. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  108727. /**
  108728. * No billboard
  108729. */
  108730. static get BILLBOARDMODE_NONE(): number;
  108731. /** Billboard on X axis */
  108732. static get BILLBOARDMODE_X(): number;
  108733. /** Billboard on Y axis */
  108734. static get BILLBOARDMODE_Y(): number;
  108735. /** Billboard on Z axis */
  108736. static get BILLBOARDMODE_Z(): number;
  108737. /** Billboard on all axes */
  108738. static get BILLBOARDMODE_ALL(): number;
  108739. /** Billboard on using position instead of orientation */
  108740. static get BILLBOARDMODE_USE_POSITION(): number;
  108741. /** @hidden */
  108742. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  108743. /**
  108744. * The culling strategy to use to check whether the mesh must be rendered or not.
  108745. * This value can be changed at any time and will be used on the next render mesh selection.
  108746. * The possible values are :
  108747. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108748. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108749. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108750. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108751. * Please read each static variable documentation to get details about the culling process.
  108752. * */
  108753. cullingStrategy: number;
  108754. /**
  108755. * Gets the number of facets in the mesh
  108756. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108757. */
  108758. get facetNb(): number;
  108759. /**
  108760. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  108761. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108762. */
  108763. get partitioningSubdivisions(): number;
  108764. set partitioningSubdivisions(nb: number);
  108765. /**
  108766. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  108767. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  108768. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  108769. */
  108770. get partitioningBBoxRatio(): number;
  108771. set partitioningBBoxRatio(ratio: number);
  108772. /**
  108773. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  108774. * Works only for updatable meshes.
  108775. * Doesn't work with multi-materials
  108776. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108777. */
  108778. get mustDepthSortFacets(): boolean;
  108779. set mustDepthSortFacets(sort: boolean);
  108780. /**
  108781. * The location (Vector3) where the facet depth sort must be computed from.
  108782. * By default, the active camera position.
  108783. * Used only when facet depth sort is enabled
  108784. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  108785. */
  108786. get facetDepthSortFrom(): Vector3;
  108787. set facetDepthSortFrom(location: Vector3);
  108788. /**
  108789. * gets a boolean indicating if facetData is enabled
  108790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  108791. */
  108792. get isFacetDataEnabled(): boolean;
  108793. /** @hidden */
  108794. _updateNonUniformScalingState(value: boolean): boolean;
  108795. /**
  108796. * An event triggered when this mesh collides with another one
  108797. */
  108798. onCollideObservable: Observable<AbstractMesh>;
  108799. /** Set a function to call when this mesh collides with another one */
  108800. set onCollide(callback: () => void);
  108801. /**
  108802. * An event triggered when the collision's position changes
  108803. */
  108804. onCollisionPositionChangeObservable: Observable<Vector3>;
  108805. /** Set a function to call when the collision's position changes */
  108806. set onCollisionPositionChange(callback: () => void);
  108807. /**
  108808. * An event triggered when material is changed
  108809. */
  108810. onMaterialChangedObservable: Observable<AbstractMesh>;
  108811. /**
  108812. * Gets or sets the orientation for POV movement & rotation
  108813. */
  108814. definedFacingForward: boolean;
  108815. /** @hidden */
  108816. _occlusionQuery: Nullable<WebGLQuery>;
  108817. /** @hidden */
  108818. _renderingGroup: Nullable<RenderingGroup>;
  108819. /**
  108820. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108821. */
  108822. get visibility(): number;
  108823. /**
  108824. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  108825. */
  108826. set visibility(value: number);
  108827. /** Gets or sets the alpha index used to sort transparent meshes
  108828. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  108829. */
  108830. alphaIndex: number;
  108831. /**
  108832. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  108833. */
  108834. isVisible: boolean;
  108835. /**
  108836. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  108837. */
  108838. isPickable: boolean;
  108839. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  108840. showSubMeshesBoundingBox: boolean;
  108841. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  108842. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  108843. */
  108844. isBlocker: boolean;
  108845. /**
  108846. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  108847. */
  108848. enablePointerMoveEvents: boolean;
  108849. /**
  108850. * Specifies the rendering group id for this mesh (0 by default)
  108851. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  108852. */
  108853. renderingGroupId: number;
  108854. private _material;
  108855. /** Gets or sets current material */
  108856. get material(): Nullable<Material>;
  108857. set material(value: Nullable<Material>);
  108858. /**
  108859. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  108860. * @see http://doc.babylonjs.com/babylon101/shadows
  108861. */
  108862. get receiveShadows(): boolean;
  108863. set receiveShadows(value: boolean);
  108864. /** Defines color to use when rendering outline */
  108865. outlineColor: Color3;
  108866. /** Define width to use when rendering outline */
  108867. outlineWidth: number;
  108868. /** Defines color to use when rendering overlay */
  108869. overlayColor: Color3;
  108870. /** Defines alpha to use when rendering overlay */
  108871. overlayAlpha: number;
  108872. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  108873. get hasVertexAlpha(): boolean;
  108874. set hasVertexAlpha(value: boolean);
  108875. /** 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) */
  108876. get useVertexColors(): boolean;
  108877. set useVertexColors(value: boolean);
  108878. /**
  108879. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  108880. */
  108881. get computeBonesUsingShaders(): boolean;
  108882. set computeBonesUsingShaders(value: boolean);
  108883. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  108884. get numBoneInfluencers(): number;
  108885. set numBoneInfluencers(value: number);
  108886. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  108887. get applyFog(): boolean;
  108888. set applyFog(value: boolean);
  108889. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  108890. useOctreeForRenderingSelection: boolean;
  108891. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  108892. useOctreeForPicking: boolean;
  108893. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  108894. useOctreeForCollisions: boolean;
  108895. /**
  108896. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  108897. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  108898. */
  108899. get layerMask(): number;
  108900. set layerMask(value: number);
  108901. /**
  108902. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  108903. */
  108904. alwaysSelectAsActiveMesh: boolean;
  108905. /**
  108906. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  108907. */
  108908. doNotSyncBoundingInfo: boolean;
  108909. /**
  108910. * Gets or sets the current action manager
  108911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108912. */
  108913. actionManager: Nullable<AbstractActionManager>;
  108914. private _meshCollisionData;
  108915. /**
  108916. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  108917. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108918. */
  108919. ellipsoid: Vector3;
  108920. /**
  108921. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  108922. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108923. */
  108924. ellipsoidOffset: Vector3;
  108925. /**
  108926. * Gets or sets a collision mask used to mask collisions (default is -1).
  108927. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108928. */
  108929. get collisionMask(): number;
  108930. set collisionMask(mask: number);
  108931. /**
  108932. * Gets or sets the current collision group mask (-1 by default).
  108933. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  108934. */
  108935. get collisionGroup(): number;
  108936. set collisionGroup(mask: number);
  108937. /**
  108938. * Gets or sets current surrounding meshes (null by default).
  108939. *
  108940. * By default collision detection is tested against every mesh in the scene.
  108941. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  108942. * meshes will be tested for the collision.
  108943. *
  108944. * Note: if set to an empty array no collision will happen when this mesh is moved.
  108945. */
  108946. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  108947. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  108948. /**
  108949. * Defines edge width used when edgesRenderer is enabled
  108950. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108951. */
  108952. edgesWidth: number;
  108953. /**
  108954. * Defines edge color used when edgesRenderer is enabled
  108955. * @see https://www.babylonjs-playground.com/#10OJSG#13
  108956. */
  108957. edgesColor: Color4;
  108958. /** @hidden */
  108959. _edgesRenderer: Nullable<IEdgesRenderer>;
  108960. /** @hidden */
  108961. _masterMesh: Nullable<AbstractMesh>;
  108962. /** @hidden */
  108963. _boundingInfo: Nullable<BoundingInfo>;
  108964. /** @hidden */
  108965. _renderId: number;
  108966. /**
  108967. * Gets or sets the list of subMeshes
  108968. * @see http://doc.babylonjs.com/how_to/multi_materials
  108969. */
  108970. subMeshes: SubMesh[];
  108971. /** @hidden */
  108972. _intersectionsInProgress: AbstractMesh[];
  108973. /** @hidden */
  108974. _unIndexed: boolean;
  108975. /** @hidden */
  108976. _lightSources: Light[];
  108977. /** Gets the list of lights affecting that mesh */
  108978. get lightSources(): Light[];
  108979. /** @hidden */
  108980. get _positions(): Nullable<Vector3[]>;
  108981. /** @hidden */
  108982. _waitingData: {
  108983. lods: Nullable<any>;
  108984. actions: Nullable<any>;
  108985. freezeWorldMatrix: Nullable<boolean>;
  108986. };
  108987. /** @hidden */
  108988. _bonesTransformMatrices: Nullable<Float32Array>;
  108989. /** @hidden */
  108990. _transformMatrixTexture: Nullable<RawTexture>;
  108991. /**
  108992. * Gets or sets a skeleton to apply skining transformations
  108993. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  108994. */
  108995. set skeleton(value: Nullable<Skeleton>);
  108996. get skeleton(): Nullable<Skeleton>;
  108997. /**
  108998. * An event triggered when the mesh is rebuilt.
  108999. */
  109000. onRebuildObservable: Observable<AbstractMesh>;
  109001. /**
  109002. * Creates a new AbstractMesh
  109003. * @param name defines the name of the mesh
  109004. * @param scene defines the hosting scene
  109005. */
  109006. constructor(name: string, scene?: Nullable<Scene>);
  109007. /**
  109008. * Returns the string "AbstractMesh"
  109009. * @returns "AbstractMesh"
  109010. */
  109011. getClassName(): string;
  109012. /**
  109013. * Gets a string representation of the current mesh
  109014. * @param fullDetails defines a boolean indicating if full details must be included
  109015. * @returns a string representation of the current mesh
  109016. */
  109017. toString(fullDetails?: boolean): string;
  109018. /**
  109019. * @hidden
  109020. */
  109021. protected _getEffectiveParent(): Nullable<Node>;
  109022. /** @hidden */
  109023. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109024. /** @hidden */
  109025. _rebuild(): void;
  109026. /** @hidden */
  109027. _resyncLightSources(): void;
  109028. /** @hidden */
  109029. _resyncLightSource(light: Light): void;
  109030. /** @hidden */
  109031. _unBindEffect(): void;
  109032. /** @hidden */
  109033. _removeLightSource(light: Light, dispose: boolean): void;
  109034. private _markSubMeshesAsDirty;
  109035. /** @hidden */
  109036. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109037. /** @hidden */
  109038. _markSubMeshesAsAttributesDirty(): void;
  109039. /** @hidden */
  109040. _markSubMeshesAsMiscDirty(): void;
  109041. /**
  109042. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109043. */
  109044. get scaling(): Vector3;
  109045. set scaling(newScaling: Vector3);
  109046. /**
  109047. * Returns true if the mesh is blocked. Implemented by child classes
  109048. */
  109049. get isBlocked(): boolean;
  109050. /**
  109051. * Returns the mesh itself by default. Implemented by child classes
  109052. * @param camera defines the camera to use to pick the right LOD level
  109053. * @returns the currentAbstractMesh
  109054. */
  109055. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109056. /**
  109057. * Returns 0 by default. Implemented by child classes
  109058. * @returns an integer
  109059. */
  109060. getTotalVertices(): number;
  109061. /**
  109062. * Returns a positive integer : the total number of indices in this mesh geometry.
  109063. * @returns the numner of indices or zero if the mesh has no geometry.
  109064. */
  109065. getTotalIndices(): number;
  109066. /**
  109067. * Returns null by default. Implemented by child classes
  109068. * @returns null
  109069. */
  109070. getIndices(): Nullable<IndicesArray>;
  109071. /**
  109072. * Returns the array of the requested vertex data kind. Implemented by child classes
  109073. * @param kind defines the vertex data kind to use
  109074. * @returns null
  109075. */
  109076. getVerticesData(kind: string): Nullable<FloatArray>;
  109077. /**
  109078. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109079. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109080. * Note that a new underlying VertexBuffer object is created each call.
  109081. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109082. * @param kind defines vertex data kind:
  109083. * * VertexBuffer.PositionKind
  109084. * * VertexBuffer.UVKind
  109085. * * VertexBuffer.UV2Kind
  109086. * * VertexBuffer.UV3Kind
  109087. * * VertexBuffer.UV4Kind
  109088. * * VertexBuffer.UV5Kind
  109089. * * VertexBuffer.UV6Kind
  109090. * * VertexBuffer.ColorKind
  109091. * * VertexBuffer.MatricesIndicesKind
  109092. * * VertexBuffer.MatricesIndicesExtraKind
  109093. * * VertexBuffer.MatricesWeightsKind
  109094. * * VertexBuffer.MatricesWeightsExtraKind
  109095. * @param data defines the data source
  109096. * @param updatable defines if the data must be flagged as updatable (or static)
  109097. * @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
  109098. * @returns the current mesh
  109099. */
  109100. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109101. /**
  109102. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109103. * If the mesh has no geometry, it is simply returned as it is.
  109104. * @param kind defines vertex data kind:
  109105. * * VertexBuffer.PositionKind
  109106. * * VertexBuffer.UVKind
  109107. * * VertexBuffer.UV2Kind
  109108. * * VertexBuffer.UV3Kind
  109109. * * VertexBuffer.UV4Kind
  109110. * * VertexBuffer.UV5Kind
  109111. * * VertexBuffer.UV6Kind
  109112. * * VertexBuffer.ColorKind
  109113. * * VertexBuffer.MatricesIndicesKind
  109114. * * VertexBuffer.MatricesIndicesExtraKind
  109115. * * VertexBuffer.MatricesWeightsKind
  109116. * * VertexBuffer.MatricesWeightsExtraKind
  109117. * @param data defines the data source
  109118. * @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
  109119. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109120. * @returns the current mesh
  109121. */
  109122. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109123. /**
  109124. * Sets the mesh indices,
  109125. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109126. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109127. * @param totalVertices Defines the total number of vertices
  109128. * @returns the current mesh
  109129. */
  109130. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109131. /**
  109132. * Gets a boolean indicating if specific vertex data is present
  109133. * @param kind defines the vertex data kind to use
  109134. * @returns true is data kind is present
  109135. */
  109136. isVerticesDataPresent(kind: string): boolean;
  109137. /**
  109138. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109139. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109140. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109141. * @returns a BoundingInfo
  109142. */
  109143. getBoundingInfo(): BoundingInfo;
  109144. /**
  109145. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109146. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109147. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109148. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109149. * @returns the current mesh
  109150. */
  109151. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109152. /**
  109153. * Overwrite the current bounding info
  109154. * @param boundingInfo defines the new bounding info
  109155. * @returns the current mesh
  109156. */
  109157. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109158. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109159. get useBones(): boolean;
  109160. /** @hidden */
  109161. _preActivate(): void;
  109162. /** @hidden */
  109163. _preActivateForIntermediateRendering(renderId: number): void;
  109164. /** @hidden */
  109165. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109166. /** @hidden */
  109167. _postActivate(): void;
  109168. /** @hidden */
  109169. _freeze(): void;
  109170. /** @hidden */
  109171. _unFreeze(): void;
  109172. /**
  109173. * Gets the current world matrix
  109174. * @returns a Matrix
  109175. */
  109176. getWorldMatrix(): Matrix;
  109177. /** @hidden */
  109178. _getWorldMatrixDeterminant(): number;
  109179. /**
  109180. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109181. */
  109182. get isAnInstance(): boolean;
  109183. /**
  109184. * Gets a boolean indicating if this mesh has instances
  109185. */
  109186. get hasInstances(): boolean;
  109187. /**
  109188. * Gets a boolean indicating if this mesh has thin instances
  109189. */
  109190. get hasThinInstances(): boolean;
  109191. /**
  109192. * Perform relative position change from the point of view of behind the front of the mesh.
  109193. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109194. * Supports definition of mesh facing forward or backward
  109195. * @param amountRight defines the distance on the right axis
  109196. * @param amountUp defines the distance on the up axis
  109197. * @param amountForward defines the distance on the forward axis
  109198. * @returns the current mesh
  109199. */
  109200. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109201. /**
  109202. * Calculate relative position change from the point of view of behind the front of the mesh.
  109203. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109204. * Supports definition of mesh facing forward or backward
  109205. * @param amountRight defines the distance on the right axis
  109206. * @param amountUp defines the distance on the up axis
  109207. * @param amountForward defines the distance on the forward axis
  109208. * @returns the new displacement vector
  109209. */
  109210. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109211. /**
  109212. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109213. * Supports definition of mesh facing forward or backward
  109214. * @param flipBack defines the flip
  109215. * @param twirlClockwise defines the twirl
  109216. * @param tiltRight defines the tilt
  109217. * @returns the current mesh
  109218. */
  109219. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109220. /**
  109221. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109222. * Supports definition of mesh facing forward or backward.
  109223. * @param flipBack defines the flip
  109224. * @param twirlClockwise defines the twirl
  109225. * @param tiltRight defines the tilt
  109226. * @returns the new rotation vector
  109227. */
  109228. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109229. /**
  109230. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109231. * This means the mesh underlying bounding box and sphere are recomputed.
  109232. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109233. * @returns the current mesh
  109234. */
  109235. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109236. /** @hidden */
  109237. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109238. /** @hidden */
  109239. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109240. /** @hidden */
  109241. _updateBoundingInfo(): AbstractMesh;
  109242. /** @hidden */
  109243. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109244. /** @hidden */
  109245. protected _afterComputeWorldMatrix(): void;
  109246. /** @hidden */
  109247. get _effectiveMesh(): AbstractMesh;
  109248. /**
  109249. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109250. * A mesh is in the frustum if its bounding box intersects the frustum
  109251. * @param frustumPlanes defines the frustum to test
  109252. * @returns true if the mesh is in the frustum planes
  109253. */
  109254. isInFrustum(frustumPlanes: Plane[]): boolean;
  109255. /**
  109256. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  109257. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  109258. * @param frustumPlanes defines the frustum to test
  109259. * @returns true if the mesh is completely in the frustum planes
  109260. */
  109261. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  109262. /**
  109263. * True if the mesh intersects another mesh or a SolidParticle object
  109264. * @param mesh defines a target mesh or SolidParticle to test
  109265. * @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)
  109266. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  109267. * @returns true if there is an intersection
  109268. */
  109269. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  109270. /**
  109271. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  109272. * @param point defines the point to test
  109273. * @returns true if there is an intersection
  109274. */
  109275. intersectsPoint(point: Vector3): boolean;
  109276. /**
  109277. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  109278. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109279. */
  109280. get checkCollisions(): boolean;
  109281. set checkCollisions(collisionEnabled: boolean);
  109282. /**
  109283. * Gets Collider object used to compute collisions (not physics)
  109284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109285. */
  109286. get collider(): Nullable<Collider>;
  109287. /**
  109288. * Move the mesh using collision engine
  109289. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109290. * @param displacement defines the requested displacement vector
  109291. * @returns the current mesh
  109292. */
  109293. moveWithCollisions(displacement: Vector3): AbstractMesh;
  109294. private _onCollisionPositionChange;
  109295. /** @hidden */
  109296. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  109297. /** @hidden */
  109298. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  109299. /** @hidden */
  109300. _checkCollision(collider: Collider): AbstractMesh;
  109301. /** @hidden */
  109302. _generatePointsArray(): boolean;
  109303. /**
  109304. * Checks if the passed Ray intersects with the mesh
  109305. * @param ray defines the ray to use
  109306. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  109307. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109308. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  109309. * @returns the picking info
  109310. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  109311. */
  109312. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  109313. /**
  109314. * Clones the current mesh
  109315. * @param name defines the mesh name
  109316. * @param newParent defines the new mesh parent
  109317. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  109318. * @returns the new mesh
  109319. */
  109320. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  109321. /**
  109322. * Disposes all the submeshes of the current meshnp
  109323. * @returns the current mesh
  109324. */
  109325. releaseSubMeshes(): AbstractMesh;
  109326. /**
  109327. * Releases resources associated with this abstract mesh.
  109328. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109329. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109330. */
  109331. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109332. /**
  109333. * Adds the passed mesh as a child to the current mesh
  109334. * @param mesh defines the child mesh
  109335. * @returns the current mesh
  109336. */
  109337. addChild(mesh: AbstractMesh): AbstractMesh;
  109338. /**
  109339. * Removes the passed mesh from the current mesh children list
  109340. * @param mesh defines the child mesh
  109341. * @returns the current mesh
  109342. */
  109343. removeChild(mesh: AbstractMesh): AbstractMesh;
  109344. /** @hidden */
  109345. private _initFacetData;
  109346. /**
  109347. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  109348. * This method can be called within the render loop.
  109349. * 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
  109350. * @returns the current mesh
  109351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109352. */
  109353. updateFacetData(): AbstractMesh;
  109354. /**
  109355. * Returns the facetLocalNormals array.
  109356. * The normals are expressed in the mesh local spac
  109357. * @returns an array of Vector3
  109358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109359. */
  109360. getFacetLocalNormals(): Vector3[];
  109361. /**
  109362. * Returns the facetLocalPositions array.
  109363. * The facet positions are expressed in the mesh local space
  109364. * @returns an array of Vector3
  109365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109366. */
  109367. getFacetLocalPositions(): Vector3[];
  109368. /**
  109369. * Returns the facetLocalPartioning array
  109370. * @returns an array of array of numbers
  109371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109372. */
  109373. getFacetLocalPartitioning(): number[][];
  109374. /**
  109375. * Returns the i-th facet position in the world system.
  109376. * This method allocates a new Vector3 per call
  109377. * @param i defines the facet index
  109378. * @returns a new Vector3
  109379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109380. */
  109381. getFacetPosition(i: number): Vector3;
  109382. /**
  109383. * Sets the reference Vector3 with the i-th facet position in the world system
  109384. * @param i defines the facet index
  109385. * @param ref defines the target vector
  109386. * @returns the current mesh
  109387. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109388. */
  109389. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  109390. /**
  109391. * Returns the i-th facet normal in the world system.
  109392. * This method allocates a new Vector3 per call
  109393. * @param i defines the facet index
  109394. * @returns a new Vector3
  109395. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109396. */
  109397. getFacetNormal(i: number): Vector3;
  109398. /**
  109399. * Sets the reference Vector3 with the i-th facet normal in the world system
  109400. * @param i defines the facet index
  109401. * @param ref defines the target vector
  109402. * @returns the current mesh
  109403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109404. */
  109405. getFacetNormalToRef(i: number, ref: Vector3): this;
  109406. /**
  109407. * 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)
  109408. * @param x defines x coordinate
  109409. * @param y defines y coordinate
  109410. * @param z defines z coordinate
  109411. * @returns the array of facet indexes
  109412. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109413. */
  109414. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  109415. /**
  109416. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  109417. * @param projected sets as the (x,y,z) world projection on the facet
  109418. * @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
  109419. * @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
  109420. * @param x defines x coordinate
  109421. * @param y defines y coordinate
  109422. * @param z defines z coordinate
  109423. * @returns the face index if found (or null instead)
  109424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109425. */
  109426. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109427. /**
  109428. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  109429. * @param projected sets as the (x,y,z) local projection on the facet
  109430. * @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
  109431. * @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
  109432. * @param x defines x coordinate
  109433. * @param y defines y coordinate
  109434. * @param z defines z coordinate
  109435. * @returns the face index if found (or null instead)
  109436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109437. */
  109438. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  109439. /**
  109440. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  109441. * @returns the parameters
  109442. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109443. */
  109444. getFacetDataParameters(): any;
  109445. /**
  109446. * Disables the feature FacetData and frees the related memory
  109447. * @returns the current mesh
  109448. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  109449. */
  109450. disableFacetData(): AbstractMesh;
  109451. /**
  109452. * Updates the AbstractMesh indices array
  109453. * @param indices defines the data source
  109454. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109455. * @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)
  109456. * @returns the current mesh
  109457. */
  109458. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109459. /**
  109460. * Creates new normals data for the mesh
  109461. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  109462. * @returns the current mesh
  109463. */
  109464. createNormals(updatable: boolean): AbstractMesh;
  109465. /**
  109466. * Align the mesh with a normal
  109467. * @param normal defines the normal to use
  109468. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  109469. * @returns the current mesh
  109470. */
  109471. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  109472. /** @hidden */
  109473. _checkOcclusionQuery(): boolean;
  109474. /**
  109475. * Disables the mesh edge rendering mode
  109476. * @returns the currentAbstractMesh
  109477. */
  109478. disableEdgesRendering(): AbstractMesh;
  109479. /**
  109480. * Enables the edge rendering mode on the mesh.
  109481. * This mode makes the mesh edges visible
  109482. * @param epsilon defines the maximal distance between two angles to detect a face
  109483. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109484. * @returns the currentAbstractMesh
  109485. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109486. */
  109487. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109488. }
  109489. }
  109490. declare module BABYLON {
  109491. /**
  109492. * Interface used to define ActionEvent
  109493. */
  109494. export interface IActionEvent {
  109495. /** The mesh or sprite that triggered the action */
  109496. source: any;
  109497. /** The X mouse cursor position at the time of the event */
  109498. pointerX: number;
  109499. /** The Y mouse cursor position at the time of the event */
  109500. pointerY: number;
  109501. /** The mesh that is currently pointed at (can be null) */
  109502. meshUnderPointer: Nullable<AbstractMesh>;
  109503. /** the original (browser) event that triggered the ActionEvent */
  109504. sourceEvent?: any;
  109505. /** additional data for the event */
  109506. additionalData?: any;
  109507. }
  109508. /**
  109509. * ActionEvent is the event being sent when an action is triggered.
  109510. */
  109511. export class ActionEvent implements IActionEvent {
  109512. /** The mesh or sprite that triggered the action */
  109513. source: any;
  109514. /** The X mouse cursor position at the time of the event */
  109515. pointerX: number;
  109516. /** The Y mouse cursor position at the time of the event */
  109517. pointerY: number;
  109518. /** The mesh that is currently pointed at (can be null) */
  109519. meshUnderPointer: Nullable<AbstractMesh>;
  109520. /** the original (browser) event that triggered the ActionEvent */
  109521. sourceEvent?: any;
  109522. /** additional data for the event */
  109523. additionalData?: any;
  109524. /**
  109525. * Creates a new ActionEvent
  109526. * @param source The mesh or sprite that triggered the action
  109527. * @param pointerX The X mouse cursor position at the time of the event
  109528. * @param pointerY The Y mouse cursor position at the time of the event
  109529. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  109530. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  109531. * @param additionalData additional data for the event
  109532. */
  109533. constructor(
  109534. /** The mesh or sprite that triggered the action */
  109535. source: any,
  109536. /** The X mouse cursor position at the time of the event */
  109537. pointerX: number,
  109538. /** The Y mouse cursor position at the time of the event */
  109539. pointerY: number,
  109540. /** The mesh that is currently pointed at (can be null) */
  109541. meshUnderPointer: Nullable<AbstractMesh>,
  109542. /** the original (browser) event that triggered the ActionEvent */
  109543. sourceEvent?: any,
  109544. /** additional data for the event */
  109545. additionalData?: any);
  109546. /**
  109547. * Helper function to auto-create an ActionEvent from a source mesh.
  109548. * @param source The source mesh that triggered the event
  109549. * @param evt The original (browser) event
  109550. * @param additionalData additional data for the event
  109551. * @returns the new ActionEvent
  109552. */
  109553. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  109554. /**
  109555. * Helper function to auto-create an ActionEvent from a source sprite
  109556. * @param source The source sprite that triggered the event
  109557. * @param scene Scene associated with the sprite
  109558. * @param evt The original (browser) event
  109559. * @param additionalData additional data for the event
  109560. * @returns the new ActionEvent
  109561. */
  109562. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  109563. /**
  109564. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  109565. * @param scene the scene where the event occurred
  109566. * @param evt The original (browser) event
  109567. * @returns the new ActionEvent
  109568. */
  109569. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  109570. /**
  109571. * Helper function to auto-create an ActionEvent from a primitive
  109572. * @param prim defines the target primitive
  109573. * @param pointerPos defines the pointer position
  109574. * @param evt The original (browser) event
  109575. * @param additionalData additional data for the event
  109576. * @returns the new ActionEvent
  109577. */
  109578. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  109579. }
  109580. }
  109581. declare module BABYLON {
  109582. /**
  109583. * Abstract class used to decouple action Manager from scene and meshes.
  109584. * Do not instantiate.
  109585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109586. */
  109587. export abstract class AbstractActionManager implements IDisposable {
  109588. /** Gets the list of active triggers */
  109589. static Triggers: {
  109590. [key: string]: number;
  109591. };
  109592. /** Gets the cursor to use when hovering items */
  109593. hoverCursor: string;
  109594. /** Gets the list of actions */
  109595. actions: IAction[];
  109596. /**
  109597. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  109598. */
  109599. isRecursive: boolean;
  109600. /**
  109601. * Releases all associated resources
  109602. */
  109603. abstract dispose(): void;
  109604. /**
  109605. * Does this action manager has pointer triggers
  109606. */
  109607. abstract get hasPointerTriggers(): boolean;
  109608. /**
  109609. * Does this action manager has pick triggers
  109610. */
  109611. abstract get hasPickTriggers(): boolean;
  109612. /**
  109613. * Process a specific trigger
  109614. * @param trigger defines the trigger to process
  109615. * @param evt defines the event details to be processed
  109616. */
  109617. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  109618. /**
  109619. * Does this action manager handles actions of any of the given triggers
  109620. * @param triggers defines the triggers to be tested
  109621. * @return a boolean indicating whether one (or more) of the triggers is handled
  109622. */
  109623. abstract hasSpecificTriggers(triggers: number[]): boolean;
  109624. /**
  109625. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  109626. * speed.
  109627. * @param triggerA defines the trigger to be tested
  109628. * @param triggerB defines the trigger to be tested
  109629. * @return a boolean indicating whether one (or more) of the triggers is handled
  109630. */
  109631. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  109632. /**
  109633. * Does this action manager handles actions of a given trigger
  109634. * @param trigger defines the trigger to be tested
  109635. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  109636. * @return whether the trigger is handled
  109637. */
  109638. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  109639. /**
  109640. * Serialize this manager to a JSON object
  109641. * @param name defines the property name to store this manager
  109642. * @returns a JSON representation of this manager
  109643. */
  109644. abstract serialize(name: string): any;
  109645. /**
  109646. * Registers an action to this action manager
  109647. * @param action defines the action to be registered
  109648. * @return the action amended (prepared) after registration
  109649. */
  109650. abstract registerAction(action: IAction): Nullable<IAction>;
  109651. /**
  109652. * Unregisters an action to this action manager
  109653. * @param action defines the action to be unregistered
  109654. * @return a boolean indicating whether the action has been unregistered
  109655. */
  109656. abstract unregisterAction(action: IAction): Boolean;
  109657. /**
  109658. * Does exist one action manager with at least one trigger
  109659. **/
  109660. static get HasTriggers(): boolean;
  109661. /**
  109662. * Does exist one action manager with at least one pick trigger
  109663. **/
  109664. static get HasPickTriggers(): boolean;
  109665. /**
  109666. * Does exist one action manager that handles actions of a given trigger
  109667. * @param trigger defines the trigger to be tested
  109668. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  109669. **/
  109670. static HasSpecificTrigger(trigger: number): boolean;
  109671. }
  109672. }
  109673. declare module BABYLON {
  109674. /**
  109675. * Defines how a node can be built from a string name.
  109676. */
  109677. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  109678. /**
  109679. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  109680. */
  109681. export class Node implements IBehaviorAware<Node> {
  109682. /** @hidden */
  109683. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  109684. private static _NodeConstructors;
  109685. /**
  109686. * Add a new node constructor
  109687. * @param type defines the type name of the node to construct
  109688. * @param constructorFunc defines the constructor function
  109689. */
  109690. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  109691. /**
  109692. * Returns a node constructor based on type name
  109693. * @param type defines the type name
  109694. * @param name defines the new node name
  109695. * @param scene defines the hosting scene
  109696. * @param options defines optional options to transmit to constructors
  109697. * @returns the new constructor or null
  109698. */
  109699. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  109700. /**
  109701. * Gets or sets the name of the node
  109702. */
  109703. name: string;
  109704. /**
  109705. * Gets or sets the id of the node
  109706. */
  109707. id: string;
  109708. /**
  109709. * Gets or sets the unique id of the node
  109710. */
  109711. uniqueId: number;
  109712. /**
  109713. * Gets or sets a string used to store user defined state for the node
  109714. */
  109715. state: string;
  109716. /**
  109717. * Gets or sets an object used to store user defined information for the node
  109718. */
  109719. metadata: any;
  109720. /**
  109721. * For internal use only. Please do not use.
  109722. */
  109723. reservedDataStore: any;
  109724. /**
  109725. * List of inspectable custom properties (used by the Inspector)
  109726. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109727. */
  109728. inspectableCustomProperties: IInspectable[];
  109729. private _doNotSerialize;
  109730. /**
  109731. * Gets or sets a boolean used to define if the node must be serialized
  109732. */
  109733. get doNotSerialize(): boolean;
  109734. set doNotSerialize(value: boolean);
  109735. /** @hidden */
  109736. _isDisposed: boolean;
  109737. /**
  109738. * Gets a list of Animations associated with the node
  109739. */
  109740. animations: Animation[];
  109741. protected _ranges: {
  109742. [name: string]: Nullable<AnimationRange>;
  109743. };
  109744. /**
  109745. * Callback raised when the node is ready to be used
  109746. */
  109747. onReady: Nullable<(node: Node) => void>;
  109748. private _isEnabled;
  109749. private _isParentEnabled;
  109750. private _isReady;
  109751. /** @hidden */
  109752. _currentRenderId: number;
  109753. private _parentUpdateId;
  109754. /** @hidden */
  109755. _childUpdateId: number;
  109756. /** @hidden */
  109757. _waitingParentId: Nullable<string>;
  109758. /** @hidden */
  109759. _scene: Scene;
  109760. /** @hidden */
  109761. _cache: any;
  109762. private _parentNode;
  109763. private _children;
  109764. /** @hidden */
  109765. _worldMatrix: Matrix;
  109766. /** @hidden */
  109767. _worldMatrixDeterminant: number;
  109768. /** @hidden */
  109769. _worldMatrixDeterminantIsDirty: boolean;
  109770. /** @hidden */
  109771. private _sceneRootNodesIndex;
  109772. /**
  109773. * Gets a boolean indicating if the node has been disposed
  109774. * @returns true if the node was disposed
  109775. */
  109776. isDisposed(): boolean;
  109777. /**
  109778. * Gets or sets the parent of the node (without keeping the current position in the scene)
  109779. * @see https://doc.babylonjs.com/how_to/parenting
  109780. */
  109781. set parent(parent: Nullable<Node>);
  109782. get parent(): Nullable<Node>;
  109783. /** @hidden */
  109784. _addToSceneRootNodes(): void;
  109785. /** @hidden */
  109786. _removeFromSceneRootNodes(): void;
  109787. private _animationPropertiesOverride;
  109788. /**
  109789. * Gets or sets the animation properties override
  109790. */
  109791. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109792. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109793. /**
  109794. * Gets a string idenfifying the name of the class
  109795. * @returns "Node" string
  109796. */
  109797. getClassName(): string;
  109798. /** @hidden */
  109799. readonly _isNode: boolean;
  109800. /**
  109801. * An event triggered when the mesh is disposed
  109802. */
  109803. onDisposeObservable: Observable<Node>;
  109804. private _onDisposeObserver;
  109805. /**
  109806. * Sets a callback that will be raised when the node will be disposed
  109807. */
  109808. set onDispose(callback: () => void);
  109809. /**
  109810. * Creates a new Node
  109811. * @param name the name and id to be given to this node
  109812. * @param scene the scene this node will be added to
  109813. */
  109814. constructor(name: string, scene?: Nullable<Scene>);
  109815. /**
  109816. * Gets the scene of the node
  109817. * @returns a scene
  109818. */
  109819. getScene(): Scene;
  109820. /**
  109821. * Gets the engine of the node
  109822. * @returns a Engine
  109823. */
  109824. getEngine(): Engine;
  109825. private _behaviors;
  109826. /**
  109827. * Attach a behavior to the node
  109828. * @see http://doc.babylonjs.com/features/behaviour
  109829. * @param behavior defines the behavior to attach
  109830. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  109831. * @returns the current Node
  109832. */
  109833. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  109834. /**
  109835. * Remove an attached behavior
  109836. * @see http://doc.babylonjs.com/features/behaviour
  109837. * @param behavior defines the behavior to attach
  109838. * @returns the current Node
  109839. */
  109840. removeBehavior(behavior: Behavior<Node>): Node;
  109841. /**
  109842. * Gets the list of attached behaviors
  109843. * @see http://doc.babylonjs.com/features/behaviour
  109844. */
  109845. get behaviors(): Behavior<Node>[];
  109846. /**
  109847. * Gets an attached behavior by name
  109848. * @param name defines the name of the behavior to look for
  109849. * @see http://doc.babylonjs.com/features/behaviour
  109850. * @returns null if behavior was not found else the requested behavior
  109851. */
  109852. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  109853. /**
  109854. * Returns the latest update of the World matrix
  109855. * @returns a Matrix
  109856. */
  109857. getWorldMatrix(): Matrix;
  109858. /** @hidden */
  109859. _getWorldMatrixDeterminant(): number;
  109860. /**
  109861. * Returns directly the latest state of the mesh World matrix.
  109862. * A Matrix is returned.
  109863. */
  109864. get worldMatrixFromCache(): Matrix;
  109865. /** @hidden */
  109866. _initCache(): void;
  109867. /** @hidden */
  109868. updateCache(force?: boolean): void;
  109869. /** @hidden */
  109870. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109871. /** @hidden */
  109872. _updateCache(ignoreParentClass?: boolean): void;
  109873. /** @hidden */
  109874. _isSynchronized(): boolean;
  109875. /** @hidden */
  109876. _markSyncedWithParent(): void;
  109877. /** @hidden */
  109878. isSynchronizedWithParent(): boolean;
  109879. /** @hidden */
  109880. isSynchronized(): boolean;
  109881. /**
  109882. * Is this node ready to be used/rendered
  109883. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109884. * @return true if the node is ready
  109885. */
  109886. isReady(completeCheck?: boolean): boolean;
  109887. /**
  109888. * Is this node enabled?
  109889. * 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
  109890. * @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
  109891. * @return whether this node (and its parent) is enabled
  109892. */
  109893. isEnabled(checkAncestors?: boolean): boolean;
  109894. /** @hidden */
  109895. protected _syncParentEnabledState(): void;
  109896. /**
  109897. * Set the enabled state of this node
  109898. * @param value defines the new enabled state
  109899. */
  109900. setEnabled(value: boolean): void;
  109901. /**
  109902. * Is this node a descendant of the given node?
  109903. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  109904. * @param ancestor defines the parent node to inspect
  109905. * @returns a boolean indicating if this node is a descendant of the given node
  109906. */
  109907. isDescendantOf(ancestor: Node): boolean;
  109908. /** @hidden */
  109909. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  109910. /**
  109911. * Will return all nodes that have this node as ascendant
  109912. * @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
  109913. * @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
  109914. * @return all children nodes of all types
  109915. */
  109916. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  109917. /**
  109918. * Get all child-meshes of this node
  109919. * @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)
  109920. * @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
  109921. * @returns an array of AbstractMesh
  109922. */
  109923. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  109924. /**
  109925. * Get all direct children of this node
  109926. * @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
  109927. * @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)
  109928. * @returns an array of Node
  109929. */
  109930. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  109931. /** @hidden */
  109932. _setReady(state: boolean): void;
  109933. /**
  109934. * Get an animation by name
  109935. * @param name defines the name of the animation to look for
  109936. * @returns null if not found else the requested animation
  109937. */
  109938. getAnimationByName(name: string): Nullable<Animation>;
  109939. /**
  109940. * Creates an animation range for this node
  109941. * @param name defines the name of the range
  109942. * @param from defines the starting key
  109943. * @param to defines the end key
  109944. */
  109945. createAnimationRange(name: string, from: number, to: number): void;
  109946. /**
  109947. * Delete a specific animation range
  109948. * @param name defines the name of the range to delete
  109949. * @param deleteFrames defines if animation frames from the range must be deleted as well
  109950. */
  109951. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  109952. /**
  109953. * Get an animation range by name
  109954. * @param name defines the name of the animation range to look for
  109955. * @returns null if not found else the requested animation range
  109956. */
  109957. getAnimationRange(name: string): Nullable<AnimationRange>;
  109958. /**
  109959. * Gets the list of all animation ranges defined on this node
  109960. * @returns an array
  109961. */
  109962. getAnimationRanges(): Nullable<AnimationRange>[];
  109963. /**
  109964. * Will start the animation sequence
  109965. * @param name defines the range frames for animation sequence
  109966. * @param loop defines if the animation should loop (false by default)
  109967. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  109968. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  109969. * @returns the object created for this animation. If range does not exist, it will return null
  109970. */
  109971. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  109972. /**
  109973. * Serialize animation ranges into a JSON compatible object
  109974. * @returns serialization object
  109975. */
  109976. serializeAnimationRanges(): any;
  109977. /**
  109978. * Computes the world matrix of the node
  109979. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  109980. * @returns the world matrix
  109981. */
  109982. computeWorldMatrix(force?: boolean): Matrix;
  109983. /**
  109984. * Releases resources associated with this node.
  109985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109987. */
  109988. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109989. /**
  109990. * Parse animation range data from a serialization object and store them into a given node
  109991. * @param node defines where to store the animation ranges
  109992. * @param parsedNode defines the serialization object to read data from
  109993. * @param scene defines the hosting scene
  109994. */
  109995. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  109996. /**
  109997. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  109998. * @param includeDescendants Include bounding info from descendants as well (true by default)
  109999. * @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
  110000. * @returns the new bounding vectors
  110001. */
  110002. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110003. min: Vector3;
  110004. max: Vector3;
  110005. };
  110006. }
  110007. }
  110008. declare module BABYLON {
  110009. /**
  110010. * @hidden
  110011. */
  110012. export class _IAnimationState {
  110013. key: number;
  110014. repeatCount: number;
  110015. workValue?: any;
  110016. loopMode?: number;
  110017. offsetValue?: any;
  110018. highLimitValue?: any;
  110019. }
  110020. /**
  110021. * Class used to store any kind of animation
  110022. */
  110023. export class Animation {
  110024. /**Name of the animation */
  110025. name: string;
  110026. /**Property to animate */
  110027. targetProperty: string;
  110028. /**The frames per second of the animation */
  110029. framePerSecond: number;
  110030. /**The data type of the animation */
  110031. dataType: number;
  110032. /**The loop mode of the animation */
  110033. loopMode?: number | undefined;
  110034. /**Specifies if blending should be enabled */
  110035. enableBlending?: boolean | undefined;
  110036. /**
  110037. * Use matrix interpolation instead of using direct key value when animating matrices
  110038. */
  110039. static AllowMatricesInterpolation: boolean;
  110040. /**
  110041. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110042. */
  110043. static AllowMatrixDecomposeForInterpolation: boolean;
  110044. /** Define the Url to load snippets */
  110045. static SnippetUrl: string;
  110046. /** Snippet ID if the animation was created from the snippet server */
  110047. snippetId: string;
  110048. /**
  110049. * Stores the key frames of the animation
  110050. */
  110051. private _keys;
  110052. /**
  110053. * Stores the easing function of the animation
  110054. */
  110055. private _easingFunction;
  110056. /**
  110057. * @hidden Internal use only
  110058. */
  110059. _runtimeAnimations: RuntimeAnimation[];
  110060. /**
  110061. * The set of event that will be linked to this animation
  110062. */
  110063. private _events;
  110064. /**
  110065. * Stores an array of target property paths
  110066. */
  110067. targetPropertyPath: string[];
  110068. /**
  110069. * Stores the blending speed of the animation
  110070. */
  110071. blendingSpeed: number;
  110072. /**
  110073. * Stores the animation ranges for the animation
  110074. */
  110075. private _ranges;
  110076. /**
  110077. * @hidden Internal use
  110078. */
  110079. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110080. /**
  110081. * Sets up an animation
  110082. * @param property The property to animate
  110083. * @param animationType The animation type to apply
  110084. * @param framePerSecond The frames per second of the animation
  110085. * @param easingFunction The easing function used in the animation
  110086. * @returns The created animation
  110087. */
  110088. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110089. /**
  110090. * Create and start an animation on a node
  110091. * @param name defines the name of the global animation that will be run on all nodes
  110092. * @param node defines the root node where the animation will take place
  110093. * @param targetProperty defines property to animate
  110094. * @param framePerSecond defines the number of frame per second yo use
  110095. * @param totalFrame defines the number of frames in total
  110096. * @param from defines the initial value
  110097. * @param to defines the final value
  110098. * @param loopMode defines which loop mode you want to use (off by default)
  110099. * @param easingFunction defines the easing function to use (linear by default)
  110100. * @param onAnimationEnd defines the callback to call when animation end
  110101. * @returns the animatable created for this animation
  110102. */
  110103. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110104. /**
  110105. * Create and start an animation on a node and its descendants
  110106. * @param name defines the name of the global animation that will be run on all nodes
  110107. * @param node defines the root node where the animation will take place
  110108. * @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
  110109. * @param targetProperty defines property to animate
  110110. * @param framePerSecond defines the number of frame per second to use
  110111. * @param totalFrame defines the number of frames in total
  110112. * @param from defines the initial value
  110113. * @param to defines the final value
  110114. * @param loopMode defines which loop mode you want to use (off by default)
  110115. * @param easingFunction defines the easing function to use (linear by default)
  110116. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110117. * @returns the list of animatables created for all nodes
  110118. * @example https://www.babylonjs-playground.com/#MH0VLI
  110119. */
  110120. 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[]>;
  110121. /**
  110122. * Creates a new animation, merges it with the existing animations and starts it
  110123. * @param name Name of the animation
  110124. * @param node Node which contains the scene that begins the animations
  110125. * @param targetProperty Specifies which property to animate
  110126. * @param framePerSecond The frames per second of the animation
  110127. * @param totalFrame The total number of frames
  110128. * @param from The frame at the beginning of the animation
  110129. * @param to The frame at the end of the animation
  110130. * @param loopMode Specifies the loop mode of the animation
  110131. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110132. * @param onAnimationEnd Callback to run once the animation is complete
  110133. * @returns Nullable animation
  110134. */
  110135. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110136. /**
  110137. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110138. * @param sourceAnimation defines the Animation containing keyframes to convert
  110139. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110140. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110141. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110142. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110143. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110144. */
  110145. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110146. /**
  110147. * Transition property of an host to the target Value
  110148. * @param property The property to transition
  110149. * @param targetValue The target Value of the property
  110150. * @param host The object where the property to animate belongs
  110151. * @param scene Scene used to run the animation
  110152. * @param frameRate Framerate (in frame/s) to use
  110153. * @param transition The transition type we want to use
  110154. * @param duration The duration of the animation, in milliseconds
  110155. * @param onAnimationEnd Callback trigger at the end of the animation
  110156. * @returns Nullable animation
  110157. */
  110158. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110159. /**
  110160. * Return the array of runtime animations currently using this animation
  110161. */
  110162. get runtimeAnimations(): RuntimeAnimation[];
  110163. /**
  110164. * Specifies if any of the runtime animations are currently running
  110165. */
  110166. get hasRunningRuntimeAnimations(): boolean;
  110167. /**
  110168. * Initializes the animation
  110169. * @param name Name of the animation
  110170. * @param targetProperty Property to animate
  110171. * @param framePerSecond The frames per second of the animation
  110172. * @param dataType The data type of the animation
  110173. * @param loopMode The loop mode of the animation
  110174. * @param enableBlending Specifies if blending should be enabled
  110175. */
  110176. constructor(
  110177. /**Name of the animation */
  110178. name: string,
  110179. /**Property to animate */
  110180. targetProperty: string,
  110181. /**The frames per second of the animation */
  110182. framePerSecond: number,
  110183. /**The data type of the animation */
  110184. dataType: number,
  110185. /**The loop mode of the animation */
  110186. loopMode?: number | undefined,
  110187. /**Specifies if blending should be enabled */
  110188. enableBlending?: boolean | undefined);
  110189. /**
  110190. * Converts the animation to a string
  110191. * @param fullDetails support for multiple levels of logging within scene loading
  110192. * @returns String form of the animation
  110193. */
  110194. toString(fullDetails?: boolean): string;
  110195. /**
  110196. * Add an event to this animation
  110197. * @param event Event to add
  110198. */
  110199. addEvent(event: AnimationEvent): void;
  110200. /**
  110201. * Remove all events found at the given frame
  110202. * @param frame The frame to remove events from
  110203. */
  110204. removeEvents(frame: number): void;
  110205. /**
  110206. * Retrieves all the events from the animation
  110207. * @returns Events from the animation
  110208. */
  110209. getEvents(): AnimationEvent[];
  110210. /**
  110211. * Creates an animation range
  110212. * @param name Name of the animation range
  110213. * @param from Starting frame of the animation range
  110214. * @param to Ending frame of the animation
  110215. */
  110216. createRange(name: string, from: number, to: number): void;
  110217. /**
  110218. * Deletes an animation range by name
  110219. * @param name Name of the animation range to delete
  110220. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110221. */
  110222. deleteRange(name: string, deleteFrames?: boolean): void;
  110223. /**
  110224. * Gets the animation range by name, or null if not defined
  110225. * @param name Name of the animation range
  110226. * @returns Nullable animation range
  110227. */
  110228. getRange(name: string): Nullable<AnimationRange>;
  110229. /**
  110230. * Gets the key frames from the animation
  110231. * @returns The key frames of the animation
  110232. */
  110233. getKeys(): Array<IAnimationKey>;
  110234. /**
  110235. * Gets the highest frame rate of the animation
  110236. * @returns Highest frame rate of the animation
  110237. */
  110238. getHighestFrame(): number;
  110239. /**
  110240. * Gets the easing function of the animation
  110241. * @returns Easing function of the animation
  110242. */
  110243. getEasingFunction(): IEasingFunction;
  110244. /**
  110245. * Sets the easing function of the animation
  110246. * @param easingFunction A custom mathematical formula for animation
  110247. */
  110248. setEasingFunction(easingFunction: EasingFunction): void;
  110249. /**
  110250. * Interpolates a scalar linearly
  110251. * @param startValue Start value of the animation curve
  110252. * @param endValue End value of the animation curve
  110253. * @param gradient Scalar amount to interpolate
  110254. * @returns Interpolated scalar value
  110255. */
  110256. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  110257. /**
  110258. * Interpolates a scalar cubically
  110259. * @param startValue Start value of the animation curve
  110260. * @param outTangent End tangent of the animation
  110261. * @param endValue End value of the animation curve
  110262. * @param inTangent Start tangent of the animation curve
  110263. * @param gradient Scalar amount to interpolate
  110264. * @returns Interpolated scalar value
  110265. */
  110266. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  110267. /**
  110268. * Interpolates a quaternion using a spherical linear interpolation
  110269. * @param startValue Start value of the animation curve
  110270. * @param endValue End value of the animation curve
  110271. * @param gradient Scalar amount to interpolate
  110272. * @returns Interpolated quaternion value
  110273. */
  110274. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  110275. /**
  110276. * Interpolates a quaternion cubically
  110277. * @param startValue Start value of the animation curve
  110278. * @param outTangent End tangent of the animation curve
  110279. * @param endValue End value of the animation curve
  110280. * @param inTangent Start tangent of the animation curve
  110281. * @param gradient Scalar amount to interpolate
  110282. * @returns Interpolated quaternion value
  110283. */
  110284. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  110285. /**
  110286. * Interpolates a Vector3 linearl
  110287. * @param startValue Start value of the animation curve
  110288. * @param endValue End value of the animation curve
  110289. * @param gradient Scalar amount to interpolate
  110290. * @returns Interpolated scalar value
  110291. */
  110292. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  110293. /**
  110294. * Interpolates a Vector3 cubically
  110295. * @param startValue Start value of the animation curve
  110296. * @param outTangent End tangent of the animation
  110297. * @param endValue End value of the animation curve
  110298. * @param inTangent Start tangent of the animation curve
  110299. * @param gradient Scalar amount to interpolate
  110300. * @returns InterpolatedVector3 value
  110301. */
  110302. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  110303. /**
  110304. * Interpolates a Vector2 linearly
  110305. * @param startValue Start value of the animation curve
  110306. * @param endValue End value of the animation curve
  110307. * @param gradient Scalar amount to interpolate
  110308. * @returns Interpolated Vector2 value
  110309. */
  110310. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  110311. /**
  110312. * Interpolates a Vector2 cubically
  110313. * @param startValue Start value of the animation curve
  110314. * @param outTangent End tangent of the animation
  110315. * @param endValue End value of the animation curve
  110316. * @param inTangent Start tangent of the animation curve
  110317. * @param gradient Scalar amount to interpolate
  110318. * @returns Interpolated Vector2 value
  110319. */
  110320. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  110321. /**
  110322. * Interpolates a size linearly
  110323. * @param startValue Start value of the animation curve
  110324. * @param endValue End value of the animation curve
  110325. * @param gradient Scalar amount to interpolate
  110326. * @returns Interpolated Size value
  110327. */
  110328. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  110329. /**
  110330. * Interpolates a Color3 linearly
  110331. * @param startValue Start value of the animation curve
  110332. * @param endValue End value of the animation curve
  110333. * @param gradient Scalar amount to interpolate
  110334. * @returns Interpolated Color3 value
  110335. */
  110336. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  110337. /**
  110338. * Interpolates a Color4 linearly
  110339. * @param startValue Start value of the animation curve
  110340. * @param endValue End value of the animation curve
  110341. * @param gradient Scalar amount to interpolate
  110342. * @returns Interpolated Color3 value
  110343. */
  110344. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  110345. /**
  110346. * @hidden Internal use only
  110347. */
  110348. _getKeyValue(value: any): any;
  110349. /**
  110350. * @hidden Internal use only
  110351. */
  110352. _interpolate(currentFrame: number, state: _IAnimationState): any;
  110353. /**
  110354. * Defines the function to use to interpolate matrices
  110355. * @param startValue defines the start matrix
  110356. * @param endValue defines the end matrix
  110357. * @param gradient defines the gradient between both matrices
  110358. * @param result defines an optional target matrix where to store the interpolation
  110359. * @returns the interpolated matrix
  110360. */
  110361. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  110362. /**
  110363. * Makes a copy of the animation
  110364. * @returns Cloned animation
  110365. */
  110366. clone(): Animation;
  110367. /**
  110368. * Sets the key frames of the animation
  110369. * @param values The animation key frames to set
  110370. */
  110371. setKeys(values: Array<IAnimationKey>): void;
  110372. /**
  110373. * Serializes the animation to an object
  110374. * @returns Serialized object
  110375. */
  110376. serialize(): any;
  110377. /**
  110378. * Float animation type
  110379. */
  110380. static readonly ANIMATIONTYPE_FLOAT: number;
  110381. /**
  110382. * Vector3 animation type
  110383. */
  110384. static readonly ANIMATIONTYPE_VECTOR3: number;
  110385. /**
  110386. * Quaternion animation type
  110387. */
  110388. static readonly ANIMATIONTYPE_QUATERNION: number;
  110389. /**
  110390. * Matrix animation type
  110391. */
  110392. static readonly ANIMATIONTYPE_MATRIX: number;
  110393. /**
  110394. * Color3 animation type
  110395. */
  110396. static readonly ANIMATIONTYPE_COLOR3: number;
  110397. /**
  110398. * Color3 animation type
  110399. */
  110400. static readonly ANIMATIONTYPE_COLOR4: number;
  110401. /**
  110402. * Vector2 animation type
  110403. */
  110404. static readonly ANIMATIONTYPE_VECTOR2: number;
  110405. /**
  110406. * Size animation type
  110407. */
  110408. static readonly ANIMATIONTYPE_SIZE: number;
  110409. /**
  110410. * Relative Loop Mode
  110411. */
  110412. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  110413. /**
  110414. * Cycle Loop Mode
  110415. */
  110416. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  110417. /**
  110418. * Constant Loop Mode
  110419. */
  110420. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  110421. /** @hidden */
  110422. static _UniversalLerp(left: any, right: any, amount: number): any;
  110423. /**
  110424. * Parses an animation object and creates an animation
  110425. * @param parsedAnimation Parsed animation object
  110426. * @returns Animation object
  110427. */
  110428. static Parse(parsedAnimation: any): Animation;
  110429. /**
  110430. * Appends the serialized animations from the source animations
  110431. * @param source Source containing the animations
  110432. * @param destination Target to store the animations
  110433. */
  110434. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110435. /**
  110436. * Creates a new animation or an array of animations from a snippet saved in a remote file
  110437. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  110438. * @param url defines the url to load from
  110439. * @returns a promise that will resolve to the new animation or an array of animations
  110440. */
  110441. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  110442. /**
  110443. * Creates an animation or an array of animations from a snippet saved by the Inspector
  110444. * @param snippetId defines the snippet to load
  110445. * @returns a promise that will resolve to the new animation or a new array of animations
  110446. */
  110447. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  110448. }
  110449. }
  110450. declare module BABYLON {
  110451. /**
  110452. * Interface containing an array of animations
  110453. */
  110454. export interface IAnimatable {
  110455. /**
  110456. * Array of animations
  110457. */
  110458. animations: Nullable<Array<Animation>>;
  110459. }
  110460. }
  110461. declare module BABYLON {
  110462. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  110463. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110464. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110465. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110466. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110467. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110468. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110469. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110470. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110471. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110472. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110473. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110474. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110475. /**
  110476. * Decorator used to define property that can be serialized as reference to a camera
  110477. * @param sourceName defines the name of the property to decorate
  110478. */
  110479. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  110480. /**
  110481. * Class used to help serialization objects
  110482. */
  110483. export class SerializationHelper {
  110484. /** @hidden */
  110485. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  110486. /** @hidden */
  110487. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  110488. /** @hidden */
  110489. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  110490. /** @hidden */
  110491. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  110492. /**
  110493. * Appends the serialized animations from the source animations
  110494. * @param source Source containing the animations
  110495. * @param destination Target to store the animations
  110496. */
  110497. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  110498. /**
  110499. * Static function used to serialized a specific entity
  110500. * @param entity defines the entity to serialize
  110501. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  110502. * @returns a JSON compatible object representing the serialization of the entity
  110503. */
  110504. static Serialize<T>(entity: T, serializationObject?: any): any;
  110505. /**
  110506. * Creates a new entity from a serialization data object
  110507. * @param creationFunction defines a function used to instanciated the new entity
  110508. * @param source defines the source serialization data
  110509. * @param scene defines the hosting scene
  110510. * @param rootUrl defines the root url for resources
  110511. * @returns a new entity
  110512. */
  110513. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  110514. /**
  110515. * Clones an object
  110516. * @param creationFunction defines the function used to instanciate the new object
  110517. * @param source defines the source object
  110518. * @returns the cloned object
  110519. */
  110520. static Clone<T>(creationFunction: () => T, source: T): T;
  110521. /**
  110522. * Instanciates a new object based on a source one (some data will be shared between both object)
  110523. * @param creationFunction defines the function used to instanciate the new object
  110524. * @param source defines the source object
  110525. * @returns the new object
  110526. */
  110527. static Instanciate<T>(creationFunction: () => T, source: T): T;
  110528. }
  110529. }
  110530. declare module BABYLON {
  110531. /**
  110532. * Base class of all the textures in babylon.
  110533. * It groups all the common properties the materials, post process, lights... might need
  110534. * in order to make a correct use of the texture.
  110535. */
  110536. export class BaseTexture implements IAnimatable {
  110537. /**
  110538. * Default anisotropic filtering level for the application.
  110539. * It is set to 4 as a good tradeoff between perf and quality.
  110540. */
  110541. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  110542. /**
  110543. * Gets or sets the unique id of the texture
  110544. */
  110545. uniqueId: number;
  110546. /**
  110547. * Define the name of the texture.
  110548. */
  110549. name: string;
  110550. /**
  110551. * Gets or sets an object used to store user defined information.
  110552. */
  110553. metadata: any;
  110554. /**
  110555. * For internal use only. Please do not use.
  110556. */
  110557. reservedDataStore: any;
  110558. private _hasAlpha;
  110559. /**
  110560. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  110561. */
  110562. set hasAlpha(value: boolean);
  110563. get hasAlpha(): boolean;
  110564. /**
  110565. * Defines if the alpha value should be determined via the rgb values.
  110566. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  110567. */
  110568. getAlphaFromRGB: boolean;
  110569. /**
  110570. * Intensity or strength of the texture.
  110571. * It is commonly used by materials to fine tune the intensity of the texture
  110572. */
  110573. level: number;
  110574. /**
  110575. * Define the UV chanel to use starting from 0 and defaulting to 0.
  110576. * This is part of the texture as textures usually maps to one uv set.
  110577. */
  110578. coordinatesIndex: number;
  110579. private _coordinatesMode;
  110580. /**
  110581. * How a texture is mapped.
  110582. *
  110583. * | Value | Type | Description |
  110584. * | ----- | ----------------------------------- | ----------- |
  110585. * | 0 | EXPLICIT_MODE | |
  110586. * | 1 | SPHERICAL_MODE | |
  110587. * | 2 | PLANAR_MODE | |
  110588. * | 3 | CUBIC_MODE | |
  110589. * | 4 | PROJECTION_MODE | |
  110590. * | 5 | SKYBOX_MODE | |
  110591. * | 6 | INVCUBIC_MODE | |
  110592. * | 7 | EQUIRECTANGULAR_MODE | |
  110593. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  110594. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  110595. */
  110596. set coordinatesMode(value: number);
  110597. get coordinatesMode(): number;
  110598. /**
  110599. * | Value | Type | Description |
  110600. * | ----- | ------------------ | ----------- |
  110601. * | 0 | CLAMP_ADDRESSMODE | |
  110602. * | 1 | WRAP_ADDRESSMODE | |
  110603. * | 2 | MIRROR_ADDRESSMODE | |
  110604. */
  110605. wrapU: number;
  110606. /**
  110607. * | Value | Type | Description |
  110608. * | ----- | ------------------ | ----------- |
  110609. * | 0 | CLAMP_ADDRESSMODE | |
  110610. * | 1 | WRAP_ADDRESSMODE | |
  110611. * | 2 | MIRROR_ADDRESSMODE | |
  110612. */
  110613. wrapV: number;
  110614. /**
  110615. * | Value | Type | Description |
  110616. * | ----- | ------------------ | ----------- |
  110617. * | 0 | CLAMP_ADDRESSMODE | |
  110618. * | 1 | WRAP_ADDRESSMODE | |
  110619. * | 2 | MIRROR_ADDRESSMODE | |
  110620. */
  110621. wrapR: number;
  110622. /**
  110623. * With compliant hardware and browser (supporting anisotropic filtering)
  110624. * this defines the level of anisotropic filtering in the texture.
  110625. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  110626. */
  110627. anisotropicFilteringLevel: number;
  110628. /**
  110629. * Define if the texture is a cube texture or if false a 2d texture.
  110630. */
  110631. get isCube(): boolean;
  110632. set isCube(value: boolean);
  110633. /**
  110634. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  110635. */
  110636. get is3D(): boolean;
  110637. set is3D(value: boolean);
  110638. /**
  110639. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  110640. */
  110641. get is2DArray(): boolean;
  110642. set is2DArray(value: boolean);
  110643. /**
  110644. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  110645. * HDR texture are usually stored in linear space.
  110646. * This only impacts the PBR and Background materials
  110647. */
  110648. gammaSpace: boolean;
  110649. /**
  110650. * Gets or sets whether or not the texture contains RGBD data.
  110651. */
  110652. get isRGBD(): boolean;
  110653. set isRGBD(value: boolean);
  110654. /**
  110655. * Is Z inverted in the texture (useful in a cube texture).
  110656. */
  110657. invertZ: boolean;
  110658. /**
  110659. * Are mip maps generated for this texture or not.
  110660. */
  110661. get noMipmap(): boolean;
  110662. /**
  110663. * @hidden
  110664. */
  110665. lodLevelInAlpha: boolean;
  110666. /**
  110667. * With prefiltered texture, defined the offset used during the prefiltering steps.
  110668. */
  110669. get lodGenerationOffset(): number;
  110670. set lodGenerationOffset(value: number);
  110671. /**
  110672. * With prefiltered texture, defined the scale used during the prefiltering steps.
  110673. */
  110674. get lodGenerationScale(): number;
  110675. set lodGenerationScale(value: number);
  110676. /**
  110677. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  110678. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  110679. * average roughness values.
  110680. */
  110681. get linearSpecularLOD(): boolean;
  110682. set linearSpecularLOD(value: boolean);
  110683. /**
  110684. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  110685. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  110686. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  110687. */
  110688. get irradianceTexture(): Nullable<BaseTexture>;
  110689. set irradianceTexture(value: Nullable<BaseTexture>);
  110690. /**
  110691. * Define if the texture is a render target.
  110692. */
  110693. isRenderTarget: boolean;
  110694. /**
  110695. * Define the unique id of the texture in the scene.
  110696. */
  110697. get uid(): string;
  110698. /** @hidden */
  110699. _prefiltered: boolean;
  110700. /**
  110701. * Return a string representation of the texture.
  110702. * @returns the texture as a string
  110703. */
  110704. toString(): string;
  110705. /**
  110706. * Get the class name of the texture.
  110707. * @returns "BaseTexture"
  110708. */
  110709. getClassName(): string;
  110710. /**
  110711. * Define the list of animation attached to the texture.
  110712. */
  110713. animations: Animation[];
  110714. /**
  110715. * An event triggered when the texture is disposed.
  110716. */
  110717. onDisposeObservable: Observable<BaseTexture>;
  110718. private _onDisposeObserver;
  110719. /**
  110720. * Callback triggered when the texture has been disposed.
  110721. * Kept for back compatibility, you can use the onDisposeObservable instead.
  110722. */
  110723. set onDispose(callback: () => void);
  110724. /**
  110725. * Define the current state of the loading sequence when in delayed load mode.
  110726. */
  110727. delayLoadState: number;
  110728. private _scene;
  110729. private _engine;
  110730. /** @hidden */
  110731. _texture: Nullable<InternalTexture>;
  110732. private _uid;
  110733. /**
  110734. * Define if the texture is preventinga material to render or not.
  110735. * If not and the texture is not ready, the engine will use a default black texture instead.
  110736. */
  110737. get isBlocking(): boolean;
  110738. /**
  110739. * Instantiates a new BaseTexture.
  110740. * Base class of all the textures in babylon.
  110741. * It groups all the common properties the materials, post process, lights... might need
  110742. * in order to make a correct use of the texture.
  110743. * @param sceneOrEngine Define the scene or engine the texture blongs to
  110744. */
  110745. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  110746. /**
  110747. * Get the scene the texture belongs to.
  110748. * @returns the scene or null if undefined
  110749. */
  110750. getScene(): Nullable<Scene>;
  110751. /** @hidden */
  110752. protected _getEngine(): Nullable<ThinEngine>;
  110753. /**
  110754. * Get the texture transform matrix used to offset tile the texture for istance.
  110755. * @returns the transformation matrix
  110756. */
  110757. getTextureMatrix(): Matrix;
  110758. /**
  110759. * Get the texture reflection matrix used to rotate/transform the reflection.
  110760. * @returns the reflection matrix
  110761. */
  110762. getReflectionTextureMatrix(): Matrix;
  110763. /**
  110764. * Get the underlying lower level texture from Babylon.
  110765. * @returns the insternal texture
  110766. */
  110767. getInternalTexture(): Nullable<InternalTexture>;
  110768. /**
  110769. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  110770. * @returns true if ready or not blocking
  110771. */
  110772. isReadyOrNotBlocking(): boolean;
  110773. /**
  110774. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  110775. * @returns true if fully ready
  110776. */
  110777. isReady(): boolean;
  110778. private _cachedSize;
  110779. /**
  110780. * Get the size of the texture.
  110781. * @returns the texture size.
  110782. */
  110783. getSize(): ISize;
  110784. /**
  110785. * Get the base size of the texture.
  110786. * It can be different from the size if the texture has been resized for POT for instance
  110787. * @returns the base size
  110788. */
  110789. getBaseSize(): ISize;
  110790. /**
  110791. * Update the sampling mode of the texture.
  110792. * Default is Trilinear mode.
  110793. *
  110794. * | Value | Type | Description |
  110795. * | ----- | ------------------ | ----------- |
  110796. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  110797. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  110798. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  110799. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  110800. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  110801. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  110802. * | 7 | NEAREST_LINEAR | |
  110803. * | 8 | NEAREST_NEAREST | |
  110804. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  110805. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  110806. * | 11 | LINEAR_LINEAR | |
  110807. * | 12 | LINEAR_NEAREST | |
  110808. *
  110809. * > _mag_: magnification filter (close to the viewer)
  110810. * > _min_: minification filter (far from the viewer)
  110811. * > _mip_: filter used between mip map levels
  110812. *@param samplingMode Define the new sampling mode of the texture
  110813. */
  110814. updateSamplingMode(samplingMode: number): void;
  110815. /**
  110816. * Scales the texture if is `canRescale()`
  110817. * @param ratio the resize factor we want to use to rescale
  110818. */
  110819. scale(ratio: number): void;
  110820. /**
  110821. * Get if the texture can rescale.
  110822. */
  110823. get canRescale(): boolean;
  110824. /** @hidden */
  110825. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  110826. /** @hidden */
  110827. _rebuild(): void;
  110828. /**
  110829. * Triggers the load sequence in delayed load mode.
  110830. */
  110831. delayLoad(): void;
  110832. /**
  110833. * Clones the texture.
  110834. * @returns the cloned texture
  110835. */
  110836. clone(): Nullable<BaseTexture>;
  110837. /**
  110838. * Get the texture underlying type (INT, FLOAT...)
  110839. */
  110840. get textureType(): number;
  110841. /**
  110842. * Get the texture underlying format (RGB, RGBA...)
  110843. */
  110844. get textureFormat(): number;
  110845. /**
  110846. * Indicates that textures need to be re-calculated for all materials
  110847. */
  110848. protected _markAllSubMeshesAsTexturesDirty(): void;
  110849. /**
  110850. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  110851. * This will returns an RGBA array buffer containing either in values (0-255) or
  110852. * float values (0-1) depending of the underlying buffer type.
  110853. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  110854. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  110855. * @param buffer defines a user defined buffer to fill with data (can be null)
  110856. * @returns The Array buffer containing the pixels data.
  110857. */
  110858. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  110859. /**
  110860. * Release and destroy the underlying lower level texture aka internalTexture.
  110861. */
  110862. releaseInternalTexture(): void;
  110863. /** @hidden */
  110864. get _lodTextureHigh(): Nullable<BaseTexture>;
  110865. /** @hidden */
  110866. get _lodTextureMid(): Nullable<BaseTexture>;
  110867. /** @hidden */
  110868. get _lodTextureLow(): Nullable<BaseTexture>;
  110869. /**
  110870. * Dispose the texture and release its associated resources.
  110871. */
  110872. dispose(): void;
  110873. /**
  110874. * Serialize the texture into a JSON representation that can be parsed later on.
  110875. * @returns the JSON representation of the texture
  110876. */
  110877. serialize(): any;
  110878. /**
  110879. * Helper function to be called back once a list of texture contains only ready textures.
  110880. * @param textures Define the list of textures to wait for
  110881. * @param callback Define the callback triggered once the entire list will be ready
  110882. */
  110883. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  110884. private static _isScene;
  110885. }
  110886. }
  110887. declare module BABYLON {
  110888. /**
  110889. * Options to be used when creating an effect.
  110890. */
  110891. export interface IEffectCreationOptions {
  110892. /**
  110893. * Atrributes that will be used in the shader.
  110894. */
  110895. attributes: string[];
  110896. /**
  110897. * Uniform varible names that will be set in the shader.
  110898. */
  110899. uniformsNames: string[];
  110900. /**
  110901. * Uniform buffer variable names that will be set in the shader.
  110902. */
  110903. uniformBuffersNames: string[];
  110904. /**
  110905. * Sampler texture variable names that will be set in the shader.
  110906. */
  110907. samplers: string[];
  110908. /**
  110909. * Define statements that will be set in the shader.
  110910. */
  110911. defines: any;
  110912. /**
  110913. * Possible fallbacks for this effect to improve performance when needed.
  110914. */
  110915. fallbacks: Nullable<IEffectFallbacks>;
  110916. /**
  110917. * Callback that will be called when the shader is compiled.
  110918. */
  110919. onCompiled: Nullable<(effect: Effect) => void>;
  110920. /**
  110921. * Callback that will be called if an error occurs during shader compilation.
  110922. */
  110923. onError: Nullable<(effect: Effect, errors: string) => void>;
  110924. /**
  110925. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  110926. */
  110927. indexParameters?: any;
  110928. /**
  110929. * Max number of lights that can be used in the shader.
  110930. */
  110931. maxSimultaneousLights?: number;
  110932. /**
  110933. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  110934. */
  110935. transformFeedbackVaryings?: Nullable<string[]>;
  110936. /**
  110937. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  110938. */
  110939. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110940. }
  110941. /**
  110942. * Effect containing vertex and fragment shader that can be executed on an object.
  110943. */
  110944. export class Effect implements IDisposable {
  110945. /**
  110946. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  110947. */
  110948. static ShadersRepository: string;
  110949. /**
  110950. * Enable logging of the shader code when a compilation error occurs
  110951. */
  110952. static LogShaderCodeOnCompilationError: boolean;
  110953. /**
  110954. * Name of the effect.
  110955. */
  110956. name: any;
  110957. /**
  110958. * String container all the define statements that should be set on the shader.
  110959. */
  110960. defines: string;
  110961. /**
  110962. * Callback that will be called when the shader is compiled.
  110963. */
  110964. onCompiled: Nullable<(effect: Effect) => void>;
  110965. /**
  110966. * Callback that will be called if an error occurs during shader compilation.
  110967. */
  110968. onError: Nullable<(effect: Effect, errors: string) => void>;
  110969. /**
  110970. * Callback that will be called when effect is bound.
  110971. */
  110972. onBind: Nullable<(effect: Effect) => void>;
  110973. /**
  110974. * Unique ID of the effect.
  110975. */
  110976. uniqueId: number;
  110977. /**
  110978. * Observable that will be called when the shader is compiled.
  110979. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  110980. */
  110981. onCompileObservable: Observable<Effect>;
  110982. /**
  110983. * Observable that will be called if an error occurs during shader compilation.
  110984. */
  110985. onErrorObservable: Observable<Effect>;
  110986. /** @hidden */
  110987. _onBindObservable: Nullable<Observable<Effect>>;
  110988. /**
  110989. * @hidden
  110990. * Specifies if the effect was previously ready
  110991. */
  110992. _wasPreviouslyReady: boolean;
  110993. /**
  110994. * Observable that will be called when effect is bound.
  110995. */
  110996. get onBindObservable(): Observable<Effect>;
  110997. /** @hidden */
  110998. _bonesComputationForcedToCPU: boolean;
  110999. private static _uniqueIdSeed;
  111000. private _engine;
  111001. private _uniformBuffersNames;
  111002. private _uniformBuffersNamesList;
  111003. private _uniformsNames;
  111004. private _samplerList;
  111005. private _samplers;
  111006. private _isReady;
  111007. private _compilationError;
  111008. private _allFallbacksProcessed;
  111009. private _attributesNames;
  111010. private _attributes;
  111011. private _attributeLocationByName;
  111012. private _uniforms;
  111013. /**
  111014. * Key for the effect.
  111015. * @hidden
  111016. */
  111017. _key: string;
  111018. private _indexParameters;
  111019. private _fallbacks;
  111020. private _vertexSourceCode;
  111021. private _fragmentSourceCode;
  111022. private _vertexSourceCodeOverride;
  111023. private _fragmentSourceCodeOverride;
  111024. private _transformFeedbackVaryings;
  111025. /**
  111026. * Compiled shader to webGL program.
  111027. * @hidden
  111028. */
  111029. _pipelineContext: Nullable<IPipelineContext>;
  111030. private _valueCache;
  111031. private static _baseCache;
  111032. /**
  111033. * Instantiates an effect.
  111034. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111035. * @param baseName Name of the effect.
  111036. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111037. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111038. * @param samplers List of sampler variables that will be passed to the shader.
  111039. * @param engine Engine to be used to render the effect
  111040. * @param defines Define statements to be added to the shader.
  111041. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111042. * @param onCompiled Callback that will be called when the shader is compiled.
  111043. * @param onError Callback that will be called if an error occurs during shader compilation.
  111044. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111045. */
  111046. 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);
  111047. private _useFinalCode;
  111048. /**
  111049. * Unique key for this effect
  111050. */
  111051. get key(): string;
  111052. /**
  111053. * If the effect has been compiled and prepared.
  111054. * @returns if the effect is compiled and prepared.
  111055. */
  111056. isReady(): boolean;
  111057. private _isReadyInternal;
  111058. /**
  111059. * The engine the effect was initialized with.
  111060. * @returns the engine.
  111061. */
  111062. getEngine(): Engine;
  111063. /**
  111064. * The pipeline context for this effect
  111065. * @returns the associated pipeline context
  111066. */
  111067. getPipelineContext(): Nullable<IPipelineContext>;
  111068. /**
  111069. * The set of names of attribute variables for the shader.
  111070. * @returns An array of attribute names.
  111071. */
  111072. getAttributesNames(): string[];
  111073. /**
  111074. * Returns the attribute at the given index.
  111075. * @param index The index of the attribute.
  111076. * @returns The location of the attribute.
  111077. */
  111078. getAttributeLocation(index: number): number;
  111079. /**
  111080. * Returns the attribute based on the name of the variable.
  111081. * @param name of the attribute to look up.
  111082. * @returns the attribute location.
  111083. */
  111084. getAttributeLocationByName(name: string): number;
  111085. /**
  111086. * The number of attributes.
  111087. * @returns the numnber of attributes.
  111088. */
  111089. getAttributesCount(): number;
  111090. /**
  111091. * Gets the index of a uniform variable.
  111092. * @param uniformName of the uniform to look up.
  111093. * @returns the index.
  111094. */
  111095. getUniformIndex(uniformName: string): number;
  111096. /**
  111097. * Returns the attribute based on the name of the variable.
  111098. * @param uniformName of the uniform to look up.
  111099. * @returns the location of the uniform.
  111100. */
  111101. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111102. /**
  111103. * Returns an array of sampler variable names
  111104. * @returns The array of sampler variable names.
  111105. */
  111106. getSamplers(): string[];
  111107. /**
  111108. * Returns an array of uniform variable names
  111109. * @returns The array of uniform variable names.
  111110. */
  111111. getUniformNames(): string[];
  111112. /**
  111113. * Returns an array of uniform buffer variable names
  111114. * @returns The array of uniform buffer variable names.
  111115. */
  111116. getUniformBuffersNames(): string[];
  111117. /**
  111118. * Returns the index parameters used to create the effect
  111119. * @returns The index parameters object
  111120. */
  111121. getIndexParameters(): any;
  111122. /**
  111123. * The error from the last compilation.
  111124. * @returns the error string.
  111125. */
  111126. getCompilationError(): string;
  111127. /**
  111128. * Gets a boolean indicating that all fallbacks were used during compilation
  111129. * @returns true if all fallbacks were used
  111130. */
  111131. allFallbacksProcessed(): boolean;
  111132. /**
  111133. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111134. * @param func The callback to be used.
  111135. */
  111136. executeWhenCompiled(func: (effect: Effect) => void): void;
  111137. private _checkIsReady;
  111138. private _loadShader;
  111139. /**
  111140. * Gets the vertex shader source code of this effect
  111141. */
  111142. get vertexSourceCode(): string;
  111143. /**
  111144. * Gets the fragment shader source code of this effect
  111145. */
  111146. get fragmentSourceCode(): string;
  111147. /**
  111148. * Recompiles the webGL program
  111149. * @param vertexSourceCode The source code for the vertex shader.
  111150. * @param fragmentSourceCode The source code for the fragment shader.
  111151. * @param onCompiled Callback called when completed.
  111152. * @param onError Callback called on error.
  111153. * @hidden
  111154. */
  111155. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111156. /**
  111157. * Prepares the effect
  111158. * @hidden
  111159. */
  111160. _prepareEffect(): void;
  111161. private _getShaderCodeAndErrorLine;
  111162. private _processCompilationErrors;
  111163. /**
  111164. * Checks if the effect is supported. (Must be called after compilation)
  111165. */
  111166. get isSupported(): boolean;
  111167. /**
  111168. * Binds a texture to the engine to be used as output of the shader.
  111169. * @param channel Name of the output variable.
  111170. * @param texture Texture to bind.
  111171. * @hidden
  111172. */
  111173. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111174. /**
  111175. * Sets a texture on the engine to be used in the shader.
  111176. * @param channel Name of the sampler variable.
  111177. * @param texture Texture to set.
  111178. */
  111179. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111180. /**
  111181. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111182. * @param channel Name of the sampler variable.
  111183. * @param texture Texture to set.
  111184. */
  111185. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111186. /**
  111187. * Sets an array of textures on the engine to be used in the shader.
  111188. * @param channel Name of the variable.
  111189. * @param textures Textures to set.
  111190. */
  111191. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111192. /**
  111193. * 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)
  111194. * @param channel Name of the sampler variable.
  111195. * @param postProcess Post process to get the input texture from.
  111196. */
  111197. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111198. /**
  111199. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111200. * 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)
  111201. * @param channel Name of the sampler variable.
  111202. * @param postProcess Post process to get the output texture from.
  111203. */
  111204. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111205. /** @hidden */
  111206. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111207. /** @hidden */
  111208. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111209. /** @hidden */
  111210. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111211. /** @hidden */
  111212. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111213. /**
  111214. * Binds a buffer to a uniform.
  111215. * @param buffer Buffer to bind.
  111216. * @param name Name of the uniform variable to bind to.
  111217. */
  111218. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111219. /**
  111220. * Binds block to a uniform.
  111221. * @param blockName Name of the block to bind.
  111222. * @param index Index to bind.
  111223. */
  111224. bindUniformBlock(blockName: string, index: number): void;
  111225. /**
  111226. * Sets an interger value on a uniform variable.
  111227. * @param uniformName Name of the variable.
  111228. * @param value Value to be set.
  111229. * @returns this effect.
  111230. */
  111231. setInt(uniformName: string, value: number): Effect;
  111232. /**
  111233. * Sets an int array on a uniform variable.
  111234. * @param uniformName Name of the variable.
  111235. * @param array array to be set.
  111236. * @returns this effect.
  111237. */
  111238. setIntArray(uniformName: string, array: Int32Array): Effect;
  111239. /**
  111240. * 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)
  111241. * @param uniformName Name of the variable.
  111242. * @param array array to be set.
  111243. * @returns this effect.
  111244. */
  111245. setIntArray2(uniformName: string, array: Int32Array): Effect;
  111246. /**
  111247. * 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)
  111248. * @param uniformName Name of the variable.
  111249. * @param array array to be set.
  111250. * @returns this effect.
  111251. */
  111252. setIntArray3(uniformName: string, array: Int32Array): Effect;
  111253. /**
  111254. * 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)
  111255. * @param uniformName Name of the variable.
  111256. * @param array array to be set.
  111257. * @returns this effect.
  111258. */
  111259. setIntArray4(uniformName: string, array: Int32Array): Effect;
  111260. /**
  111261. * Sets an float array on a uniform variable.
  111262. * @param uniformName Name of the variable.
  111263. * @param array array to be set.
  111264. * @returns this effect.
  111265. */
  111266. setFloatArray(uniformName: string, array: Float32Array): Effect;
  111267. /**
  111268. * 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)
  111269. * @param uniformName Name of the variable.
  111270. * @param array array to be set.
  111271. * @returns this effect.
  111272. */
  111273. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  111274. /**
  111275. * 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)
  111276. * @param uniformName Name of the variable.
  111277. * @param array array to be set.
  111278. * @returns this effect.
  111279. */
  111280. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  111281. /**
  111282. * 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)
  111283. * @param uniformName Name of the variable.
  111284. * @param array array to be set.
  111285. * @returns this effect.
  111286. */
  111287. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  111288. /**
  111289. * Sets an array on a uniform variable.
  111290. * @param uniformName Name of the variable.
  111291. * @param array array to be set.
  111292. * @returns this effect.
  111293. */
  111294. setArray(uniformName: string, array: number[]): Effect;
  111295. /**
  111296. * 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)
  111297. * @param uniformName Name of the variable.
  111298. * @param array array to be set.
  111299. * @returns this effect.
  111300. */
  111301. setArray2(uniformName: string, array: number[]): Effect;
  111302. /**
  111303. * 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)
  111304. * @param uniformName Name of the variable.
  111305. * @param array array to be set.
  111306. * @returns this effect.
  111307. */
  111308. setArray3(uniformName: string, array: number[]): Effect;
  111309. /**
  111310. * 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)
  111311. * @param uniformName Name of the variable.
  111312. * @param array array to be set.
  111313. * @returns this effect.
  111314. */
  111315. setArray4(uniformName: string, array: number[]): Effect;
  111316. /**
  111317. * Sets matrices on a uniform variable.
  111318. * @param uniformName Name of the variable.
  111319. * @param matrices matrices to be set.
  111320. * @returns this effect.
  111321. */
  111322. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  111323. /**
  111324. * Sets matrix on a uniform variable.
  111325. * @param uniformName Name of the variable.
  111326. * @param matrix matrix to be set.
  111327. * @returns this effect.
  111328. */
  111329. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  111330. /**
  111331. * 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)
  111332. * @param uniformName Name of the variable.
  111333. * @param matrix matrix to be set.
  111334. * @returns this effect.
  111335. */
  111336. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  111337. /**
  111338. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  111339. * @param uniformName Name of the variable.
  111340. * @param matrix matrix to be set.
  111341. * @returns this effect.
  111342. */
  111343. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  111344. /**
  111345. * Sets a float on a uniform variable.
  111346. * @param uniformName Name of the variable.
  111347. * @param value value to be set.
  111348. * @returns this effect.
  111349. */
  111350. setFloat(uniformName: string, value: number): Effect;
  111351. /**
  111352. * Sets a boolean on a uniform variable.
  111353. * @param uniformName Name of the variable.
  111354. * @param bool value to be set.
  111355. * @returns this effect.
  111356. */
  111357. setBool(uniformName: string, bool: boolean): Effect;
  111358. /**
  111359. * Sets a Vector2 on a uniform variable.
  111360. * @param uniformName Name of the variable.
  111361. * @param vector2 vector2 to be set.
  111362. * @returns this effect.
  111363. */
  111364. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  111365. /**
  111366. * Sets a float2 on a uniform variable.
  111367. * @param uniformName Name of the variable.
  111368. * @param x First float in float2.
  111369. * @param y Second float in float2.
  111370. * @returns this effect.
  111371. */
  111372. setFloat2(uniformName: string, x: number, y: number): Effect;
  111373. /**
  111374. * Sets a Vector3 on a uniform variable.
  111375. * @param uniformName Name of the variable.
  111376. * @param vector3 Value to be set.
  111377. * @returns this effect.
  111378. */
  111379. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  111380. /**
  111381. * Sets a float3 on a uniform variable.
  111382. * @param uniformName Name of the variable.
  111383. * @param x First float in float3.
  111384. * @param y Second float in float3.
  111385. * @param z Third float in float3.
  111386. * @returns this effect.
  111387. */
  111388. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  111389. /**
  111390. * Sets a Vector4 on a uniform variable.
  111391. * @param uniformName Name of the variable.
  111392. * @param vector4 Value to be set.
  111393. * @returns this effect.
  111394. */
  111395. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  111396. /**
  111397. * Sets a float4 on a uniform variable.
  111398. * @param uniformName Name of the variable.
  111399. * @param x First float in float4.
  111400. * @param y Second float in float4.
  111401. * @param z Third float in float4.
  111402. * @param w Fourth float in float4.
  111403. * @returns this effect.
  111404. */
  111405. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  111406. /**
  111407. * Sets a Color3 on a uniform variable.
  111408. * @param uniformName Name of the variable.
  111409. * @param color3 Value to be set.
  111410. * @returns this effect.
  111411. */
  111412. setColor3(uniformName: string, color3: IColor3Like): Effect;
  111413. /**
  111414. * Sets a Color4 on a uniform variable.
  111415. * @param uniformName Name of the variable.
  111416. * @param color3 Value to be set.
  111417. * @param alpha Alpha value to be set.
  111418. * @returns this effect.
  111419. */
  111420. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  111421. /**
  111422. * Sets a Color4 on a uniform variable
  111423. * @param uniformName defines the name of the variable
  111424. * @param color4 defines the value to be set
  111425. * @returns this effect.
  111426. */
  111427. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  111428. /** Release all associated resources */
  111429. dispose(): void;
  111430. /**
  111431. * This function will add a new shader to the shader store
  111432. * @param name the name of the shader
  111433. * @param pixelShader optional pixel shader content
  111434. * @param vertexShader optional vertex shader content
  111435. */
  111436. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  111437. /**
  111438. * Store of each shader (The can be looked up using effect.key)
  111439. */
  111440. static ShadersStore: {
  111441. [key: string]: string;
  111442. };
  111443. /**
  111444. * Store of each included file for a shader (The can be looked up using effect.key)
  111445. */
  111446. static IncludesShadersStore: {
  111447. [key: string]: string;
  111448. };
  111449. /**
  111450. * Resets the cache of effects.
  111451. */
  111452. static ResetCache(): void;
  111453. }
  111454. }
  111455. declare module BABYLON {
  111456. /**
  111457. * Interface used to describe the capabilities of the engine relatively to the current browser
  111458. */
  111459. export interface EngineCapabilities {
  111460. /** Maximum textures units per fragment shader */
  111461. maxTexturesImageUnits: number;
  111462. /** Maximum texture units per vertex shader */
  111463. maxVertexTextureImageUnits: number;
  111464. /** Maximum textures units in the entire pipeline */
  111465. maxCombinedTexturesImageUnits: number;
  111466. /** Maximum texture size */
  111467. maxTextureSize: number;
  111468. /** Maximum texture samples */
  111469. maxSamples?: number;
  111470. /** Maximum cube texture size */
  111471. maxCubemapTextureSize: number;
  111472. /** Maximum render texture size */
  111473. maxRenderTextureSize: number;
  111474. /** Maximum number of vertex attributes */
  111475. maxVertexAttribs: number;
  111476. /** Maximum number of varyings */
  111477. maxVaryingVectors: number;
  111478. /** Maximum number of uniforms per vertex shader */
  111479. maxVertexUniformVectors: number;
  111480. /** Maximum number of uniforms per fragment shader */
  111481. maxFragmentUniformVectors: number;
  111482. /** Defines if standard derivates (dx/dy) are supported */
  111483. standardDerivatives: boolean;
  111484. /** Defines if s3tc texture compression is supported */
  111485. s3tc?: WEBGL_compressed_texture_s3tc;
  111486. /** Defines if pvrtc texture compression is supported */
  111487. pvrtc: any;
  111488. /** Defines if etc1 texture compression is supported */
  111489. etc1: any;
  111490. /** Defines if etc2 texture compression is supported */
  111491. etc2: any;
  111492. /** Defines if astc texture compression is supported */
  111493. astc: any;
  111494. /** Defines if float textures are supported */
  111495. textureFloat: boolean;
  111496. /** Defines if vertex array objects are supported */
  111497. vertexArrayObject: boolean;
  111498. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  111499. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  111500. /** Gets the maximum level of anisotropy supported */
  111501. maxAnisotropy: number;
  111502. /** Defines if instancing is supported */
  111503. instancedArrays: boolean;
  111504. /** Defines if 32 bits indices are supported */
  111505. uintIndices: boolean;
  111506. /** Defines if high precision shaders are supported */
  111507. highPrecisionShaderSupported: boolean;
  111508. /** Defines if depth reading in the fragment shader is supported */
  111509. fragmentDepthSupported: boolean;
  111510. /** Defines if float texture linear filtering is supported*/
  111511. textureFloatLinearFiltering: boolean;
  111512. /** Defines if rendering to float textures is supported */
  111513. textureFloatRender: boolean;
  111514. /** Defines if half float textures are supported*/
  111515. textureHalfFloat: boolean;
  111516. /** Defines if half float texture linear filtering is supported*/
  111517. textureHalfFloatLinearFiltering: boolean;
  111518. /** Defines if rendering to half float textures is supported */
  111519. textureHalfFloatRender: boolean;
  111520. /** Defines if textureLOD shader command is supported */
  111521. textureLOD: boolean;
  111522. /** Defines if draw buffers extension is supported */
  111523. drawBuffersExtension: boolean;
  111524. /** Defines if depth textures are supported */
  111525. depthTextureExtension: boolean;
  111526. /** Defines if float color buffer are supported */
  111527. colorBufferFloat: boolean;
  111528. /** Gets disjoint timer query extension (null if not supported) */
  111529. timerQuery?: EXT_disjoint_timer_query;
  111530. /** Defines if timestamp can be used with timer query */
  111531. canUseTimestampForTimerQuery: boolean;
  111532. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  111533. multiview?: any;
  111534. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  111535. oculusMultiview?: any;
  111536. /** Function used to let the system compiles shaders in background */
  111537. parallelShaderCompile?: {
  111538. COMPLETION_STATUS_KHR: number;
  111539. };
  111540. /** Max number of texture samples for MSAA */
  111541. maxMSAASamples: number;
  111542. /** Defines if the blend min max extension is supported */
  111543. blendMinMax: boolean;
  111544. }
  111545. }
  111546. declare module BABYLON {
  111547. /**
  111548. * @hidden
  111549. **/
  111550. export class DepthCullingState {
  111551. private _isDepthTestDirty;
  111552. private _isDepthMaskDirty;
  111553. private _isDepthFuncDirty;
  111554. private _isCullFaceDirty;
  111555. private _isCullDirty;
  111556. private _isZOffsetDirty;
  111557. private _isFrontFaceDirty;
  111558. private _depthTest;
  111559. private _depthMask;
  111560. private _depthFunc;
  111561. private _cull;
  111562. private _cullFace;
  111563. private _zOffset;
  111564. private _frontFace;
  111565. /**
  111566. * Initializes the state.
  111567. */
  111568. constructor();
  111569. get isDirty(): boolean;
  111570. get zOffset(): number;
  111571. set zOffset(value: number);
  111572. get cullFace(): Nullable<number>;
  111573. set cullFace(value: Nullable<number>);
  111574. get cull(): Nullable<boolean>;
  111575. set cull(value: Nullable<boolean>);
  111576. get depthFunc(): Nullable<number>;
  111577. set depthFunc(value: Nullable<number>);
  111578. get depthMask(): boolean;
  111579. set depthMask(value: boolean);
  111580. get depthTest(): boolean;
  111581. set depthTest(value: boolean);
  111582. get frontFace(): Nullable<number>;
  111583. set frontFace(value: Nullable<number>);
  111584. reset(): void;
  111585. apply(gl: WebGLRenderingContext): void;
  111586. }
  111587. }
  111588. declare module BABYLON {
  111589. /**
  111590. * @hidden
  111591. **/
  111592. export class StencilState {
  111593. /** 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 */
  111594. static readonly ALWAYS: number;
  111595. /** Passed to stencilOperation to specify that stencil value must be kept */
  111596. static readonly KEEP: number;
  111597. /** Passed to stencilOperation to specify that stencil value must be replaced */
  111598. static readonly REPLACE: number;
  111599. private _isStencilTestDirty;
  111600. private _isStencilMaskDirty;
  111601. private _isStencilFuncDirty;
  111602. private _isStencilOpDirty;
  111603. private _stencilTest;
  111604. private _stencilMask;
  111605. private _stencilFunc;
  111606. private _stencilFuncRef;
  111607. private _stencilFuncMask;
  111608. private _stencilOpStencilFail;
  111609. private _stencilOpDepthFail;
  111610. private _stencilOpStencilDepthPass;
  111611. get isDirty(): boolean;
  111612. get stencilFunc(): number;
  111613. set stencilFunc(value: number);
  111614. get stencilFuncRef(): number;
  111615. set stencilFuncRef(value: number);
  111616. get stencilFuncMask(): number;
  111617. set stencilFuncMask(value: number);
  111618. get stencilOpStencilFail(): number;
  111619. set stencilOpStencilFail(value: number);
  111620. get stencilOpDepthFail(): number;
  111621. set stencilOpDepthFail(value: number);
  111622. get stencilOpStencilDepthPass(): number;
  111623. set stencilOpStencilDepthPass(value: number);
  111624. get stencilMask(): number;
  111625. set stencilMask(value: number);
  111626. get stencilTest(): boolean;
  111627. set stencilTest(value: boolean);
  111628. constructor();
  111629. reset(): void;
  111630. apply(gl: WebGLRenderingContext): void;
  111631. }
  111632. }
  111633. declare module BABYLON {
  111634. /**
  111635. * @hidden
  111636. **/
  111637. export class AlphaState {
  111638. private _isAlphaBlendDirty;
  111639. private _isBlendFunctionParametersDirty;
  111640. private _isBlendEquationParametersDirty;
  111641. private _isBlendConstantsDirty;
  111642. private _alphaBlend;
  111643. private _blendFunctionParameters;
  111644. private _blendEquationParameters;
  111645. private _blendConstants;
  111646. /**
  111647. * Initializes the state.
  111648. */
  111649. constructor();
  111650. get isDirty(): boolean;
  111651. get alphaBlend(): boolean;
  111652. set alphaBlend(value: boolean);
  111653. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  111654. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  111655. setAlphaEquationParameters(rgb: number, alpha: number): void;
  111656. reset(): void;
  111657. apply(gl: WebGLRenderingContext): void;
  111658. }
  111659. }
  111660. declare module BABYLON {
  111661. /** @hidden */
  111662. export class WebGL2ShaderProcessor implements IShaderProcessor {
  111663. attributeProcessor(attribute: string): string;
  111664. varyingProcessor(varying: string, isFragment: boolean): string;
  111665. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111666. }
  111667. }
  111668. declare module BABYLON {
  111669. /**
  111670. * Interface for attribute information associated with buffer instanciation
  111671. */
  111672. export interface InstancingAttributeInfo {
  111673. /**
  111674. * Name of the GLSL attribute
  111675. * if attribute index is not specified, this is used to retrieve the index from the effect
  111676. */
  111677. attributeName: string;
  111678. /**
  111679. * Index/offset of the attribute in the vertex shader
  111680. * if not specified, this will be computes from the name.
  111681. */
  111682. index?: number;
  111683. /**
  111684. * size of the attribute, 1, 2, 3 or 4
  111685. */
  111686. attributeSize: number;
  111687. /**
  111688. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  111689. */
  111690. offset: number;
  111691. /**
  111692. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  111693. * default to 1
  111694. */
  111695. divisor?: number;
  111696. /**
  111697. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  111698. * default is FLOAT
  111699. */
  111700. attributeType?: number;
  111701. /**
  111702. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  111703. */
  111704. normalized?: boolean;
  111705. }
  111706. }
  111707. declare module BABYLON {
  111708. interface ThinEngine {
  111709. /**
  111710. * Update a video texture
  111711. * @param texture defines the texture to update
  111712. * @param video defines the video element to use
  111713. * @param invertY defines if data must be stored with Y axis inverted
  111714. */
  111715. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  111716. }
  111717. }
  111718. declare module BABYLON {
  111719. interface ThinEngine {
  111720. /**
  111721. * Creates a dynamic texture
  111722. * @param width defines the width of the texture
  111723. * @param height defines the height of the texture
  111724. * @param generateMipMaps defines if the engine should generate the mip levels
  111725. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  111726. * @returns the dynamic texture inside an InternalTexture
  111727. */
  111728. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  111729. /**
  111730. * Update the content of a dynamic texture
  111731. * @param texture defines the texture to update
  111732. * @param canvas defines the canvas containing the source
  111733. * @param invertY defines if data must be stored with Y axis inverted
  111734. * @param premulAlpha defines if alpha is stored as premultiplied
  111735. * @param format defines the format of the data
  111736. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  111737. */
  111738. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  111739. }
  111740. }
  111741. declare module BABYLON {
  111742. /**
  111743. * Settings for finer control over video usage
  111744. */
  111745. export interface VideoTextureSettings {
  111746. /**
  111747. * Applies `autoplay` to video, if specified
  111748. */
  111749. autoPlay?: boolean;
  111750. /**
  111751. * Applies `loop` to video, if specified
  111752. */
  111753. loop?: boolean;
  111754. /**
  111755. * Automatically updates internal texture from video at every frame in the render loop
  111756. */
  111757. autoUpdateTexture: boolean;
  111758. /**
  111759. * Image src displayed during the video loading or until the user interacts with the video.
  111760. */
  111761. poster?: string;
  111762. }
  111763. /**
  111764. * If you want to display a video in your scene, this is the special texture for that.
  111765. * This special texture works similar to other textures, with the exception of a few parameters.
  111766. * @see https://doc.babylonjs.com/how_to/video_texture
  111767. */
  111768. export class VideoTexture extends Texture {
  111769. /**
  111770. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  111771. */
  111772. readonly autoUpdateTexture: boolean;
  111773. /**
  111774. * The video instance used by the texture internally
  111775. */
  111776. readonly video: HTMLVideoElement;
  111777. private _onUserActionRequestedObservable;
  111778. /**
  111779. * Event triggerd when a dom action is required by the user to play the video.
  111780. * This happens due to recent changes in browser policies preventing video to auto start.
  111781. */
  111782. get onUserActionRequestedObservable(): Observable<Texture>;
  111783. private _generateMipMaps;
  111784. private _stillImageCaptured;
  111785. private _displayingPosterTexture;
  111786. private _settings;
  111787. private _createInternalTextureOnEvent;
  111788. private _frameId;
  111789. private _currentSrc;
  111790. /**
  111791. * Creates a video texture.
  111792. * If you want to display a video in your scene, this is the special texture for that.
  111793. * This special texture works similar to other textures, with the exception of a few parameters.
  111794. * @see https://doc.babylonjs.com/how_to/video_texture
  111795. * @param name optional name, will detect from video source, if not defined
  111796. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  111797. * @param scene is obviously the current scene.
  111798. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  111799. * @param invertY is false by default but can be used to invert video on Y axis
  111800. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  111801. * @param settings allows finer control over video usage
  111802. */
  111803. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  111804. private _getName;
  111805. private _getVideo;
  111806. private _createInternalTexture;
  111807. private reset;
  111808. /**
  111809. * @hidden Internal method to initiate `update`.
  111810. */
  111811. _rebuild(): void;
  111812. /**
  111813. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  111814. */
  111815. update(): void;
  111816. /**
  111817. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  111818. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  111819. */
  111820. updateTexture(isVisible: boolean): void;
  111821. protected _updateInternalTexture: () => void;
  111822. /**
  111823. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  111824. * @param url New url.
  111825. */
  111826. updateURL(url: string): void;
  111827. /**
  111828. * Clones the texture.
  111829. * @returns the cloned texture
  111830. */
  111831. clone(): VideoTexture;
  111832. /**
  111833. * Dispose the texture and release its associated resources.
  111834. */
  111835. dispose(): void;
  111836. /**
  111837. * Creates a video texture straight from a stream.
  111838. * @param scene Define the scene the texture should be created in
  111839. * @param stream Define the stream the texture should be created from
  111840. * @returns The created video texture as a promise
  111841. */
  111842. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  111843. /**
  111844. * Creates a video texture straight from your WebCam video feed.
  111845. * @param scene Define the scene the texture should be created in
  111846. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111847. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111848. * @returns The created video texture as a promise
  111849. */
  111850. static CreateFromWebCamAsync(scene: Scene, constraints: {
  111851. minWidth: number;
  111852. maxWidth: number;
  111853. minHeight: number;
  111854. maxHeight: number;
  111855. deviceId: string;
  111856. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  111857. /**
  111858. * Creates a video texture straight from your WebCam video feed.
  111859. * @param scene Define the scene the texture should be created in
  111860. * @param onReady Define a callback to triggered once the texture will be ready
  111861. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  111862. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  111863. */
  111864. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  111865. minWidth: number;
  111866. maxWidth: number;
  111867. minHeight: number;
  111868. maxHeight: number;
  111869. deviceId: string;
  111870. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  111871. }
  111872. }
  111873. declare module BABYLON {
  111874. /**
  111875. * Defines the interface used by objects working like Scene
  111876. * @hidden
  111877. */
  111878. export interface ISceneLike {
  111879. _addPendingData(data: any): void;
  111880. _removePendingData(data: any): void;
  111881. offlineProvider: IOfflineProvider;
  111882. }
  111883. /** Interface defining initialization parameters for Engine class */
  111884. export interface EngineOptions extends WebGLContextAttributes {
  111885. /**
  111886. * Defines if the engine should no exceed a specified device ratio
  111887. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  111888. */
  111889. limitDeviceRatio?: number;
  111890. /**
  111891. * Defines if webvr should be enabled automatically
  111892. * @see http://doc.babylonjs.com/how_to/webvr_camera
  111893. */
  111894. autoEnableWebVR?: boolean;
  111895. /**
  111896. * Defines if webgl2 should be turned off even if supported
  111897. * @see http://doc.babylonjs.com/features/webgl2
  111898. */
  111899. disableWebGL2Support?: boolean;
  111900. /**
  111901. * Defines if webaudio should be initialized as well
  111902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111903. */
  111904. audioEngine?: boolean;
  111905. /**
  111906. * Defines if animations should run using a deterministic lock step
  111907. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  111908. */
  111909. deterministicLockstep?: boolean;
  111910. /** Defines the maximum steps to use with deterministic lock step mode */
  111911. lockstepMaxSteps?: number;
  111912. /** Defines the seconds between each deterministic lock step */
  111913. timeStep?: number;
  111914. /**
  111915. * Defines that engine should ignore context lost events
  111916. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  111917. */
  111918. doNotHandleContextLost?: boolean;
  111919. /**
  111920. * Defines that engine should ignore modifying touch action attribute and style
  111921. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  111922. */
  111923. doNotHandleTouchAction?: boolean;
  111924. /**
  111925. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  111926. */
  111927. useHighPrecisionFloats?: boolean;
  111928. /**
  111929. * Make the canvas XR Compatible for XR sessions
  111930. */
  111931. xrCompatible?: boolean;
  111932. }
  111933. /**
  111934. * The base engine class (root of all engines)
  111935. */
  111936. export class ThinEngine {
  111937. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  111938. static ExceptionList: ({
  111939. key: string;
  111940. capture: string;
  111941. captureConstraint: number;
  111942. targets: string[];
  111943. } | {
  111944. key: string;
  111945. capture: null;
  111946. captureConstraint: null;
  111947. targets: string[];
  111948. })[];
  111949. /** @hidden */
  111950. static _TextureLoaders: IInternalTextureLoader[];
  111951. /**
  111952. * Returns the current npm package of the sdk
  111953. */
  111954. static get NpmPackage(): string;
  111955. /**
  111956. * Returns the current version of the framework
  111957. */
  111958. static get Version(): string;
  111959. /**
  111960. * Returns a string describing the current engine
  111961. */
  111962. get description(): string;
  111963. /**
  111964. * Gets or sets the epsilon value used by collision engine
  111965. */
  111966. static CollisionsEpsilon: number;
  111967. /**
  111968. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111969. */
  111970. static get ShadersRepository(): string;
  111971. static set ShadersRepository(value: string);
  111972. /** @hidden */
  111973. _shaderProcessor: IShaderProcessor;
  111974. /**
  111975. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  111976. */
  111977. forcePOTTextures: boolean;
  111978. /**
  111979. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  111980. */
  111981. isFullscreen: boolean;
  111982. /**
  111983. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  111984. */
  111985. cullBackFaces: boolean;
  111986. /**
  111987. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  111988. */
  111989. renderEvenInBackground: boolean;
  111990. /**
  111991. * Gets or sets a boolean indicating that cache can be kept between frames
  111992. */
  111993. preventCacheWipeBetweenFrames: boolean;
  111994. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  111995. validateShaderPrograms: boolean;
  111996. /**
  111997. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  111998. * This can provide greater z depth for distant objects.
  111999. */
  112000. useReverseDepthBuffer: boolean;
  112001. /**
  112002. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112003. */
  112004. disableUniformBuffers: boolean;
  112005. /** @hidden */
  112006. _uniformBuffers: UniformBuffer[];
  112007. /**
  112008. * Gets a boolean indicating that the engine supports uniform buffers
  112009. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112010. */
  112011. get supportsUniformBuffers(): boolean;
  112012. /** @hidden */
  112013. _gl: WebGLRenderingContext;
  112014. /** @hidden */
  112015. _webGLVersion: number;
  112016. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112017. protected _windowIsBackground: boolean;
  112018. protected _creationOptions: EngineOptions;
  112019. protected _highPrecisionShadersAllowed: boolean;
  112020. /** @hidden */
  112021. get _shouldUseHighPrecisionShader(): boolean;
  112022. /**
  112023. * Gets a boolean indicating that only power of 2 textures are supported
  112024. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112025. */
  112026. get needPOTTextures(): boolean;
  112027. /** @hidden */
  112028. _badOS: boolean;
  112029. /** @hidden */
  112030. _badDesktopOS: boolean;
  112031. private _hardwareScalingLevel;
  112032. /** @hidden */
  112033. _caps: EngineCapabilities;
  112034. private _isStencilEnable;
  112035. private _glVersion;
  112036. private _glRenderer;
  112037. private _glVendor;
  112038. /** @hidden */
  112039. _videoTextureSupported: boolean;
  112040. protected _renderingQueueLaunched: boolean;
  112041. protected _activeRenderLoops: (() => void)[];
  112042. /**
  112043. * Observable signaled when a context lost event is raised
  112044. */
  112045. onContextLostObservable: Observable<ThinEngine>;
  112046. /**
  112047. * Observable signaled when a context restored event is raised
  112048. */
  112049. onContextRestoredObservable: Observable<ThinEngine>;
  112050. private _onContextLost;
  112051. private _onContextRestored;
  112052. protected _contextWasLost: boolean;
  112053. /** @hidden */
  112054. _doNotHandleContextLost: boolean;
  112055. /**
  112056. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112057. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112058. */
  112059. get doNotHandleContextLost(): boolean;
  112060. set doNotHandleContextLost(value: boolean);
  112061. /**
  112062. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112063. */
  112064. disableVertexArrayObjects: boolean;
  112065. /** @hidden */
  112066. protected _colorWrite: boolean;
  112067. /** @hidden */
  112068. protected _colorWriteChanged: boolean;
  112069. /** @hidden */
  112070. protected _depthCullingState: DepthCullingState;
  112071. /** @hidden */
  112072. protected _stencilState: StencilState;
  112073. /** @hidden */
  112074. _alphaState: AlphaState;
  112075. /** @hidden */
  112076. _alphaMode: number;
  112077. /** @hidden */
  112078. _alphaEquation: number;
  112079. /** @hidden */
  112080. _internalTexturesCache: InternalTexture[];
  112081. /** @hidden */
  112082. protected _activeChannel: number;
  112083. private _currentTextureChannel;
  112084. /** @hidden */
  112085. protected _boundTexturesCache: {
  112086. [key: string]: Nullable<InternalTexture>;
  112087. };
  112088. /** @hidden */
  112089. protected _currentEffect: Nullable<Effect>;
  112090. /** @hidden */
  112091. protected _currentProgram: Nullable<WebGLProgram>;
  112092. private _compiledEffects;
  112093. private _vertexAttribArraysEnabled;
  112094. /** @hidden */
  112095. protected _cachedViewport: Nullable<IViewportLike>;
  112096. private _cachedVertexArrayObject;
  112097. /** @hidden */
  112098. protected _cachedVertexBuffers: any;
  112099. /** @hidden */
  112100. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112101. /** @hidden */
  112102. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112103. /** @hidden */
  112104. _currentRenderTarget: Nullable<InternalTexture>;
  112105. private _uintIndicesCurrentlySet;
  112106. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112107. /** @hidden */
  112108. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112109. /** @hidden */
  112110. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112111. private _currentBufferPointers;
  112112. private _currentInstanceLocations;
  112113. private _currentInstanceBuffers;
  112114. private _textureUnits;
  112115. /** @hidden */
  112116. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112117. /** @hidden */
  112118. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112119. /** @hidden */
  112120. _boundRenderFunction: any;
  112121. private _vaoRecordInProgress;
  112122. private _mustWipeVertexAttributes;
  112123. private _emptyTexture;
  112124. private _emptyCubeTexture;
  112125. private _emptyTexture3D;
  112126. private _emptyTexture2DArray;
  112127. /** @hidden */
  112128. _frameHandler: number;
  112129. private _nextFreeTextureSlots;
  112130. private _maxSimultaneousTextures;
  112131. private _activeRequests;
  112132. /** @hidden */
  112133. _transformTextureUrl: Nullable<(url: string) => string>;
  112134. protected get _supportsHardwareTextureRescaling(): boolean;
  112135. private _framebufferDimensionsObject;
  112136. /**
  112137. * sets the object from which width and height will be taken from when getting render width and height
  112138. * Will fallback to the gl object
  112139. * @param dimensions the framebuffer width and height that will be used.
  112140. */
  112141. set framebufferDimensionsObject(dimensions: Nullable<{
  112142. framebufferWidth: number;
  112143. framebufferHeight: number;
  112144. }>);
  112145. /**
  112146. * Gets the current viewport
  112147. */
  112148. get currentViewport(): Nullable<IViewportLike>;
  112149. /**
  112150. * Gets the default empty texture
  112151. */
  112152. get emptyTexture(): InternalTexture;
  112153. /**
  112154. * Gets the default empty 3D texture
  112155. */
  112156. get emptyTexture3D(): InternalTexture;
  112157. /**
  112158. * Gets the default empty 2D array texture
  112159. */
  112160. get emptyTexture2DArray(): InternalTexture;
  112161. /**
  112162. * Gets the default empty cube texture
  112163. */
  112164. get emptyCubeTexture(): InternalTexture;
  112165. /**
  112166. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112167. */
  112168. readonly premultipliedAlpha: boolean;
  112169. /**
  112170. * Observable event triggered before each texture is initialized
  112171. */
  112172. onBeforeTextureInitObservable: Observable<Texture>;
  112173. /**
  112174. * Creates a new engine
  112175. * @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
  112176. * @param antialias defines enable antialiasing (default: false)
  112177. * @param options defines further options to be sent to the getContext() function
  112178. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112179. */
  112180. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112181. private _rebuildInternalTextures;
  112182. private _rebuildEffects;
  112183. /**
  112184. * Gets a boolean indicating if all created effects are ready
  112185. * @returns true if all effects are ready
  112186. */
  112187. areAllEffectsReady(): boolean;
  112188. protected _rebuildBuffers(): void;
  112189. protected _initGLContext(): void;
  112190. /**
  112191. * Gets version of the current webGL context
  112192. */
  112193. get webGLVersion(): number;
  112194. /**
  112195. * Gets a string idenfifying the name of the class
  112196. * @returns "Engine" string
  112197. */
  112198. getClassName(): string;
  112199. /**
  112200. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112201. */
  112202. get isStencilEnable(): boolean;
  112203. /** @hidden */
  112204. _prepareWorkingCanvas(): void;
  112205. /**
  112206. * Reset the texture cache to empty state
  112207. */
  112208. resetTextureCache(): void;
  112209. /**
  112210. * Gets an object containing information about the current webGL context
  112211. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112212. */
  112213. getGlInfo(): {
  112214. vendor: string;
  112215. renderer: string;
  112216. version: string;
  112217. };
  112218. /**
  112219. * Defines the hardware scaling level.
  112220. * By default the hardware scaling level is computed from the window device ratio.
  112221. * 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.
  112222. * @param level defines the level to use
  112223. */
  112224. setHardwareScalingLevel(level: number): void;
  112225. /**
  112226. * Gets the current hardware scaling level.
  112227. * By default the hardware scaling level is computed from the window device ratio.
  112228. * 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.
  112229. * @returns a number indicating the current hardware scaling level
  112230. */
  112231. getHardwareScalingLevel(): number;
  112232. /**
  112233. * Gets the list of loaded textures
  112234. * @returns an array containing all loaded textures
  112235. */
  112236. getLoadedTexturesCache(): InternalTexture[];
  112237. /**
  112238. * Gets the object containing all engine capabilities
  112239. * @returns the EngineCapabilities object
  112240. */
  112241. getCaps(): EngineCapabilities;
  112242. /**
  112243. * stop executing a render loop function and remove it from the execution array
  112244. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  112245. */
  112246. stopRenderLoop(renderFunction?: () => void): void;
  112247. /** @hidden */
  112248. _renderLoop(): void;
  112249. /**
  112250. * Gets the HTML canvas attached with the current webGL context
  112251. * @returns a HTML canvas
  112252. */
  112253. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  112254. /**
  112255. * Gets host window
  112256. * @returns the host window object
  112257. */
  112258. getHostWindow(): Nullable<Window>;
  112259. /**
  112260. * Gets the current render width
  112261. * @param useScreen defines if screen size must be used (or the current render target if any)
  112262. * @returns a number defining the current render width
  112263. */
  112264. getRenderWidth(useScreen?: boolean): number;
  112265. /**
  112266. * Gets the current render height
  112267. * @param useScreen defines if screen size must be used (or the current render target if any)
  112268. * @returns a number defining the current render height
  112269. */
  112270. getRenderHeight(useScreen?: boolean): number;
  112271. /**
  112272. * Can be used to override the current requestAnimationFrame requester.
  112273. * @hidden
  112274. */
  112275. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  112276. /**
  112277. * Register and execute a render loop. The engine can have more than one render function
  112278. * @param renderFunction defines the function to continuously execute
  112279. */
  112280. runRenderLoop(renderFunction: () => void): void;
  112281. /**
  112282. * Clear the current render buffer or the current render target (if any is set up)
  112283. * @param color defines the color to use
  112284. * @param backBuffer defines if the back buffer must be cleared
  112285. * @param depth defines if the depth buffer must be cleared
  112286. * @param stencil defines if the stencil buffer must be cleared
  112287. */
  112288. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  112289. private _viewportCached;
  112290. /** @hidden */
  112291. _viewport(x: number, y: number, width: number, height: number): void;
  112292. /**
  112293. * Set the WebGL's viewport
  112294. * @param viewport defines the viewport element to be used
  112295. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  112296. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  112297. */
  112298. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  112299. /**
  112300. * Begin a new frame
  112301. */
  112302. beginFrame(): void;
  112303. /**
  112304. * Enf the current frame
  112305. */
  112306. endFrame(): void;
  112307. /**
  112308. * Resize the view according to the canvas' size
  112309. */
  112310. resize(): void;
  112311. /**
  112312. * Force a specific size of the canvas
  112313. * @param width defines the new canvas' width
  112314. * @param height defines the new canvas' height
  112315. */
  112316. setSize(width: number, height: number): void;
  112317. /**
  112318. * Binds the frame buffer to the specified texture.
  112319. * @param texture The texture to render to or null for the default canvas
  112320. * @param faceIndex The face of the texture to render to in case of cube texture
  112321. * @param requiredWidth The width of the target to render to
  112322. * @param requiredHeight The height of the target to render to
  112323. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  112324. * @param lodLevel defines the lod level to bind to the frame buffer
  112325. * @param layer defines the 2d array index to bind to frame buffer to
  112326. */
  112327. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  112328. /** @hidden */
  112329. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  112330. /**
  112331. * Unbind the current render target texture from the webGL context
  112332. * @param texture defines the render target texture to unbind
  112333. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  112334. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  112335. */
  112336. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  112337. /**
  112338. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  112339. */
  112340. flushFramebuffer(): void;
  112341. /**
  112342. * Unbind the current render target and bind the default framebuffer
  112343. */
  112344. restoreDefaultFramebuffer(): void;
  112345. /** @hidden */
  112346. protected _resetVertexBufferBinding(): void;
  112347. /**
  112348. * Creates a vertex buffer
  112349. * @param data the data for the vertex buffer
  112350. * @returns the new WebGL static buffer
  112351. */
  112352. createVertexBuffer(data: DataArray): DataBuffer;
  112353. private _createVertexBuffer;
  112354. /**
  112355. * Creates a dynamic vertex buffer
  112356. * @param data the data for the dynamic vertex buffer
  112357. * @returns the new WebGL dynamic buffer
  112358. */
  112359. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  112360. protected _resetIndexBufferBinding(): void;
  112361. /**
  112362. * Creates a new index buffer
  112363. * @param indices defines the content of the index buffer
  112364. * @param updatable defines if the index buffer must be updatable
  112365. * @returns a new webGL buffer
  112366. */
  112367. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  112368. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  112369. /**
  112370. * Bind a webGL buffer to the webGL context
  112371. * @param buffer defines the buffer to bind
  112372. */
  112373. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  112374. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  112375. private bindBuffer;
  112376. /**
  112377. * update the bound buffer with the given data
  112378. * @param data defines the data to update
  112379. */
  112380. updateArrayBuffer(data: Float32Array): void;
  112381. private _vertexAttribPointer;
  112382. /** @hidden */
  112383. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  112384. private _bindVertexBuffersAttributes;
  112385. /**
  112386. * Records a vertex array object
  112387. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112388. * @param vertexBuffers defines the list of vertex buffers to store
  112389. * @param indexBuffer defines the index buffer to store
  112390. * @param effect defines the effect to store
  112391. * @returns the new vertex array object
  112392. */
  112393. recordVertexArrayObject(vertexBuffers: {
  112394. [key: string]: VertexBuffer;
  112395. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  112396. /**
  112397. * Bind a specific vertex array object
  112398. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  112399. * @param vertexArrayObject defines the vertex array object to bind
  112400. * @param indexBuffer defines the index buffer to bind
  112401. */
  112402. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  112403. /**
  112404. * Bind webGl buffers directly to the webGL context
  112405. * @param vertexBuffer defines the vertex buffer to bind
  112406. * @param indexBuffer defines the index buffer to bind
  112407. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  112408. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  112409. * @param effect defines the effect associated with the vertex buffer
  112410. */
  112411. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  112412. private _unbindVertexArrayObject;
  112413. /**
  112414. * Bind a list of vertex buffers to the webGL context
  112415. * @param vertexBuffers defines the list of vertex buffers to bind
  112416. * @param indexBuffer defines the index buffer to bind
  112417. * @param effect defines the effect associated with the vertex buffers
  112418. */
  112419. bindBuffers(vertexBuffers: {
  112420. [key: string]: Nullable<VertexBuffer>;
  112421. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  112422. /**
  112423. * Unbind all instance attributes
  112424. */
  112425. unbindInstanceAttributes(): void;
  112426. /**
  112427. * Release and free the memory of a vertex array object
  112428. * @param vao defines the vertex array object to delete
  112429. */
  112430. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  112431. /** @hidden */
  112432. _releaseBuffer(buffer: DataBuffer): boolean;
  112433. protected _deleteBuffer(buffer: DataBuffer): void;
  112434. /**
  112435. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  112436. * @param instancesBuffer defines the webGL buffer to update and bind
  112437. * @param data defines the data to store in the buffer
  112438. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  112439. */
  112440. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  112441. /**
  112442. * Bind the content of a webGL buffer used with instantiation
  112443. * @param instancesBuffer defines the webGL buffer to bind
  112444. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  112445. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  112446. */
  112447. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  112448. /**
  112449. * Disable the instance attribute corresponding to the name in parameter
  112450. * @param name defines the name of the attribute to disable
  112451. */
  112452. disableInstanceAttributeByName(name: string): void;
  112453. /**
  112454. * Disable the instance attribute corresponding to the location in parameter
  112455. * @param attributeLocation defines the attribute location of the attribute to disable
  112456. */
  112457. disableInstanceAttribute(attributeLocation: number): void;
  112458. /**
  112459. * Disable the attribute corresponding to the location in parameter
  112460. * @param attributeLocation defines the attribute location of the attribute to disable
  112461. */
  112462. disableAttributeByIndex(attributeLocation: number): void;
  112463. /**
  112464. * Send a draw order
  112465. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112466. * @param indexStart defines the starting index
  112467. * @param indexCount defines the number of index to draw
  112468. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112469. */
  112470. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  112471. /**
  112472. * Draw a list of points
  112473. * @param verticesStart defines the index of first vertex to draw
  112474. * @param verticesCount defines the count of vertices to draw
  112475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112476. */
  112477. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112478. /**
  112479. * Draw a list of unindexed primitives
  112480. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  112481. * @param verticesStart defines the index of first vertex to draw
  112482. * @param verticesCount defines the count of vertices to draw
  112483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112484. */
  112485. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112486. /**
  112487. * Draw a list of indexed primitives
  112488. * @param fillMode defines the primitive to use
  112489. * @param indexStart defines the starting index
  112490. * @param indexCount defines the number of index to draw
  112491. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112492. */
  112493. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  112494. /**
  112495. * Draw a list of unindexed primitives
  112496. * @param fillMode defines the primitive to use
  112497. * @param verticesStart defines the index of first vertex to draw
  112498. * @param verticesCount defines the count of vertices to draw
  112499. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  112500. */
  112501. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  112502. private _drawMode;
  112503. /** @hidden */
  112504. protected _reportDrawCall(): void;
  112505. /** @hidden */
  112506. _releaseEffect(effect: Effect): void;
  112507. /** @hidden */
  112508. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  112509. /**
  112510. * Create a new effect (used to store vertex/fragment shaders)
  112511. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  112512. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  112513. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  112514. * @param samplers defines an array of string used to represent textures
  112515. * @param defines defines the string containing the defines to use to compile the shaders
  112516. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  112517. * @param onCompiled defines a function to call when the effect creation is successful
  112518. * @param onError defines a function to call when the effect creation has failed
  112519. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  112520. * @returns the new Effect
  112521. */
  112522. 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;
  112523. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  112524. private _compileShader;
  112525. private _compileRawShader;
  112526. /** @hidden */
  112527. _getShaderSource(shader: WebGLShader): Nullable<string>;
  112528. /**
  112529. * Directly creates a webGL program
  112530. * @param pipelineContext defines the pipeline context to attach to
  112531. * @param vertexCode defines the vertex shader code to use
  112532. * @param fragmentCode defines the fragment shader code to use
  112533. * @param context defines the webGL context to use (if not set, the current one will be used)
  112534. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112535. * @returns the new webGL program
  112536. */
  112537. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112538. /**
  112539. * Creates a webGL program
  112540. * @param pipelineContext defines the pipeline context to attach to
  112541. * @param vertexCode defines the vertex shader code to use
  112542. * @param fragmentCode defines the fragment shader code to use
  112543. * @param defines defines the string containing the defines to use to compile the shaders
  112544. * @param context defines the webGL context to use (if not set, the current one will be used)
  112545. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  112546. * @returns the new webGL program
  112547. */
  112548. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112549. /**
  112550. * Creates a new pipeline context
  112551. * @returns the new pipeline
  112552. */
  112553. createPipelineContext(): IPipelineContext;
  112554. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  112555. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  112556. /** @hidden */
  112557. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  112558. /** @hidden */
  112559. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  112560. /** @hidden */
  112561. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  112562. /**
  112563. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  112564. * @param pipelineContext defines the pipeline context to use
  112565. * @param uniformsNames defines the list of uniform names
  112566. * @returns an array of webGL uniform locations
  112567. */
  112568. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  112569. /**
  112570. * Gets the lsit of active attributes for a given webGL program
  112571. * @param pipelineContext defines the pipeline context to use
  112572. * @param attributesNames defines the list of attribute names to get
  112573. * @returns an array of indices indicating the offset of each attribute
  112574. */
  112575. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  112576. /**
  112577. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  112578. * @param effect defines the effect to activate
  112579. */
  112580. enableEffect(effect: Nullable<Effect>): void;
  112581. /**
  112582. * Set the value of an uniform to a number (int)
  112583. * @param uniform defines the webGL uniform location where to store the value
  112584. * @param value defines the int number to store
  112585. */
  112586. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112587. /**
  112588. * Set the value of an uniform to an array of int32
  112589. * @param uniform defines the webGL uniform location where to store the value
  112590. * @param array defines the array of int32 to store
  112591. */
  112592. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112593. /**
  112594. * Set the value of an uniform to an array of int32 (stored as vec2)
  112595. * @param uniform defines the webGL uniform location where to store the value
  112596. * @param array defines the array of int32 to store
  112597. */
  112598. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112599. /**
  112600. * Set the value of an uniform to an array of int32 (stored as vec3)
  112601. * @param uniform defines the webGL uniform location where to store the value
  112602. * @param array defines the array of int32 to store
  112603. */
  112604. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112605. /**
  112606. * Set the value of an uniform to an array of int32 (stored as vec4)
  112607. * @param uniform defines the webGL uniform location where to store the value
  112608. * @param array defines the array of int32 to store
  112609. */
  112610. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  112611. /**
  112612. * Set the value of an uniform to an array of number
  112613. * @param uniform defines the webGL uniform location where to store the value
  112614. * @param array defines the array of number to store
  112615. */
  112616. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112617. /**
  112618. * Set the value of an uniform to an array of number (stored as vec2)
  112619. * @param uniform defines the webGL uniform location where to store the value
  112620. * @param array defines the array of number to store
  112621. */
  112622. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112623. /**
  112624. * Set the value of an uniform to an array of number (stored as vec3)
  112625. * @param uniform defines the webGL uniform location where to store the value
  112626. * @param array defines the array of number to store
  112627. */
  112628. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112629. /**
  112630. * Set the value of an uniform to an array of number (stored as vec4)
  112631. * @param uniform defines the webGL uniform location where to store the value
  112632. * @param array defines the array of number to store
  112633. */
  112634. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  112635. /**
  112636. * Set the value of an uniform to an array of float32 (stored as matrices)
  112637. * @param uniform defines the webGL uniform location where to store the value
  112638. * @param matrices defines the array of float32 to store
  112639. */
  112640. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  112641. /**
  112642. * Set the value of an uniform to a matrix (3x3)
  112643. * @param uniform defines the webGL uniform location where to store the value
  112644. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  112645. */
  112646. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112647. /**
  112648. * Set the value of an uniform to a matrix (2x2)
  112649. * @param uniform defines the webGL uniform location where to store the value
  112650. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  112651. */
  112652. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  112653. /**
  112654. * Set the value of an uniform to a number (float)
  112655. * @param uniform defines the webGL uniform location where to store the value
  112656. * @param value defines the float number to store
  112657. */
  112658. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  112659. /**
  112660. * Set the value of an uniform to a vec2
  112661. * @param uniform defines the webGL uniform location where to store the value
  112662. * @param x defines the 1st component of the value
  112663. * @param y defines the 2nd component of the value
  112664. */
  112665. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  112666. /**
  112667. * Set the value of an uniform to a vec3
  112668. * @param uniform defines the webGL uniform location where to store the value
  112669. * @param x defines the 1st component of the value
  112670. * @param y defines the 2nd component of the value
  112671. * @param z defines the 3rd component of the value
  112672. */
  112673. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  112674. /**
  112675. * Set the value of an uniform to a vec4
  112676. * @param uniform defines the webGL uniform location where to store the value
  112677. * @param x defines the 1st component of the value
  112678. * @param y defines the 2nd component of the value
  112679. * @param z defines the 3rd component of the value
  112680. * @param w defines the 4th component of the value
  112681. */
  112682. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  112683. /**
  112684. * Apply all cached states (depth, culling, stencil and alpha)
  112685. */
  112686. applyStates(): void;
  112687. /**
  112688. * Enable or disable color writing
  112689. * @param enable defines the state to set
  112690. */
  112691. setColorWrite(enable: boolean): void;
  112692. /**
  112693. * Gets a boolean indicating if color writing is enabled
  112694. * @returns the current color writing state
  112695. */
  112696. getColorWrite(): boolean;
  112697. /**
  112698. * Gets the depth culling state manager
  112699. */
  112700. get depthCullingState(): DepthCullingState;
  112701. /**
  112702. * Gets the alpha state manager
  112703. */
  112704. get alphaState(): AlphaState;
  112705. /**
  112706. * Gets the stencil state manager
  112707. */
  112708. get stencilState(): StencilState;
  112709. /**
  112710. * Clears the list of texture accessible through engine.
  112711. * This can help preventing texture load conflict due to name collision.
  112712. */
  112713. clearInternalTexturesCache(): void;
  112714. /**
  112715. * Force the entire cache to be cleared
  112716. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  112717. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  112718. */
  112719. wipeCaches(bruteForce?: boolean): void;
  112720. /** @hidden */
  112721. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  112722. min: number;
  112723. mag: number;
  112724. };
  112725. /** @hidden */
  112726. _createTexture(): WebGLTexture;
  112727. /**
  112728. * Usually called from Texture.ts.
  112729. * Passed information to create a WebGLTexture
  112730. * @param url defines a value which contains one of the following:
  112731. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  112732. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  112733. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  112734. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  112735. * @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)
  112736. * @param scene needed for loading to the correct scene
  112737. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  112738. * @param onLoad optional callback to be called upon successful completion
  112739. * @param onError optional callback to be called upon failure
  112740. * @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
  112741. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  112742. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  112743. * @param forcedExtension defines the extension to use to pick the right loader
  112744. * @param mimeType defines an optional mime type
  112745. * @returns a InternalTexture for assignment back into BABYLON.Texture
  112746. */
  112747. 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;
  112748. /**
  112749. * Loads an image as an HTMLImageElement.
  112750. * @param input url string, ArrayBuffer, or Blob to load
  112751. * @param onLoad callback called when the image successfully loads
  112752. * @param onError callback called when the image fails to load
  112753. * @param offlineProvider offline provider for caching
  112754. * @param mimeType optional mime type
  112755. * @returns the HTMLImageElement of the loaded image
  112756. * @hidden
  112757. */
  112758. 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>;
  112759. /**
  112760. * @hidden
  112761. */
  112762. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  112763. private _unpackFlipYCached;
  112764. /**
  112765. * In case you are sharing the context with other applications, it might
  112766. * be interested to not cache the unpack flip y state to ensure a consistent
  112767. * value would be set.
  112768. */
  112769. enableUnpackFlipYCached: boolean;
  112770. /** @hidden */
  112771. _unpackFlipY(value: boolean): void;
  112772. /** @hidden */
  112773. _getUnpackAlignement(): number;
  112774. private _getTextureTarget;
  112775. /**
  112776. * Update the sampling mode of a given texture
  112777. * @param samplingMode defines the required sampling mode
  112778. * @param texture defines the texture to update
  112779. * @param generateMipMaps defines whether to generate mipmaps for the texture
  112780. */
  112781. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  112782. /**
  112783. * Update the sampling mode of a given texture
  112784. * @param texture defines the texture to update
  112785. * @param wrapU defines the texture wrap mode of the u coordinates
  112786. * @param wrapV defines the texture wrap mode of the v coordinates
  112787. * @param wrapR defines the texture wrap mode of the r coordinates
  112788. */
  112789. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  112790. /** @hidden */
  112791. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  112792. width: number;
  112793. height: number;
  112794. layers?: number;
  112795. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  112796. /** @hidden */
  112797. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112798. /** @hidden */
  112799. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  112800. /**
  112801. * Update a portion of an internal texture
  112802. * @param texture defines the texture to update
  112803. * @param imageData defines the data to store into the texture
  112804. * @param xOffset defines the x coordinates of the update rectangle
  112805. * @param yOffset defines the y coordinates of the update rectangle
  112806. * @param width defines the width of the update rectangle
  112807. * @param height defines the height of the update rectangle
  112808. * @param faceIndex defines the face index if texture is a cube (0 by default)
  112809. * @param lod defines the lod level to update (0 by default)
  112810. */
  112811. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  112812. /** @hidden */
  112813. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  112814. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  112815. private _prepareWebGLTexture;
  112816. /** @hidden */
  112817. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  112818. private _getDepthStencilBuffer;
  112819. /** @hidden */
  112820. _releaseFramebufferObjects(texture: InternalTexture): void;
  112821. /** @hidden */
  112822. _releaseTexture(texture: InternalTexture): void;
  112823. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  112824. protected _setProgram(program: WebGLProgram): void;
  112825. protected _boundUniforms: {
  112826. [key: number]: WebGLUniformLocation;
  112827. };
  112828. /**
  112829. * Binds an effect to the webGL context
  112830. * @param effect defines the effect to bind
  112831. */
  112832. bindSamplers(effect: Effect): void;
  112833. private _activateCurrentTexture;
  112834. /** @hidden */
  112835. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  112836. /** @hidden */
  112837. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  112838. /**
  112839. * Unbind all textures from the webGL context
  112840. */
  112841. unbindAllTextures(): void;
  112842. /**
  112843. * Sets a texture to the according uniform.
  112844. * @param channel The texture channel
  112845. * @param uniform The uniform to set
  112846. * @param texture The texture to apply
  112847. */
  112848. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  112849. private _bindSamplerUniformToChannel;
  112850. private _getTextureWrapMode;
  112851. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  112852. /**
  112853. * Sets an array of texture to the webGL context
  112854. * @param channel defines the channel where the texture array must be set
  112855. * @param uniform defines the associated uniform location
  112856. * @param textures defines the array of textures to bind
  112857. */
  112858. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  112859. /** @hidden */
  112860. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  112861. private _setTextureParameterFloat;
  112862. private _setTextureParameterInteger;
  112863. /**
  112864. * Unbind all vertex attributes from the webGL context
  112865. */
  112866. unbindAllAttributes(): void;
  112867. /**
  112868. * 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
  112869. */
  112870. releaseEffects(): void;
  112871. /**
  112872. * Dispose and release all associated resources
  112873. */
  112874. dispose(): void;
  112875. /**
  112876. * Attach a new callback raised when context lost event is fired
  112877. * @param callback defines the callback to call
  112878. */
  112879. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112880. /**
  112881. * Attach a new callback raised when context restored event is fired
  112882. * @param callback defines the callback to call
  112883. */
  112884. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  112885. /**
  112886. * Get the current error code of the webGL context
  112887. * @returns the error code
  112888. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  112889. */
  112890. getError(): number;
  112891. private _canRenderToFloatFramebuffer;
  112892. private _canRenderToHalfFloatFramebuffer;
  112893. private _canRenderToFramebuffer;
  112894. /** @hidden */
  112895. _getWebGLTextureType(type: number): number;
  112896. /** @hidden */
  112897. _getInternalFormat(format: number): number;
  112898. /** @hidden */
  112899. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  112900. /** @hidden */
  112901. _getRGBAMultiSampleBufferFormat(type: number): number;
  112902. /** @hidden */
  112903. _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;
  112904. /**
  112905. * Loads a file from a url
  112906. * @param url url to load
  112907. * @param onSuccess callback called when the file successfully loads
  112908. * @param onProgress callback called while file is loading (if the server supports this mode)
  112909. * @param offlineProvider defines the offline provider for caching
  112910. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  112911. * @param onError callback called when the file fails to load
  112912. * @returns a file request object
  112913. * @hidden
  112914. */
  112915. 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;
  112916. /**
  112917. * Reads pixels from the current frame buffer. Please note that this function can be slow
  112918. * @param x defines the x coordinate of the rectangle where pixels must be read
  112919. * @param y defines the y coordinate of the rectangle where pixels must be read
  112920. * @param width defines the width of the rectangle where pixels must be read
  112921. * @param height defines the height of the rectangle where pixels must be read
  112922. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  112923. * @returns a Uint8Array containing RGBA colors
  112924. */
  112925. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  112926. private static _isSupported;
  112927. /**
  112928. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  112929. * @returns true if the engine can be created
  112930. * @ignorenaming
  112931. */
  112932. static isSupported(): boolean;
  112933. /**
  112934. * Find the next highest power of two.
  112935. * @param x Number to start search from.
  112936. * @return Next highest power of two.
  112937. */
  112938. static CeilingPOT(x: number): number;
  112939. /**
  112940. * Find the next lowest power of two.
  112941. * @param x Number to start search from.
  112942. * @return Next lowest power of two.
  112943. */
  112944. static FloorPOT(x: number): number;
  112945. /**
  112946. * Find the nearest power of two.
  112947. * @param x Number to start search from.
  112948. * @return Next nearest power of two.
  112949. */
  112950. static NearestPOT(x: number): number;
  112951. /**
  112952. * Get the closest exponent of two
  112953. * @param value defines the value to approximate
  112954. * @param max defines the maximum value to return
  112955. * @param mode defines how to define the closest value
  112956. * @returns closest exponent of two of the given value
  112957. */
  112958. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  112959. /**
  112960. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  112961. * @param func - the function to be called
  112962. * @param requester - the object that will request the next frame. Falls back to window.
  112963. * @returns frame number
  112964. */
  112965. static QueueNewFrame(func: () => void, requester?: any): number;
  112966. /**
  112967. * Gets host document
  112968. * @returns the host document object
  112969. */
  112970. getHostDocument(): Nullable<Document>;
  112971. }
  112972. }
  112973. declare module BABYLON {
  112974. /**
  112975. * Class representing spherical harmonics coefficients to the 3rd degree
  112976. */
  112977. export class SphericalHarmonics {
  112978. /**
  112979. * Defines whether or not the harmonics have been prescaled for rendering.
  112980. */
  112981. preScaled: boolean;
  112982. /**
  112983. * The l0,0 coefficients of the spherical harmonics
  112984. */
  112985. l00: Vector3;
  112986. /**
  112987. * The l1,-1 coefficients of the spherical harmonics
  112988. */
  112989. l1_1: Vector3;
  112990. /**
  112991. * The l1,0 coefficients of the spherical harmonics
  112992. */
  112993. l10: Vector3;
  112994. /**
  112995. * The l1,1 coefficients of the spherical harmonics
  112996. */
  112997. l11: Vector3;
  112998. /**
  112999. * The l2,-2 coefficients of the spherical harmonics
  113000. */
  113001. l2_2: Vector3;
  113002. /**
  113003. * The l2,-1 coefficients of the spherical harmonics
  113004. */
  113005. l2_1: Vector3;
  113006. /**
  113007. * The l2,0 coefficients of the spherical harmonics
  113008. */
  113009. l20: Vector3;
  113010. /**
  113011. * The l2,1 coefficients of the spherical harmonics
  113012. */
  113013. l21: Vector3;
  113014. /**
  113015. * The l2,2 coefficients of the spherical harmonics
  113016. */
  113017. l22: Vector3;
  113018. /**
  113019. * Adds a light to the spherical harmonics
  113020. * @param direction the direction of the light
  113021. * @param color the color of the light
  113022. * @param deltaSolidAngle the delta solid angle of the light
  113023. */
  113024. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113025. /**
  113026. * Scales the spherical harmonics by the given amount
  113027. * @param scale the amount to scale
  113028. */
  113029. scaleInPlace(scale: number): void;
  113030. /**
  113031. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113032. *
  113033. * ```
  113034. * E_lm = A_l * L_lm
  113035. * ```
  113036. *
  113037. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113038. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113039. * the scaling factors are given in equation 9.
  113040. */
  113041. convertIncidentRadianceToIrradiance(): void;
  113042. /**
  113043. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113044. *
  113045. * ```
  113046. * L = (1/pi) * E * rho
  113047. * ```
  113048. *
  113049. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113050. */
  113051. convertIrradianceToLambertianRadiance(): void;
  113052. /**
  113053. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113054. * required operations at run time.
  113055. *
  113056. * This is simply done by scaling back the SH with Ylm constants parameter.
  113057. * The trigonometric part being applied by the shader at run time.
  113058. */
  113059. preScaleForRendering(): void;
  113060. /**
  113061. * Constructs a spherical harmonics from an array.
  113062. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113063. * @returns the spherical harmonics
  113064. */
  113065. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113066. /**
  113067. * Gets the spherical harmonics from polynomial
  113068. * @param polynomial the spherical polynomial
  113069. * @returns the spherical harmonics
  113070. */
  113071. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113072. }
  113073. /**
  113074. * Class representing spherical polynomial coefficients to the 3rd degree
  113075. */
  113076. export class SphericalPolynomial {
  113077. private _harmonics;
  113078. /**
  113079. * The spherical harmonics used to create the polynomials.
  113080. */
  113081. get preScaledHarmonics(): SphericalHarmonics;
  113082. /**
  113083. * The x coefficients of the spherical polynomial
  113084. */
  113085. x: Vector3;
  113086. /**
  113087. * The y coefficients of the spherical polynomial
  113088. */
  113089. y: Vector3;
  113090. /**
  113091. * The z coefficients of the spherical polynomial
  113092. */
  113093. z: Vector3;
  113094. /**
  113095. * The xx coefficients of the spherical polynomial
  113096. */
  113097. xx: Vector3;
  113098. /**
  113099. * The yy coefficients of the spherical polynomial
  113100. */
  113101. yy: Vector3;
  113102. /**
  113103. * The zz coefficients of the spherical polynomial
  113104. */
  113105. zz: Vector3;
  113106. /**
  113107. * The xy coefficients of the spherical polynomial
  113108. */
  113109. xy: Vector3;
  113110. /**
  113111. * The yz coefficients of the spherical polynomial
  113112. */
  113113. yz: Vector3;
  113114. /**
  113115. * The zx coefficients of the spherical polynomial
  113116. */
  113117. zx: Vector3;
  113118. /**
  113119. * Adds an ambient color to the spherical polynomial
  113120. * @param color the color to add
  113121. */
  113122. addAmbient(color: Color3): void;
  113123. /**
  113124. * Scales the spherical polynomial by the given amount
  113125. * @param scale the amount to scale
  113126. */
  113127. scaleInPlace(scale: number): void;
  113128. /**
  113129. * Gets the spherical polynomial from harmonics
  113130. * @param harmonics the spherical harmonics
  113131. * @returns the spherical polynomial
  113132. */
  113133. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113134. /**
  113135. * Constructs a spherical polynomial from an array.
  113136. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113137. * @returns the spherical polynomial
  113138. */
  113139. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113140. }
  113141. }
  113142. declare module BABYLON {
  113143. /**
  113144. * Defines the source of the internal texture
  113145. */
  113146. export enum InternalTextureSource {
  113147. /**
  113148. * The source of the texture data is unknown
  113149. */
  113150. Unknown = 0,
  113151. /**
  113152. * Texture data comes from an URL
  113153. */
  113154. Url = 1,
  113155. /**
  113156. * Texture data is only used for temporary storage
  113157. */
  113158. Temp = 2,
  113159. /**
  113160. * Texture data comes from raw data (ArrayBuffer)
  113161. */
  113162. Raw = 3,
  113163. /**
  113164. * Texture content is dynamic (video or dynamic texture)
  113165. */
  113166. Dynamic = 4,
  113167. /**
  113168. * Texture content is generated by rendering to it
  113169. */
  113170. RenderTarget = 5,
  113171. /**
  113172. * Texture content is part of a multi render target process
  113173. */
  113174. MultiRenderTarget = 6,
  113175. /**
  113176. * Texture data comes from a cube data file
  113177. */
  113178. Cube = 7,
  113179. /**
  113180. * Texture data comes from a raw cube data
  113181. */
  113182. CubeRaw = 8,
  113183. /**
  113184. * Texture data come from a prefiltered cube data file
  113185. */
  113186. CubePrefiltered = 9,
  113187. /**
  113188. * Texture content is raw 3D data
  113189. */
  113190. Raw3D = 10,
  113191. /**
  113192. * Texture content is raw 2D array data
  113193. */
  113194. Raw2DArray = 11,
  113195. /**
  113196. * Texture content is a depth texture
  113197. */
  113198. Depth = 12,
  113199. /**
  113200. * Texture data comes from a raw cube data encoded with RGBD
  113201. */
  113202. CubeRawRGBD = 13
  113203. }
  113204. /**
  113205. * Class used to store data associated with WebGL texture data for the engine
  113206. * This class should not be used directly
  113207. */
  113208. export class InternalTexture {
  113209. /** @hidden */
  113210. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113211. /**
  113212. * Defines if the texture is ready
  113213. */
  113214. isReady: boolean;
  113215. /**
  113216. * Defines if the texture is a cube texture
  113217. */
  113218. isCube: boolean;
  113219. /**
  113220. * Defines if the texture contains 3D data
  113221. */
  113222. is3D: boolean;
  113223. /**
  113224. * Defines if the texture contains 2D array data
  113225. */
  113226. is2DArray: boolean;
  113227. /**
  113228. * Defines if the texture contains multiview data
  113229. */
  113230. isMultiview: boolean;
  113231. /**
  113232. * Gets the URL used to load this texture
  113233. */
  113234. url: string;
  113235. /**
  113236. * Gets the sampling mode of the texture
  113237. */
  113238. samplingMode: number;
  113239. /**
  113240. * Gets a boolean indicating if the texture needs mipmaps generation
  113241. */
  113242. generateMipMaps: boolean;
  113243. /**
  113244. * Gets the number of samples used by the texture (WebGL2+ only)
  113245. */
  113246. samples: number;
  113247. /**
  113248. * Gets the type of the texture (int, float...)
  113249. */
  113250. type: number;
  113251. /**
  113252. * Gets the format of the texture (RGB, RGBA...)
  113253. */
  113254. format: number;
  113255. /**
  113256. * Observable called when the texture is loaded
  113257. */
  113258. onLoadedObservable: Observable<InternalTexture>;
  113259. /**
  113260. * Gets the width of the texture
  113261. */
  113262. width: number;
  113263. /**
  113264. * Gets the height of the texture
  113265. */
  113266. height: number;
  113267. /**
  113268. * Gets the depth of the texture
  113269. */
  113270. depth: number;
  113271. /**
  113272. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  113273. */
  113274. baseWidth: number;
  113275. /**
  113276. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  113277. */
  113278. baseHeight: number;
  113279. /**
  113280. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  113281. */
  113282. baseDepth: number;
  113283. /**
  113284. * Gets a boolean indicating if the texture is inverted on Y axis
  113285. */
  113286. invertY: boolean;
  113287. /** @hidden */
  113288. _invertVScale: boolean;
  113289. /** @hidden */
  113290. _associatedChannel: number;
  113291. /** @hidden */
  113292. _source: InternalTextureSource;
  113293. /** @hidden */
  113294. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  113295. /** @hidden */
  113296. _bufferView: Nullable<ArrayBufferView>;
  113297. /** @hidden */
  113298. _bufferViewArray: Nullable<ArrayBufferView[]>;
  113299. /** @hidden */
  113300. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  113301. /** @hidden */
  113302. _size: number;
  113303. /** @hidden */
  113304. _extension: string;
  113305. /** @hidden */
  113306. _files: Nullable<string[]>;
  113307. /** @hidden */
  113308. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  113309. /** @hidden */
  113310. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  113311. /** @hidden */
  113312. _framebuffer: Nullable<WebGLFramebuffer>;
  113313. /** @hidden */
  113314. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  113315. /** @hidden */
  113316. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  113317. /** @hidden */
  113318. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  113319. /** @hidden */
  113320. _attachments: Nullable<number[]>;
  113321. /** @hidden */
  113322. _cachedCoordinatesMode: Nullable<number>;
  113323. /** @hidden */
  113324. _cachedWrapU: Nullable<number>;
  113325. /** @hidden */
  113326. _cachedWrapV: Nullable<number>;
  113327. /** @hidden */
  113328. _cachedWrapR: Nullable<number>;
  113329. /** @hidden */
  113330. _cachedAnisotropicFilteringLevel: Nullable<number>;
  113331. /** @hidden */
  113332. _isDisabled: boolean;
  113333. /** @hidden */
  113334. _compression: Nullable<string>;
  113335. /** @hidden */
  113336. _generateStencilBuffer: boolean;
  113337. /** @hidden */
  113338. _generateDepthBuffer: boolean;
  113339. /** @hidden */
  113340. _comparisonFunction: number;
  113341. /** @hidden */
  113342. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  113343. /** @hidden */
  113344. _lodGenerationScale: number;
  113345. /** @hidden */
  113346. _lodGenerationOffset: number;
  113347. /** @hidden */
  113348. _depthStencilTexture: Nullable<InternalTexture>;
  113349. /** @hidden */
  113350. _colorTextureArray: Nullable<WebGLTexture>;
  113351. /** @hidden */
  113352. _depthStencilTextureArray: Nullable<WebGLTexture>;
  113353. /** @hidden */
  113354. _lodTextureHigh: Nullable<BaseTexture>;
  113355. /** @hidden */
  113356. _lodTextureMid: Nullable<BaseTexture>;
  113357. /** @hidden */
  113358. _lodTextureLow: Nullable<BaseTexture>;
  113359. /** @hidden */
  113360. _isRGBD: boolean;
  113361. /** @hidden */
  113362. _linearSpecularLOD: boolean;
  113363. /** @hidden */
  113364. _irradianceTexture: Nullable<BaseTexture>;
  113365. /** @hidden */
  113366. _webGLTexture: Nullable<WebGLTexture>;
  113367. /** @hidden */
  113368. _references: number;
  113369. private _engine;
  113370. /**
  113371. * Gets the Engine the texture belongs to.
  113372. * @returns The babylon engine
  113373. */
  113374. getEngine(): ThinEngine;
  113375. /**
  113376. * Gets the data source type of the texture
  113377. */
  113378. get source(): InternalTextureSource;
  113379. /**
  113380. * Creates a new InternalTexture
  113381. * @param engine defines the engine to use
  113382. * @param source defines the type of data that will be used
  113383. * @param delayAllocation if the texture allocation should be delayed (default: false)
  113384. */
  113385. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  113386. /**
  113387. * Increments the number of references (ie. the number of Texture that point to it)
  113388. */
  113389. incrementReferences(): void;
  113390. /**
  113391. * Change the size of the texture (not the size of the content)
  113392. * @param width defines the new width
  113393. * @param height defines the new height
  113394. * @param depth defines the new depth (1 by default)
  113395. */
  113396. updateSize(width: int, height: int, depth?: int): void;
  113397. /** @hidden */
  113398. _rebuild(): void;
  113399. /** @hidden */
  113400. _swapAndDie(target: InternalTexture): void;
  113401. /**
  113402. * Dispose the current allocated resources
  113403. */
  113404. dispose(): void;
  113405. }
  113406. }
  113407. declare module BABYLON {
  113408. /**
  113409. * Class used to work with sound analyzer using fast fourier transform (FFT)
  113410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113411. */
  113412. export class Analyser {
  113413. /**
  113414. * Gets or sets the smoothing
  113415. * @ignorenaming
  113416. */
  113417. SMOOTHING: number;
  113418. /**
  113419. * Gets or sets the FFT table size
  113420. * @ignorenaming
  113421. */
  113422. FFT_SIZE: number;
  113423. /**
  113424. * Gets or sets the bar graph amplitude
  113425. * @ignorenaming
  113426. */
  113427. BARGRAPHAMPLITUDE: number;
  113428. /**
  113429. * Gets or sets the position of the debug canvas
  113430. * @ignorenaming
  113431. */
  113432. DEBUGCANVASPOS: {
  113433. x: number;
  113434. y: number;
  113435. };
  113436. /**
  113437. * Gets or sets the debug canvas size
  113438. * @ignorenaming
  113439. */
  113440. DEBUGCANVASSIZE: {
  113441. width: number;
  113442. height: number;
  113443. };
  113444. private _byteFreqs;
  113445. private _byteTime;
  113446. private _floatFreqs;
  113447. private _webAudioAnalyser;
  113448. private _debugCanvas;
  113449. private _debugCanvasContext;
  113450. private _scene;
  113451. private _registerFunc;
  113452. private _audioEngine;
  113453. /**
  113454. * Creates a new analyser
  113455. * @param scene defines hosting scene
  113456. */
  113457. constructor(scene: Scene);
  113458. /**
  113459. * Get the number of data values you will have to play with for the visualization
  113460. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  113461. * @returns a number
  113462. */
  113463. getFrequencyBinCount(): number;
  113464. /**
  113465. * Gets the current frequency data as a byte array
  113466. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113467. * @returns a Uint8Array
  113468. */
  113469. getByteFrequencyData(): Uint8Array;
  113470. /**
  113471. * Gets the current waveform as a byte array
  113472. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  113473. * @returns a Uint8Array
  113474. */
  113475. getByteTimeDomainData(): Uint8Array;
  113476. /**
  113477. * Gets the current frequency data as a float array
  113478. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  113479. * @returns a Float32Array
  113480. */
  113481. getFloatFrequencyData(): Float32Array;
  113482. /**
  113483. * Renders the debug canvas
  113484. */
  113485. drawDebugCanvas(): void;
  113486. /**
  113487. * Stops rendering the debug canvas and removes it
  113488. */
  113489. stopDebugCanvas(): void;
  113490. /**
  113491. * Connects two audio nodes
  113492. * @param inputAudioNode defines first node to connect
  113493. * @param outputAudioNode defines second node to connect
  113494. */
  113495. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  113496. /**
  113497. * Releases all associated resources
  113498. */
  113499. dispose(): void;
  113500. }
  113501. }
  113502. declare module BABYLON {
  113503. /**
  113504. * This represents an audio engine and it is responsible
  113505. * to play, synchronize and analyse sounds throughout the application.
  113506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113507. */
  113508. export interface IAudioEngine extends IDisposable {
  113509. /**
  113510. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113511. */
  113512. readonly canUseWebAudio: boolean;
  113513. /**
  113514. * Gets the current AudioContext if available.
  113515. */
  113516. readonly audioContext: Nullable<AudioContext>;
  113517. /**
  113518. * The master gain node defines the global audio volume of your audio engine.
  113519. */
  113520. readonly masterGain: GainNode;
  113521. /**
  113522. * Gets whether or not mp3 are supported by your browser.
  113523. */
  113524. readonly isMP3supported: boolean;
  113525. /**
  113526. * Gets whether or not ogg are supported by your browser.
  113527. */
  113528. readonly isOGGsupported: boolean;
  113529. /**
  113530. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113531. * @ignoreNaming
  113532. */
  113533. WarnedWebAudioUnsupported: boolean;
  113534. /**
  113535. * Defines if the audio engine relies on a custom unlocked button.
  113536. * In this case, the embedded button will not be displayed.
  113537. */
  113538. useCustomUnlockedButton: boolean;
  113539. /**
  113540. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  113541. */
  113542. readonly unlocked: boolean;
  113543. /**
  113544. * Event raised when audio has been unlocked on the browser.
  113545. */
  113546. onAudioUnlockedObservable: Observable<AudioEngine>;
  113547. /**
  113548. * Event raised when audio has been locked on the browser.
  113549. */
  113550. onAudioLockedObservable: Observable<AudioEngine>;
  113551. /**
  113552. * Flags the audio engine in Locked state.
  113553. * This happens due to new browser policies preventing audio to autoplay.
  113554. */
  113555. lock(): void;
  113556. /**
  113557. * Unlocks the audio engine once a user action has been done on the dom.
  113558. * This is helpful to resume play once browser policies have been satisfied.
  113559. */
  113560. unlock(): void;
  113561. /**
  113562. * Gets the global volume sets on the master gain.
  113563. * @returns the global volume if set or -1 otherwise
  113564. */
  113565. getGlobalVolume(): number;
  113566. /**
  113567. * Sets the global volume of your experience (sets on the master gain).
  113568. * @param newVolume Defines the new global volume of the application
  113569. */
  113570. setGlobalVolume(newVolume: number): void;
  113571. /**
  113572. * Connect the audio engine to an audio analyser allowing some amazing
  113573. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113575. * @param analyser The analyser to connect to the engine
  113576. */
  113577. connectToAnalyser(analyser: Analyser): void;
  113578. }
  113579. /**
  113580. * This represents the default audio engine used in babylon.
  113581. * It is responsible to play, synchronize and analyse sounds throughout the application.
  113582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  113583. */
  113584. export class AudioEngine implements IAudioEngine {
  113585. private _audioContext;
  113586. private _audioContextInitialized;
  113587. private _muteButton;
  113588. private _hostElement;
  113589. /**
  113590. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  113591. */
  113592. canUseWebAudio: boolean;
  113593. /**
  113594. * The master gain node defines the global audio volume of your audio engine.
  113595. */
  113596. masterGain: GainNode;
  113597. /**
  113598. * Defines if Babylon should emit a warning if WebAudio is not supported.
  113599. * @ignoreNaming
  113600. */
  113601. WarnedWebAudioUnsupported: boolean;
  113602. /**
  113603. * Gets whether or not mp3 are supported by your browser.
  113604. */
  113605. isMP3supported: boolean;
  113606. /**
  113607. * Gets whether or not ogg are supported by your browser.
  113608. */
  113609. isOGGsupported: boolean;
  113610. /**
  113611. * Gets whether audio has been unlocked on the device.
  113612. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  113613. * a user interaction has happened.
  113614. */
  113615. unlocked: boolean;
  113616. /**
  113617. * Defines if the audio engine relies on a custom unlocked button.
  113618. * In this case, the embedded button will not be displayed.
  113619. */
  113620. useCustomUnlockedButton: boolean;
  113621. /**
  113622. * Event raised when audio has been unlocked on the browser.
  113623. */
  113624. onAudioUnlockedObservable: Observable<AudioEngine>;
  113625. /**
  113626. * Event raised when audio has been locked on the browser.
  113627. */
  113628. onAudioLockedObservable: Observable<AudioEngine>;
  113629. /**
  113630. * Gets the current AudioContext if available.
  113631. */
  113632. get audioContext(): Nullable<AudioContext>;
  113633. private _connectedAnalyser;
  113634. /**
  113635. * Instantiates a new audio engine.
  113636. *
  113637. * There should be only one per page as some browsers restrict the number
  113638. * of audio contexts you can create.
  113639. * @param hostElement defines the host element where to display the mute icon if necessary
  113640. */
  113641. constructor(hostElement?: Nullable<HTMLElement>);
  113642. /**
  113643. * Flags the audio engine in Locked state.
  113644. * This happens due to new browser policies preventing audio to autoplay.
  113645. */
  113646. lock(): void;
  113647. /**
  113648. * Unlocks the audio engine once a user action has been done on the dom.
  113649. * This is helpful to resume play once browser policies have been satisfied.
  113650. */
  113651. unlock(): void;
  113652. private _resumeAudioContext;
  113653. private _initializeAudioContext;
  113654. private _tryToRun;
  113655. private _triggerRunningState;
  113656. private _triggerSuspendedState;
  113657. private _displayMuteButton;
  113658. private _moveButtonToTopLeft;
  113659. private _onResize;
  113660. private _hideMuteButton;
  113661. /**
  113662. * Destroy and release the resources associated with the audio ccontext.
  113663. */
  113664. dispose(): void;
  113665. /**
  113666. * Gets the global volume sets on the master gain.
  113667. * @returns the global volume if set or -1 otherwise
  113668. */
  113669. getGlobalVolume(): number;
  113670. /**
  113671. * Sets the global volume of your experience (sets on the master gain).
  113672. * @param newVolume Defines the new global volume of the application
  113673. */
  113674. setGlobalVolume(newVolume: number): void;
  113675. /**
  113676. * Connect the audio engine to an audio analyser allowing some amazing
  113677. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  113678. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  113679. * @param analyser The analyser to connect to the engine
  113680. */
  113681. connectToAnalyser(analyser: Analyser): void;
  113682. }
  113683. }
  113684. declare module BABYLON {
  113685. /**
  113686. * Interface used to present a loading screen while loading a scene
  113687. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113688. */
  113689. export interface ILoadingScreen {
  113690. /**
  113691. * Function called to display the loading screen
  113692. */
  113693. displayLoadingUI: () => void;
  113694. /**
  113695. * Function called to hide the loading screen
  113696. */
  113697. hideLoadingUI: () => void;
  113698. /**
  113699. * Gets or sets the color to use for the background
  113700. */
  113701. loadingUIBackgroundColor: string;
  113702. /**
  113703. * Gets or sets the text to display while loading
  113704. */
  113705. loadingUIText: string;
  113706. }
  113707. /**
  113708. * Class used for the default loading screen
  113709. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  113710. */
  113711. export class DefaultLoadingScreen implements ILoadingScreen {
  113712. private _renderingCanvas;
  113713. private _loadingText;
  113714. private _loadingDivBackgroundColor;
  113715. private _loadingDiv;
  113716. private _loadingTextDiv;
  113717. /** Gets or sets the logo url to use for the default loading screen */
  113718. static DefaultLogoUrl: string;
  113719. /** Gets or sets the spinner url to use for the default loading screen */
  113720. static DefaultSpinnerUrl: string;
  113721. /**
  113722. * Creates a new default loading screen
  113723. * @param _renderingCanvas defines the canvas used to render the scene
  113724. * @param _loadingText defines the default text to display
  113725. * @param _loadingDivBackgroundColor defines the default background color
  113726. */
  113727. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  113728. /**
  113729. * Function called to display the loading screen
  113730. */
  113731. displayLoadingUI(): void;
  113732. /**
  113733. * Function called to hide the loading screen
  113734. */
  113735. hideLoadingUI(): void;
  113736. /**
  113737. * Gets or sets the text to display while loading
  113738. */
  113739. set loadingUIText(text: string);
  113740. get loadingUIText(): string;
  113741. /**
  113742. * Gets or sets the color to use for the background
  113743. */
  113744. get loadingUIBackgroundColor(): string;
  113745. set loadingUIBackgroundColor(color: string);
  113746. private _resizeLoadingUI;
  113747. }
  113748. }
  113749. declare module BABYLON {
  113750. /**
  113751. * Interface for any object that can request an animation frame
  113752. */
  113753. export interface ICustomAnimationFrameRequester {
  113754. /**
  113755. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  113756. */
  113757. renderFunction?: Function;
  113758. /**
  113759. * Called to request the next frame to render to
  113760. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  113761. */
  113762. requestAnimationFrame: Function;
  113763. /**
  113764. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  113765. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  113766. */
  113767. requestID?: number;
  113768. }
  113769. }
  113770. declare module BABYLON {
  113771. /**
  113772. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  113773. */
  113774. export class PerformanceMonitor {
  113775. private _enabled;
  113776. private _rollingFrameTime;
  113777. private _lastFrameTimeMs;
  113778. /**
  113779. * constructor
  113780. * @param frameSampleSize The number of samples required to saturate the sliding window
  113781. */
  113782. constructor(frameSampleSize?: number);
  113783. /**
  113784. * Samples current frame
  113785. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  113786. */
  113787. sampleFrame(timeMs?: number): void;
  113788. /**
  113789. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113790. */
  113791. get averageFrameTime(): number;
  113792. /**
  113793. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  113794. */
  113795. get averageFrameTimeVariance(): number;
  113796. /**
  113797. * Returns the frame time of the most recent frame
  113798. */
  113799. get instantaneousFrameTime(): number;
  113800. /**
  113801. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  113802. */
  113803. get averageFPS(): number;
  113804. /**
  113805. * Returns the average framerate in frames per second using the most recent frame time
  113806. */
  113807. get instantaneousFPS(): number;
  113808. /**
  113809. * Returns true if enough samples have been taken to completely fill the sliding window
  113810. */
  113811. get isSaturated(): boolean;
  113812. /**
  113813. * Enables contributions to the sliding window sample set
  113814. */
  113815. enable(): void;
  113816. /**
  113817. * Disables contributions to the sliding window sample set
  113818. * Samples will not be interpolated over the disabled period
  113819. */
  113820. disable(): void;
  113821. /**
  113822. * Returns true if sampling is enabled
  113823. */
  113824. get isEnabled(): boolean;
  113825. /**
  113826. * Resets performance monitor
  113827. */
  113828. reset(): void;
  113829. }
  113830. /**
  113831. * RollingAverage
  113832. *
  113833. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  113834. */
  113835. export class RollingAverage {
  113836. /**
  113837. * Current average
  113838. */
  113839. average: number;
  113840. /**
  113841. * Current variance
  113842. */
  113843. variance: number;
  113844. protected _samples: Array<number>;
  113845. protected _sampleCount: number;
  113846. protected _pos: number;
  113847. protected _m2: number;
  113848. /**
  113849. * constructor
  113850. * @param length The number of samples required to saturate the sliding window
  113851. */
  113852. constructor(length: number);
  113853. /**
  113854. * Adds a sample to the sample set
  113855. * @param v The sample value
  113856. */
  113857. add(v: number): void;
  113858. /**
  113859. * Returns previously added values or null if outside of history or outside the sliding window domain
  113860. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  113861. * @return Value previously recorded with add() or null if outside of range
  113862. */
  113863. history(i: number): number;
  113864. /**
  113865. * Returns true if enough samples have been taken to completely fill the sliding window
  113866. * @return true if sample-set saturated
  113867. */
  113868. isSaturated(): boolean;
  113869. /**
  113870. * Resets the rolling average (equivalent to 0 samples taken so far)
  113871. */
  113872. reset(): void;
  113873. /**
  113874. * Wraps a value around the sample range boundaries
  113875. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  113876. * @return Wrapped position in sample range
  113877. */
  113878. protected _wrapPosition(i: number): number;
  113879. }
  113880. }
  113881. declare module BABYLON {
  113882. /**
  113883. * This class is used to track a performance counter which is number based.
  113884. * The user has access to many properties which give statistics of different nature.
  113885. *
  113886. * The implementer can track two kinds of Performance Counter: time and count.
  113887. * 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.
  113888. * 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.
  113889. */
  113890. export class PerfCounter {
  113891. /**
  113892. * Gets or sets a global boolean to turn on and off all the counters
  113893. */
  113894. static Enabled: boolean;
  113895. /**
  113896. * Returns the smallest value ever
  113897. */
  113898. get min(): number;
  113899. /**
  113900. * Returns the biggest value ever
  113901. */
  113902. get max(): number;
  113903. /**
  113904. * Returns the average value since the performance counter is running
  113905. */
  113906. get average(): number;
  113907. /**
  113908. * Returns the average value of the last second the counter was monitored
  113909. */
  113910. get lastSecAverage(): number;
  113911. /**
  113912. * Returns the current value
  113913. */
  113914. get current(): number;
  113915. /**
  113916. * Gets the accumulated total
  113917. */
  113918. get total(): number;
  113919. /**
  113920. * Gets the total value count
  113921. */
  113922. get count(): number;
  113923. /**
  113924. * Creates a new counter
  113925. */
  113926. constructor();
  113927. /**
  113928. * Call this method to start monitoring a new frame.
  113929. * 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.
  113930. */
  113931. fetchNewFrame(): void;
  113932. /**
  113933. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  113934. * @param newCount the count value to add to the monitored count
  113935. * @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.
  113936. */
  113937. addCount(newCount: number, fetchResult: boolean): void;
  113938. /**
  113939. * Start monitoring this performance counter
  113940. */
  113941. beginMonitoring(): void;
  113942. /**
  113943. * Compute the time lapsed since the previous beginMonitoring() call.
  113944. * @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
  113945. */
  113946. endMonitoring(newFrame?: boolean): void;
  113947. private _fetchResult;
  113948. private _startMonitoringTime;
  113949. private _min;
  113950. private _max;
  113951. private _average;
  113952. private _current;
  113953. private _totalValueCount;
  113954. private _totalAccumulated;
  113955. private _lastSecAverage;
  113956. private _lastSecAccumulated;
  113957. private _lastSecTime;
  113958. private _lastSecValueCount;
  113959. }
  113960. }
  113961. declare module BABYLON {
  113962. interface ThinEngine {
  113963. /**
  113964. * Sets alpha constants used by some alpha blending modes
  113965. * @param r defines the red component
  113966. * @param g defines the green component
  113967. * @param b defines the blue component
  113968. * @param a defines the alpha component
  113969. */
  113970. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  113971. /**
  113972. * Sets the current alpha mode
  113973. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  113974. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  113975. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113976. */
  113977. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  113978. /**
  113979. * Gets the current alpha mode
  113980. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  113981. * @returns the current alpha mode
  113982. */
  113983. getAlphaMode(): number;
  113984. /**
  113985. * Sets the current alpha equation
  113986. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  113987. */
  113988. setAlphaEquation(equation: number): void;
  113989. /**
  113990. * Gets the current alpha equation.
  113991. * @returns the current alpha equation
  113992. */
  113993. getAlphaEquation(): number;
  113994. }
  113995. }
  113996. declare module BABYLON {
  113997. interface ThinEngine {
  113998. /** @hidden */
  113999. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114000. }
  114001. }
  114002. declare module BABYLON {
  114003. /**
  114004. * Defines the interface used by display changed events
  114005. */
  114006. export interface IDisplayChangedEventArgs {
  114007. /** Gets the vrDisplay object (if any) */
  114008. vrDisplay: Nullable<any>;
  114009. /** Gets a boolean indicating if webVR is supported */
  114010. vrSupported: boolean;
  114011. }
  114012. /**
  114013. * Defines the interface used by objects containing a viewport (like a camera)
  114014. */
  114015. interface IViewportOwnerLike {
  114016. /**
  114017. * Gets or sets the viewport
  114018. */
  114019. viewport: IViewportLike;
  114020. }
  114021. /**
  114022. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114023. */
  114024. export class Engine extends ThinEngine {
  114025. /** Defines that alpha blending is disabled */
  114026. static readonly ALPHA_DISABLE: number;
  114027. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114028. static readonly ALPHA_ADD: number;
  114029. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114030. static readonly ALPHA_COMBINE: number;
  114031. /** Defines that alpha blending to DEST - SRC * DEST */
  114032. static readonly ALPHA_SUBTRACT: number;
  114033. /** Defines that alpha blending to SRC * DEST */
  114034. static readonly ALPHA_MULTIPLY: number;
  114035. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114036. static readonly ALPHA_MAXIMIZED: number;
  114037. /** Defines that alpha blending to SRC + DEST */
  114038. static readonly ALPHA_ONEONE: number;
  114039. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114040. static readonly ALPHA_PREMULTIPLIED: number;
  114041. /**
  114042. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114043. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114044. */
  114045. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114046. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114047. static readonly ALPHA_INTERPOLATE: number;
  114048. /**
  114049. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114050. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114051. */
  114052. static readonly ALPHA_SCREENMODE: number;
  114053. /** Defines that the ressource is not delayed*/
  114054. static readonly DELAYLOADSTATE_NONE: number;
  114055. /** Defines that the ressource was successfully delay loaded */
  114056. static readonly DELAYLOADSTATE_LOADED: number;
  114057. /** Defines that the ressource is currently delay loading */
  114058. static readonly DELAYLOADSTATE_LOADING: number;
  114059. /** Defines that the ressource is delayed and has not started loading */
  114060. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114061. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114062. static readonly NEVER: number;
  114063. /** 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 */
  114064. static readonly ALWAYS: number;
  114065. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114066. static readonly LESS: number;
  114067. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114068. static readonly EQUAL: number;
  114069. /** 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 */
  114070. static readonly LEQUAL: number;
  114071. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114072. static readonly GREATER: number;
  114073. /** 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 */
  114074. static readonly GEQUAL: number;
  114075. /** 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 */
  114076. static readonly NOTEQUAL: number;
  114077. /** Passed to stencilOperation to specify that stencil value must be kept */
  114078. static readonly KEEP: number;
  114079. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114080. static readonly REPLACE: number;
  114081. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114082. static readonly INCR: number;
  114083. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114084. static readonly DECR: number;
  114085. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114086. static readonly INVERT: number;
  114087. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114088. static readonly INCR_WRAP: number;
  114089. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114090. static readonly DECR_WRAP: number;
  114091. /** Texture is not repeating outside of 0..1 UVs */
  114092. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114093. /** Texture is repeating outside of 0..1 UVs */
  114094. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114095. /** Texture is repeating and mirrored */
  114096. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114097. /** ALPHA */
  114098. static readonly TEXTUREFORMAT_ALPHA: number;
  114099. /** LUMINANCE */
  114100. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114101. /** LUMINANCE_ALPHA */
  114102. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114103. /** RGB */
  114104. static readonly TEXTUREFORMAT_RGB: number;
  114105. /** RGBA */
  114106. static readonly TEXTUREFORMAT_RGBA: number;
  114107. /** RED */
  114108. static readonly TEXTUREFORMAT_RED: number;
  114109. /** RED (2nd reference) */
  114110. static readonly TEXTUREFORMAT_R: number;
  114111. /** RG */
  114112. static readonly TEXTUREFORMAT_RG: number;
  114113. /** RED_INTEGER */
  114114. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114115. /** RED_INTEGER (2nd reference) */
  114116. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114117. /** RG_INTEGER */
  114118. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114119. /** RGB_INTEGER */
  114120. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114121. /** RGBA_INTEGER */
  114122. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114123. /** UNSIGNED_BYTE */
  114124. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114125. /** UNSIGNED_BYTE (2nd reference) */
  114126. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114127. /** FLOAT */
  114128. static readonly TEXTURETYPE_FLOAT: number;
  114129. /** HALF_FLOAT */
  114130. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114131. /** BYTE */
  114132. static readonly TEXTURETYPE_BYTE: number;
  114133. /** SHORT */
  114134. static readonly TEXTURETYPE_SHORT: number;
  114135. /** UNSIGNED_SHORT */
  114136. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114137. /** INT */
  114138. static readonly TEXTURETYPE_INT: number;
  114139. /** UNSIGNED_INT */
  114140. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114141. /** UNSIGNED_SHORT_4_4_4_4 */
  114142. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114143. /** UNSIGNED_SHORT_5_5_5_1 */
  114144. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114145. /** UNSIGNED_SHORT_5_6_5 */
  114146. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114147. /** UNSIGNED_INT_2_10_10_10_REV */
  114148. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114149. /** UNSIGNED_INT_24_8 */
  114150. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114151. /** UNSIGNED_INT_10F_11F_11F_REV */
  114152. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114153. /** UNSIGNED_INT_5_9_9_9_REV */
  114154. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114155. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114156. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114157. /** nearest is mag = nearest and min = nearest and mip = linear */
  114158. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114159. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114160. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114161. /** Trilinear is mag = linear and min = linear and mip = linear */
  114162. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114163. /** nearest is mag = nearest and min = nearest and mip = linear */
  114164. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114165. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114166. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114167. /** Trilinear is mag = linear and min = linear and mip = linear */
  114168. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114169. /** mag = nearest and min = nearest and mip = nearest */
  114170. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114171. /** mag = nearest and min = linear and mip = nearest */
  114172. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114173. /** mag = nearest and min = linear and mip = linear */
  114174. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114175. /** mag = nearest and min = linear and mip = none */
  114176. static readonly TEXTURE_NEAREST_LINEAR: number;
  114177. /** mag = nearest and min = nearest and mip = none */
  114178. static readonly TEXTURE_NEAREST_NEAREST: number;
  114179. /** mag = linear and min = nearest and mip = nearest */
  114180. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114181. /** mag = linear and min = nearest and mip = linear */
  114182. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114183. /** mag = linear and min = linear and mip = none */
  114184. static readonly TEXTURE_LINEAR_LINEAR: number;
  114185. /** mag = linear and min = nearest and mip = none */
  114186. static readonly TEXTURE_LINEAR_NEAREST: number;
  114187. /** Explicit coordinates mode */
  114188. static readonly TEXTURE_EXPLICIT_MODE: number;
  114189. /** Spherical coordinates mode */
  114190. static readonly TEXTURE_SPHERICAL_MODE: number;
  114191. /** Planar coordinates mode */
  114192. static readonly TEXTURE_PLANAR_MODE: number;
  114193. /** Cubic coordinates mode */
  114194. static readonly TEXTURE_CUBIC_MODE: number;
  114195. /** Projection coordinates mode */
  114196. static readonly TEXTURE_PROJECTION_MODE: number;
  114197. /** Skybox coordinates mode */
  114198. static readonly TEXTURE_SKYBOX_MODE: number;
  114199. /** Inverse Cubic coordinates mode */
  114200. static readonly TEXTURE_INVCUBIC_MODE: number;
  114201. /** Equirectangular coordinates mode */
  114202. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114203. /** Equirectangular Fixed coordinates mode */
  114204. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114205. /** Equirectangular Fixed Mirrored coordinates mode */
  114206. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114207. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114208. static readonly SCALEMODE_FLOOR: number;
  114209. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114210. static readonly SCALEMODE_NEAREST: number;
  114211. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114212. static readonly SCALEMODE_CEILING: number;
  114213. /**
  114214. * Returns the current npm package of the sdk
  114215. */
  114216. static get NpmPackage(): string;
  114217. /**
  114218. * Returns the current version of the framework
  114219. */
  114220. static get Version(): string;
  114221. /** Gets the list of created engines */
  114222. static get Instances(): Engine[];
  114223. /**
  114224. * Gets the latest created engine
  114225. */
  114226. static get LastCreatedEngine(): Nullable<Engine>;
  114227. /**
  114228. * Gets the latest created scene
  114229. */
  114230. static get LastCreatedScene(): Nullable<Scene>;
  114231. /**
  114232. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  114233. * @param flag defines which part of the materials must be marked as dirty
  114234. * @param predicate defines a predicate used to filter which materials should be affected
  114235. */
  114236. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  114237. /**
  114238. * Method called to create the default loading screen.
  114239. * This can be overriden in your own app.
  114240. * @param canvas The rendering canvas element
  114241. * @returns The loading screen
  114242. */
  114243. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  114244. /**
  114245. * Method called to create the default rescale post process on each engine.
  114246. */
  114247. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  114248. /**
  114249. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  114250. **/
  114251. enableOfflineSupport: boolean;
  114252. /**
  114253. * 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)
  114254. **/
  114255. disableManifestCheck: boolean;
  114256. /**
  114257. * Gets the list of created scenes
  114258. */
  114259. scenes: Scene[];
  114260. /**
  114261. * Event raised when a new scene is created
  114262. */
  114263. onNewSceneAddedObservable: Observable<Scene>;
  114264. /**
  114265. * Gets the list of created postprocesses
  114266. */
  114267. postProcesses: PostProcess[];
  114268. /**
  114269. * Gets a boolean indicating if the pointer is currently locked
  114270. */
  114271. isPointerLock: boolean;
  114272. /**
  114273. * Observable event triggered each time the rendering canvas is resized
  114274. */
  114275. onResizeObservable: Observable<Engine>;
  114276. /**
  114277. * Observable event triggered each time the canvas loses focus
  114278. */
  114279. onCanvasBlurObservable: Observable<Engine>;
  114280. /**
  114281. * Observable event triggered each time the canvas gains focus
  114282. */
  114283. onCanvasFocusObservable: Observable<Engine>;
  114284. /**
  114285. * Observable event triggered each time the canvas receives pointerout event
  114286. */
  114287. onCanvasPointerOutObservable: Observable<PointerEvent>;
  114288. /**
  114289. * Observable raised when the engine begins a new frame
  114290. */
  114291. onBeginFrameObservable: Observable<Engine>;
  114292. /**
  114293. * If set, will be used to request the next animation frame for the render loop
  114294. */
  114295. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  114296. /**
  114297. * Observable raised when the engine ends the current frame
  114298. */
  114299. onEndFrameObservable: Observable<Engine>;
  114300. /**
  114301. * Observable raised when the engine is about to compile a shader
  114302. */
  114303. onBeforeShaderCompilationObservable: Observable<Engine>;
  114304. /**
  114305. * Observable raised when the engine has jsut compiled a shader
  114306. */
  114307. onAfterShaderCompilationObservable: Observable<Engine>;
  114308. /**
  114309. * Gets the audio engine
  114310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  114311. * @ignorenaming
  114312. */
  114313. static audioEngine: IAudioEngine;
  114314. /**
  114315. * Default AudioEngine factory responsible of creating the Audio Engine.
  114316. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  114317. */
  114318. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  114319. /**
  114320. * Default offline support factory responsible of creating a tool used to store data locally.
  114321. * By default, this will create a Database object if the workload has been embedded.
  114322. */
  114323. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  114324. private _loadingScreen;
  114325. private _pointerLockRequested;
  114326. private _rescalePostProcess;
  114327. private _deterministicLockstep;
  114328. private _lockstepMaxSteps;
  114329. private _timeStep;
  114330. protected get _supportsHardwareTextureRescaling(): boolean;
  114331. private _fps;
  114332. private _deltaTime;
  114333. /** @hidden */
  114334. _drawCalls: PerfCounter;
  114335. /** 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 */
  114336. canvasTabIndex: number;
  114337. /**
  114338. * Turn this value on if you want to pause FPS computation when in background
  114339. */
  114340. disablePerformanceMonitorInBackground: boolean;
  114341. private _performanceMonitor;
  114342. /**
  114343. * Gets the performance monitor attached to this engine
  114344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114345. */
  114346. get performanceMonitor(): PerformanceMonitor;
  114347. private _onFocus;
  114348. private _onBlur;
  114349. private _onCanvasPointerOut;
  114350. private _onCanvasBlur;
  114351. private _onCanvasFocus;
  114352. private _onFullscreenChange;
  114353. private _onPointerLockChange;
  114354. /**
  114355. * Gets the HTML element used to attach event listeners
  114356. * @returns a HTML element
  114357. */
  114358. getInputElement(): Nullable<HTMLElement>;
  114359. /**
  114360. * Creates a new engine
  114361. * @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
  114362. * @param antialias defines enable antialiasing (default: false)
  114363. * @param options defines further options to be sent to the getContext() function
  114364. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  114365. */
  114366. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  114367. /**
  114368. * Gets current aspect ratio
  114369. * @param viewportOwner defines the camera to use to get the aspect ratio
  114370. * @param useScreen defines if screen size must be used (or the current render target if any)
  114371. * @returns a number defining the aspect ratio
  114372. */
  114373. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  114374. /**
  114375. * Gets current screen aspect ratio
  114376. * @returns a number defining the aspect ratio
  114377. */
  114378. getScreenAspectRatio(): number;
  114379. /**
  114380. * Gets the client rect of the HTML canvas attached with the current webGL context
  114381. * @returns a client rectanglee
  114382. */
  114383. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  114384. /**
  114385. * Gets the client rect of the HTML element used for events
  114386. * @returns a client rectanglee
  114387. */
  114388. getInputElementClientRect(): Nullable<ClientRect>;
  114389. /**
  114390. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  114391. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114392. * @returns true if engine is in deterministic lock step mode
  114393. */
  114394. isDeterministicLockStep(): boolean;
  114395. /**
  114396. * Gets the max steps when engine is running in deterministic lock step
  114397. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  114398. * @returns the max steps
  114399. */
  114400. getLockstepMaxSteps(): number;
  114401. /**
  114402. * Returns the time in ms between steps when using deterministic lock step.
  114403. * @returns time step in (ms)
  114404. */
  114405. getTimeStep(): number;
  114406. /**
  114407. * Force the mipmap generation for the given render target texture
  114408. * @param texture defines the render target texture to use
  114409. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  114410. */
  114411. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  114412. /** States */
  114413. /**
  114414. * Set various states to the webGL context
  114415. * @param culling defines backface culling state
  114416. * @param zOffset defines the value to apply to zOffset (0 by default)
  114417. * @param force defines if states must be applied even if cache is up to date
  114418. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  114419. */
  114420. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  114421. /**
  114422. * Set the z offset to apply to current rendering
  114423. * @param value defines the offset to apply
  114424. */
  114425. setZOffset(value: number): void;
  114426. /**
  114427. * Gets the current value of the zOffset
  114428. * @returns the current zOffset state
  114429. */
  114430. getZOffset(): number;
  114431. /**
  114432. * Enable or disable depth buffering
  114433. * @param enable defines the state to set
  114434. */
  114435. setDepthBuffer(enable: boolean): void;
  114436. /**
  114437. * Gets a boolean indicating if depth writing is enabled
  114438. * @returns the current depth writing state
  114439. */
  114440. getDepthWrite(): boolean;
  114441. /**
  114442. * Enable or disable depth writing
  114443. * @param enable defines the state to set
  114444. */
  114445. setDepthWrite(enable: boolean): void;
  114446. /**
  114447. * Gets a boolean indicating if stencil buffer is enabled
  114448. * @returns the current stencil buffer state
  114449. */
  114450. getStencilBuffer(): boolean;
  114451. /**
  114452. * Enable or disable the stencil buffer
  114453. * @param enable defines if the stencil buffer must be enabled or disabled
  114454. */
  114455. setStencilBuffer(enable: boolean): void;
  114456. /**
  114457. * Gets the current stencil mask
  114458. * @returns a number defining the new stencil mask to use
  114459. */
  114460. getStencilMask(): number;
  114461. /**
  114462. * Sets the current stencil mask
  114463. * @param mask defines the new stencil mask to use
  114464. */
  114465. setStencilMask(mask: number): void;
  114466. /**
  114467. * Gets the current stencil function
  114468. * @returns a number defining the stencil function to use
  114469. */
  114470. getStencilFunction(): number;
  114471. /**
  114472. * Gets the current stencil reference value
  114473. * @returns a number defining the stencil reference value to use
  114474. */
  114475. getStencilFunctionReference(): number;
  114476. /**
  114477. * Gets the current stencil mask
  114478. * @returns a number defining the stencil mask to use
  114479. */
  114480. getStencilFunctionMask(): number;
  114481. /**
  114482. * Sets the current stencil function
  114483. * @param stencilFunc defines the new stencil function to use
  114484. */
  114485. setStencilFunction(stencilFunc: number): void;
  114486. /**
  114487. * Sets the current stencil reference
  114488. * @param reference defines the new stencil reference to use
  114489. */
  114490. setStencilFunctionReference(reference: number): void;
  114491. /**
  114492. * Sets the current stencil mask
  114493. * @param mask defines the new stencil mask to use
  114494. */
  114495. setStencilFunctionMask(mask: number): void;
  114496. /**
  114497. * Gets the current stencil operation when stencil fails
  114498. * @returns a number defining stencil operation to use when stencil fails
  114499. */
  114500. getStencilOperationFail(): number;
  114501. /**
  114502. * Gets the current stencil operation when depth fails
  114503. * @returns a number defining stencil operation to use when depth fails
  114504. */
  114505. getStencilOperationDepthFail(): number;
  114506. /**
  114507. * Gets the current stencil operation when stencil passes
  114508. * @returns a number defining stencil operation to use when stencil passes
  114509. */
  114510. getStencilOperationPass(): number;
  114511. /**
  114512. * Sets the stencil operation to use when stencil fails
  114513. * @param operation defines the stencil operation to use when stencil fails
  114514. */
  114515. setStencilOperationFail(operation: number): void;
  114516. /**
  114517. * Sets the stencil operation to use when depth fails
  114518. * @param operation defines the stencil operation to use when depth fails
  114519. */
  114520. setStencilOperationDepthFail(operation: number): void;
  114521. /**
  114522. * Sets the stencil operation to use when stencil passes
  114523. * @param operation defines the stencil operation to use when stencil passes
  114524. */
  114525. setStencilOperationPass(operation: number): void;
  114526. /**
  114527. * Sets a boolean indicating if the dithering state is enabled or disabled
  114528. * @param value defines the dithering state
  114529. */
  114530. setDitheringState(value: boolean): void;
  114531. /**
  114532. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  114533. * @param value defines the rasterizer state
  114534. */
  114535. setRasterizerState(value: boolean): void;
  114536. /**
  114537. * Gets the current depth function
  114538. * @returns a number defining the depth function
  114539. */
  114540. getDepthFunction(): Nullable<number>;
  114541. /**
  114542. * Sets the current depth function
  114543. * @param depthFunc defines the function to use
  114544. */
  114545. setDepthFunction(depthFunc: number): void;
  114546. /**
  114547. * Sets the current depth function to GREATER
  114548. */
  114549. setDepthFunctionToGreater(): void;
  114550. /**
  114551. * Sets the current depth function to GEQUAL
  114552. */
  114553. setDepthFunctionToGreaterOrEqual(): void;
  114554. /**
  114555. * Sets the current depth function to LESS
  114556. */
  114557. setDepthFunctionToLess(): void;
  114558. /**
  114559. * Sets the current depth function to LEQUAL
  114560. */
  114561. setDepthFunctionToLessOrEqual(): void;
  114562. private _cachedStencilBuffer;
  114563. private _cachedStencilFunction;
  114564. private _cachedStencilMask;
  114565. private _cachedStencilOperationPass;
  114566. private _cachedStencilOperationFail;
  114567. private _cachedStencilOperationDepthFail;
  114568. private _cachedStencilReference;
  114569. /**
  114570. * Caches the the state of the stencil buffer
  114571. */
  114572. cacheStencilState(): void;
  114573. /**
  114574. * Restores the state of the stencil buffer
  114575. */
  114576. restoreStencilState(): void;
  114577. /**
  114578. * Directly set the WebGL Viewport
  114579. * @param x defines the x coordinate of the viewport (in screen space)
  114580. * @param y defines the y coordinate of the viewport (in screen space)
  114581. * @param width defines the width of the viewport (in screen space)
  114582. * @param height defines the height of the viewport (in screen space)
  114583. * @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
  114584. */
  114585. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  114586. /**
  114587. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  114588. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114589. * @param y defines the y-coordinate of the corner of the clear rectangle
  114590. * @param width defines the width of the clear rectangle
  114591. * @param height defines the height of the clear rectangle
  114592. * @param clearColor defines the clear color
  114593. */
  114594. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  114595. /**
  114596. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  114597. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  114598. * @param y defines the y-coordinate of the corner of the clear rectangle
  114599. * @param width defines the width of the clear rectangle
  114600. * @param height defines the height of the clear rectangle
  114601. */
  114602. enableScissor(x: number, y: number, width: number, height: number): void;
  114603. /**
  114604. * Disable previously set scissor test rectangle
  114605. */
  114606. disableScissor(): void;
  114607. protected _reportDrawCall(): void;
  114608. /**
  114609. * Initializes a webVR display and starts listening to display change events
  114610. * The onVRDisplayChangedObservable will be notified upon these changes
  114611. * @returns The onVRDisplayChangedObservable
  114612. */
  114613. initWebVR(): Observable<IDisplayChangedEventArgs>;
  114614. /** @hidden */
  114615. _prepareVRComponent(): void;
  114616. /** @hidden */
  114617. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  114618. /** @hidden */
  114619. _submitVRFrame(): void;
  114620. /**
  114621. * Call this function to leave webVR mode
  114622. * Will do nothing if webVR is not supported or if there is no webVR device
  114623. * @see http://doc.babylonjs.com/how_to/webvr_camera
  114624. */
  114625. disableVR(): void;
  114626. /**
  114627. * Gets a boolean indicating that the system is in VR mode and is presenting
  114628. * @returns true if VR mode is engaged
  114629. */
  114630. isVRPresenting(): boolean;
  114631. /** @hidden */
  114632. _requestVRFrame(): void;
  114633. /** @hidden */
  114634. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  114635. /**
  114636. * Gets the source code of the vertex shader associated with a specific webGL program
  114637. * @param program defines the program to use
  114638. * @returns a string containing the source code of the vertex shader associated with the program
  114639. */
  114640. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  114641. /**
  114642. * Gets the source code of the fragment shader associated with a specific webGL program
  114643. * @param program defines the program to use
  114644. * @returns a string containing the source code of the fragment shader associated with the program
  114645. */
  114646. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  114647. /**
  114648. * Sets a depth stencil texture from a render target to the according uniform.
  114649. * @param channel The texture channel
  114650. * @param uniform The uniform to set
  114651. * @param texture The render target texture containing the depth stencil texture to apply
  114652. */
  114653. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  114654. /**
  114655. * Sets a texture to the webGL context from a postprocess
  114656. * @param channel defines the channel to use
  114657. * @param postProcess defines the source postprocess
  114658. */
  114659. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  114660. /**
  114661. * Binds the output of the passed in post process to the texture channel specified
  114662. * @param channel The channel the texture should be bound to
  114663. * @param postProcess The post process which's output should be bound
  114664. */
  114665. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  114666. protected _rebuildBuffers(): void;
  114667. /** @hidden */
  114668. _renderFrame(): void;
  114669. _renderLoop(): void;
  114670. /** @hidden */
  114671. _renderViews(): boolean;
  114672. /**
  114673. * Toggle full screen mode
  114674. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114675. */
  114676. switchFullscreen(requestPointerLock: boolean): void;
  114677. /**
  114678. * Enters full screen mode
  114679. * @param requestPointerLock defines if a pointer lock should be requested from the user
  114680. */
  114681. enterFullscreen(requestPointerLock: boolean): void;
  114682. /**
  114683. * Exits full screen mode
  114684. */
  114685. exitFullscreen(): void;
  114686. /**
  114687. * Enters Pointerlock mode
  114688. */
  114689. enterPointerlock(): void;
  114690. /**
  114691. * Exits Pointerlock mode
  114692. */
  114693. exitPointerlock(): void;
  114694. /**
  114695. * Begin a new frame
  114696. */
  114697. beginFrame(): void;
  114698. /**
  114699. * Enf the current frame
  114700. */
  114701. endFrame(): void;
  114702. resize(): void;
  114703. /**
  114704. * Force a specific size of the canvas
  114705. * @param width defines the new canvas' width
  114706. * @param height defines the new canvas' height
  114707. */
  114708. setSize(width: number, height: number): void;
  114709. /**
  114710. * Updates a dynamic vertex buffer.
  114711. * @param vertexBuffer the vertex buffer to update
  114712. * @param data the data used to update the vertex buffer
  114713. * @param byteOffset the byte offset of the data
  114714. * @param byteLength the byte length of the data
  114715. */
  114716. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  114717. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  114718. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114719. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  114720. _releaseTexture(texture: InternalTexture): void;
  114721. /**
  114722. * @hidden
  114723. * Rescales a texture
  114724. * @param source input texutre
  114725. * @param destination destination texture
  114726. * @param scene scene to use to render the resize
  114727. * @param internalFormat format to use when resizing
  114728. * @param onComplete callback to be called when resize has completed
  114729. */
  114730. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  114731. /**
  114732. * Gets the current framerate
  114733. * @returns a number representing the framerate
  114734. */
  114735. getFps(): number;
  114736. /**
  114737. * Gets the time spent between current and previous frame
  114738. * @returns a number representing the delta time in ms
  114739. */
  114740. getDeltaTime(): number;
  114741. private _measureFps;
  114742. /** @hidden */
  114743. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  114744. /**
  114745. * Update a dynamic index buffer
  114746. * @param indexBuffer defines the target index buffer
  114747. * @param indices defines the data to update
  114748. * @param offset defines the offset in the target index buffer where update should start
  114749. */
  114750. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  114751. /**
  114752. * Updates the sample count of a render target texture
  114753. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  114754. * @param texture defines the texture to update
  114755. * @param samples defines the sample count to set
  114756. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  114757. */
  114758. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  114759. /**
  114760. * Updates a depth texture Comparison Mode and Function.
  114761. * If the comparison Function is equal to 0, the mode will be set to none.
  114762. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  114763. * @param texture The texture to set the comparison function for
  114764. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  114765. */
  114766. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  114767. /**
  114768. * Creates a webGL buffer to use with instanciation
  114769. * @param capacity defines the size of the buffer
  114770. * @returns the webGL buffer
  114771. */
  114772. createInstancesBuffer(capacity: number): DataBuffer;
  114773. /**
  114774. * Delete a webGL buffer used with instanciation
  114775. * @param buffer defines the webGL buffer to delete
  114776. */
  114777. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  114778. private _clientWaitAsync;
  114779. /** @hidden */
  114780. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  114781. dispose(): void;
  114782. private _disableTouchAction;
  114783. /**
  114784. * Display the loading screen
  114785. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114786. */
  114787. displayLoadingUI(): void;
  114788. /**
  114789. * Hide the loading screen
  114790. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114791. */
  114792. hideLoadingUI(): void;
  114793. /**
  114794. * Gets the current loading screen object
  114795. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114796. */
  114797. get loadingScreen(): ILoadingScreen;
  114798. /**
  114799. * Sets the current loading screen object
  114800. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114801. */
  114802. set loadingScreen(loadingScreen: ILoadingScreen);
  114803. /**
  114804. * Sets the current loading screen text
  114805. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114806. */
  114807. set loadingUIText(text: string);
  114808. /**
  114809. * Sets the current loading screen background color
  114810. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114811. */
  114812. set loadingUIBackgroundColor(color: string);
  114813. /** Pointerlock and fullscreen */
  114814. /**
  114815. * Ask the browser to promote the current element to pointerlock mode
  114816. * @param element defines the DOM element to promote
  114817. */
  114818. static _RequestPointerlock(element: HTMLElement): void;
  114819. /**
  114820. * Asks the browser to exit pointerlock mode
  114821. */
  114822. static _ExitPointerlock(): void;
  114823. /**
  114824. * Ask the browser to promote the current element to fullscreen rendering mode
  114825. * @param element defines the DOM element to promote
  114826. */
  114827. static _RequestFullscreen(element: HTMLElement): void;
  114828. /**
  114829. * Asks the browser to exit fullscreen mode
  114830. */
  114831. static _ExitFullscreen(): void;
  114832. }
  114833. }
  114834. declare module BABYLON {
  114835. /**
  114836. * The engine store class is responsible to hold all the instances of Engine and Scene created
  114837. * during the life time of the application.
  114838. */
  114839. export class EngineStore {
  114840. /** Gets the list of created engines */
  114841. static Instances: Engine[];
  114842. /** @hidden */
  114843. static _LastCreatedScene: Nullable<Scene>;
  114844. /**
  114845. * Gets the latest created engine
  114846. */
  114847. static get LastCreatedEngine(): Nullable<Engine>;
  114848. /**
  114849. * Gets the latest created scene
  114850. */
  114851. static get LastCreatedScene(): Nullable<Scene>;
  114852. /**
  114853. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114854. * @ignorenaming
  114855. */
  114856. static UseFallbackTexture: boolean;
  114857. /**
  114858. * Texture content used if a texture cannot loaded
  114859. * @ignorenaming
  114860. */
  114861. static FallbackTexture: string;
  114862. }
  114863. }
  114864. declare module BABYLON {
  114865. /**
  114866. * Helper class that provides a small promise polyfill
  114867. */
  114868. export class PromisePolyfill {
  114869. /**
  114870. * Static function used to check if the polyfill is required
  114871. * If this is the case then the function will inject the polyfill to window.Promise
  114872. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  114873. */
  114874. static Apply(force?: boolean): void;
  114875. }
  114876. }
  114877. declare module BABYLON {
  114878. /**
  114879. * Interface for screenshot methods with describe argument called `size` as object with options
  114880. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  114881. */
  114882. export interface IScreenshotSize {
  114883. /**
  114884. * number in pixels for canvas height
  114885. */
  114886. height?: number;
  114887. /**
  114888. * multiplier allowing render at a higher or lower resolution
  114889. * If value is defined then height and width will be ignored and taken from camera
  114890. */
  114891. precision?: number;
  114892. /**
  114893. * number in pixels for canvas width
  114894. */
  114895. width?: number;
  114896. }
  114897. }
  114898. declare module BABYLON {
  114899. interface IColor4Like {
  114900. r: float;
  114901. g: float;
  114902. b: float;
  114903. a: float;
  114904. }
  114905. /**
  114906. * Class containing a set of static utilities functions
  114907. */
  114908. export class Tools {
  114909. /**
  114910. * Gets or sets the base URL to use to load assets
  114911. */
  114912. static get BaseUrl(): string;
  114913. static set BaseUrl(value: string);
  114914. /**
  114915. * Enable/Disable Custom HTTP Request Headers globally.
  114916. * default = false
  114917. * @see CustomRequestHeaders
  114918. */
  114919. static UseCustomRequestHeaders: boolean;
  114920. /**
  114921. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  114922. * i.e. when loading files, where the server/service expects an Authorization header
  114923. */
  114924. static CustomRequestHeaders: {
  114925. [key: string]: string;
  114926. };
  114927. /**
  114928. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  114929. */
  114930. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  114931. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  114932. /**
  114933. * Default behaviour for cors in the application.
  114934. * It can be a string if the expected behavior is identical in the entire app.
  114935. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  114936. */
  114937. static get CorsBehavior(): string | ((url: string | string[]) => string);
  114938. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  114939. /**
  114940. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  114941. * @ignorenaming
  114942. */
  114943. static get UseFallbackTexture(): boolean;
  114944. static set UseFallbackTexture(value: boolean);
  114945. /**
  114946. * Use this object to register external classes like custom textures or material
  114947. * to allow the laoders to instantiate them
  114948. */
  114949. static get RegisteredExternalClasses(): {
  114950. [key: string]: Object;
  114951. };
  114952. static set RegisteredExternalClasses(classes: {
  114953. [key: string]: Object;
  114954. });
  114955. /**
  114956. * Texture content used if a texture cannot loaded
  114957. * @ignorenaming
  114958. */
  114959. static get fallbackTexture(): string;
  114960. static set fallbackTexture(value: string);
  114961. /**
  114962. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  114963. * @param u defines the coordinate on X axis
  114964. * @param v defines the coordinate on Y axis
  114965. * @param width defines the width of the source data
  114966. * @param height defines the height of the source data
  114967. * @param pixels defines the source byte array
  114968. * @param color defines the output color
  114969. */
  114970. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  114971. /**
  114972. * Interpolates between a and b via alpha
  114973. * @param a The lower value (returned when alpha = 0)
  114974. * @param b The upper value (returned when alpha = 1)
  114975. * @param alpha The interpolation-factor
  114976. * @return The mixed value
  114977. */
  114978. static Mix(a: number, b: number, alpha: number): number;
  114979. /**
  114980. * Tries to instantiate a new object from a given class name
  114981. * @param className defines the class name to instantiate
  114982. * @returns the new object or null if the system was not able to do the instantiation
  114983. */
  114984. static Instantiate(className: string): any;
  114985. /**
  114986. * Provides a slice function that will work even on IE
  114987. * @param data defines the array to slice
  114988. * @param start defines the start of the data (optional)
  114989. * @param end defines the end of the data (optional)
  114990. * @returns the new sliced array
  114991. */
  114992. static Slice<T>(data: T, start?: number, end?: number): T;
  114993. /**
  114994. * Polyfill for setImmediate
  114995. * @param action defines the action to execute after the current execution block
  114996. */
  114997. static SetImmediate(action: () => void): void;
  114998. /**
  114999. * Function indicating if a number is an exponent of 2
  115000. * @param value defines the value to test
  115001. * @returns true if the value is an exponent of 2
  115002. */
  115003. static IsExponentOfTwo(value: number): boolean;
  115004. private static _tmpFloatArray;
  115005. /**
  115006. * Returns the nearest 32-bit single precision float representation of a Number
  115007. * @param value A Number. If the parameter is of a different type, it will get converted
  115008. * to a number or to NaN if it cannot be converted
  115009. * @returns number
  115010. */
  115011. static FloatRound(value: number): number;
  115012. /**
  115013. * Extracts the filename from a path
  115014. * @param path defines the path to use
  115015. * @returns the filename
  115016. */
  115017. static GetFilename(path: string): string;
  115018. /**
  115019. * Extracts the "folder" part of a path (everything before the filename).
  115020. * @param uri The URI to extract the info from
  115021. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115022. * @returns The "folder" part of the path
  115023. */
  115024. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115025. /**
  115026. * Extracts text content from a DOM element hierarchy
  115027. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115028. */
  115029. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115030. /**
  115031. * Convert an angle in radians to degrees
  115032. * @param angle defines the angle to convert
  115033. * @returns the angle in degrees
  115034. */
  115035. static ToDegrees(angle: number): number;
  115036. /**
  115037. * Convert an angle in degrees to radians
  115038. * @param angle defines the angle to convert
  115039. * @returns the angle in radians
  115040. */
  115041. static ToRadians(angle: number): number;
  115042. /**
  115043. * Returns an array if obj is not an array
  115044. * @param obj defines the object to evaluate as an array
  115045. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115046. * @returns either obj directly if obj is an array or a new array containing obj
  115047. */
  115048. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115049. /**
  115050. * Gets the pointer prefix to use
  115051. * @param engine defines the engine we are finding the prefix for
  115052. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115053. */
  115054. static GetPointerPrefix(engine: Engine): string;
  115055. /**
  115056. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115057. * @param url define the url we are trying
  115058. * @param element define the dom element where to configure the cors policy
  115059. */
  115060. static SetCorsBehavior(url: string | string[], element: {
  115061. crossOrigin: string | null;
  115062. }): void;
  115063. /**
  115064. * Removes unwanted characters from an url
  115065. * @param url defines the url to clean
  115066. * @returns the cleaned url
  115067. */
  115068. static CleanUrl(url: string): string;
  115069. /**
  115070. * Gets or sets a function used to pre-process url before using them to load assets
  115071. */
  115072. static get PreprocessUrl(): (url: string) => string;
  115073. static set PreprocessUrl(processor: (url: string) => string);
  115074. /**
  115075. * Loads an image as an HTMLImageElement.
  115076. * @param input url string, ArrayBuffer, or Blob to load
  115077. * @param onLoad callback called when the image successfully loads
  115078. * @param onError callback called when the image fails to load
  115079. * @param offlineProvider offline provider for caching
  115080. * @param mimeType optional mime type
  115081. * @returns the HTMLImageElement of the loaded image
  115082. */
  115083. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115084. /**
  115085. * Loads a file from a url
  115086. * @param url url string, ArrayBuffer, or Blob to load
  115087. * @param onSuccess callback called when the file successfully loads
  115088. * @param onProgress callback called while file is loading (if the server supports this mode)
  115089. * @param offlineProvider defines the offline provider for caching
  115090. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115091. * @param onError callback called when the file fails to load
  115092. * @returns a file request object
  115093. */
  115094. 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;
  115095. /**
  115096. * Loads a file from a url
  115097. * @param url the file url to load
  115098. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115099. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115100. */
  115101. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115102. /**
  115103. * Load a script (identified by an url). When the url returns, the
  115104. * content of this file is added into a new script element, attached to the DOM (body element)
  115105. * @param scriptUrl defines the url of the script to laod
  115106. * @param onSuccess defines the callback called when the script is loaded
  115107. * @param onError defines the callback to call if an error occurs
  115108. * @param scriptId defines the id of the script element
  115109. */
  115110. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115111. /**
  115112. * Load an asynchronous script (identified by an url). When the url returns, the
  115113. * content of this file is added into a new script element, attached to the DOM (body element)
  115114. * @param scriptUrl defines the url of the script to laod
  115115. * @param scriptId defines the id of the script element
  115116. * @returns a promise request object
  115117. */
  115118. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115119. /**
  115120. * Loads a file from a blob
  115121. * @param fileToLoad defines the blob to use
  115122. * @param callback defines the callback to call when data is loaded
  115123. * @param progressCallback defines the callback to call during loading process
  115124. * @returns a file request object
  115125. */
  115126. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115127. /**
  115128. * Reads a file from a File object
  115129. * @param file defines the file to load
  115130. * @param onSuccess defines the callback to call when data is loaded
  115131. * @param onProgress defines the callback to call during loading process
  115132. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115133. * @param onError defines the callback to call when an error occurs
  115134. * @returns a file request object
  115135. */
  115136. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115137. /**
  115138. * Creates a data url from a given string content
  115139. * @param content defines the content to convert
  115140. * @returns the new data url link
  115141. */
  115142. static FileAsURL(content: string): string;
  115143. /**
  115144. * Format the given number to a specific decimal format
  115145. * @param value defines the number to format
  115146. * @param decimals defines the number of decimals to use
  115147. * @returns the formatted string
  115148. */
  115149. static Format(value: number, decimals?: number): string;
  115150. /**
  115151. * Tries to copy an object by duplicating every property
  115152. * @param source defines the source object
  115153. * @param destination defines the target object
  115154. * @param doNotCopyList defines a list of properties to avoid
  115155. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115156. */
  115157. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115158. /**
  115159. * Gets a boolean indicating if the given object has no own property
  115160. * @param obj defines the object to test
  115161. * @returns true if object has no own property
  115162. */
  115163. static IsEmpty(obj: any): boolean;
  115164. /**
  115165. * Function used to register events at window level
  115166. * @param windowElement defines the Window object to use
  115167. * @param events defines the events to register
  115168. */
  115169. static RegisterTopRootEvents(windowElement: Window, events: {
  115170. name: string;
  115171. handler: Nullable<(e: FocusEvent) => any>;
  115172. }[]): void;
  115173. /**
  115174. * Function used to unregister events from window level
  115175. * @param windowElement defines the Window object to use
  115176. * @param events defines the events to unregister
  115177. */
  115178. static UnregisterTopRootEvents(windowElement: Window, events: {
  115179. name: string;
  115180. handler: Nullable<(e: FocusEvent) => any>;
  115181. }[]): void;
  115182. /**
  115183. * @ignore
  115184. */
  115185. static _ScreenshotCanvas: HTMLCanvasElement;
  115186. /**
  115187. * Dumps the current bound framebuffer
  115188. * @param width defines the rendering width
  115189. * @param height defines the rendering height
  115190. * @param engine defines the hosting engine
  115191. * @param successCallback defines the callback triggered once the data are available
  115192. * @param mimeType defines the mime type of the result
  115193. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115194. */
  115195. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115196. /**
  115197. * Converts the canvas data to blob.
  115198. * This acts as a polyfill for browsers not supporting the to blob function.
  115199. * @param canvas Defines the canvas to extract the data from
  115200. * @param successCallback Defines the callback triggered once the data are available
  115201. * @param mimeType Defines the mime type of the result
  115202. */
  115203. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115204. /**
  115205. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115206. * @param successCallback defines the callback triggered once the data are available
  115207. * @param mimeType defines the mime type of the result
  115208. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115209. */
  115210. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115211. /**
  115212. * Downloads a blob in the browser
  115213. * @param blob defines the blob to download
  115214. * @param fileName defines the name of the downloaded file
  115215. */
  115216. static Download(blob: Blob, fileName: string): void;
  115217. /**
  115218. * Captures a screenshot of the current rendering
  115219. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115220. * @param engine defines the rendering engine
  115221. * @param camera defines the source camera
  115222. * @param size This parameter can be set to a single number or to an object with the
  115223. * following (optional) properties: precision, width, height. If a single number is passed,
  115224. * it will be used for both width and height. If an object is passed, the screenshot size
  115225. * will be derived from the parameters. The precision property is a multiplier allowing
  115226. * rendering at a higher or lower resolution
  115227. * @param successCallback defines the callback receives a single parameter which contains the
  115228. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115229. * src parameter of an <img> to display it
  115230. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115231. * Check your browser for supported MIME types
  115232. */
  115233. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  115234. /**
  115235. * Captures a screenshot of the current rendering
  115236. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115237. * @param engine defines the rendering engine
  115238. * @param camera defines the source camera
  115239. * @param size This parameter can be set to a single number or to an object with the
  115240. * following (optional) properties: precision, width, height. If a single number is passed,
  115241. * it will be used for both width and height. If an object is passed, the screenshot size
  115242. * will be derived from the parameters. The precision property is a multiplier allowing
  115243. * rendering at a higher or lower resolution
  115244. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115245. * Check your browser for supported MIME types
  115246. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115247. * to the src parameter of an <img> to display it
  115248. */
  115249. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  115250. /**
  115251. * Generates an image screenshot from the specified camera.
  115252. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115253. * @param engine The engine to use for rendering
  115254. * @param camera The camera to use for rendering
  115255. * @param size This parameter can be set to a single number or to an object with the
  115256. * following (optional) properties: precision, width, height. If a single number is passed,
  115257. * it will be used for both width and height. If an object is passed, the screenshot size
  115258. * will be derived from the parameters. The precision property is a multiplier allowing
  115259. * rendering at a higher or lower resolution
  115260. * @param successCallback The callback receives a single parameter which contains the
  115261. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115262. * src parameter of an <img> to display it
  115263. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115264. * Check your browser for supported MIME types
  115265. * @param samples Texture samples (default: 1)
  115266. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115267. * @param fileName A name for for the downloaded file.
  115268. */
  115269. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115270. /**
  115271. * Generates an image screenshot from the specified camera.
  115272. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115273. * @param engine The engine to use for rendering
  115274. * @param camera The camera to use for rendering
  115275. * @param size This parameter can be set to a single number or to an object with the
  115276. * following (optional) properties: precision, width, height. If a single number is passed,
  115277. * it will be used for both width and height. If an object is passed, the screenshot size
  115278. * will be derived from the parameters. The precision property is a multiplier allowing
  115279. * rendering at a higher or lower resolution
  115280. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115281. * Check your browser for supported MIME types
  115282. * @param samples Texture samples (default: 1)
  115283. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115284. * @param fileName A name for for the downloaded file.
  115285. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  115286. * to the src parameter of an <img> to display it
  115287. */
  115288. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  115289. /**
  115290. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  115291. * Be aware Math.random() could cause collisions, but:
  115292. * "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"
  115293. * @returns a pseudo random id
  115294. */
  115295. static RandomId(): string;
  115296. /**
  115297. * Test if the given uri is a base64 string
  115298. * @param uri The uri to test
  115299. * @return True if the uri is a base64 string or false otherwise
  115300. */
  115301. static IsBase64(uri: string): boolean;
  115302. /**
  115303. * Decode the given base64 uri.
  115304. * @param uri The uri to decode
  115305. * @return The decoded base64 data.
  115306. */
  115307. static DecodeBase64(uri: string): ArrayBuffer;
  115308. /**
  115309. * Gets the absolute url.
  115310. * @param url the input url
  115311. * @return the absolute url
  115312. */
  115313. static GetAbsoluteUrl(url: string): string;
  115314. /**
  115315. * No log
  115316. */
  115317. static readonly NoneLogLevel: number;
  115318. /**
  115319. * Only message logs
  115320. */
  115321. static readonly MessageLogLevel: number;
  115322. /**
  115323. * Only warning logs
  115324. */
  115325. static readonly WarningLogLevel: number;
  115326. /**
  115327. * Only error logs
  115328. */
  115329. static readonly ErrorLogLevel: number;
  115330. /**
  115331. * All logs
  115332. */
  115333. static readonly AllLogLevel: number;
  115334. /**
  115335. * Gets a value indicating the number of loading errors
  115336. * @ignorenaming
  115337. */
  115338. static get errorsCount(): number;
  115339. /**
  115340. * Callback called when a new log is added
  115341. */
  115342. static OnNewCacheEntry: (entry: string) => void;
  115343. /**
  115344. * Log a message to the console
  115345. * @param message defines the message to log
  115346. */
  115347. static Log(message: string): void;
  115348. /**
  115349. * Write a warning message to the console
  115350. * @param message defines the message to log
  115351. */
  115352. static Warn(message: string): void;
  115353. /**
  115354. * Write an error message to the console
  115355. * @param message defines the message to log
  115356. */
  115357. static Error(message: string): void;
  115358. /**
  115359. * Gets current log cache (list of logs)
  115360. */
  115361. static get LogCache(): string;
  115362. /**
  115363. * Clears the log cache
  115364. */
  115365. static ClearLogCache(): void;
  115366. /**
  115367. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  115368. */
  115369. static set LogLevels(level: number);
  115370. /**
  115371. * Checks if the window object exists
  115372. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  115373. */
  115374. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  115375. /**
  115376. * No performance log
  115377. */
  115378. static readonly PerformanceNoneLogLevel: number;
  115379. /**
  115380. * Use user marks to log performance
  115381. */
  115382. static readonly PerformanceUserMarkLogLevel: number;
  115383. /**
  115384. * Log performance to the console
  115385. */
  115386. static readonly PerformanceConsoleLogLevel: number;
  115387. private static _performance;
  115388. /**
  115389. * Sets the current performance log level
  115390. */
  115391. static set PerformanceLogLevel(level: number);
  115392. private static _StartPerformanceCounterDisabled;
  115393. private static _EndPerformanceCounterDisabled;
  115394. private static _StartUserMark;
  115395. private static _EndUserMark;
  115396. private static _StartPerformanceConsole;
  115397. private static _EndPerformanceConsole;
  115398. /**
  115399. * Starts a performance counter
  115400. */
  115401. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115402. /**
  115403. * Ends a specific performance coutner
  115404. */
  115405. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  115406. /**
  115407. * Gets either window.performance.now() if supported or Date.now() else
  115408. */
  115409. static get Now(): number;
  115410. /**
  115411. * This method will return the name of the class used to create the instance of the given object.
  115412. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  115413. * @param object the object to get the class name from
  115414. * @param isType defines if the object is actually a type
  115415. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  115416. */
  115417. static GetClassName(object: any, isType?: boolean): string;
  115418. /**
  115419. * Gets the first element of an array satisfying a given predicate
  115420. * @param array defines the array to browse
  115421. * @param predicate defines the predicate to use
  115422. * @returns null if not found or the element
  115423. */
  115424. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  115425. /**
  115426. * This method will return the name of the full name of the class, including its owning module (if any).
  115427. * 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).
  115428. * @param object the object to get the class name from
  115429. * @param isType defines if the object is actually a type
  115430. * @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.
  115431. * @ignorenaming
  115432. */
  115433. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  115434. /**
  115435. * Returns a promise that resolves after the given amount of time.
  115436. * @param delay Number of milliseconds to delay
  115437. * @returns Promise that resolves after the given amount of time
  115438. */
  115439. static DelayAsync(delay: number): Promise<void>;
  115440. /**
  115441. * Utility function to detect if the current user agent is Safari
  115442. * @returns whether or not the current user agent is safari
  115443. */
  115444. static IsSafari(): boolean;
  115445. }
  115446. /**
  115447. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  115448. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  115449. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  115450. * @param name The name of the class, case should be preserved
  115451. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  115452. */
  115453. export function className(name: string, module?: string): (target: Object) => void;
  115454. /**
  115455. * An implementation of a loop for asynchronous functions.
  115456. */
  115457. export class AsyncLoop {
  115458. /**
  115459. * Defines the number of iterations for the loop
  115460. */
  115461. iterations: number;
  115462. /**
  115463. * Defines the current index of the loop.
  115464. */
  115465. index: number;
  115466. private _done;
  115467. private _fn;
  115468. private _successCallback;
  115469. /**
  115470. * Constructor.
  115471. * @param iterations the number of iterations.
  115472. * @param func the function to run each iteration
  115473. * @param successCallback the callback that will be called upon succesful execution
  115474. * @param offset starting offset.
  115475. */
  115476. constructor(
  115477. /**
  115478. * Defines the number of iterations for the loop
  115479. */
  115480. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  115481. /**
  115482. * Execute the next iteration. Must be called after the last iteration was finished.
  115483. */
  115484. executeNext(): void;
  115485. /**
  115486. * Break the loop and run the success callback.
  115487. */
  115488. breakLoop(): void;
  115489. /**
  115490. * Create and run an async loop.
  115491. * @param iterations the number of iterations.
  115492. * @param fn the function to run each iteration
  115493. * @param successCallback the callback that will be called upon succesful execution
  115494. * @param offset starting offset.
  115495. * @returns the created async loop object
  115496. */
  115497. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  115498. /**
  115499. * A for-loop that will run a given number of iterations synchronous and the rest async.
  115500. * @param iterations total number of iterations
  115501. * @param syncedIterations number of synchronous iterations in each async iteration.
  115502. * @param fn the function to call each iteration.
  115503. * @param callback a success call back that will be called when iterating stops.
  115504. * @param breakFunction a break condition (optional)
  115505. * @param timeout timeout settings for the setTimeout function. default - 0.
  115506. * @returns the created async loop object
  115507. */
  115508. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  115509. }
  115510. }
  115511. declare module BABYLON {
  115512. /**
  115513. * This class implement a typical dictionary using a string as key and the generic type T as value.
  115514. * The underlying implementation relies on an associative array to ensure the best performances.
  115515. * The value can be anything including 'null' but except 'undefined'
  115516. */
  115517. export class StringDictionary<T> {
  115518. /**
  115519. * This will clear this dictionary and copy the content from the 'source' one.
  115520. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  115521. * @param source the dictionary to take the content from and copy to this dictionary
  115522. */
  115523. copyFrom(source: StringDictionary<T>): void;
  115524. /**
  115525. * Get a value based from its key
  115526. * @param key the given key to get the matching value from
  115527. * @return the value if found, otherwise undefined is returned
  115528. */
  115529. get(key: string): T | undefined;
  115530. /**
  115531. * Get a value from its key or add it if it doesn't exist.
  115532. * This method will ensure you that a given key/data will be present in the dictionary.
  115533. * @param key the given key to get the matching value from
  115534. * @param factory the factory that will create the value if the key is not present in the dictionary.
  115535. * The factory will only be invoked if there's no data for the given key.
  115536. * @return the value corresponding to the key.
  115537. */
  115538. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  115539. /**
  115540. * Get a value from its key if present in the dictionary otherwise add it
  115541. * @param key the key to get the value from
  115542. * @param val if there's no such key/value pair in the dictionary add it with this value
  115543. * @return the value corresponding to the key
  115544. */
  115545. getOrAdd(key: string, val: T): T;
  115546. /**
  115547. * Check if there's a given key in the dictionary
  115548. * @param key the key to check for
  115549. * @return true if the key is present, false otherwise
  115550. */
  115551. contains(key: string): boolean;
  115552. /**
  115553. * Add a new key and its corresponding value
  115554. * @param key the key to add
  115555. * @param value the value corresponding to the key
  115556. * @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
  115557. */
  115558. add(key: string, value: T): boolean;
  115559. /**
  115560. * Update a specific value associated to a key
  115561. * @param key defines the key to use
  115562. * @param value defines the value to store
  115563. * @returns true if the value was updated (or false if the key was not found)
  115564. */
  115565. set(key: string, value: T): boolean;
  115566. /**
  115567. * Get the element of the given key and remove it from the dictionary
  115568. * @param key defines the key to search
  115569. * @returns the value associated with the key or null if not found
  115570. */
  115571. getAndRemove(key: string): Nullable<T>;
  115572. /**
  115573. * Remove a key/value from the dictionary.
  115574. * @param key the key to remove
  115575. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  115576. */
  115577. remove(key: string): boolean;
  115578. /**
  115579. * Clear the whole content of the dictionary
  115580. */
  115581. clear(): void;
  115582. /**
  115583. * Gets the current count
  115584. */
  115585. get count(): number;
  115586. /**
  115587. * Execute a callback on each key/val of the dictionary.
  115588. * Note that you can remove any element in this dictionary in the callback implementation
  115589. * @param callback the callback to execute on a given key/value pair
  115590. */
  115591. forEach(callback: (key: string, val: T) => void): void;
  115592. /**
  115593. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  115594. * If the callback returns null or undefined the method will iterate to the next key/value pair
  115595. * Note that you can remove any element in this dictionary in the callback implementation
  115596. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  115597. * @returns the first item
  115598. */
  115599. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  115600. private _count;
  115601. private _data;
  115602. }
  115603. }
  115604. declare module BABYLON {
  115605. /** @hidden */
  115606. export interface ICollisionCoordinator {
  115607. createCollider(): Collider;
  115608. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115609. init(scene: Scene): void;
  115610. }
  115611. /** @hidden */
  115612. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  115613. private _scene;
  115614. private _scaledPosition;
  115615. private _scaledVelocity;
  115616. private _finalPosition;
  115617. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  115618. createCollider(): Collider;
  115619. init(scene: Scene): void;
  115620. private _collideWithWorld;
  115621. }
  115622. }
  115623. declare module BABYLON {
  115624. /**
  115625. * Class used to manage all inputs for the scene.
  115626. */
  115627. export class InputManager {
  115628. /** The distance in pixel that you have to move to prevent some events */
  115629. static DragMovementThreshold: number;
  115630. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  115631. static LongPressDelay: number;
  115632. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  115633. static DoubleClickDelay: number;
  115634. /** If you need to check double click without raising a single click at first click, enable this flag */
  115635. static ExclusiveDoubleClickMode: boolean;
  115636. private _wheelEventName;
  115637. private _onPointerMove;
  115638. private _onPointerDown;
  115639. private _onPointerUp;
  115640. private _initClickEvent;
  115641. private _initActionManager;
  115642. private _delayedSimpleClick;
  115643. private _delayedSimpleClickTimeout;
  115644. private _previousDelayedSimpleClickTimeout;
  115645. private _meshPickProceed;
  115646. private _previousButtonPressed;
  115647. private _currentPickResult;
  115648. private _previousPickResult;
  115649. private _totalPointersPressed;
  115650. private _doubleClickOccured;
  115651. private _pointerOverMesh;
  115652. private _pickedDownMesh;
  115653. private _pickedUpMesh;
  115654. private _pointerX;
  115655. private _pointerY;
  115656. private _unTranslatedPointerX;
  115657. private _unTranslatedPointerY;
  115658. private _startingPointerPosition;
  115659. private _previousStartingPointerPosition;
  115660. private _startingPointerTime;
  115661. private _previousStartingPointerTime;
  115662. private _pointerCaptures;
  115663. private _onKeyDown;
  115664. private _onKeyUp;
  115665. private _onCanvasFocusObserver;
  115666. private _onCanvasBlurObserver;
  115667. private _scene;
  115668. /**
  115669. * Creates a new InputManager
  115670. * @param scene defines the hosting scene
  115671. */
  115672. constructor(scene: Scene);
  115673. /**
  115674. * Gets the mesh that is currently under the pointer
  115675. */
  115676. get meshUnderPointer(): Nullable<AbstractMesh>;
  115677. /**
  115678. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  115679. */
  115680. get unTranslatedPointer(): Vector2;
  115681. /**
  115682. * Gets or sets the current on-screen X position of the pointer
  115683. */
  115684. get pointerX(): number;
  115685. set pointerX(value: number);
  115686. /**
  115687. * Gets or sets the current on-screen Y position of the pointer
  115688. */
  115689. get pointerY(): number;
  115690. set pointerY(value: number);
  115691. private _updatePointerPosition;
  115692. private _processPointerMove;
  115693. private _setRayOnPointerInfo;
  115694. private _checkPrePointerObservable;
  115695. /**
  115696. * Use this method to simulate a pointer move on a mesh
  115697. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115698. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115699. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115700. */
  115701. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115702. /**
  115703. * Use this method to simulate a pointer down on a mesh
  115704. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115705. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115706. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115707. */
  115708. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  115709. private _processPointerDown;
  115710. /** @hidden */
  115711. _isPointerSwiping(): boolean;
  115712. /**
  115713. * Use this method to simulate a pointer up on a mesh
  115714. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  115715. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  115716. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  115717. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  115718. */
  115719. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  115720. private _processPointerUp;
  115721. /**
  115722. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  115723. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  115724. * @returns true if the pointer was captured
  115725. */
  115726. isPointerCaptured(pointerId?: number): boolean;
  115727. /**
  115728. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  115729. * @param attachUp defines if you want to attach events to pointerup
  115730. * @param attachDown defines if you want to attach events to pointerdown
  115731. * @param attachMove defines if you want to attach events to pointermove
  115732. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  115733. */
  115734. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  115735. /**
  115736. * Detaches all event handlers
  115737. */
  115738. detachControl(): void;
  115739. /**
  115740. * Force the value of meshUnderPointer
  115741. * @param mesh defines the mesh to use
  115742. */
  115743. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  115744. /**
  115745. * Gets the mesh under the pointer
  115746. * @returns a Mesh or null if no mesh is under the pointer
  115747. */
  115748. getPointerOverMesh(): Nullable<AbstractMesh>;
  115749. }
  115750. }
  115751. declare module BABYLON {
  115752. /**
  115753. * This class defines the direct association between an animation and a target
  115754. */
  115755. export class TargetedAnimation {
  115756. /**
  115757. * Animation to perform
  115758. */
  115759. animation: Animation;
  115760. /**
  115761. * Target to animate
  115762. */
  115763. target: any;
  115764. /**
  115765. * Returns the string "TargetedAnimation"
  115766. * @returns "TargetedAnimation"
  115767. */
  115768. getClassName(): string;
  115769. /**
  115770. * Serialize the object
  115771. * @returns the JSON object representing the current entity
  115772. */
  115773. serialize(): any;
  115774. }
  115775. /**
  115776. * Use this class to create coordinated animations on multiple targets
  115777. */
  115778. export class AnimationGroup implements IDisposable {
  115779. /** The name of the animation group */
  115780. name: string;
  115781. private _scene;
  115782. private _targetedAnimations;
  115783. private _animatables;
  115784. private _from;
  115785. private _to;
  115786. private _isStarted;
  115787. private _isPaused;
  115788. private _speedRatio;
  115789. private _loopAnimation;
  115790. private _isAdditive;
  115791. /**
  115792. * Gets or sets the unique id of the node
  115793. */
  115794. uniqueId: number;
  115795. /**
  115796. * This observable will notify when one animation have ended
  115797. */
  115798. onAnimationEndObservable: Observable<TargetedAnimation>;
  115799. /**
  115800. * Observer raised when one animation loops
  115801. */
  115802. onAnimationLoopObservable: Observable<TargetedAnimation>;
  115803. /**
  115804. * Observer raised when all animations have looped
  115805. */
  115806. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  115807. /**
  115808. * This observable will notify when all animations have ended.
  115809. */
  115810. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  115811. /**
  115812. * This observable will notify when all animations have paused.
  115813. */
  115814. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  115815. /**
  115816. * This observable will notify when all animations are playing.
  115817. */
  115818. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  115819. /**
  115820. * Gets the first frame
  115821. */
  115822. get from(): number;
  115823. /**
  115824. * Gets the last frame
  115825. */
  115826. get to(): number;
  115827. /**
  115828. * Define if the animations are started
  115829. */
  115830. get isStarted(): boolean;
  115831. /**
  115832. * Gets a value indicating that the current group is playing
  115833. */
  115834. get isPlaying(): boolean;
  115835. /**
  115836. * Gets or sets the speed ratio to use for all animations
  115837. */
  115838. get speedRatio(): number;
  115839. /**
  115840. * Gets or sets the speed ratio to use for all animations
  115841. */
  115842. set speedRatio(value: number);
  115843. /**
  115844. * Gets or sets if all animations should loop or not
  115845. */
  115846. get loopAnimation(): boolean;
  115847. set loopAnimation(value: boolean);
  115848. /**
  115849. * Gets or sets if all animations should be evaluated additively
  115850. */
  115851. get isAdditive(): boolean;
  115852. set isAdditive(value: boolean);
  115853. /**
  115854. * Gets the targeted animations for this animation group
  115855. */
  115856. get targetedAnimations(): Array<TargetedAnimation>;
  115857. /**
  115858. * returning the list of animatables controlled by this animation group.
  115859. */
  115860. get animatables(): Array<Animatable>;
  115861. /**
  115862. * Gets the list of target animations
  115863. */
  115864. get children(): TargetedAnimation[];
  115865. /**
  115866. * Instantiates a new Animation Group.
  115867. * This helps managing several animations at once.
  115868. * @see http://doc.babylonjs.com/how_to/group
  115869. * @param name Defines the name of the group
  115870. * @param scene Defines the scene the group belongs to
  115871. */
  115872. constructor(
  115873. /** The name of the animation group */
  115874. name: string, scene?: Nullable<Scene>);
  115875. /**
  115876. * Add an animation (with its target) in the group
  115877. * @param animation defines the animation we want to add
  115878. * @param target defines the target of the animation
  115879. * @returns the TargetedAnimation object
  115880. */
  115881. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  115882. /**
  115883. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  115884. * It can add constant keys at begin or end
  115885. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  115886. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  115887. * @returns the animation group
  115888. */
  115889. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  115890. private _animationLoopCount;
  115891. private _animationLoopFlags;
  115892. private _processLoop;
  115893. /**
  115894. * Start all animations on given targets
  115895. * @param loop defines if animations must loop
  115896. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  115897. * @param from defines the from key (optional)
  115898. * @param to defines the to key (optional)
  115899. * @param isAdditive defines the additive state for the resulting animatables (optional)
  115900. * @returns the current animation group
  115901. */
  115902. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  115903. /**
  115904. * Pause all animations
  115905. * @returns the animation group
  115906. */
  115907. pause(): AnimationGroup;
  115908. /**
  115909. * Play all animations to initial state
  115910. * This function will start() the animations if they were not started or will restart() them if they were paused
  115911. * @param loop defines if animations must loop
  115912. * @returns the animation group
  115913. */
  115914. play(loop?: boolean): AnimationGroup;
  115915. /**
  115916. * Reset all animations to initial state
  115917. * @returns the animation group
  115918. */
  115919. reset(): AnimationGroup;
  115920. /**
  115921. * Restart animations from key 0
  115922. * @returns the animation group
  115923. */
  115924. restart(): AnimationGroup;
  115925. /**
  115926. * Stop all animations
  115927. * @returns the animation group
  115928. */
  115929. stop(): AnimationGroup;
  115930. /**
  115931. * Set animation weight for all animatables
  115932. * @param weight defines the weight to use
  115933. * @return the animationGroup
  115934. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115935. */
  115936. setWeightForAllAnimatables(weight: number): AnimationGroup;
  115937. /**
  115938. * Synchronize and normalize all animatables with a source animatable
  115939. * @param root defines the root animatable to synchronize with
  115940. * @return the animationGroup
  115941. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  115942. */
  115943. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  115944. /**
  115945. * Goes to a specific frame in this animation group
  115946. * @param frame the frame number to go to
  115947. * @return the animationGroup
  115948. */
  115949. goToFrame(frame: number): AnimationGroup;
  115950. /**
  115951. * Dispose all associated resources
  115952. */
  115953. dispose(): void;
  115954. private _checkAnimationGroupEnded;
  115955. /**
  115956. * Clone the current animation group and returns a copy
  115957. * @param newName defines the name of the new group
  115958. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  115959. * @returns the new aniamtion group
  115960. */
  115961. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  115962. /**
  115963. * Serializes the animationGroup to an object
  115964. * @returns Serialized object
  115965. */
  115966. serialize(): any;
  115967. /**
  115968. * Returns a new AnimationGroup object parsed from the source provided.
  115969. * @param parsedAnimationGroup defines the source
  115970. * @param scene defines the scene that will receive the animationGroup
  115971. * @returns a new AnimationGroup
  115972. */
  115973. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  115974. /**
  115975. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  115976. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  115977. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  115978. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  115979. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  115980. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  115981. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  115982. */
  115983. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  115984. /**
  115985. * Returns the string "AnimationGroup"
  115986. * @returns "AnimationGroup"
  115987. */
  115988. getClassName(): string;
  115989. /**
  115990. * Creates a detailled string about the object
  115991. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  115992. * @returns a string representing the object
  115993. */
  115994. toString(fullDetails?: boolean): string;
  115995. }
  115996. }
  115997. declare module BABYLON {
  115998. /**
  115999. * Define an interface for all classes that will hold resources
  116000. */
  116001. export interface IDisposable {
  116002. /**
  116003. * Releases all held resources
  116004. */
  116005. dispose(): void;
  116006. }
  116007. /** Interface defining initialization parameters for Scene class */
  116008. export interface SceneOptions {
  116009. /**
  116010. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116011. * It will improve performance when the number of geometries becomes important.
  116012. */
  116013. useGeometryUniqueIdsMap?: boolean;
  116014. /**
  116015. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116016. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116017. */
  116018. useMaterialMeshMap?: boolean;
  116019. /**
  116020. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116021. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116022. */
  116023. useClonedMeshMap?: boolean;
  116024. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116025. virtual?: boolean;
  116026. }
  116027. /**
  116028. * Represents a scene to be rendered by the engine.
  116029. * @see http://doc.babylonjs.com/features/scene
  116030. */
  116031. export class Scene extends AbstractScene implements IAnimatable {
  116032. /** The fog is deactivated */
  116033. static readonly FOGMODE_NONE: number;
  116034. /** The fog density is following an exponential function */
  116035. static readonly FOGMODE_EXP: number;
  116036. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116037. static readonly FOGMODE_EXP2: number;
  116038. /** The fog density is following a linear function. */
  116039. static readonly FOGMODE_LINEAR: number;
  116040. /**
  116041. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116042. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116043. */
  116044. static MinDeltaTime: number;
  116045. /**
  116046. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116047. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116048. */
  116049. static MaxDeltaTime: number;
  116050. /**
  116051. * Factory used to create the default material.
  116052. * @param name The name of the material to create
  116053. * @param scene The scene to create the material for
  116054. * @returns The default material
  116055. */
  116056. static DefaultMaterialFactory(scene: Scene): Material;
  116057. /**
  116058. * Factory used to create the a collision coordinator.
  116059. * @returns The collision coordinator
  116060. */
  116061. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116062. /** @hidden */
  116063. _inputManager: InputManager;
  116064. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116065. cameraToUseForPointers: Nullable<Camera>;
  116066. /** @hidden */
  116067. readonly _isScene: boolean;
  116068. /** @hidden */
  116069. _blockEntityCollection: boolean;
  116070. /**
  116071. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116072. */
  116073. autoClear: boolean;
  116074. /**
  116075. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116076. */
  116077. autoClearDepthAndStencil: boolean;
  116078. /**
  116079. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116080. */
  116081. clearColor: Color4;
  116082. /**
  116083. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116084. */
  116085. ambientColor: Color3;
  116086. /**
  116087. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116088. * It should only be one of the following (if not the default embedded one):
  116089. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116090. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116091. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116092. * The material properties need to be setup according to the type of texture in use.
  116093. */
  116094. environmentBRDFTexture: BaseTexture;
  116095. /** @hidden */
  116096. protected _environmentTexture: Nullable<BaseTexture>;
  116097. /**
  116098. * Texture used in all pbr material as the reflection texture.
  116099. * As in the majority of the scene they are the same (exception for multi room and so on),
  116100. * this is easier to reference from here than from all the materials.
  116101. */
  116102. get environmentTexture(): Nullable<BaseTexture>;
  116103. /**
  116104. * Texture used in all pbr material as the reflection texture.
  116105. * As in the majority of the scene they are the same (exception for multi room and so on),
  116106. * this is easier to set here than in all the materials.
  116107. */
  116108. set environmentTexture(value: Nullable<BaseTexture>);
  116109. /** @hidden */
  116110. protected _environmentIntensity: number;
  116111. /**
  116112. * Intensity of the environment in all pbr material.
  116113. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116114. * As in the majority of the scene they are the same (exception for multi room and so on),
  116115. * this is easier to reference from here than from all the materials.
  116116. */
  116117. get environmentIntensity(): number;
  116118. /**
  116119. * Intensity of the environment in all pbr material.
  116120. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116121. * As in the majority of the scene they are the same (exception for multi room and so on),
  116122. * this is easier to set here than in all the materials.
  116123. */
  116124. set environmentIntensity(value: number);
  116125. /** @hidden */
  116126. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116127. /**
  116128. * Default image processing configuration used either in the rendering
  116129. * Forward main pass or through the imageProcessingPostProcess if present.
  116130. * As in the majority of the scene they are the same (exception for multi camera),
  116131. * this is easier to reference from here than from all the materials and post process.
  116132. *
  116133. * No setter as we it is a shared configuration, you can set the values instead.
  116134. */
  116135. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116136. private _forceWireframe;
  116137. /**
  116138. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116139. */
  116140. set forceWireframe(value: boolean);
  116141. get forceWireframe(): boolean;
  116142. private _skipFrustumClipping;
  116143. /**
  116144. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116145. */
  116146. set skipFrustumClipping(value: boolean);
  116147. get skipFrustumClipping(): boolean;
  116148. private _forcePointsCloud;
  116149. /**
  116150. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116151. */
  116152. set forcePointsCloud(value: boolean);
  116153. get forcePointsCloud(): boolean;
  116154. /**
  116155. * Gets or sets the active clipplane 1
  116156. */
  116157. clipPlane: Nullable<Plane>;
  116158. /**
  116159. * Gets or sets the active clipplane 2
  116160. */
  116161. clipPlane2: Nullable<Plane>;
  116162. /**
  116163. * Gets or sets the active clipplane 3
  116164. */
  116165. clipPlane3: Nullable<Plane>;
  116166. /**
  116167. * Gets or sets the active clipplane 4
  116168. */
  116169. clipPlane4: Nullable<Plane>;
  116170. /**
  116171. * Gets or sets the active clipplane 5
  116172. */
  116173. clipPlane5: Nullable<Plane>;
  116174. /**
  116175. * Gets or sets the active clipplane 6
  116176. */
  116177. clipPlane6: Nullable<Plane>;
  116178. /**
  116179. * Gets or sets a boolean indicating if animations are enabled
  116180. */
  116181. animationsEnabled: boolean;
  116182. private _animationPropertiesOverride;
  116183. /**
  116184. * Gets or sets the animation properties override
  116185. */
  116186. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116187. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116188. /**
  116189. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116190. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116191. */
  116192. useConstantAnimationDeltaTime: boolean;
  116193. /**
  116194. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116195. * Please note that it requires to run a ray cast through the scene on every frame
  116196. */
  116197. constantlyUpdateMeshUnderPointer: boolean;
  116198. /**
  116199. * Defines the HTML cursor to use when hovering over interactive elements
  116200. */
  116201. hoverCursor: string;
  116202. /**
  116203. * Defines the HTML default cursor to use (empty by default)
  116204. */
  116205. defaultCursor: string;
  116206. /**
  116207. * Defines whether cursors are handled by the scene.
  116208. */
  116209. doNotHandleCursors: boolean;
  116210. /**
  116211. * This is used to call preventDefault() on pointer down
  116212. * in order to block unwanted artifacts like system double clicks
  116213. */
  116214. preventDefaultOnPointerDown: boolean;
  116215. /**
  116216. * This is used to call preventDefault() on pointer up
  116217. * in order to block unwanted artifacts like system double clicks
  116218. */
  116219. preventDefaultOnPointerUp: boolean;
  116220. /**
  116221. * Gets or sets user defined metadata
  116222. */
  116223. metadata: any;
  116224. /**
  116225. * For internal use only. Please do not use.
  116226. */
  116227. reservedDataStore: any;
  116228. /**
  116229. * Gets the name of the plugin used to load this scene (null by default)
  116230. */
  116231. loadingPluginName: string;
  116232. /**
  116233. * Use this array to add regular expressions used to disable offline support for specific urls
  116234. */
  116235. disableOfflineSupportExceptionRules: RegExp[];
  116236. /**
  116237. * An event triggered when the scene is disposed.
  116238. */
  116239. onDisposeObservable: Observable<Scene>;
  116240. private _onDisposeObserver;
  116241. /** Sets a function to be executed when this scene is disposed. */
  116242. set onDispose(callback: () => void);
  116243. /**
  116244. * An event triggered before rendering the scene (right after animations and physics)
  116245. */
  116246. onBeforeRenderObservable: Observable<Scene>;
  116247. private _onBeforeRenderObserver;
  116248. /** Sets a function to be executed before rendering this scene */
  116249. set beforeRender(callback: Nullable<() => void>);
  116250. /**
  116251. * An event triggered after rendering the scene
  116252. */
  116253. onAfterRenderObservable: Observable<Scene>;
  116254. /**
  116255. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  116256. */
  116257. onAfterRenderCameraObservable: Observable<Camera>;
  116258. private _onAfterRenderObserver;
  116259. /** Sets a function to be executed after rendering this scene */
  116260. set afterRender(callback: Nullable<() => void>);
  116261. /**
  116262. * An event triggered before animating the scene
  116263. */
  116264. onBeforeAnimationsObservable: Observable<Scene>;
  116265. /**
  116266. * An event triggered after animations processing
  116267. */
  116268. onAfterAnimationsObservable: Observable<Scene>;
  116269. /**
  116270. * An event triggered before draw calls are ready to be sent
  116271. */
  116272. onBeforeDrawPhaseObservable: Observable<Scene>;
  116273. /**
  116274. * An event triggered after draw calls have been sent
  116275. */
  116276. onAfterDrawPhaseObservable: Observable<Scene>;
  116277. /**
  116278. * An event triggered when the scene is ready
  116279. */
  116280. onReadyObservable: Observable<Scene>;
  116281. /**
  116282. * An event triggered before rendering a camera
  116283. */
  116284. onBeforeCameraRenderObservable: Observable<Camera>;
  116285. private _onBeforeCameraRenderObserver;
  116286. /** Sets a function to be executed before rendering a camera*/
  116287. set beforeCameraRender(callback: () => void);
  116288. /**
  116289. * An event triggered after rendering a camera
  116290. */
  116291. onAfterCameraRenderObservable: Observable<Camera>;
  116292. private _onAfterCameraRenderObserver;
  116293. /** Sets a function to be executed after rendering a camera*/
  116294. set afterCameraRender(callback: () => void);
  116295. /**
  116296. * An event triggered when active meshes evaluation is about to start
  116297. */
  116298. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  116299. /**
  116300. * An event triggered when active meshes evaluation is done
  116301. */
  116302. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  116303. /**
  116304. * An event triggered when particles rendering is about to start
  116305. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116306. */
  116307. onBeforeParticlesRenderingObservable: Observable<Scene>;
  116308. /**
  116309. * An event triggered when particles rendering is done
  116310. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  116311. */
  116312. onAfterParticlesRenderingObservable: Observable<Scene>;
  116313. /**
  116314. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  116315. */
  116316. onDataLoadedObservable: Observable<Scene>;
  116317. /**
  116318. * An event triggered when a camera is created
  116319. */
  116320. onNewCameraAddedObservable: Observable<Camera>;
  116321. /**
  116322. * An event triggered when a camera is removed
  116323. */
  116324. onCameraRemovedObservable: Observable<Camera>;
  116325. /**
  116326. * An event triggered when a light is created
  116327. */
  116328. onNewLightAddedObservable: Observable<Light>;
  116329. /**
  116330. * An event triggered when a light is removed
  116331. */
  116332. onLightRemovedObservable: Observable<Light>;
  116333. /**
  116334. * An event triggered when a geometry is created
  116335. */
  116336. onNewGeometryAddedObservable: Observable<Geometry>;
  116337. /**
  116338. * An event triggered when a geometry is removed
  116339. */
  116340. onGeometryRemovedObservable: Observable<Geometry>;
  116341. /**
  116342. * An event triggered when a transform node is created
  116343. */
  116344. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  116345. /**
  116346. * An event triggered when a transform node is removed
  116347. */
  116348. onTransformNodeRemovedObservable: Observable<TransformNode>;
  116349. /**
  116350. * An event triggered when a mesh is created
  116351. */
  116352. onNewMeshAddedObservable: Observable<AbstractMesh>;
  116353. /**
  116354. * An event triggered when a mesh is removed
  116355. */
  116356. onMeshRemovedObservable: Observable<AbstractMesh>;
  116357. /**
  116358. * An event triggered when a skeleton is created
  116359. */
  116360. onNewSkeletonAddedObservable: Observable<Skeleton>;
  116361. /**
  116362. * An event triggered when a skeleton is removed
  116363. */
  116364. onSkeletonRemovedObservable: Observable<Skeleton>;
  116365. /**
  116366. * An event triggered when a material is created
  116367. */
  116368. onNewMaterialAddedObservable: Observable<Material>;
  116369. /**
  116370. * An event triggered when a material is removed
  116371. */
  116372. onMaterialRemovedObservable: Observable<Material>;
  116373. /**
  116374. * An event triggered when a texture is created
  116375. */
  116376. onNewTextureAddedObservable: Observable<BaseTexture>;
  116377. /**
  116378. * An event triggered when a texture is removed
  116379. */
  116380. onTextureRemovedObservable: Observable<BaseTexture>;
  116381. /**
  116382. * An event triggered when render targets are about to be rendered
  116383. * Can happen multiple times per frame.
  116384. */
  116385. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  116386. /**
  116387. * An event triggered when render targets were rendered.
  116388. * Can happen multiple times per frame.
  116389. */
  116390. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  116391. /**
  116392. * An event triggered before calculating deterministic simulation step
  116393. */
  116394. onBeforeStepObservable: Observable<Scene>;
  116395. /**
  116396. * An event triggered after calculating deterministic simulation step
  116397. */
  116398. onAfterStepObservable: Observable<Scene>;
  116399. /**
  116400. * An event triggered when the activeCamera property is updated
  116401. */
  116402. onActiveCameraChanged: Observable<Scene>;
  116403. /**
  116404. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  116405. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116406. * 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)
  116407. */
  116408. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116409. /**
  116410. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  116411. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  116412. * 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)
  116413. */
  116414. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  116415. /**
  116416. * This Observable will when a mesh has been imported into the scene.
  116417. */
  116418. onMeshImportedObservable: Observable<AbstractMesh>;
  116419. /**
  116420. * This Observable will when an animation file has been imported into the scene.
  116421. */
  116422. onAnimationFileImportedObservable: Observable<Scene>;
  116423. /**
  116424. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  116425. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  116426. */
  116427. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  116428. /** @hidden */
  116429. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  116430. /**
  116431. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  116432. */
  116433. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  116434. /**
  116435. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  116436. */
  116437. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  116438. /**
  116439. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  116440. */
  116441. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  116442. /** Callback called when a pointer move is detected */
  116443. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116444. /** Callback called when a pointer down is detected */
  116445. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  116446. /** Callback called when a pointer up is detected */
  116447. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  116448. /** Callback called when a pointer pick is detected */
  116449. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  116450. /**
  116451. * 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).
  116452. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  116453. */
  116454. onPrePointerObservable: Observable<PointerInfoPre>;
  116455. /**
  116456. * Observable event triggered each time an input event is received from the rendering canvas
  116457. */
  116458. onPointerObservable: Observable<PointerInfo>;
  116459. /**
  116460. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  116461. */
  116462. get unTranslatedPointer(): Vector2;
  116463. /**
  116464. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  116465. */
  116466. static get DragMovementThreshold(): number;
  116467. static set DragMovementThreshold(value: number);
  116468. /**
  116469. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  116470. */
  116471. static get LongPressDelay(): number;
  116472. static set LongPressDelay(value: number);
  116473. /**
  116474. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  116475. */
  116476. static get DoubleClickDelay(): number;
  116477. static set DoubleClickDelay(value: number);
  116478. /** If you need to check double click without raising a single click at first click, enable this flag */
  116479. static get ExclusiveDoubleClickMode(): boolean;
  116480. static set ExclusiveDoubleClickMode(value: boolean);
  116481. /** @hidden */
  116482. _mirroredCameraPosition: Nullable<Vector3>;
  116483. /**
  116484. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  116485. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  116486. */
  116487. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  116488. /**
  116489. * Observable event triggered each time an keyboard event is received from the hosting window
  116490. */
  116491. onKeyboardObservable: Observable<KeyboardInfo>;
  116492. private _useRightHandedSystem;
  116493. /**
  116494. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  116495. */
  116496. set useRightHandedSystem(value: boolean);
  116497. get useRightHandedSystem(): boolean;
  116498. private _timeAccumulator;
  116499. private _currentStepId;
  116500. private _currentInternalStep;
  116501. /**
  116502. * Sets the step Id used by deterministic lock step
  116503. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116504. * @param newStepId defines the step Id
  116505. */
  116506. setStepId(newStepId: number): void;
  116507. /**
  116508. * Gets the step Id used by deterministic lock step
  116509. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116510. * @returns the step Id
  116511. */
  116512. getStepId(): number;
  116513. /**
  116514. * Gets the internal step used by deterministic lock step
  116515. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116516. * @returns the internal step
  116517. */
  116518. getInternalStep(): number;
  116519. private _fogEnabled;
  116520. /**
  116521. * Gets or sets a boolean indicating if fog is enabled on this scene
  116522. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116523. * (Default is true)
  116524. */
  116525. set fogEnabled(value: boolean);
  116526. get fogEnabled(): boolean;
  116527. private _fogMode;
  116528. /**
  116529. * Gets or sets the fog mode to use
  116530. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116531. * | mode | value |
  116532. * | --- | --- |
  116533. * | FOGMODE_NONE | 0 |
  116534. * | FOGMODE_EXP | 1 |
  116535. * | FOGMODE_EXP2 | 2 |
  116536. * | FOGMODE_LINEAR | 3 |
  116537. */
  116538. set fogMode(value: number);
  116539. get fogMode(): number;
  116540. /**
  116541. * Gets or sets the fog color to use
  116542. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116543. * (Default is Color3(0.2, 0.2, 0.3))
  116544. */
  116545. fogColor: Color3;
  116546. /**
  116547. * Gets or sets the fog density to use
  116548. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116549. * (Default is 0.1)
  116550. */
  116551. fogDensity: number;
  116552. /**
  116553. * Gets or sets the fog start distance to use
  116554. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116555. * (Default is 0)
  116556. */
  116557. fogStart: number;
  116558. /**
  116559. * Gets or sets the fog end distance to use
  116560. * @see http://doc.babylonjs.com/babylon101/environment#fog
  116561. * (Default is 1000)
  116562. */
  116563. fogEnd: number;
  116564. private _shadowsEnabled;
  116565. /**
  116566. * Gets or sets a boolean indicating if shadows are enabled on this scene
  116567. */
  116568. set shadowsEnabled(value: boolean);
  116569. get shadowsEnabled(): boolean;
  116570. private _lightsEnabled;
  116571. /**
  116572. * Gets or sets a boolean indicating if lights are enabled on this scene
  116573. */
  116574. set lightsEnabled(value: boolean);
  116575. get lightsEnabled(): boolean;
  116576. /** All of the active cameras added to this scene. */
  116577. activeCameras: Camera[];
  116578. /** @hidden */
  116579. _activeCamera: Nullable<Camera>;
  116580. /** Gets or sets the current active camera */
  116581. get activeCamera(): Nullable<Camera>;
  116582. set activeCamera(value: Nullable<Camera>);
  116583. private _defaultMaterial;
  116584. /** The default material used on meshes when no material is affected */
  116585. get defaultMaterial(): Material;
  116586. /** The default material used on meshes when no material is affected */
  116587. set defaultMaterial(value: Material);
  116588. private _texturesEnabled;
  116589. /**
  116590. * Gets or sets a boolean indicating if textures are enabled on this scene
  116591. */
  116592. set texturesEnabled(value: boolean);
  116593. get texturesEnabled(): boolean;
  116594. /**
  116595. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  116596. */
  116597. physicsEnabled: boolean;
  116598. /**
  116599. * Gets or sets a boolean indicating if particles are enabled on this scene
  116600. */
  116601. particlesEnabled: boolean;
  116602. /**
  116603. * Gets or sets a boolean indicating if sprites are enabled on this scene
  116604. */
  116605. spritesEnabled: boolean;
  116606. private _skeletonsEnabled;
  116607. /**
  116608. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  116609. */
  116610. set skeletonsEnabled(value: boolean);
  116611. get skeletonsEnabled(): boolean;
  116612. /**
  116613. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  116614. */
  116615. lensFlaresEnabled: boolean;
  116616. /**
  116617. * Gets or sets a boolean indicating if collisions are enabled on this scene
  116618. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116619. */
  116620. collisionsEnabled: boolean;
  116621. private _collisionCoordinator;
  116622. /** @hidden */
  116623. get collisionCoordinator(): ICollisionCoordinator;
  116624. /**
  116625. * Defines the gravity applied to this scene (used only for collisions)
  116626. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116627. */
  116628. gravity: Vector3;
  116629. /**
  116630. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  116631. */
  116632. postProcessesEnabled: boolean;
  116633. /**
  116634. * The list of postprocesses added to the scene
  116635. */
  116636. postProcesses: PostProcess[];
  116637. /**
  116638. * Gets the current postprocess manager
  116639. */
  116640. postProcessManager: PostProcessManager;
  116641. /**
  116642. * Gets or sets a boolean indicating if render targets are enabled on this scene
  116643. */
  116644. renderTargetsEnabled: boolean;
  116645. /**
  116646. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  116647. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  116648. */
  116649. dumpNextRenderTargets: boolean;
  116650. /**
  116651. * The list of user defined render targets added to the scene
  116652. */
  116653. customRenderTargets: RenderTargetTexture[];
  116654. /**
  116655. * Defines if texture loading must be delayed
  116656. * If true, textures will only be loaded when they need to be rendered
  116657. */
  116658. useDelayedTextureLoading: boolean;
  116659. /**
  116660. * Gets the list of meshes imported to the scene through SceneLoader
  116661. */
  116662. importedMeshesFiles: String[];
  116663. /**
  116664. * Gets or sets a boolean indicating if probes are enabled on this scene
  116665. */
  116666. probesEnabled: boolean;
  116667. /**
  116668. * Gets or sets the current offline provider to use to store scene data
  116669. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116670. */
  116671. offlineProvider: IOfflineProvider;
  116672. /**
  116673. * Gets or sets the action manager associated with the scene
  116674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  116675. */
  116676. actionManager: AbstractActionManager;
  116677. private _meshesForIntersections;
  116678. /**
  116679. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  116680. */
  116681. proceduralTexturesEnabled: boolean;
  116682. private _engine;
  116683. private _totalVertices;
  116684. /** @hidden */
  116685. _activeIndices: PerfCounter;
  116686. /** @hidden */
  116687. _activeParticles: PerfCounter;
  116688. /** @hidden */
  116689. _activeBones: PerfCounter;
  116690. private _animationRatio;
  116691. /** @hidden */
  116692. _animationTimeLast: number;
  116693. /** @hidden */
  116694. _animationTime: number;
  116695. /**
  116696. * Gets or sets a general scale for animation speed
  116697. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  116698. */
  116699. animationTimeScale: number;
  116700. /** @hidden */
  116701. _cachedMaterial: Nullable<Material>;
  116702. /** @hidden */
  116703. _cachedEffect: Nullable<Effect>;
  116704. /** @hidden */
  116705. _cachedVisibility: Nullable<number>;
  116706. private _renderId;
  116707. private _frameId;
  116708. private _executeWhenReadyTimeoutId;
  116709. private _intermediateRendering;
  116710. private _viewUpdateFlag;
  116711. private _projectionUpdateFlag;
  116712. /** @hidden */
  116713. _toBeDisposed: Nullable<IDisposable>[];
  116714. private _activeRequests;
  116715. /** @hidden */
  116716. _pendingData: any[];
  116717. private _isDisposed;
  116718. /**
  116719. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  116720. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  116721. */
  116722. dispatchAllSubMeshesOfActiveMeshes: boolean;
  116723. private _activeMeshes;
  116724. private _processedMaterials;
  116725. private _renderTargets;
  116726. /** @hidden */
  116727. _activeParticleSystems: SmartArray<IParticleSystem>;
  116728. private _activeSkeletons;
  116729. private _softwareSkinnedMeshes;
  116730. private _renderingManager;
  116731. /** @hidden */
  116732. _activeAnimatables: Animatable[];
  116733. private _transformMatrix;
  116734. private _sceneUbo;
  116735. /** @hidden */
  116736. _viewMatrix: Matrix;
  116737. private _projectionMatrix;
  116738. /** @hidden */
  116739. _forcedViewPosition: Nullable<Vector3>;
  116740. /** @hidden */
  116741. _frustumPlanes: Plane[];
  116742. /**
  116743. * Gets the list of frustum planes (built from the active camera)
  116744. */
  116745. get frustumPlanes(): Plane[];
  116746. /**
  116747. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  116748. * This is useful if there are more lights that the maximum simulteanous authorized
  116749. */
  116750. requireLightSorting: boolean;
  116751. /** @hidden */
  116752. readonly useMaterialMeshMap: boolean;
  116753. /** @hidden */
  116754. readonly useClonedMeshMap: boolean;
  116755. private _externalData;
  116756. private _uid;
  116757. /**
  116758. * @hidden
  116759. * Backing store of defined scene components.
  116760. */
  116761. _components: ISceneComponent[];
  116762. /**
  116763. * @hidden
  116764. * Backing store of defined scene components.
  116765. */
  116766. _serializableComponents: ISceneSerializableComponent[];
  116767. /**
  116768. * List of components to register on the next registration step.
  116769. */
  116770. private _transientComponents;
  116771. /**
  116772. * Registers the transient components if needed.
  116773. */
  116774. private _registerTransientComponents;
  116775. /**
  116776. * @hidden
  116777. * Add a component to the scene.
  116778. * Note that the ccomponent could be registered on th next frame if this is called after
  116779. * the register component stage.
  116780. * @param component Defines the component to add to the scene
  116781. */
  116782. _addComponent(component: ISceneComponent): void;
  116783. /**
  116784. * @hidden
  116785. * Gets a component from the scene.
  116786. * @param name defines the name of the component to retrieve
  116787. * @returns the component or null if not present
  116788. */
  116789. _getComponent(name: string): Nullable<ISceneComponent>;
  116790. /**
  116791. * @hidden
  116792. * Defines the actions happening before camera updates.
  116793. */
  116794. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  116795. /**
  116796. * @hidden
  116797. * Defines the actions happening before clear the canvas.
  116798. */
  116799. _beforeClearStage: Stage<SimpleStageAction>;
  116800. /**
  116801. * @hidden
  116802. * Defines the actions when collecting render targets for the frame.
  116803. */
  116804. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116805. /**
  116806. * @hidden
  116807. * Defines the actions happening for one camera in the frame.
  116808. */
  116809. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  116810. /**
  116811. * @hidden
  116812. * Defines the actions happening during the per mesh ready checks.
  116813. */
  116814. _isReadyForMeshStage: Stage<MeshStageAction>;
  116815. /**
  116816. * @hidden
  116817. * Defines the actions happening before evaluate active mesh checks.
  116818. */
  116819. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  116820. /**
  116821. * @hidden
  116822. * Defines the actions happening during the evaluate sub mesh checks.
  116823. */
  116824. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  116825. /**
  116826. * @hidden
  116827. * Defines the actions happening during the active mesh stage.
  116828. */
  116829. _activeMeshStage: Stage<ActiveMeshStageAction>;
  116830. /**
  116831. * @hidden
  116832. * Defines the actions happening during the per camera render target step.
  116833. */
  116834. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  116835. /**
  116836. * @hidden
  116837. * Defines the actions happening just before the active camera is drawing.
  116838. */
  116839. _beforeCameraDrawStage: Stage<CameraStageAction>;
  116840. /**
  116841. * @hidden
  116842. * Defines the actions happening just before a render target is drawing.
  116843. */
  116844. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116845. /**
  116846. * @hidden
  116847. * Defines the actions happening just before a rendering group is drawing.
  116848. */
  116849. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116850. /**
  116851. * @hidden
  116852. * Defines the actions happening just before a mesh is drawing.
  116853. */
  116854. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116855. /**
  116856. * @hidden
  116857. * Defines the actions happening just after a mesh has been drawn.
  116858. */
  116859. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  116860. /**
  116861. * @hidden
  116862. * Defines the actions happening just after a rendering group has been drawn.
  116863. */
  116864. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  116865. /**
  116866. * @hidden
  116867. * Defines the actions happening just after the active camera has been drawn.
  116868. */
  116869. _afterCameraDrawStage: Stage<CameraStageAction>;
  116870. /**
  116871. * @hidden
  116872. * Defines the actions happening just after a render target has been drawn.
  116873. */
  116874. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  116875. /**
  116876. * @hidden
  116877. * Defines the actions happening just after rendering all cameras and computing intersections.
  116878. */
  116879. _afterRenderStage: Stage<SimpleStageAction>;
  116880. /**
  116881. * @hidden
  116882. * Defines the actions happening when a pointer move event happens.
  116883. */
  116884. _pointerMoveStage: Stage<PointerMoveStageAction>;
  116885. /**
  116886. * @hidden
  116887. * Defines the actions happening when a pointer down event happens.
  116888. */
  116889. _pointerDownStage: Stage<PointerUpDownStageAction>;
  116890. /**
  116891. * @hidden
  116892. * Defines the actions happening when a pointer up event happens.
  116893. */
  116894. _pointerUpStage: Stage<PointerUpDownStageAction>;
  116895. /**
  116896. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  116897. */
  116898. private geometriesByUniqueId;
  116899. /**
  116900. * Creates a new Scene
  116901. * @param engine defines the engine to use to render this scene
  116902. * @param options defines the scene options
  116903. */
  116904. constructor(engine: Engine, options?: SceneOptions);
  116905. /**
  116906. * Gets a string idenfifying the name of the class
  116907. * @returns "Scene" string
  116908. */
  116909. getClassName(): string;
  116910. private _defaultMeshCandidates;
  116911. /**
  116912. * @hidden
  116913. */
  116914. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116915. private _defaultSubMeshCandidates;
  116916. /**
  116917. * @hidden
  116918. */
  116919. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116920. /**
  116921. * Sets the default candidate providers for the scene.
  116922. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  116923. * and getCollidingSubMeshCandidates to their default function
  116924. */
  116925. setDefaultCandidateProviders(): void;
  116926. /**
  116927. * Gets the mesh that is currently under the pointer
  116928. */
  116929. get meshUnderPointer(): Nullable<AbstractMesh>;
  116930. /**
  116931. * Gets or sets the current on-screen X position of the pointer
  116932. */
  116933. get pointerX(): number;
  116934. set pointerX(value: number);
  116935. /**
  116936. * Gets or sets the current on-screen Y position of the pointer
  116937. */
  116938. get pointerY(): number;
  116939. set pointerY(value: number);
  116940. /**
  116941. * Gets the cached material (ie. the latest rendered one)
  116942. * @returns the cached material
  116943. */
  116944. getCachedMaterial(): Nullable<Material>;
  116945. /**
  116946. * Gets the cached effect (ie. the latest rendered one)
  116947. * @returns the cached effect
  116948. */
  116949. getCachedEffect(): Nullable<Effect>;
  116950. /**
  116951. * Gets the cached visibility state (ie. the latest rendered one)
  116952. * @returns the cached visibility state
  116953. */
  116954. getCachedVisibility(): Nullable<number>;
  116955. /**
  116956. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  116957. * @param material defines the current material
  116958. * @param effect defines the current effect
  116959. * @param visibility defines the current visibility state
  116960. * @returns true if one parameter is not cached
  116961. */
  116962. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  116963. /**
  116964. * Gets the engine associated with the scene
  116965. * @returns an Engine
  116966. */
  116967. getEngine(): Engine;
  116968. /**
  116969. * Gets the total number of vertices rendered per frame
  116970. * @returns the total number of vertices rendered per frame
  116971. */
  116972. getTotalVertices(): number;
  116973. /**
  116974. * Gets the performance counter for total vertices
  116975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116976. */
  116977. get totalVerticesPerfCounter(): PerfCounter;
  116978. /**
  116979. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  116980. * @returns the total number of active indices rendered per frame
  116981. */
  116982. getActiveIndices(): number;
  116983. /**
  116984. * Gets the performance counter for active indices
  116985. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116986. */
  116987. get totalActiveIndicesPerfCounter(): PerfCounter;
  116988. /**
  116989. * Gets the total number of active particles rendered per frame
  116990. * @returns the total number of active particles rendered per frame
  116991. */
  116992. getActiveParticles(): number;
  116993. /**
  116994. * Gets the performance counter for active particles
  116995. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  116996. */
  116997. get activeParticlesPerfCounter(): PerfCounter;
  116998. /**
  116999. * Gets the total number of active bones rendered per frame
  117000. * @returns the total number of active bones rendered per frame
  117001. */
  117002. getActiveBones(): number;
  117003. /**
  117004. * Gets the performance counter for active bones
  117005. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117006. */
  117007. get activeBonesPerfCounter(): PerfCounter;
  117008. /**
  117009. * Gets the array of active meshes
  117010. * @returns an array of AbstractMesh
  117011. */
  117012. getActiveMeshes(): SmartArray<AbstractMesh>;
  117013. /**
  117014. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117015. * @returns a number
  117016. */
  117017. getAnimationRatio(): number;
  117018. /**
  117019. * Gets an unique Id for the current render phase
  117020. * @returns a number
  117021. */
  117022. getRenderId(): number;
  117023. /**
  117024. * Gets an unique Id for the current frame
  117025. * @returns a number
  117026. */
  117027. getFrameId(): number;
  117028. /** Call this function if you want to manually increment the render Id*/
  117029. incrementRenderId(): void;
  117030. private _createUbo;
  117031. /**
  117032. * Use this method to simulate a pointer move on a mesh
  117033. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117034. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117035. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117036. * @returns the current scene
  117037. */
  117038. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117039. /**
  117040. * Use this method to simulate a pointer down on a mesh
  117041. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117042. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117043. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117044. * @returns the current scene
  117045. */
  117046. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117047. /**
  117048. * Use this method to simulate a pointer up on a mesh
  117049. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117050. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117051. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117052. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117053. * @returns the current scene
  117054. */
  117055. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117056. /**
  117057. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117058. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117059. * @returns true if the pointer was captured
  117060. */
  117061. isPointerCaptured(pointerId?: number): boolean;
  117062. /**
  117063. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117064. * @param attachUp defines if you want to attach events to pointerup
  117065. * @param attachDown defines if you want to attach events to pointerdown
  117066. * @param attachMove defines if you want to attach events to pointermove
  117067. */
  117068. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117069. /** Detaches all event handlers*/
  117070. detachControl(): void;
  117071. /**
  117072. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117073. * Delay loaded resources are not taking in account
  117074. * @return true if all required resources are ready
  117075. */
  117076. isReady(): boolean;
  117077. /** Resets all cached information relative to material (including effect and visibility) */
  117078. resetCachedMaterial(): void;
  117079. /**
  117080. * Registers a function to be called before every frame render
  117081. * @param func defines the function to register
  117082. */
  117083. registerBeforeRender(func: () => void): void;
  117084. /**
  117085. * Unregisters a function called before every frame render
  117086. * @param func defines the function to unregister
  117087. */
  117088. unregisterBeforeRender(func: () => void): void;
  117089. /**
  117090. * Registers a function to be called after every frame render
  117091. * @param func defines the function to register
  117092. */
  117093. registerAfterRender(func: () => void): void;
  117094. /**
  117095. * Unregisters a function called after every frame render
  117096. * @param func defines the function to unregister
  117097. */
  117098. unregisterAfterRender(func: () => void): void;
  117099. private _executeOnceBeforeRender;
  117100. /**
  117101. * The provided function will run before render once and will be disposed afterwards.
  117102. * A timeout delay can be provided so that the function will be executed in N ms.
  117103. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117104. * @param func The function to be executed.
  117105. * @param timeout optional delay in ms
  117106. */
  117107. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117108. /** @hidden */
  117109. _addPendingData(data: any): void;
  117110. /** @hidden */
  117111. _removePendingData(data: any): void;
  117112. /**
  117113. * Returns the number of items waiting to be loaded
  117114. * @returns the number of items waiting to be loaded
  117115. */
  117116. getWaitingItemsCount(): number;
  117117. /**
  117118. * Returns a boolean indicating if the scene is still loading data
  117119. */
  117120. get isLoading(): boolean;
  117121. /**
  117122. * Registers a function to be executed when the scene is ready
  117123. * @param {Function} func - the function to be executed
  117124. */
  117125. executeWhenReady(func: () => void): void;
  117126. /**
  117127. * Returns a promise that resolves when the scene is ready
  117128. * @returns A promise that resolves when the scene is ready
  117129. */
  117130. whenReadyAsync(): Promise<void>;
  117131. /** @hidden */
  117132. _checkIsReady(): void;
  117133. /**
  117134. * Gets all animatable attached to the scene
  117135. */
  117136. get animatables(): Animatable[];
  117137. /**
  117138. * Resets the last animation time frame.
  117139. * Useful to override when animations start running when loading a scene for the first time.
  117140. */
  117141. resetLastAnimationTimeFrame(): void;
  117142. /**
  117143. * Gets the current view matrix
  117144. * @returns a Matrix
  117145. */
  117146. getViewMatrix(): Matrix;
  117147. /**
  117148. * Gets the current projection matrix
  117149. * @returns a Matrix
  117150. */
  117151. getProjectionMatrix(): Matrix;
  117152. /**
  117153. * Gets the current transform matrix
  117154. * @returns a Matrix made of View * Projection
  117155. */
  117156. getTransformMatrix(): Matrix;
  117157. /**
  117158. * Sets the current transform matrix
  117159. * @param viewL defines the View matrix to use
  117160. * @param projectionL defines the Projection matrix to use
  117161. * @param viewR defines the right View matrix to use (if provided)
  117162. * @param projectionR defines the right Projection matrix to use (if provided)
  117163. */
  117164. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117165. /**
  117166. * Gets the uniform buffer used to store scene data
  117167. * @returns a UniformBuffer
  117168. */
  117169. getSceneUniformBuffer(): UniformBuffer;
  117170. /**
  117171. * Gets an unique (relatively to the current scene) Id
  117172. * @returns an unique number for the scene
  117173. */
  117174. getUniqueId(): number;
  117175. /**
  117176. * Add a mesh to the list of scene's meshes
  117177. * @param newMesh defines the mesh to add
  117178. * @param recursive if all child meshes should also be added to the scene
  117179. */
  117180. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117181. /**
  117182. * Remove a mesh for the list of scene's meshes
  117183. * @param toRemove defines the mesh to remove
  117184. * @param recursive if all child meshes should also be removed from the scene
  117185. * @returns the index where the mesh was in the mesh list
  117186. */
  117187. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117188. /**
  117189. * Add a transform node to the list of scene's transform nodes
  117190. * @param newTransformNode defines the transform node to add
  117191. */
  117192. addTransformNode(newTransformNode: TransformNode): void;
  117193. /**
  117194. * Remove a transform node for the list of scene's transform nodes
  117195. * @param toRemove defines the transform node to remove
  117196. * @returns the index where the transform node was in the transform node list
  117197. */
  117198. removeTransformNode(toRemove: TransformNode): number;
  117199. /**
  117200. * Remove a skeleton for the list of scene's skeletons
  117201. * @param toRemove defines the skeleton to remove
  117202. * @returns the index where the skeleton was in the skeleton list
  117203. */
  117204. removeSkeleton(toRemove: Skeleton): number;
  117205. /**
  117206. * Remove a morph target for the list of scene's morph targets
  117207. * @param toRemove defines the morph target to remove
  117208. * @returns the index where the morph target was in the morph target list
  117209. */
  117210. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117211. /**
  117212. * Remove a light for the list of scene's lights
  117213. * @param toRemove defines the light to remove
  117214. * @returns the index where the light was in the light list
  117215. */
  117216. removeLight(toRemove: Light): number;
  117217. /**
  117218. * Remove a camera for the list of scene's cameras
  117219. * @param toRemove defines the camera to remove
  117220. * @returns the index where the camera was in the camera list
  117221. */
  117222. removeCamera(toRemove: Camera): number;
  117223. /**
  117224. * Remove a particle system for the list of scene's particle systems
  117225. * @param toRemove defines the particle system to remove
  117226. * @returns the index where the particle system was in the particle system list
  117227. */
  117228. removeParticleSystem(toRemove: IParticleSystem): number;
  117229. /**
  117230. * Remove a animation for the list of scene's animations
  117231. * @param toRemove defines the animation to remove
  117232. * @returns the index where the animation was in the animation list
  117233. */
  117234. removeAnimation(toRemove: Animation): number;
  117235. /**
  117236. * Will stop the animation of the given target
  117237. * @param target - the target
  117238. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  117239. * @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)
  117240. */
  117241. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  117242. /**
  117243. * Removes the given animation group from this scene.
  117244. * @param toRemove The animation group to remove
  117245. * @returns The index of the removed animation group
  117246. */
  117247. removeAnimationGroup(toRemove: AnimationGroup): number;
  117248. /**
  117249. * Removes the given multi-material from this scene.
  117250. * @param toRemove The multi-material to remove
  117251. * @returns The index of the removed multi-material
  117252. */
  117253. removeMultiMaterial(toRemove: MultiMaterial): number;
  117254. /**
  117255. * Removes the given material from this scene.
  117256. * @param toRemove The material to remove
  117257. * @returns The index of the removed material
  117258. */
  117259. removeMaterial(toRemove: Material): number;
  117260. /**
  117261. * Removes the given action manager from this scene.
  117262. * @param toRemove The action manager to remove
  117263. * @returns The index of the removed action manager
  117264. */
  117265. removeActionManager(toRemove: AbstractActionManager): number;
  117266. /**
  117267. * Removes the given texture from this scene.
  117268. * @param toRemove The texture to remove
  117269. * @returns The index of the removed texture
  117270. */
  117271. removeTexture(toRemove: BaseTexture): number;
  117272. /**
  117273. * Adds the given light to this scene
  117274. * @param newLight The light to add
  117275. */
  117276. addLight(newLight: Light): void;
  117277. /**
  117278. * Sorts the list list based on light priorities
  117279. */
  117280. sortLightsByPriority(): void;
  117281. /**
  117282. * Adds the given camera to this scene
  117283. * @param newCamera The camera to add
  117284. */
  117285. addCamera(newCamera: Camera): void;
  117286. /**
  117287. * Adds the given skeleton to this scene
  117288. * @param newSkeleton The skeleton to add
  117289. */
  117290. addSkeleton(newSkeleton: Skeleton): void;
  117291. /**
  117292. * Adds the given particle system to this scene
  117293. * @param newParticleSystem The particle system to add
  117294. */
  117295. addParticleSystem(newParticleSystem: IParticleSystem): void;
  117296. /**
  117297. * Adds the given animation to this scene
  117298. * @param newAnimation The animation to add
  117299. */
  117300. addAnimation(newAnimation: Animation): void;
  117301. /**
  117302. * Adds the given animation group to this scene.
  117303. * @param newAnimationGroup The animation group to add
  117304. */
  117305. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  117306. /**
  117307. * Adds the given multi-material to this scene
  117308. * @param newMultiMaterial The multi-material to add
  117309. */
  117310. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  117311. /**
  117312. * Adds the given material to this scene
  117313. * @param newMaterial The material to add
  117314. */
  117315. addMaterial(newMaterial: Material): void;
  117316. /**
  117317. * Adds the given morph target to this scene
  117318. * @param newMorphTargetManager The morph target to add
  117319. */
  117320. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  117321. /**
  117322. * Adds the given geometry to this scene
  117323. * @param newGeometry The geometry to add
  117324. */
  117325. addGeometry(newGeometry: Geometry): void;
  117326. /**
  117327. * Adds the given action manager to this scene
  117328. * @param newActionManager The action manager to add
  117329. */
  117330. addActionManager(newActionManager: AbstractActionManager): void;
  117331. /**
  117332. * Adds the given texture to this scene.
  117333. * @param newTexture The texture to add
  117334. */
  117335. addTexture(newTexture: BaseTexture): void;
  117336. /**
  117337. * Switch active camera
  117338. * @param newCamera defines the new active camera
  117339. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  117340. */
  117341. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  117342. /**
  117343. * sets the active camera of the scene using its ID
  117344. * @param id defines the camera's ID
  117345. * @return the new active camera or null if none found.
  117346. */
  117347. setActiveCameraByID(id: string): Nullable<Camera>;
  117348. /**
  117349. * sets the active camera of the scene using its name
  117350. * @param name defines the camera's name
  117351. * @returns the new active camera or null if none found.
  117352. */
  117353. setActiveCameraByName(name: string): Nullable<Camera>;
  117354. /**
  117355. * get an animation group using its name
  117356. * @param name defines the material's name
  117357. * @return the animation group or null if none found.
  117358. */
  117359. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  117360. /**
  117361. * Get a material using its unique id
  117362. * @param uniqueId defines the material's unique id
  117363. * @return the material or null if none found.
  117364. */
  117365. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  117366. /**
  117367. * get a material using its id
  117368. * @param id defines the material's ID
  117369. * @return the material or null if none found.
  117370. */
  117371. getMaterialByID(id: string): Nullable<Material>;
  117372. /**
  117373. * Gets a the last added material using a given id
  117374. * @param id defines the material's ID
  117375. * @return the last material with the given id or null if none found.
  117376. */
  117377. getLastMaterialByID(id: string): Nullable<Material>;
  117378. /**
  117379. * Gets a material using its name
  117380. * @param name defines the material's name
  117381. * @return the material or null if none found.
  117382. */
  117383. getMaterialByName(name: string): Nullable<Material>;
  117384. /**
  117385. * Get a texture using its unique id
  117386. * @param uniqueId defines the texture's unique id
  117387. * @return the texture or null if none found.
  117388. */
  117389. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  117390. /**
  117391. * Gets a camera using its id
  117392. * @param id defines the id to look for
  117393. * @returns the camera or null if not found
  117394. */
  117395. getCameraByID(id: string): Nullable<Camera>;
  117396. /**
  117397. * Gets a camera using its unique id
  117398. * @param uniqueId defines the unique id to look for
  117399. * @returns the camera or null if not found
  117400. */
  117401. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  117402. /**
  117403. * Gets a camera using its name
  117404. * @param name defines the camera's name
  117405. * @return the camera or null if none found.
  117406. */
  117407. getCameraByName(name: string): Nullable<Camera>;
  117408. /**
  117409. * Gets a bone using its id
  117410. * @param id defines the bone's id
  117411. * @return the bone or null if not found
  117412. */
  117413. getBoneByID(id: string): Nullable<Bone>;
  117414. /**
  117415. * Gets a bone using its id
  117416. * @param name defines the bone's name
  117417. * @return the bone or null if not found
  117418. */
  117419. getBoneByName(name: string): Nullable<Bone>;
  117420. /**
  117421. * Gets a light node using its name
  117422. * @param name defines the the light's name
  117423. * @return the light or null if none found.
  117424. */
  117425. getLightByName(name: string): Nullable<Light>;
  117426. /**
  117427. * Gets a light node using its id
  117428. * @param id defines the light's id
  117429. * @return the light or null if none found.
  117430. */
  117431. getLightByID(id: string): Nullable<Light>;
  117432. /**
  117433. * Gets a light node using its scene-generated unique ID
  117434. * @param uniqueId defines the light's unique id
  117435. * @return the light or null if none found.
  117436. */
  117437. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  117438. /**
  117439. * Gets a particle system by id
  117440. * @param id defines the particle system id
  117441. * @return the corresponding system or null if none found
  117442. */
  117443. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  117444. /**
  117445. * Gets a geometry using its ID
  117446. * @param id defines the geometry's id
  117447. * @return the geometry or null if none found.
  117448. */
  117449. getGeometryByID(id: string): Nullable<Geometry>;
  117450. private _getGeometryByUniqueID;
  117451. /**
  117452. * Add a new geometry to this scene
  117453. * @param geometry defines the geometry to be added to the scene.
  117454. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  117455. * @return a boolean defining if the geometry was added or not
  117456. */
  117457. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  117458. /**
  117459. * Removes an existing geometry
  117460. * @param geometry defines the geometry to be removed from the scene
  117461. * @return a boolean defining if the geometry was removed or not
  117462. */
  117463. removeGeometry(geometry: Geometry): boolean;
  117464. /**
  117465. * Gets the list of geometries attached to the scene
  117466. * @returns an array of Geometry
  117467. */
  117468. getGeometries(): Geometry[];
  117469. /**
  117470. * Gets the first added mesh found of a given ID
  117471. * @param id defines the id to search for
  117472. * @return the mesh found or null if not found at all
  117473. */
  117474. getMeshByID(id: string): Nullable<AbstractMesh>;
  117475. /**
  117476. * Gets a list of meshes using their id
  117477. * @param id defines the id to search for
  117478. * @returns a list of meshes
  117479. */
  117480. getMeshesByID(id: string): Array<AbstractMesh>;
  117481. /**
  117482. * Gets the first added transform node found of a given ID
  117483. * @param id defines the id to search for
  117484. * @return the found transform node or null if not found at all.
  117485. */
  117486. getTransformNodeByID(id: string): Nullable<TransformNode>;
  117487. /**
  117488. * Gets a transform node with its auto-generated unique id
  117489. * @param uniqueId efines the unique id to search for
  117490. * @return the found transform node or null if not found at all.
  117491. */
  117492. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  117493. /**
  117494. * Gets a list of transform nodes using their id
  117495. * @param id defines the id to search for
  117496. * @returns a list of transform nodes
  117497. */
  117498. getTransformNodesByID(id: string): Array<TransformNode>;
  117499. /**
  117500. * Gets a mesh with its auto-generated unique id
  117501. * @param uniqueId defines the unique id to search for
  117502. * @return the found mesh or null if not found at all.
  117503. */
  117504. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  117505. /**
  117506. * Gets a the last added mesh using a given id
  117507. * @param id defines the id to search for
  117508. * @return the found mesh or null if not found at all.
  117509. */
  117510. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  117511. /**
  117512. * Gets a the last added node (Mesh, Camera, Light) using a given id
  117513. * @param id defines the id to search for
  117514. * @return the found node or null if not found at all
  117515. */
  117516. getLastEntryByID(id: string): Nullable<Node>;
  117517. /**
  117518. * Gets a node (Mesh, Camera, Light) using a given id
  117519. * @param id defines the id to search for
  117520. * @return the found node or null if not found at all
  117521. */
  117522. getNodeByID(id: string): Nullable<Node>;
  117523. /**
  117524. * Gets a node (Mesh, Camera, Light) using a given name
  117525. * @param name defines the name to search for
  117526. * @return the found node or null if not found at all.
  117527. */
  117528. getNodeByName(name: string): Nullable<Node>;
  117529. /**
  117530. * Gets a mesh using a given name
  117531. * @param name defines the name to search for
  117532. * @return the found mesh or null if not found at all.
  117533. */
  117534. getMeshByName(name: string): Nullable<AbstractMesh>;
  117535. /**
  117536. * Gets a transform node using a given name
  117537. * @param name defines the name to search for
  117538. * @return the found transform node or null if not found at all.
  117539. */
  117540. getTransformNodeByName(name: string): Nullable<TransformNode>;
  117541. /**
  117542. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  117543. * @param id defines the id to search for
  117544. * @return the found skeleton or null if not found at all.
  117545. */
  117546. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  117547. /**
  117548. * Gets a skeleton using a given auto generated unique id
  117549. * @param uniqueId defines the unique id to search for
  117550. * @return the found skeleton or null if not found at all.
  117551. */
  117552. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  117553. /**
  117554. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  117555. * @param id defines the id to search for
  117556. * @return the found skeleton or null if not found at all.
  117557. */
  117558. getSkeletonById(id: string): Nullable<Skeleton>;
  117559. /**
  117560. * Gets a skeleton using a given name
  117561. * @param name defines the name to search for
  117562. * @return the found skeleton or null if not found at all.
  117563. */
  117564. getSkeletonByName(name: string): Nullable<Skeleton>;
  117565. /**
  117566. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  117567. * @param id defines the id to search for
  117568. * @return the found morph target manager or null if not found at all.
  117569. */
  117570. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  117571. /**
  117572. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  117573. * @param id defines the id to search for
  117574. * @return the found morph target or null if not found at all.
  117575. */
  117576. getMorphTargetById(id: string): Nullable<MorphTarget>;
  117577. /**
  117578. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  117579. * @param name defines the name to search for
  117580. * @return the found morph target or null if not found at all.
  117581. */
  117582. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  117583. /**
  117584. * Gets a boolean indicating if the given mesh is active
  117585. * @param mesh defines the mesh to look for
  117586. * @returns true if the mesh is in the active list
  117587. */
  117588. isActiveMesh(mesh: AbstractMesh): boolean;
  117589. /**
  117590. * Return a unique id as a string which can serve as an identifier for the scene
  117591. */
  117592. get uid(): string;
  117593. /**
  117594. * Add an externaly attached data from its key.
  117595. * This method call will fail and return false, if such key already exists.
  117596. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  117597. * @param key the unique key that identifies the data
  117598. * @param data the data object to associate to the key for this Engine instance
  117599. * @return true if no such key were already present and the data was added successfully, false otherwise
  117600. */
  117601. addExternalData<T>(key: string, data: T): boolean;
  117602. /**
  117603. * Get an externaly attached data from its key
  117604. * @param key the unique key that identifies the data
  117605. * @return the associated data, if present (can be null), or undefined if not present
  117606. */
  117607. getExternalData<T>(key: string): Nullable<T>;
  117608. /**
  117609. * Get an externaly attached data from its key, create it using a factory if it's not already present
  117610. * @param key the unique key that identifies the data
  117611. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  117612. * @return the associated data, can be null if the factory returned null.
  117613. */
  117614. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  117615. /**
  117616. * Remove an externaly attached data from the Engine instance
  117617. * @param key the unique key that identifies the data
  117618. * @return true if the data was successfully removed, false if it doesn't exist
  117619. */
  117620. removeExternalData(key: string): boolean;
  117621. private _evaluateSubMesh;
  117622. /**
  117623. * Clear the processed materials smart array preventing retention point in material dispose.
  117624. */
  117625. freeProcessedMaterials(): void;
  117626. private _preventFreeActiveMeshesAndRenderingGroups;
  117627. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  117628. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  117629. * when disposing several meshes in a row or a hierarchy of meshes.
  117630. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  117631. */
  117632. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  117633. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  117634. /**
  117635. * Clear the active meshes smart array preventing retention point in mesh dispose.
  117636. */
  117637. freeActiveMeshes(): void;
  117638. /**
  117639. * Clear the info related to rendering groups preventing retention points during dispose.
  117640. */
  117641. freeRenderingGroups(): void;
  117642. /** @hidden */
  117643. _isInIntermediateRendering(): boolean;
  117644. /**
  117645. * Lambda returning the list of potentially active meshes.
  117646. */
  117647. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  117648. /**
  117649. * Lambda returning the list of potentially active sub meshes.
  117650. */
  117651. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  117652. /**
  117653. * Lambda returning the list of potentially intersecting sub meshes.
  117654. */
  117655. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  117656. /**
  117657. * Lambda returning the list of potentially colliding sub meshes.
  117658. */
  117659. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  117660. private _activeMeshesFrozen;
  117661. private _skipEvaluateActiveMeshesCompletely;
  117662. /**
  117663. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  117664. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  117665. * @returns the current scene
  117666. */
  117667. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  117668. /**
  117669. * Use this function to restart evaluating active meshes on every frame
  117670. * @returns the current scene
  117671. */
  117672. unfreezeActiveMeshes(): Scene;
  117673. private _evaluateActiveMeshes;
  117674. private _activeMesh;
  117675. /**
  117676. * Update the transform matrix to update from the current active camera
  117677. * @param force defines a boolean used to force the update even if cache is up to date
  117678. */
  117679. updateTransformMatrix(force?: boolean): void;
  117680. private _bindFrameBuffer;
  117681. /** @hidden */
  117682. _allowPostProcessClearColor: boolean;
  117683. /** @hidden */
  117684. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  117685. private _processSubCameras;
  117686. private _checkIntersections;
  117687. /** @hidden */
  117688. _advancePhysicsEngineStep(step: number): void;
  117689. /**
  117690. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  117691. */
  117692. getDeterministicFrameTime: () => number;
  117693. /** @hidden */
  117694. _animate(): void;
  117695. /** Execute all animations (for a frame) */
  117696. animate(): void;
  117697. /**
  117698. * Render the scene
  117699. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  117700. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  117701. */
  117702. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  117703. /**
  117704. * Freeze all materials
  117705. * A frozen material will not be updatable but should be faster to render
  117706. */
  117707. freezeMaterials(): void;
  117708. /**
  117709. * Unfreeze all materials
  117710. * A frozen material will not be updatable but should be faster to render
  117711. */
  117712. unfreezeMaterials(): void;
  117713. /**
  117714. * Releases all held ressources
  117715. */
  117716. dispose(): void;
  117717. /**
  117718. * Gets if the scene is already disposed
  117719. */
  117720. get isDisposed(): boolean;
  117721. /**
  117722. * Call this function to reduce memory footprint of the scene.
  117723. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  117724. */
  117725. clearCachedVertexData(): void;
  117726. /**
  117727. * This function will remove the local cached buffer data from texture.
  117728. * It will save memory but will prevent the texture from being rebuilt
  117729. */
  117730. cleanCachedTextureBuffer(): void;
  117731. /**
  117732. * Get the world extend vectors with an optional filter
  117733. *
  117734. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  117735. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  117736. */
  117737. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  117738. min: Vector3;
  117739. max: Vector3;
  117740. };
  117741. /**
  117742. * Creates a ray that can be used to pick in the scene
  117743. * @param x defines the x coordinate of the origin (on-screen)
  117744. * @param y defines the y coordinate of the origin (on-screen)
  117745. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117746. * @param camera defines the camera to use for the picking
  117747. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117748. * @returns a Ray
  117749. */
  117750. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  117751. /**
  117752. * Creates a ray that can be used to pick in the scene
  117753. * @param x defines the x coordinate of the origin (on-screen)
  117754. * @param y defines the y coordinate of the origin (on-screen)
  117755. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  117756. * @param result defines the ray where to store the picking ray
  117757. * @param camera defines the camera to use for the picking
  117758. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  117759. * @returns the current scene
  117760. */
  117761. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  117762. /**
  117763. * Creates a ray that can be used to pick in the scene
  117764. * @param x defines the x coordinate of the origin (on-screen)
  117765. * @param y defines the y coordinate of the origin (on-screen)
  117766. * @param camera defines the camera to use for the picking
  117767. * @returns a Ray
  117768. */
  117769. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  117770. /**
  117771. * Creates a ray that can be used to pick in the scene
  117772. * @param x defines the x coordinate of the origin (on-screen)
  117773. * @param y defines the y coordinate of the origin (on-screen)
  117774. * @param result defines the ray where to store the picking ray
  117775. * @param camera defines the camera to use for the picking
  117776. * @returns the current scene
  117777. */
  117778. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  117779. /** Launch a ray to try to pick a mesh in the scene
  117780. * @param x position on screen
  117781. * @param y position on screen
  117782. * @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
  117783. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117784. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117785. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117786. * @returns a PickingInfo
  117787. */
  117788. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117789. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  117790. * @param x position on screen
  117791. * @param y position on screen
  117792. * @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
  117793. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117794. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117795. * @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)
  117796. */
  117797. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  117798. /** Use the given ray to pick a mesh in the scene
  117799. * @param ray The ray to use to pick meshes
  117800. * @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
  117801. * @param fastCheck defines if the first intersection will be used (and not the closest)
  117802. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117803. * @returns a PickingInfo
  117804. */
  117805. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  117806. /**
  117807. * Launch a ray to try to pick a mesh in the scene
  117808. * @param x X position on screen
  117809. * @param y Y position on screen
  117810. * @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
  117811. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  117812. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117813. * @returns an array of PickingInfo
  117814. */
  117815. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117816. /**
  117817. * Launch a ray to try to pick a mesh in the scene
  117818. * @param ray Ray to use
  117819. * @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
  117820. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117821. * @returns an array of PickingInfo
  117822. */
  117823. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  117824. /**
  117825. * Force the value of meshUnderPointer
  117826. * @param mesh defines the mesh to use
  117827. */
  117828. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  117829. /**
  117830. * Gets the mesh under the pointer
  117831. * @returns a Mesh or null if no mesh is under the pointer
  117832. */
  117833. getPointerOverMesh(): Nullable<AbstractMesh>;
  117834. /** @hidden */
  117835. _rebuildGeometries(): void;
  117836. /** @hidden */
  117837. _rebuildTextures(): void;
  117838. private _getByTags;
  117839. /**
  117840. * Get a list of meshes by tags
  117841. * @param tagsQuery defines the tags query to use
  117842. * @param forEach defines a predicate used to filter results
  117843. * @returns an array of Mesh
  117844. */
  117845. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  117846. /**
  117847. * Get a list of cameras by tags
  117848. * @param tagsQuery defines the tags query to use
  117849. * @param forEach defines a predicate used to filter results
  117850. * @returns an array of Camera
  117851. */
  117852. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  117853. /**
  117854. * Get a list of lights by tags
  117855. * @param tagsQuery defines the tags query to use
  117856. * @param forEach defines a predicate used to filter results
  117857. * @returns an array of Light
  117858. */
  117859. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  117860. /**
  117861. * Get a list of materials by tags
  117862. * @param tagsQuery defines the tags query to use
  117863. * @param forEach defines a predicate used to filter results
  117864. * @returns an array of Material
  117865. */
  117866. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  117867. /**
  117868. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  117869. * This allowed control for front to back rendering or reversly depending of the special needs.
  117870. *
  117871. * @param renderingGroupId The rendering group id corresponding to its index
  117872. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  117873. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  117874. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  117875. */
  117876. 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;
  117877. /**
  117878. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  117879. *
  117880. * @param renderingGroupId The rendering group id corresponding to its index
  117881. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117882. * @param depth Automatically clears depth between groups if true and autoClear is true.
  117883. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  117884. */
  117885. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  117886. /**
  117887. * Gets the current auto clear configuration for one rendering group of the rendering
  117888. * manager.
  117889. * @param index the rendering group index to get the information for
  117890. * @returns The auto clear setup for the requested rendering group
  117891. */
  117892. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  117893. private _blockMaterialDirtyMechanism;
  117894. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  117895. get blockMaterialDirtyMechanism(): boolean;
  117896. set blockMaterialDirtyMechanism(value: boolean);
  117897. /**
  117898. * Will flag all materials as dirty to trigger new shader compilation
  117899. * @param flag defines the flag used to specify which material part must be marked as dirty
  117900. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  117901. */
  117902. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117903. /** @hidden */
  117904. _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;
  117905. /** @hidden */
  117906. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117907. /** @hidden */
  117908. _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;
  117909. /** @hidden */
  117910. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  117911. /** @hidden */
  117912. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  117913. /** @hidden */
  117914. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  117915. }
  117916. }
  117917. declare module BABYLON {
  117918. /**
  117919. * Set of assets to keep when moving a scene into an asset container.
  117920. */
  117921. export class KeepAssets extends AbstractScene {
  117922. }
  117923. /**
  117924. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  117925. */
  117926. export class InstantiatedEntries {
  117927. /**
  117928. * List of new root nodes (eg. nodes with no parent)
  117929. */
  117930. rootNodes: TransformNode[];
  117931. /**
  117932. * List of new skeletons
  117933. */
  117934. skeletons: Skeleton[];
  117935. /**
  117936. * List of new animation groups
  117937. */
  117938. animationGroups: AnimationGroup[];
  117939. }
  117940. /**
  117941. * Container with a set of assets that can be added or removed from a scene.
  117942. */
  117943. export class AssetContainer extends AbstractScene {
  117944. private _wasAddedToScene;
  117945. /**
  117946. * The scene the AssetContainer belongs to.
  117947. */
  117948. scene: Scene;
  117949. /**
  117950. * Instantiates an AssetContainer.
  117951. * @param scene The scene the AssetContainer belongs to.
  117952. */
  117953. constructor(scene: Scene);
  117954. /**
  117955. * Instantiate or clone all meshes and add the new ones to the scene.
  117956. * Skeletons and animation groups will all be cloned
  117957. * @param nameFunction defines an optional function used to get new names for clones
  117958. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  117959. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  117960. */
  117961. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  117962. /**
  117963. * Adds all the assets from the container to the scene.
  117964. */
  117965. addAllToScene(): void;
  117966. /**
  117967. * Removes all the assets in the container from the scene
  117968. */
  117969. removeAllFromScene(): void;
  117970. /**
  117971. * Disposes all the assets in the container
  117972. */
  117973. dispose(): void;
  117974. private _moveAssets;
  117975. /**
  117976. * Removes all the assets contained in the scene and adds them to the container.
  117977. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  117978. */
  117979. moveAllFromScene(keepAssets?: KeepAssets): void;
  117980. /**
  117981. * 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.
  117982. * @returns the root mesh
  117983. */
  117984. createRootMesh(): Mesh;
  117985. /**
  117986. * Merge animations (direct and animation groups) from this asset container into a scene
  117987. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  117988. * @param animatables set of animatables to retarget to a node from the scene
  117989. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  117990. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  117991. */
  117992. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  117993. }
  117994. }
  117995. declare module BABYLON {
  117996. /**
  117997. * Defines how the parser contract is defined.
  117998. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  117999. */
  118000. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118001. /**
  118002. * Defines how the individual parser contract is defined.
  118003. * These parser can parse an individual asset
  118004. */
  118005. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118006. /**
  118007. * Base class of the scene acting as a container for the different elements composing a scene.
  118008. * This class is dynamically extended by the different components of the scene increasing
  118009. * flexibility and reducing coupling
  118010. */
  118011. export abstract class AbstractScene {
  118012. /**
  118013. * Stores the list of available parsers in the application.
  118014. */
  118015. private static _BabylonFileParsers;
  118016. /**
  118017. * Stores the list of available individual parsers in the application.
  118018. */
  118019. private static _IndividualBabylonFileParsers;
  118020. /**
  118021. * Adds a parser in the list of available ones
  118022. * @param name Defines the name of the parser
  118023. * @param parser Defines the parser to add
  118024. */
  118025. static AddParser(name: string, parser: BabylonFileParser): void;
  118026. /**
  118027. * Gets a general parser from the list of avaialble ones
  118028. * @param name Defines the name of the parser
  118029. * @returns the requested parser or null
  118030. */
  118031. static GetParser(name: string): Nullable<BabylonFileParser>;
  118032. /**
  118033. * Adds n individual parser in the list of available ones
  118034. * @param name Defines the name of the parser
  118035. * @param parser Defines the parser to add
  118036. */
  118037. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118038. /**
  118039. * Gets an individual parser from the list of avaialble ones
  118040. * @param name Defines the name of the parser
  118041. * @returns the requested parser or null
  118042. */
  118043. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118044. /**
  118045. * Parser json data and populate both a scene and its associated container object
  118046. * @param jsonData Defines the data to parse
  118047. * @param scene Defines the scene to parse the data for
  118048. * @param container Defines the container attached to the parsing sequence
  118049. * @param rootUrl Defines the root url of the data
  118050. */
  118051. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118052. /**
  118053. * Gets the list of root nodes (ie. nodes with no parent)
  118054. */
  118055. rootNodes: Node[];
  118056. /** All of the cameras added to this scene
  118057. * @see http://doc.babylonjs.com/babylon101/cameras
  118058. */
  118059. cameras: Camera[];
  118060. /**
  118061. * All of the lights added to this scene
  118062. * @see http://doc.babylonjs.com/babylon101/lights
  118063. */
  118064. lights: Light[];
  118065. /**
  118066. * All of the (abstract) meshes added to this scene
  118067. */
  118068. meshes: AbstractMesh[];
  118069. /**
  118070. * The list of skeletons added to the scene
  118071. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118072. */
  118073. skeletons: Skeleton[];
  118074. /**
  118075. * All of the particle systems added to this scene
  118076. * @see http://doc.babylonjs.com/babylon101/particles
  118077. */
  118078. particleSystems: IParticleSystem[];
  118079. /**
  118080. * Gets a list of Animations associated with the scene
  118081. */
  118082. animations: Animation[];
  118083. /**
  118084. * All of the animation groups added to this scene
  118085. * @see http://doc.babylonjs.com/how_to/group
  118086. */
  118087. animationGroups: AnimationGroup[];
  118088. /**
  118089. * All of the multi-materials added to this scene
  118090. * @see http://doc.babylonjs.com/how_to/multi_materials
  118091. */
  118092. multiMaterials: MultiMaterial[];
  118093. /**
  118094. * All of the materials added to this scene
  118095. * In the context of a Scene, it is not supposed to be modified manually.
  118096. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118097. * Note also that the order of the Material within the array is not significant and might change.
  118098. * @see http://doc.babylonjs.com/babylon101/materials
  118099. */
  118100. materials: Material[];
  118101. /**
  118102. * The list of morph target managers added to the scene
  118103. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118104. */
  118105. morphTargetManagers: MorphTargetManager[];
  118106. /**
  118107. * The list of geometries used in the scene.
  118108. */
  118109. geometries: Geometry[];
  118110. /**
  118111. * All of the tranform nodes added to this scene
  118112. * In the context of a Scene, it is not supposed to be modified manually.
  118113. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118114. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118115. * @see http://doc.babylonjs.com/how_to/transformnode
  118116. */
  118117. transformNodes: TransformNode[];
  118118. /**
  118119. * ActionManagers available on the scene.
  118120. */
  118121. actionManagers: AbstractActionManager[];
  118122. /**
  118123. * Textures to keep.
  118124. */
  118125. textures: BaseTexture[];
  118126. /**
  118127. * Environment texture for the scene
  118128. */
  118129. environmentTexture: Nullable<BaseTexture>;
  118130. /**
  118131. * @returns all meshes, lights, cameras, transformNodes and bones
  118132. */
  118133. getNodes(): Array<Node>;
  118134. }
  118135. }
  118136. declare module BABYLON {
  118137. /**
  118138. * Interface used to define options for Sound class
  118139. */
  118140. export interface ISoundOptions {
  118141. /**
  118142. * Does the sound autoplay once loaded.
  118143. */
  118144. autoplay?: boolean;
  118145. /**
  118146. * Does the sound loop after it finishes playing once.
  118147. */
  118148. loop?: boolean;
  118149. /**
  118150. * Sound's volume
  118151. */
  118152. volume?: number;
  118153. /**
  118154. * Is it a spatial sound?
  118155. */
  118156. spatialSound?: boolean;
  118157. /**
  118158. * Maximum distance to hear that sound
  118159. */
  118160. maxDistance?: number;
  118161. /**
  118162. * Uses user defined attenuation function
  118163. */
  118164. useCustomAttenuation?: boolean;
  118165. /**
  118166. * Define the roll off factor of spatial sounds.
  118167. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118168. */
  118169. rolloffFactor?: number;
  118170. /**
  118171. * Define the reference distance the sound should be heard perfectly.
  118172. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118173. */
  118174. refDistance?: number;
  118175. /**
  118176. * Define the distance attenuation model the sound will follow.
  118177. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118178. */
  118179. distanceModel?: string;
  118180. /**
  118181. * Defines the playback speed (1 by default)
  118182. */
  118183. playbackRate?: number;
  118184. /**
  118185. * Defines if the sound is from a streaming source
  118186. */
  118187. streaming?: boolean;
  118188. /**
  118189. * Defines an optional length (in seconds) inside the sound file
  118190. */
  118191. length?: number;
  118192. /**
  118193. * Defines an optional offset (in seconds) inside the sound file
  118194. */
  118195. offset?: number;
  118196. /**
  118197. * If true, URLs will not be required to state the audio file codec to use.
  118198. */
  118199. skipCodecCheck?: boolean;
  118200. }
  118201. /**
  118202. * Defines a sound that can be played in the application.
  118203. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118205. */
  118206. export class Sound {
  118207. /**
  118208. * The name of the sound in the scene.
  118209. */
  118210. name: string;
  118211. /**
  118212. * Does the sound autoplay once loaded.
  118213. */
  118214. autoplay: boolean;
  118215. /**
  118216. * Does the sound loop after it finishes playing once.
  118217. */
  118218. loop: boolean;
  118219. /**
  118220. * Does the sound use a custom attenuation curve to simulate the falloff
  118221. * happening when the source gets further away from the camera.
  118222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118223. */
  118224. useCustomAttenuation: boolean;
  118225. /**
  118226. * The sound track id this sound belongs to.
  118227. */
  118228. soundTrackId: number;
  118229. /**
  118230. * Is this sound currently played.
  118231. */
  118232. isPlaying: boolean;
  118233. /**
  118234. * Is this sound currently paused.
  118235. */
  118236. isPaused: boolean;
  118237. /**
  118238. * Does this sound enables spatial sound.
  118239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118240. */
  118241. spatialSound: boolean;
  118242. /**
  118243. * Define the reference distance the sound should be heard perfectly.
  118244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118245. */
  118246. refDistance: number;
  118247. /**
  118248. * Define the roll off factor of spatial sounds.
  118249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118250. */
  118251. rolloffFactor: number;
  118252. /**
  118253. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  118254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118255. */
  118256. maxDistance: number;
  118257. /**
  118258. * Define the distance attenuation model the sound will follow.
  118259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118260. */
  118261. distanceModel: string;
  118262. /**
  118263. * @hidden
  118264. * Back Compat
  118265. **/
  118266. onended: () => any;
  118267. /**
  118268. * Gets or sets an object used to store user defined information for the sound.
  118269. */
  118270. metadata: any;
  118271. /**
  118272. * Observable event when the current playing sound finishes.
  118273. */
  118274. onEndedObservable: Observable<Sound>;
  118275. private _panningModel;
  118276. private _playbackRate;
  118277. private _streaming;
  118278. private _startTime;
  118279. private _startOffset;
  118280. private _position;
  118281. /** @hidden */
  118282. _positionInEmitterSpace: boolean;
  118283. private _localDirection;
  118284. private _volume;
  118285. private _isReadyToPlay;
  118286. private _isDirectional;
  118287. private _readyToPlayCallback;
  118288. private _audioBuffer;
  118289. private _soundSource;
  118290. private _streamingSource;
  118291. private _soundPanner;
  118292. private _soundGain;
  118293. private _inputAudioNode;
  118294. private _outputAudioNode;
  118295. private _coneInnerAngle;
  118296. private _coneOuterAngle;
  118297. private _coneOuterGain;
  118298. private _scene;
  118299. private _connectedTransformNode;
  118300. private _customAttenuationFunction;
  118301. private _registerFunc;
  118302. private _isOutputConnected;
  118303. private _htmlAudioElement;
  118304. private _urlType;
  118305. private _length?;
  118306. private _offset?;
  118307. /** @hidden */
  118308. static _SceneComponentInitialization: (scene: Scene) => void;
  118309. /**
  118310. * Create a sound and attach it to a scene
  118311. * @param name Name of your sound
  118312. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  118313. * @param scene defines the scene the sound belongs to
  118314. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  118315. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  118316. */
  118317. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  118318. /**
  118319. * Release the sound and its associated resources
  118320. */
  118321. dispose(): void;
  118322. /**
  118323. * Gets if the sounds is ready to be played or not.
  118324. * @returns true if ready, otherwise false
  118325. */
  118326. isReady(): boolean;
  118327. private _soundLoaded;
  118328. /**
  118329. * Sets the data of the sound from an audiobuffer
  118330. * @param audioBuffer The audioBuffer containing the data
  118331. */
  118332. setAudioBuffer(audioBuffer: AudioBuffer): void;
  118333. /**
  118334. * Updates the current sounds options such as maxdistance, loop...
  118335. * @param options A JSON object containing values named as the object properties
  118336. */
  118337. updateOptions(options: ISoundOptions): void;
  118338. private _createSpatialParameters;
  118339. private _updateSpatialParameters;
  118340. /**
  118341. * Switch the panning model to HRTF:
  118342. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118344. */
  118345. switchPanningModelToHRTF(): void;
  118346. /**
  118347. * Switch the panning model to Equal Power:
  118348. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118350. */
  118351. switchPanningModelToEqualPower(): void;
  118352. private _switchPanningModel;
  118353. /**
  118354. * Connect this sound to a sound track audio node like gain...
  118355. * @param soundTrackAudioNode the sound track audio node to connect to
  118356. */
  118357. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  118358. /**
  118359. * Transform this sound into a directional source
  118360. * @param coneInnerAngle Size of the inner cone in degree
  118361. * @param coneOuterAngle Size of the outer cone in degree
  118362. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  118363. */
  118364. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  118365. /**
  118366. * Gets or sets the inner angle for the directional cone.
  118367. */
  118368. get directionalConeInnerAngle(): number;
  118369. /**
  118370. * Gets or sets the inner angle for the directional cone.
  118371. */
  118372. set directionalConeInnerAngle(value: number);
  118373. /**
  118374. * Gets or sets the outer angle for the directional cone.
  118375. */
  118376. get directionalConeOuterAngle(): number;
  118377. /**
  118378. * Gets or sets the outer angle for the directional cone.
  118379. */
  118380. set directionalConeOuterAngle(value: number);
  118381. /**
  118382. * Sets the position of the emitter if spatial sound is enabled
  118383. * @param newPosition Defines the new posisiton
  118384. */
  118385. setPosition(newPosition: Vector3): void;
  118386. /**
  118387. * Sets the local direction of the emitter if spatial sound is enabled
  118388. * @param newLocalDirection Defines the new local direction
  118389. */
  118390. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  118391. private _updateDirection;
  118392. /** @hidden */
  118393. updateDistanceFromListener(): void;
  118394. /**
  118395. * Sets a new custom attenuation function for the sound.
  118396. * @param callback Defines the function used for the attenuation
  118397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118398. */
  118399. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  118400. /**
  118401. * Play the sound
  118402. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  118403. * @param offset (optional) Start the sound at a specific time in seconds
  118404. * @param length (optional) Sound duration (in seconds)
  118405. */
  118406. play(time?: number, offset?: number, length?: number): void;
  118407. private _onended;
  118408. /**
  118409. * Stop the sound
  118410. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  118411. */
  118412. stop(time?: number): void;
  118413. /**
  118414. * Put the sound in pause
  118415. */
  118416. pause(): void;
  118417. /**
  118418. * Sets a dedicated volume for this sounds
  118419. * @param newVolume Define the new volume of the sound
  118420. * @param time Define time for gradual change to new volume
  118421. */
  118422. setVolume(newVolume: number, time?: number): void;
  118423. /**
  118424. * Set the sound play back rate
  118425. * @param newPlaybackRate Define the playback rate the sound should be played at
  118426. */
  118427. setPlaybackRate(newPlaybackRate: number): void;
  118428. /**
  118429. * Gets the volume of the sound.
  118430. * @returns the volume of the sound
  118431. */
  118432. getVolume(): number;
  118433. /**
  118434. * Attach the sound to a dedicated mesh
  118435. * @param transformNode The transform node to connect the sound with
  118436. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118437. */
  118438. attachToMesh(transformNode: TransformNode): void;
  118439. /**
  118440. * Detach the sound from the previously attached mesh
  118441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  118442. */
  118443. detachFromMesh(): void;
  118444. private _onRegisterAfterWorldMatrixUpdate;
  118445. /**
  118446. * Clone the current sound in the scene.
  118447. * @returns the new sound clone
  118448. */
  118449. clone(): Nullable<Sound>;
  118450. /**
  118451. * Gets the current underlying audio buffer containing the data
  118452. * @returns the audio buffer
  118453. */
  118454. getAudioBuffer(): Nullable<AudioBuffer>;
  118455. /**
  118456. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  118457. * @returns the source node
  118458. */
  118459. getSoundSource(): Nullable<AudioBufferSourceNode>;
  118460. /**
  118461. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  118462. * @returns the gain node
  118463. */
  118464. getSoundGain(): Nullable<GainNode>;
  118465. /**
  118466. * Serializes the Sound in a JSON representation
  118467. * @returns the JSON representation of the sound
  118468. */
  118469. serialize(): any;
  118470. /**
  118471. * Parse a JSON representation of a sound to innstantiate in a given scene
  118472. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  118473. * @param scene Define the scene the new parsed sound should be created in
  118474. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  118475. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  118476. * @returns the newly parsed sound
  118477. */
  118478. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  118479. }
  118480. }
  118481. declare module BABYLON {
  118482. /**
  118483. * This defines an action helpful to play a defined sound on a triggered action.
  118484. */
  118485. export class PlaySoundAction extends Action {
  118486. private _sound;
  118487. /**
  118488. * Instantiate the action
  118489. * @param triggerOptions defines the trigger options
  118490. * @param sound defines the sound to play
  118491. * @param condition defines the trigger related conditions
  118492. */
  118493. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118494. /** @hidden */
  118495. _prepare(): void;
  118496. /**
  118497. * Execute the action and play the sound.
  118498. */
  118499. execute(): void;
  118500. /**
  118501. * Serializes the actions and its related information.
  118502. * @param parent defines the object to serialize in
  118503. * @returns the serialized object
  118504. */
  118505. serialize(parent: any): any;
  118506. }
  118507. /**
  118508. * This defines an action helpful to stop a defined sound on a triggered action.
  118509. */
  118510. export class StopSoundAction extends Action {
  118511. private _sound;
  118512. /**
  118513. * Instantiate the action
  118514. * @param triggerOptions defines the trigger options
  118515. * @param sound defines the sound to stop
  118516. * @param condition defines the trigger related conditions
  118517. */
  118518. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  118519. /** @hidden */
  118520. _prepare(): void;
  118521. /**
  118522. * Execute the action and stop the sound.
  118523. */
  118524. execute(): void;
  118525. /**
  118526. * Serializes the actions and its related information.
  118527. * @param parent defines the object to serialize in
  118528. * @returns the serialized object
  118529. */
  118530. serialize(parent: any): any;
  118531. }
  118532. }
  118533. declare module BABYLON {
  118534. /**
  118535. * This defines an action responsible to change the value of a property
  118536. * by interpolating between its current value and the newly set one once triggered.
  118537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  118538. */
  118539. export class InterpolateValueAction extends Action {
  118540. /**
  118541. * Defines the path of the property where the value should be interpolated
  118542. */
  118543. propertyPath: string;
  118544. /**
  118545. * Defines the target value at the end of the interpolation.
  118546. */
  118547. value: any;
  118548. /**
  118549. * Defines the time it will take for the property to interpolate to the value.
  118550. */
  118551. duration: number;
  118552. /**
  118553. * Defines if the other scene animations should be stopped when the action has been triggered
  118554. */
  118555. stopOtherAnimations?: boolean;
  118556. /**
  118557. * Defines a callback raised once the interpolation animation has been done.
  118558. */
  118559. onInterpolationDone?: () => void;
  118560. /**
  118561. * Observable triggered once the interpolation animation has been done.
  118562. */
  118563. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  118564. private _target;
  118565. private _effectiveTarget;
  118566. private _property;
  118567. /**
  118568. * Instantiate the action
  118569. * @param triggerOptions defines the trigger options
  118570. * @param target defines the object containing the value to interpolate
  118571. * @param propertyPath defines the path to the property in the target object
  118572. * @param value defines the target value at the end of the interpolation
  118573. * @param duration deines the time it will take for the property to interpolate to the value.
  118574. * @param condition defines the trigger related conditions
  118575. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  118576. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  118577. */
  118578. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  118579. /** @hidden */
  118580. _prepare(): void;
  118581. /**
  118582. * Execute the action starts the value interpolation.
  118583. */
  118584. execute(): void;
  118585. /**
  118586. * Serializes the actions and its related information.
  118587. * @param parent defines the object to serialize in
  118588. * @returns the serialized object
  118589. */
  118590. serialize(parent: any): any;
  118591. }
  118592. }
  118593. declare module BABYLON {
  118594. /**
  118595. * Options allowed during the creation of a sound track.
  118596. */
  118597. export interface ISoundTrackOptions {
  118598. /**
  118599. * The volume the sound track should take during creation
  118600. */
  118601. volume?: number;
  118602. /**
  118603. * Define if the sound track is the main sound track of the scene
  118604. */
  118605. mainTrack?: boolean;
  118606. }
  118607. /**
  118608. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  118609. * It will be also used in a future release to apply effects on a specific track.
  118610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118611. */
  118612. export class SoundTrack {
  118613. /**
  118614. * The unique identifier of the sound track in the scene.
  118615. */
  118616. id: number;
  118617. /**
  118618. * The list of sounds included in the sound track.
  118619. */
  118620. soundCollection: Array<Sound>;
  118621. private _outputAudioNode;
  118622. private _scene;
  118623. private _connectedAnalyser;
  118624. private _options;
  118625. private _isInitialized;
  118626. /**
  118627. * Creates a new sound track.
  118628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  118629. * @param scene Define the scene the sound track belongs to
  118630. * @param options
  118631. */
  118632. constructor(scene: Scene, options?: ISoundTrackOptions);
  118633. private _initializeSoundTrackAudioGraph;
  118634. /**
  118635. * Release the sound track and its associated resources
  118636. */
  118637. dispose(): void;
  118638. /**
  118639. * Adds a sound to this sound track
  118640. * @param sound define the cound to add
  118641. * @ignoreNaming
  118642. */
  118643. AddSound(sound: Sound): void;
  118644. /**
  118645. * Removes a sound to this sound track
  118646. * @param sound define the cound to remove
  118647. * @ignoreNaming
  118648. */
  118649. RemoveSound(sound: Sound): void;
  118650. /**
  118651. * Set a global volume for the full sound track.
  118652. * @param newVolume Define the new volume of the sound track
  118653. */
  118654. setVolume(newVolume: number): void;
  118655. /**
  118656. * Switch the panning model to HRTF:
  118657. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  118658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118659. */
  118660. switchPanningModelToHRTF(): void;
  118661. /**
  118662. * Switch the panning model to Equal Power:
  118663. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  118664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118665. */
  118666. switchPanningModelToEqualPower(): void;
  118667. /**
  118668. * Connect the sound track to an audio analyser allowing some amazing
  118669. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  118670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  118671. * @param analyser The analyser to connect to the engine
  118672. */
  118673. connectToAnalyser(analyser: Analyser): void;
  118674. }
  118675. }
  118676. declare module BABYLON {
  118677. interface AbstractScene {
  118678. /**
  118679. * The list of sounds used in the scene.
  118680. */
  118681. sounds: Nullable<Array<Sound>>;
  118682. }
  118683. interface Scene {
  118684. /**
  118685. * @hidden
  118686. * Backing field
  118687. */
  118688. _mainSoundTrack: SoundTrack;
  118689. /**
  118690. * The main sound track played by the scene.
  118691. * It cotains your primary collection of sounds.
  118692. */
  118693. mainSoundTrack: SoundTrack;
  118694. /**
  118695. * The list of sound tracks added to the scene
  118696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118697. */
  118698. soundTracks: Nullable<Array<SoundTrack>>;
  118699. /**
  118700. * Gets a sound using a given name
  118701. * @param name defines the name to search for
  118702. * @return the found sound or null if not found at all.
  118703. */
  118704. getSoundByName(name: string): Nullable<Sound>;
  118705. /**
  118706. * Gets or sets if audio support is enabled
  118707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118708. */
  118709. audioEnabled: boolean;
  118710. /**
  118711. * Gets or sets if audio will be output to headphones
  118712. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118713. */
  118714. headphone: boolean;
  118715. /**
  118716. * Gets or sets custom audio listener position provider
  118717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  118718. */
  118719. audioListenerPositionProvider: Nullable<() => Vector3>;
  118720. /**
  118721. * Gets or sets a refresh rate when using 3D audio positioning
  118722. */
  118723. audioPositioningRefreshRate: number;
  118724. }
  118725. /**
  118726. * Defines the sound scene component responsible to manage any sounds
  118727. * in a given scene.
  118728. */
  118729. export class AudioSceneComponent implements ISceneSerializableComponent {
  118730. /**
  118731. * The component name helpfull to identify the component in the list of scene components.
  118732. */
  118733. readonly name: string;
  118734. /**
  118735. * The scene the component belongs to.
  118736. */
  118737. scene: Scene;
  118738. private _audioEnabled;
  118739. /**
  118740. * Gets whether audio is enabled or not.
  118741. * Please use related enable/disable method to switch state.
  118742. */
  118743. get audioEnabled(): boolean;
  118744. private _headphone;
  118745. /**
  118746. * Gets whether audio is outputing to headphone or not.
  118747. * Please use the according Switch methods to change output.
  118748. */
  118749. get headphone(): boolean;
  118750. /**
  118751. * Gets or sets a refresh rate when using 3D audio positioning
  118752. */
  118753. audioPositioningRefreshRate: number;
  118754. private _audioListenerPositionProvider;
  118755. /**
  118756. * Gets the current audio listener position provider
  118757. */
  118758. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  118759. /**
  118760. * Sets a custom listener position for all sounds in the scene
  118761. * By default, this is the position of the first active camera
  118762. */
  118763. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  118764. /**
  118765. * Creates a new instance of the component for the given scene
  118766. * @param scene Defines the scene to register the component in
  118767. */
  118768. constructor(scene: Scene);
  118769. /**
  118770. * Registers the component in a given scene
  118771. */
  118772. register(): void;
  118773. /**
  118774. * Rebuilds the elements related to this component in case of
  118775. * context lost for instance.
  118776. */
  118777. rebuild(): void;
  118778. /**
  118779. * Serializes the component data to the specified json object
  118780. * @param serializationObject The object to serialize to
  118781. */
  118782. serialize(serializationObject: any): void;
  118783. /**
  118784. * Adds all the elements from the container to the scene
  118785. * @param container the container holding the elements
  118786. */
  118787. addFromContainer(container: AbstractScene): void;
  118788. /**
  118789. * Removes all the elements in the container from the scene
  118790. * @param container contains the elements to remove
  118791. * @param dispose if the removed element should be disposed (default: false)
  118792. */
  118793. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  118794. /**
  118795. * Disposes the component and the associated ressources.
  118796. */
  118797. dispose(): void;
  118798. /**
  118799. * Disables audio in the associated scene.
  118800. */
  118801. disableAudio(): void;
  118802. /**
  118803. * Enables audio in the associated scene.
  118804. */
  118805. enableAudio(): void;
  118806. /**
  118807. * Switch audio to headphone output.
  118808. */
  118809. switchAudioModeForHeadphones(): void;
  118810. /**
  118811. * Switch audio to normal speakers.
  118812. */
  118813. switchAudioModeForNormalSpeakers(): void;
  118814. private _cachedCameraDirection;
  118815. private _cachedCameraPosition;
  118816. private _lastCheck;
  118817. private _afterRender;
  118818. }
  118819. }
  118820. declare module BABYLON {
  118821. /**
  118822. * Wraps one or more Sound objects and selects one with random weight for playback.
  118823. */
  118824. export class WeightedSound {
  118825. /** When true a Sound will be selected and played when the current playing Sound completes. */
  118826. loop: boolean;
  118827. private _coneInnerAngle;
  118828. private _coneOuterAngle;
  118829. private _volume;
  118830. /** A Sound is currently playing. */
  118831. isPlaying: boolean;
  118832. /** A Sound is currently paused. */
  118833. isPaused: boolean;
  118834. private _sounds;
  118835. private _weights;
  118836. private _currentIndex?;
  118837. /**
  118838. * Creates a new WeightedSound from the list of sounds given.
  118839. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  118840. * @param sounds Array of Sounds that will be selected from.
  118841. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  118842. */
  118843. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  118844. /**
  118845. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  118846. */
  118847. get directionalConeInnerAngle(): number;
  118848. /**
  118849. * The size of cone in degress for a directional sound in which there will be no attenuation.
  118850. */
  118851. set directionalConeInnerAngle(value: number);
  118852. /**
  118853. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118854. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118855. */
  118856. get directionalConeOuterAngle(): number;
  118857. /**
  118858. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  118859. * Listener angles between innerAngle and outerAngle will falloff linearly.
  118860. */
  118861. set directionalConeOuterAngle(value: number);
  118862. /**
  118863. * Playback volume.
  118864. */
  118865. get volume(): number;
  118866. /**
  118867. * Playback volume.
  118868. */
  118869. set volume(value: number);
  118870. private _onended;
  118871. /**
  118872. * Suspend playback
  118873. */
  118874. pause(): void;
  118875. /**
  118876. * Stop playback
  118877. */
  118878. stop(): void;
  118879. /**
  118880. * Start playback.
  118881. * @param startOffset Position the clip head at a specific time in seconds.
  118882. */
  118883. play(startOffset?: number): void;
  118884. }
  118885. }
  118886. declare module BABYLON {
  118887. /**
  118888. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  118889. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  118890. */
  118891. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  118892. /**
  118893. * Gets the name of the behavior.
  118894. */
  118895. get name(): string;
  118896. /**
  118897. * The easing function used by animations
  118898. */
  118899. static EasingFunction: BackEase;
  118900. /**
  118901. * The easing mode used by animations
  118902. */
  118903. static EasingMode: number;
  118904. /**
  118905. * The duration of the animation, in milliseconds
  118906. */
  118907. transitionDuration: number;
  118908. /**
  118909. * Length of the distance animated by the transition when lower radius is reached
  118910. */
  118911. lowerRadiusTransitionRange: number;
  118912. /**
  118913. * Length of the distance animated by the transition when upper radius is reached
  118914. */
  118915. upperRadiusTransitionRange: number;
  118916. private _autoTransitionRange;
  118917. /**
  118918. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118919. */
  118920. get autoTransitionRange(): boolean;
  118921. /**
  118922. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  118923. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  118924. */
  118925. set autoTransitionRange(value: boolean);
  118926. private _attachedCamera;
  118927. private _onAfterCheckInputsObserver;
  118928. private _onMeshTargetChangedObserver;
  118929. /**
  118930. * Initializes the behavior.
  118931. */
  118932. init(): void;
  118933. /**
  118934. * Attaches the behavior to its arc rotate camera.
  118935. * @param camera Defines the camera to attach the behavior to
  118936. */
  118937. attach(camera: ArcRotateCamera): void;
  118938. /**
  118939. * Detaches the behavior from its current arc rotate camera.
  118940. */
  118941. detach(): void;
  118942. private _radiusIsAnimating;
  118943. private _radiusBounceTransition;
  118944. private _animatables;
  118945. private _cachedWheelPrecision;
  118946. /**
  118947. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  118948. * @param radiusLimit The limit to check against.
  118949. * @return Bool to indicate if at limit.
  118950. */
  118951. private _isRadiusAtLimit;
  118952. /**
  118953. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  118954. * @param radiusDelta The delta by which to animate to. Can be negative.
  118955. */
  118956. private _applyBoundRadiusAnimation;
  118957. /**
  118958. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  118959. */
  118960. protected _clearAnimationLocks(): void;
  118961. /**
  118962. * Stops and removes all animations that have been applied to the camera
  118963. */
  118964. stopAllAnimations(): void;
  118965. }
  118966. }
  118967. declare module BABYLON {
  118968. /**
  118969. * 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.
  118970. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  118971. */
  118972. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  118973. /**
  118974. * Gets the name of the behavior.
  118975. */
  118976. get name(): string;
  118977. private _mode;
  118978. private _radiusScale;
  118979. private _positionScale;
  118980. private _defaultElevation;
  118981. private _elevationReturnTime;
  118982. private _elevationReturnWaitTime;
  118983. private _zoomStopsAnimation;
  118984. private _framingTime;
  118985. /**
  118986. * The easing function used by animations
  118987. */
  118988. static EasingFunction: ExponentialEase;
  118989. /**
  118990. * The easing mode used by animations
  118991. */
  118992. static EasingMode: number;
  118993. /**
  118994. * Sets the current mode used by the behavior
  118995. */
  118996. set mode(mode: number);
  118997. /**
  118998. * Gets current mode used by the behavior.
  118999. */
  119000. get mode(): number;
  119001. /**
  119002. * Sets the scale applied to the radius (1 by default)
  119003. */
  119004. set radiusScale(radius: number);
  119005. /**
  119006. * Gets the scale applied to the radius
  119007. */
  119008. get radiusScale(): number;
  119009. /**
  119010. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119011. */
  119012. set positionScale(scale: number);
  119013. /**
  119014. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119015. */
  119016. get positionScale(): number;
  119017. /**
  119018. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119019. * behaviour is triggered, in radians.
  119020. */
  119021. set defaultElevation(elevation: number);
  119022. /**
  119023. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119024. * behaviour is triggered, in radians.
  119025. */
  119026. get defaultElevation(): number;
  119027. /**
  119028. * Sets the time (in milliseconds) taken to return to the default beta position.
  119029. * Negative value indicates camera should not return to default.
  119030. */
  119031. set elevationReturnTime(speed: number);
  119032. /**
  119033. * Gets the time (in milliseconds) taken to return to the default beta position.
  119034. * Negative value indicates camera should not return to default.
  119035. */
  119036. get elevationReturnTime(): number;
  119037. /**
  119038. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119039. */
  119040. set elevationReturnWaitTime(time: number);
  119041. /**
  119042. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119043. */
  119044. get elevationReturnWaitTime(): number;
  119045. /**
  119046. * Sets the flag that indicates if user zooming should stop animation.
  119047. */
  119048. set zoomStopsAnimation(flag: boolean);
  119049. /**
  119050. * Gets the flag that indicates if user zooming should stop animation.
  119051. */
  119052. get zoomStopsAnimation(): boolean;
  119053. /**
  119054. * Sets the transition time when framing the mesh, in milliseconds
  119055. */
  119056. set framingTime(time: number);
  119057. /**
  119058. * Gets the transition time when framing the mesh, in milliseconds
  119059. */
  119060. get framingTime(): number;
  119061. /**
  119062. * Define if the behavior should automatically change the configured
  119063. * camera limits and sensibilities.
  119064. */
  119065. autoCorrectCameraLimitsAndSensibility: boolean;
  119066. private _onPrePointerObservableObserver;
  119067. private _onAfterCheckInputsObserver;
  119068. private _onMeshTargetChangedObserver;
  119069. private _attachedCamera;
  119070. private _isPointerDown;
  119071. private _lastInteractionTime;
  119072. /**
  119073. * Initializes the behavior.
  119074. */
  119075. init(): void;
  119076. /**
  119077. * Attaches the behavior to its arc rotate camera.
  119078. * @param camera Defines the camera to attach the behavior to
  119079. */
  119080. attach(camera: ArcRotateCamera): void;
  119081. /**
  119082. * Detaches the behavior from its current arc rotate camera.
  119083. */
  119084. detach(): void;
  119085. private _animatables;
  119086. private _betaIsAnimating;
  119087. private _betaTransition;
  119088. private _radiusTransition;
  119089. private _vectorTransition;
  119090. /**
  119091. * Targets the given mesh and updates zoom level accordingly.
  119092. * @param mesh The mesh to target.
  119093. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119094. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119095. */
  119096. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119097. /**
  119098. * Targets the given mesh with its children and updates zoom level accordingly.
  119099. * @param mesh The mesh to target.
  119100. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119101. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119102. */
  119103. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119104. /**
  119105. * Targets the given meshes with their children and updates zoom level accordingly.
  119106. * @param meshes The mesh to target.
  119107. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119108. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119109. */
  119110. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119111. /**
  119112. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119113. * @param minimumWorld Determines the smaller position of the bounding box extend
  119114. * @param maximumWorld Determines the bigger position of the bounding box extend
  119115. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119116. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119117. */
  119118. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119119. /**
  119120. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119121. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119122. * frustum width.
  119123. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119124. * to fully enclose the mesh in the viewing frustum.
  119125. */
  119126. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119127. /**
  119128. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119129. * is automatically returned to its default position (expected to be above ground plane).
  119130. */
  119131. private _maintainCameraAboveGround;
  119132. /**
  119133. * Returns the frustum slope based on the canvas ratio and camera FOV
  119134. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119135. */
  119136. private _getFrustumSlope;
  119137. /**
  119138. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119139. */
  119140. private _clearAnimationLocks;
  119141. /**
  119142. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119143. */
  119144. private _applyUserInteraction;
  119145. /**
  119146. * Stops and removes all animations that have been applied to the camera
  119147. */
  119148. stopAllAnimations(): void;
  119149. /**
  119150. * Gets a value indicating if the user is moving the camera
  119151. */
  119152. get isUserIsMoving(): boolean;
  119153. /**
  119154. * The camera can move all the way towards the mesh.
  119155. */
  119156. static IgnoreBoundsSizeMode: number;
  119157. /**
  119158. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119159. */
  119160. static FitFrustumSidesMode: number;
  119161. }
  119162. }
  119163. declare module BABYLON {
  119164. /**
  119165. * Base class for Camera Pointer Inputs.
  119166. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119167. * for example usage.
  119168. */
  119169. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119170. /**
  119171. * Defines the camera the input is attached to.
  119172. */
  119173. abstract camera: Camera;
  119174. /**
  119175. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119176. */
  119177. protected _altKey: boolean;
  119178. protected _ctrlKey: boolean;
  119179. protected _metaKey: boolean;
  119180. protected _shiftKey: boolean;
  119181. /**
  119182. * Which mouse buttons were pressed at time of last mouse event.
  119183. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119184. */
  119185. protected _buttonsPressed: number;
  119186. /**
  119187. * Defines the buttons associated with the input to handle camera move.
  119188. */
  119189. buttons: number[];
  119190. /**
  119191. * Attach the input controls to a specific dom element to get the input from.
  119192. * @param element Defines the element the controls should be listened from
  119193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119194. */
  119195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119196. /**
  119197. * Detach the current controls from the specified dom element.
  119198. * @param element Defines the element to stop listening the inputs from
  119199. */
  119200. detachControl(element: Nullable<HTMLElement>): void;
  119201. /**
  119202. * Gets the class name of the current input.
  119203. * @returns the class name
  119204. */
  119205. getClassName(): string;
  119206. /**
  119207. * Get the friendly name associated with the input class.
  119208. * @returns the input friendly name
  119209. */
  119210. getSimpleName(): string;
  119211. /**
  119212. * Called on pointer POINTERDOUBLETAP event.
  119213. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119214. */
  119215. protected onDoubleTap(type: string): void;
  119216. /**
  119217. * Called on pointer POINTERMOVE event if only a single touch is active.
  119218. * Override this method to provide functionality.
  119219. */
  119220. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119221. /**
  119222. * Called on pointer POINTERMOVE event if multiple touches are active.
  119223. * Override this method to provide functionality.
  119224. */
  119225. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119226. /**
  119227. * Called on JS contextmenu event.
  119228. * Override this method to provide functionality.
  119229. */
  119230. protected onContextMenu(evt: PointerEvent): void;
  119231. /**
  119232. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119233. * press.
  119234. * Override this method to provide functionality.
  119235. */
  119236. protected onButtonDown(evt: PointerEvent): void;
  119237. /**
  119238. * Called each time a new POINTERUP event occurs. Ie, for each button
  119239. * release.
  119240. * Override this method to provide functionality.
  119241. */
  119242. protected onButtonUp(evt: PointerEvent): void;
  119243. /**
  119244. * Called when window becomes inactive.
  119245. * Override this method to provide functionality.
  119246. */
  119247. protected onLostFocus(): void;
  119248. private _pointerInput;
  119249. private _observer;
  119250. private _onLostFocus;
  119251. private pointA;
  119252. private pointB;
  119253. }
  119254. }
  119255. declare module BABYLON {
  119256. /**
  119257. * Manage the pointers inputs to control an arc rotate camera.
  119258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119259. */
  119260. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  119261. /**
  119262. * Defines the camera the input is attached to.
  119263. */
  119264. camera: ArcRotateCamera;
  119265. /**
  119266. * Gets the class name of the current input.
  119267. * @returns the class name
  119268. */
  119269. getClassName(): string;
  119270. /**
  119271. * Defines the buttons associated with the input to handle camera move.
  119272. */
  119273. buttons: number[];
  119274. /**
  119275. * Defines the pointer angular sensibility along the X axis or how fast is
  119276. * the camera rotating.
  119277. */
  119278. angularSensibilityX: number;
  119279. /**
  119280. * Defines the pointer angular sensibility along the Y axis or how fast is
  119281. * the camera rotating.
  119282. */
  119283. angularSensibilityY: number;
  119284. /**
  119285. * Defines the pointer pinch precision or how fast is the camera zooming.
  119286. */
  119287. pinchPrecision: number;
  119288. /**
  119289. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  119290. * from 0.
  119291. * It defines the percentage of current camera.radius to use as delta when
  119292. * pinch zoom is used.
  119293. */
  119294. pinchDeltaPercentage: number;
  119295. /**
  119296. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119297. * that any object in the plane at the camera's target point will scale
  119298. * perfectly with finger motion.
  119299. * Overrides pinchDeltaPercentage and pinchPrecision.
  119300. */
  119301. useNaturalPinchZoom: boolean;
  119302. /**
  119303. * Defines the pointer panning sensibility or how fast is the camera moving.
  119304. */
  119305. panningSensibility: number;
  119306. /**
  119307. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  119308. */
  119309. multiTouchPanning: boolean;
  119310. /**
  119311. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  119312. * zoom (pinch) through multitouch.
  119313. */
  119314. multiTouchPanAndZoom: boolean;
  119315. /**
  119316. * Revers pinch action direction.
  119317. */
  119318. pinchInwards: boolean;
  119319. private _isPanClick;
  119320. private _twoFingerActivityCount;
  119321. private _isPinching;
  119322. /**
  119323. * Called on pointer POINTERMOVE event if only a single touch is active.
  119324. */
  119325. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119326. /**
  119327. * Called on pointer POINTERDOUBLETAP event.
  119328. */
  119329. protected onDoubleTap(type: string): void;
  119330. /**
  119331. * Called on pointer POINTERMOVE event if multiple touches are active.
  119332. */
  119333. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119334. /**
  119335. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  119336. * press.
  119337. */
  119338. protected onButtonDown(evt: PointerEvent): void;
  119339. /**
  119340. * Called each time a new POINTERUP event occurs. Ie, for each button
  119341. * release.
  119342. */
  119343. protected onButtonUp(evt: PointerEvent): void;
  119344. /**
  119345. * Called when window becomes inactive.
  119346. */
  119347. protected onLostFocus(): void;
  119348. }
  119349. }
  119350. declare module BABYLON {
  119351. /**
  119352. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  119353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119354. */
  119355. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  119356. /**
  119357. * Defines the camera the input is attached to.
  119358. */
  119359. camera: ArcRotateCamera;
  119360. /**
  119361. * Defines the list of key codes associated with the up action (increase alpha)
  119362. */
  119363. keysUp: number[];
  119364. /**
  119365. * Defines the list of key codes associated with the down action (decrease alpha)
  119366. */
  119367. keysDown: number[];
  119368. /**
  119369. * Defines the list of key codes associated with the left action (increase beta)
  119370. */
  119371. keysLeft: number[];
  119372. /**
  119373. * Defines the list of key codes associated with the right action (decrease beta)
  119374. */
  119375. keysRight: number[];
  119376. /**
  119377. * Defines the list of key codes associated with the reset action.
  119378. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  119379. */
  119380. keysReset: number[];
  119381. /**
  119382. * Defines the panning sensibility of the inputs.
  119383. * (How fast is the camera panning)
  119384. */
  119385. panningSensibility: number;
  119386. /**
  119387. * Defines the zooming sensibility of the inputs.
  119388. * (How fast is the camera zooming)
  119389. */
  119390. zoomingSensibility: number;
  119391. /**
  119392. * Defines whether maintaining the alt key down switch the movement mode from
  119393. * orientation to zoom.
  119394. */
  119395. useAltToZoom: boolean;
  119396. /**
  119397. * Rotation speed of the camera
  119398. */
  119399. angularSpeed: number;
  119400. private _keys;
  119401. private _ctrlPressed;
  119402. private _altPressed;
  119403. private _onCanvasBlurObserver;
  119404. private _onKeyboardObserver;
  119405. private _engine;
  119406. private _scene;
  119407. /**
  119408. * Attach the input controls to a specific dom element to get the input from.
  119409. * @param element Defines the element the controls should be listened from
  119410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119411. */
  119412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119413. /**
  119414. * Detach the current controls from the specified dom element.
  119415. * @param element Defines the element to stop listening the inputs from
  119416. */
  119417. detachControl(element: Nullable<HTMLElement>): void;
  119418. /**
  119419. * Update the current camera state depending on the inputs that have been used this frame.
  119420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  119421. */
  119422. checkInputs(): void;
  119423. /**
  119424. * Gets the class name of the current intput.
  119425. * @returns the class name
  119426. */
  119427. getClassName(): string;
  119428. /**
  119429. * Get the friendly name associated with the input class.
  119430. * @returns the input friendly name
  119431. */
  119432. getSimpleName(): string;
  119433. }
  119434. }
  119435. declare module BABYLON {
  119436. /**
  119437. * Manage the mouse wheel inputs to control an arc rotate camera.
  119438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119439. */
  119440. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  119441. /**
  119442. * Defines the camera the input is attached to.
  119443. */
  119444. camera: ArcRotateCamera;
  119445. /**
  119446. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119447. */
  119448. wheelPrecision: number;
  119449. /**
  119450. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  119451. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  119452. */
  119453. wheelDeltaPercentage: number;
  119454. private _wheel;
  119455. private _observer;
  119456. private computeDeltaFromMouseWheelLegacyEvent;
  119457. /**
  119458. * Attach the input controls to a specific dom element to get the input from.
  119459. * @param element Defines the element the controls should be listened from
  119460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119461. */
  119462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119463. /**
  119464. * Detach the current controls from the specified dom element.
  119465. * @param element Defines the element to stop listening the inputs from
  119466. */
  119467. detachControl(element: Nullable<HTMLElement>): void;
  119468. /**
  119469. * Gets the class name of the current intput.
  119470. * @returns the class name
  119471. */
  119472. getClassName(): string;
  119473. /**
  119474. * Get the friendly name associated with the input class.
  119475. * @returns the input friendly name
  119476. */
  119477. getSimpleName(): string;
  119478. }
  119479. }
  119480. declare module BABYLON {
  119481. /**
  119482. * Default Inputs manager for the ArcRotateCamera.
  119483. * It groups all the default supported inputs for ease of use.
  119484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  119485. */
  119486. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  119487. /**
  119488. * Instantiates a new ArcRotateCameraInputsManager.
  119489. * @param camera Defines the camera the inputs belong to
  119490. */
  119491. constructor(camera: ArcRotateCamera);
  119492. /**
  119493. * Add mouse wheel input support to the input manager.
  119494. * @returns the current input manager
  119495. */
  119496. addMouseWheel(): ArcRotateCameraInputsManager;
  119497. /**
  119498. * Add pointers input support to the input manager.
  119499. * @returns the current input manager
  119500. */
  119501. addPointers(): ArcRotateCameraInputsManager;
  119502. /**
  119503. * Add keyboard input support to the input manager.
  119504. * @returns the current input manager
  119505. */
  119506. addKeyboard(): ArcRotateCameraInputsManager;
  119507. }
  119508. }
  119509. declare module BABYLON {
  119510. /**
  119511. * This represents an orbital type of camera.
  119512. *
  119513. * 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.
  119514. * 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.
  119515. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  119516. */
  119517. export class ArcRotateCamera extends TargetCamera {
  119518. /**
  119519. * Defines the rotation angle of the camera along the longitudinal axis.
  119520. */
  119521. alpha: number;
  119522. /**
  119523. * Defines the rotation angle of the camera along the latitudinal axis.
  119524. */
  119525. beta: number;
  119526. /**
  119527. * Defines the radius of the camera from it s target point.
  119528. */
  119529. radius: number;
  119530. protected _target: Vector3;
  119531. protected _targetHost: Nullable<AbstractMesh>;
  119532. /**
  119533. * Defines the target point of the camera.
  119534. * The camera looks towards it form the radius distance.
  119535. */
  119536. get target(): Vector3;
  119537. set target(value: Vector3);
  119538. /**
  119539. * Define the current local position of the camera in the scene
  119540. */
  119541. get position(): Vector3;
  119542. set position(newPosition: Vector3);
  119543. protected _upVector: Vector3;
  119544. protected _upToYMatrix: Matrix;
  119545. protected _YToUpMatrix: Matrix;
  119546. /**
  119547. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  119548. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  119549. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  119550. */
  119551. set upVector(vec: Vector3);
  119552. get upVector(): Vector3;
  119553. /**
  119554. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  119555. */
  119556. setMatUp(): void;
  119557. /**
  119558. * Current inertia value on the longitudinal axis.
  119559. * The bigger this number the longer it will take for the camera to stop.
  119560. */
  119561. inertialAlphaOffset: number;
  119562. /**
  119563. * Current inertia value on the latitudinal axis.
  119564. * The bigger this number the longer it will take for the camera to stop.
  119565. */
  119566. inertialBetaOffset: number;
  119567. /**
  119568. * Current inertia value on the radius axis.
  119569. * The bigger this number the longer it will take for the camera to stop.
  119570. */
  119571. inertialRadiusOffset: number;
  119572. /**
  119573. * Minimum allowed angle on the longitudinal axis.
  119574. * This can help limiting how the Camera is able to move in the scene.
  119575. */
  119576. lowerAlphaLimit: Nullable<number>;
  119577. /**
  119578. * Maximum allowed angle on the longitudinal axis.
  119579. * This can help limiting how the Camera is able to move in the scene.
  119580. */
  119581. upperAlphaLimit: Nullable<number>;
  119582. /**
  119583. * Minimum allowed angle on the latitudinal axis.
  119584. * This can help limiting how the Camera is able to move in the scene.
  119585. */
  119586. lowerBetaLimit: number;
  119587. /**
  119588. * Maximum allowed angle on the latitudinal axis.
  119589. * This can help limiting how the Camera is able to move in the scene.
  119590. */
  119591. upperBetaLimit: number;
  119592. /**
  119593. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  119594. * This can help limiting how the Camera is able to move in the scene.
  119595. */
  119596. lowerRadiusLimit: Nullable<number>;
  119597. /**
  119598. * Maximum allowed distance of the camera to the target (The camera can not get further).
  119599. * This can help limiting how the Camera is able to move in the scene.
  119600. */
  119601. upperRadiusLimit: Nullable<number>;
  119602. /**
  119603. * Defines the current inertia value used during panning of the camera along the X axis.
  119604. */
  119605. inertialPanningX: number;
  119606. /**
  119607. * Defines the current inertia value used during panning of the camera along the Y axis.
  119608. */
  119609. inertialPanningY: number;
  119610. /**
  119611. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  119612. * Basically if your fingers moves away from more than this distance you will be considered
  119613. * in pinch mode.
  119614. */
  119615. pinchToPanMaxDistance: number;
  119616. /**
  119617. * Defines the maximum distance the camera can pan.
  119618. * This could help keeping the cammera always in your scene.
  119619. */
  119620. panningDistanceLimit: Nullable<number>;
  119621. /**
  119622. * Defines the target of the camera before paning.
  119623. */
  119624. panningOriginTarget: Vector3;
  119625. /**
  119626. * Defines the value of the inertia used during panning.
  119627. * 0 would mean stop inertia and one would mean no decelleration at all.
  119628. */
  119629. panningInertia: number;
  119630. /**
  119631. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  119632. */
  119633. get angularSensibilityX(): number;
  119634. set angularSensibilityX(value: number);
  119635. /**
  119636. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  119637. */
  119638. get angularSensibilityY(): number;
  119639. set angularSensibilityY(value: number);
  119640. /**
  119641. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  119642. */
  119643. get pinchPrecision(): number;
  119644. set pinchPrecision(value: number);
  119645. /**
  119646. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  119647. * It will be used instead of pinchDeltaPrecision if different from 0.
  119648. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119649. */
  119650. get pinchDeltaPercentage(): number;
  119651. set pinchDeltaPercentage(value: number);
  119652. /**
  119653. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  119654. * and pinch delta percentage.
  119655. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  119656. * that any object in the plane at the camera's target point will scale
  119657. * perfectly with finger motion.
  119658. */
  119659. get useNaturalPinchZoom(): boolean;
  119660. set useNaturalPinchZoom(value: boolean);
  119661. /**
  119662. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  119663. */
  119664. get panningSensibility(): number;
  119665. set panningSensibility(value: number);
  119666. /**
  119667. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  119668. */
  119669. get keysUp(): number[];
  119670. set keysUp(value: number[]);
  119671. /**
  119672. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  119673. */
  119674. get keysDown(): number[];
  119675. set keysDown(value: number[]);
  119676. /**
  119677. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  119678. */
  119679. get keysLeft(): number[];
  119680. set keysLeft(value: number[]);
  119681. /**
  119682. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  119683. */
  119684. get keysRight(): number[];
  119685. set keysRight(value: number[]);
  119686. /**
  119687. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  119688. */
  119689. get wheelPrecision(): number;
  119690. set wheelPrecision(value: number);
  119691. /**
  119692. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  119693. * It will be used instead of pinchDeltaPrecision if different from 0.
  119694. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  119695. */
  119696. get wheelDeltaPercentage(): number;
  119697. set wheelDeltaPercentage(value: number);
  119698. /**
  119699. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  119700. */
  119701. zoomOnFactor: number;
  119702. /**
  119703. * Defines a screen offset for the camera position.
  119704. */
  119705. targetScreenOffset: Vector2;
  119706. /**
  119707. * Allows the camera to be completely reversed.
  119708. * If false the camera can not arrive upside down.
  119709. */
  119710. allowUpsideDown: boolean;
  119711. /**
  119712. * Define if double tap/click is used to restore the previously saved state of the camera.
  119713. */
  119714. useInputToRestoreState: boolean;
  119715. /** @hidden */
  119716. _viewMatrix: Matrix;
  119717. /** @hidden */
  119718. _useCtrlForPanning: boolean;
  119719. /** @hidden */
  119720. _panningMouseButton: number;
  119721. /**
  119722. * Defines the input associated to the camera.
  119723. */
  119724. inputs: ArcRotateCameraInputsManager;
  119725. /** @hidden */
  119726. _reset: () => void;
  119727. /**
  119728. * Defines the allowed panning axis.
  119729. */
  119730. panningAxis: Vector3;
  119731. protected _localDirection: Vector3;
  119732. protected _transformedDirection: Vector3;
  119733. private _bouncingBehavior;
  119734. /**
  119735. * Gets the bouncing behavior of the camera if it has been enabled.
  119736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119737. */
  119738. get bouncingBehavior(): Nullable<BouncingBehavior>;
  119739. /**
  119740. * Defines if the bouncing behavior of the camera is enabled on the camera.
  119741. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119742. */
  119743. get useBouncingBehavior(): boolean;
  119744. set useBouncingBehavior(value: boolean);
  119745. private _framingBehavior;
  119746. /**
  119747. * Gets the framing behavior of the camera if it has been enabled.
  119748. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119749. */
  119750. get framingBehavior(): Nullable<FramingBehavior>;
  119751. /**
  119752. * Defines if the framing behavior of the camera is enabled on the camera.
  119753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119754. */
  119755. get useFramingBehavior(): boolean;
  119756. set useFramingBehavior(value: boolean);
  119757. private _autoRotationBehavior;
  119758. /**
  119759. * Gets the auto rotation behavior of the camera if it has been enabled.
  119760. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119761. */
  119762. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  119763. /**
  119764. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  119765. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119766. */
  119767. get useAutoRotationBehavior(): boolean;
  119768. set useAutoRotationBehavior(value: boolean);
  119769. /**
  119770. * Observable triggered when the mesh target has been changed on the camera.
  119771. */
  119772. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  119773. /**
  119774. * Event raised when the camera is colliding with a mesh.
  119775. */
  119776. onCollide: (collidedMesh: AbstractMesh) => void;
  119777. /**
  119778. * Defines whether the camera should check collision with the objects oh the scene.
  119779. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  119780. */
  119781. checkCollisions: boolean;
  119782. /**
  119783. * Defines the collision radius of the camera.
  119784. * This simulates a sphere around the camera.
  119785. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  119786. */
  119787. collisionRadius: Vector3;
  119788. protected _collider: Collider;
  119789. protected _previousPosition: Vector3;
  119790. protected _collisionVelocity: Vector3;
  119791. protected _newPosition: Vector3;
  119792. protected _previousAlpha: number;
  119793. protected _previousBeta: number;
  119794. protected _previousRadius: number;
  119795. protected _collisionTriggered: boolean;
  119796. protected _targetBoundingCenter: Nullable<Vector3>;
  119797. private _computationVector;
  119798. /**
  119799. * Instantiates a new ArcRotateCamera in a given scene
  119800. * @param name Defines the name of the camera
  119801. * @param alpha Defines the camera rotation along the logitudinal axis
  119802. * @param beta Defines the camera rotation along the latitudinal axis
  119803. * @param radius Defines the camera distance from its target
  119804. * @param target Defines the camera target
  119805. * @param scene Defines the scene the camera belongs to
  119806. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  119807. */
  119808. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  119809. /** @hidden */
  119810. _initCache(): void;
  119811. /** @hidden */
  119812. _updateCache(ignoreParentClass?: boolean): void;
  119813. protected _getTargetPosition(): Vector3;
  119814. private _storedAlpha;
  119815. private _storedBeta;
  119816. private _storedRadius;
  119817. private _storedTarget;
  119818. private _storedTargetScreenOffset;
  119819. /**
  119820. * Stores the current state of the camera (alpha, beta, radius and target)
  119821. * @returns the camera itself
  119822. */
  119823. storeState(): Camera;
  119824. /**
  119825. * @hidden
  119826. * Restored camera state. You must call storeState() first
  119827. */
  119828. _restoreStateValues(): boolean;
  119829. /** @hidden */
  119830. _isSynchronizedViewMatrix(): boolean;
  119831. /**
  119832. * Attached controls to the current camera.
  119833. * @param element Defines the element the controls should be listened from
  119834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119835. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  119836. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  119837. */
  119838. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  119839. /**
  119840. * Detach the current controls from the camera.
  119841. * The camera will stop reacting to inputs.
  119842. * @param element Defines the element to stop listening the inputs from
  119843. */
  119844. detachControl(element: HTMLElement): void;
  119845. /** @hidden */
  119846. _checkInputs(): void;
  119847. protected _checkLimits(): void;
  119848. /**
  119849. * Rebuilds angles (alpha, beta) and radius from the give position and target
  119850. */
  119851. rebuildAnglesAndRadius(): void;
  119852. /**
  119853. * Use a position to define the current camera related information like alpha, beta and radius
  119854. * @param position Defines the position to set the camera at
  119855. */
  119856. setPosition(position: Vector3): void;
  119857. /**
  119858. * Defines the target the camera should look at.
  119859. * This will automatically adapt alpha beta and radius to fit within the new target.
  119860. * @param target Defines the new target as a Vector or a mesh
  119861. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  119862. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  119863. */
  119864. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  119865. /** @hidden */
  119866. _getViewMatrix(): Matrix;
  119867. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  119868. /**
  119869. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  119870. * @param meshes Defines the mesh to zoom on
  119871. * @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)
  119872. */
  119873. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  119874. /**
  119875. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  119876. * The target will be changed but the radius
  119877. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  119878. * @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)
  119879. */
  119880. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  119881. min: Vector3;
  119882. max: Vector3;
  119883. distance: number;
  119884. }, doNotUpdateMaxZ?: boolean): void;
  119885. /**
  119886. * @override
  119887. * Override Camera.createRigCamera
  119888. */
  119889. createRigCamera(name: string, cameraIndex: number): Camera;
  119890. /**
  119891. * @hidden
  119892. * @override
  119893. * Override Camera._updateRigCameras
  119894. */
  119895. _updateRigCameras(): void;
  119896. /**
  119897. * Destroy the camera and release the current resources hold by it.
  119898. */
  119899. dispose(): void;
  119900. /**
  119901. * Gets the current object class name.
  119902. * @return the class name
  119903. */
  119904. getClassName(): string;
  119905. }
  119906. }
  119907. declare module BABYLON {
  119908. /**
  119909. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  119910. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  119911. */
  119912. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  119913. /**
  119914. * Gets the name of the behavior.
  119915. */
  119916. get name(): string;
  119917. private _zoomStopsAnimation;
  119918. private _idleRotationSpeed;
  119919. private _idleRotationWaitTime;
  119920. private _idleRotationSpinupTime;
  119921. /**
  119922. * Sets the flag that indicates if user zooming should stop animation.
  119923. */
  119924. set zoomStopsAnimation(flag: boolean);
  119925. /**
  119926. * Gets the flag that indicates if user zooming should stop animation.
  119927. */
  119928. get zoomStopsAnimation(): boolean;
  119929. /**
  119930. * Sets the default speed at which the camera rotates around the model.
  119931. */
  119932. set idleRotationSpeed(speed: number);
  119933. /**
  119934. * Gets the default speed at which the camera rotates around the model.
  119935. */
  119936. get idleRotationSpeed(): number;
  119937. /**
  119938. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  119939. */
  119940. set idleRotationWaitTime(time: number);
  119941. /**
  119942. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  119943. */
  119944. get idleRotationWaitTime(): number;
  119945. /**
  119946. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119947. */
  119948. set idleRotationSpinupTime(time: number);
  119949. /**
  119950. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  119951. */
  119952. get idleRotationSpinupTime(): number;
  119953. /**
  119954. * Gets a value indicating if the camera is currently rotating because of this behavior
  119955. */
  119956. get rotationInProgress(): boolean;
  119957. private _onPrePointerObservableObserver;
  119958. private _onAfterCheckInputsObserver;
  119959. private _attachedCamera;
  119960. private _isPointerDown;
  119961. private _lastFrameTime;
  119962. private _lastInteractionTime;
  119963. private _cameraRotationSpeed;
  119964. /**
  119965. * Initializes the behavior.
  119966. */
  119967. init(): void;
  119968. /**
  119969. * Attaches the behavior to its arc rotate camera.
  119970. * @param camera Defines the camera to attach the behavior to
  119971. */
  119972. attach(camera: ArcRotateCamera): void;
  119973. /**
  119974. * Detaches the behavior from its current arc rotate camera.
  119975. */
  119976. detach(): void;
  119977. /**
  119978. * Returns true if user is scrolling.
  119979. * @return true if user is scrolling.
  119980. */
  119981. private _userIsZooming;
  119982. private _lastFrameRadius;
  119983. private _shouldAnimationStopForInteraction;
  119984. /**
  119985. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119986. */
  119987. private _applyUserInteraction;
  119988. private _userIsMoving;
  119989. }
  119990. }
  119991. declare module BABYLON {
  119992. /**
  119993. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  119994. */
  119995. export class AttachToBoxBehavior implements Behavior<Mesh> {
  119996. private ui;
  119997. /**
  119998. * The name of the behavior
  119999. */
  120000. name: string;
  120001. /**
  120002. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120003. */
  120004. distanceAwayFromFace: number;
  120005. /**
  120006. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120007. */
  120008. distanceAwayFromBottomOfFace: number;
  120009. private _faceVectors;
  120010. private _target;
  120011. private _scene;
  120012. private _onRenderObserver;
  120013. private _tmpMatrix;
  120014. private _tmpVector;
  120015. /**
  120016. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120017. * @param ui The transform node that should be attched to the mesh
  120018. */
  120019. constructor(ui: TransformNode);
  120020. /**
  120021. * Initializes the behavior
  120022. */
  120023. init(): void;
  120024. private _closestFace;
  120025. private _zeroVector;
  120026. private _lookAtTmpMatrix;
  120027. private _lookAtToRef;
  120028. /**
  120029. * Attaches the AttachToBoxBehavior to the passed in mesh
  120030. * @param target The mesh that the specified node will be attached to
  120031. */
  120032. attach(target: Mesh): void;
  120033. /**
  120034. * Detaches the behavior from the mesh
  120035. */
  120036. detach(): void;
  120037. }
  120038. }
  120039. declare module BABYLON {
  120040. /**
  120041. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120042. */
  120043. export class FadeInOutBehavior implements Behavior<Mesh> {
  120044. /**
  120045. * Time in milliseconds to delay before fading in (Default: 0)
  120046. */
  120047. delay: number;
  120048. /**
  120049. * Time in milliseconds for the mesh to fade in (Default: 300)
  120050. */
  120051. fadeInTime: number;
  120052. private _millisecondsPerFrame;
  120053. private _hovered;
  120054. private _hoverValue;
  120055. private _ownerNode;
  120056. /**
  120057. * Instatiates the FadeInOutBehavior
  120058. */
  120059. constructor();
  120060. /**
  120061. * The name of the behavior
  120062. */
  120063. get name(): string;
  120064. /**
  120065. * Initializes the behavior
  120066. */
  120067. init(): void;
  120068. /**
  120069. * Attaches the fade behavior on the passed in mesh
  120070. * @param ownerNode The mesh that will be faded in/out once attached
  120071. */
  120072. attach(ownerNode: Mesh): void;
  120073. /**
  120074. * Detaches the behavior from the mesh
  120075. */
  120076. detach(): void;
  120077. /**
  120078. * Triggers the mesh to begin fading in or out
  120079. * @param value if the object should fade in or out (true to fade in)
  120080. */
  120081. fadeIn(value: boolean): void;
  120082. private _update;
  120083. private _setAllVisibility;
  120084. }
  120085. }
  120086. declare module BABYLON {
  120087. /**
  120088. * Class containing a set of static utilities functions for managing Pivots
  120089. * @hidden
  120090. */
  120091. export class PivotTools {
  120092. private static _PivotCached;
  120093. private static _OldPivotPoint;
  120094. private static _PivotTranslation;
  120095. private static _PivotTmpVector;
  120096. /** @hidden */
  120097. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120098. /** @hidden */
  120099. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120100. }
  120101. }
  120102. declare module BABYLON {
  120103. /**
  120104. * Class containing static functions to help procedurally build meshes
  120105. */
  120106. export class PlaneBuilder {
  120107. /**
  120108. * Creates a plane mesh
  120109. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120110. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120111. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120115. * @param name defines the name of the mesh
  120116. * @param options defines the options used to create the mesh
  120117. * @param scene defines the hosting scene
  120118. * @returns the plane mesh
  120119. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120120. */
  120121. static CreatePlane(name: string, options: {
  120122. size?: number;
  120123. width?: number;
  120124. height?: number;
  120125. sideOrientation?: number;
  120126. frontUVs?: Vector4;
  120127. backUVs?: Vector4;
  120128. updatable?: boolean;
  120129. sourcePlane?: Plane;
  120130. }, scene?: Nullable<Scene>): Mesh;
  120131. }
  120132. }
  120133. declare module BABYLON {
  120134. /**
  120135. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120136. */
  120137. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120138. private static _AnyMouseID;
  120139. /**
  120140. * Abstract mesh the behavior is set on
  120141. */
  120142. attachedNode: AbstractMesh;
  120143. private _dragPlane;
  120144. private _scene;
  120145. private _pointerObserver;
  120146. private _beforeRenderObserver;
  120147. private static _planeScene;
  120148. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120149. /**
  120150. * 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)
  120151. */
  120152. maxDragAngle: number;
  120153. /**
  120154. * @hidden
  120155. */
  120156. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120157. /**
  120158. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120159. */
  120160. currentDraggingPointerID: number;
  120161. /**
  120162. * The last position where the pointer hit the drag plane in world space
  120163. */
  120164. lastDragPosition: Vector3;
  120165. /**
  120166. * If the behavior is currently in a dragging state
  120167. */
  120168. dragging: boolean;
  120169. /**
  120170. * 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)
  120171. */
  120172. dragDeltaRatio: number;
  120173. /**
  120174. * If the drag plane orientation should be updated during the dragging (Default: true)
  120175. */
  120176. updateDragPlane: boolean;
  120177. private _debugMode;
  120178. private _moving;
  120179. /**
  120180. * Fires each time the attached mesh is dragged with the pointer
  120181. * * delta between last drag position and current drag position in world space
  120182. * * dragDistance along the drag axis
  120183. * * dragPlaneNormal normal of the current drag plane used during the drag
  120184. * * dragPlanePoint in world space where the drag intersects the drag plane
  120185. */
  120186. onDragObservable: Observable<{
  120187. delta: Vector3;
  120188. dragPlanePoint: Vector3;
  120189. dragPlaneNormal: Vector3;
  120190. dragDistance: number;
  120191. pointerId: number;
  120192. }>;
  120193. /**
  120194. * Fires each time a drag begins (eg. mouse down on mesh)
  120195. */
  120196. onDragStartObservable: Observable<{
  120197. dragPlanePoint: Vector3;
  120198. pointerId: number;
  120199. }>;
  120200. /**
  120201. * Fires each time a drag ends (eg. mouse release after drag)
  120202. */
  120203. onDragEndObservable: Observable<{
  120204. dragPlanePoint: Vector3;
  120205. pointerId: number;
  120206. }>;
  120207. /**
  120208. * If the attached mesh should be moved when dragged
  120209. */
  120210. moveAttached: boolean;
  120211. /**
  120212. * If the drag behavior will react to drag events (Default: true)
  120213. */
  120214. enabled: boolean;
  120215. /**
  120216. * If pointer events should start and release the drag (Default: true)
  120217. */
  120218. startAndReleaseDragOnPointerEvents: boolean;
  120219. /**
  120220. * If camera controls should be detached during the drag
  120221. */
  120222. detachCameraControls: boolean;
  120223. /**
  120224. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120225. */
  120226. useObjectOrientationForDragging: boolean;
  120227. private _options;
  120228. /**
  120229. * Gets the options used by the behavior
  120230. */
  120231. get options(): {
  120232. dragAxis?: Vector3;
  120233. dragPlaneNormal?: Vector3;
  120234. };
  120235. /**
  120236. * Sets the options used by the behavior
  120237. */
  120238. set options(options: {
  120239. dragAxis?: Vector3;
  120240. dragPlaneNormal?: Vector3;
  120241. });
  120242. /**
  120243. * Creates a pointer drag behavior that can be attached to a mesh
  120244. * @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)
  120245. */
  120246. constructor(options?: {
  120247. dragAxis?: Vector3;
  120248. dragPlaneNormal?: Vector3;
  120249. });
  120250. /**
  120251. * Predicate to determine if it is valid to move the object to a new position when it is moved
  120252. */
  120253. validateDrag: (targetPosition: Vector3) => boolean;
  120254. /**
  120255. * The name of the behavior
  120256. */
  120257. get name(): string;
  120258. /**
  120259. * Initializes the behavior
  120260. */
  120261. init(): void;
  120262. private _tmpVector;
  120263. private _alternatePickedPoint;
  120264. private _worldDragAxis;
  120265. private _targetPosition;
  120266. private _attachedElement;
  120267. /**
  120268. * Attaches the drag behavior the passed in mesh
  120269. * @param ownerNode The mesh that will be dragged around once attached
  120270. * @param predicate Predicate to use for pick filtering
  120271. */
  120272. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  120273. /**
  120274. * Force relase the drag action by code.
  120275. */
  120276. releaseDrag(): void;
  120277. private _startDragRay;
  120278. private _lastPointerRay;
  120279. /**
  120280. * Simulates the start of a pointer drag event on the behavior
  120281. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  120282. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  120283. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  120284. */
  120285. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  120286. private _startDrag;
  120287. private _dragDelta;
  120288. private _moveDrag;
  120289. private _pickWithRayOnDragPlane;
  120290. private _pointA;
  120291. private _pointB;
  120292. private _pointC;
  120293. private _lineA;
  120294. private _lineB;
  120295. private _localAxis;
  120296. private _lookAt;
  120297. private _updateDragPlanePosition;
  120298. /**
  120299. * Detaches the behavior from the mesh
  120300. */
  120301. detach(): void;
  120302. }
  120303. }
  120304. declare module BABYLON {
  120305. /**
  120306. * A behavior that when attached to a mesh will allow the mesh to be scaled
  120307. */
  120308. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  120309. private _dragBehaviorA;
  120310. private _dragBehaviorB;
  120311. private _startDistance;
  120312. private _initialScale;
  120313. private _targetScale;
  120314. private _ownerNode;
  120315. private _sceneRenderObserver;
  120316. /**
  120317. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  120318. */
  120319. constructor();
  120320. /**
  120321. * The name of the behavior
  120322. */
  120323. get name(): string;
  120324. /**
  120325. * Initializes the behavior
  120326. */
  120327. init(): void;
  120328. private _getCurrentDistance;
  120329. /**
  120330. * Attaches the scale behavior the passed in mesh
  120331. * @param ownerNode The mesh that will be scaled around once attached
  120332. */
  120333. attach(ownerNode: Mesh): void;
  120334. /**
  120335. * Detaches the behavior from the mesh
  120336. */
  120337. detach(): void;
  120338. }
  120339. }
  120340. declare module BABYLON {
  120341. /**
  120342. * 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
  120343. */
  120344. export class SixDofDragBehavior implements Behavior<Mesh> {
  120345. private static _virtualScene;
  120346. private _ownerNode;
  120347. private _sceneRenderObserver;
  120348. private _scene;
  120349. private _targetPosition;
  120350. private _virtualOriginMesh;
  120351. private _virtualDragMesh;
  120352. private _pointerObserver;
  120353. private _moving;
  120354. private _startingOrientation;
  120355. private _attachedElement;
  120356. /**
  120357. * 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)
  120358. */
  120359. private zDragFactor;
  120360. /**
  120361. * If the object should rotate to face the drag origin
  120362. */
  120363. rotateDraggedObject: boolean;
  120364. /**
  120365. * If the behavior is currently in a dragging state
  120366. */
  120367. dragging: boolean;
  120368. /**
  120369. * 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)
  120370. */
  120371. dragDeltaRatio: number;
  120372. /**
  120373. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120374. */
  120375. currentDraggingPointerID: number;
  120376. /**
  120377. * If camera controls should be detached during the drag
  120378. */
  120379. detachCameraControls: boolean;
  120380. /**
  120381. * Fires each time a drag starts
  120382. */
  120383. onDragStartObservable: Observable<{}>;
  120384. /**
  120385. * Fires each time a drag ends (eg. mouse release after drag)
  120386. */
  120387. onDragEndObservable: Observable<{}>;
  120388. /**
  120389. * 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
  120390. */
  120391. constructor();
  120392. /**
  120393. * The name of the behavior
  120394. */
  120395. get name(): string;
  120396. /**
  120397. * Initializes the behavior
  120398. */
  120399. init(): void;
  120400. /**
  120401. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  120402. */
  120403. private get _pointerCamera();
  120404. /**
  120405. * Attaches the scale behavior the passed in mesh
  120406. * @param ownerNode The mesh that will be scaled around once attached
  120407. */
  120408. attach(ownerNode: Mesh): void;
  120409. /**
  120410. * Detaches the behavior from the mesh
  120411. */
  120412. detach(): void;
  120413. }
  120414. }
  120415. declare module BABYLON {
  120416. /**
  120417. * Class used to apply inverse kinematics to bones
  120418. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  120419. */
  120420. export class BoneIKController {
  120421. private static _tmpVecs;
  120422. private static _tmpQuat;
  120423. private static _tmpMats;
  120424. /**
  120425. * Gets or sets the target mesh
  120426. */
  120427. targetMesh: AbstractMesh;
  120428. /** Gets or sets the mesh used as pole */
  120429. poleTargetMesh: AbstractMesh;
  120430. /**
  120431. * Gets or sets the bone used as pole
  120432. */
  120433. poleTargetBone: Nullable<Bone>;
  120434. /**
  120435. * Gets or sets the target position
  120436. */
  120437. targetPosition: Vector3;
  120438. /**
  120439. * Gets or sets the pole target position
  120440. */
  120441. poleTargetPosition: Vector3;
  120442. /**
  120443. * Gets or sets the pole target local offset
  120444. */
  120445. poleTargetLocalOffset: Vector3;
  120446. /**
  120447. * Gets or sets the pole angle
  120448. */
  120449. poleAngle: number;
  120450. /**
  120451. * Gets or sets the mesh associated with the controller
  120452. */
  120453. mesh: AbstractMesh;
  120454. /**
  120455. * 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)
  120456. */
  120457. slerpAmount: number;
  120458. private _bone1Quat;
  120459. private _bone1Mat;
  120460. private _bone2Ang;
  120461. private _bone1;
  120462. private _bone2;
  120463. private _bone1Length;
  120464. private _bone2Length;
  120465. private _maxAngle;
  120466. private _maxReach;
  120467. private _rightHandedSystem;
  120468. private _bendAxis;
  120469. private _slerping;
  120470. private _adjustRoll;
  120471. /**
  120472. * Gets or sets maximum allowed angle
  120473. */
  120474. get maxAngle(): number;
  120475. set maxAngle(value: number);
  120476. /**
  120477. * Creates a new BoneIKController
  120478. * @param mesh defines the mesh to control
  120479. * @param bone defines the bone to control
  120480. * @param options defines options to set up the controller
  120481. */
  120482. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  120483. targetMesh?: AbstractMesh;
  120484. poleTargetMesh?: AbstractMesh;
  120485. poleTargetBone?: Bone;
  120486. poleTargetLocalOffset?: Vector3;
  120487. poleAngle?: number;
  120488. bendAxis?: Vector3;
  120489. maxAngle?: number;
  120490. slerpAmount?: number;
  120491. });
  120492. private _setMaxAngle;
  120493. /**
  120494. * Force the controller to update the bones
  120495. */
  120496. update(): void;
  120497. }
  120498. }
  120499. declare module BABYLON {
  120500. /**
  120501. * Class used to make a bone look toward a point in space
  120502. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  120503. */
  120504. export class BoneLookController {
  120505. private static _tmpVecs;
  120506. private static _tmpQuat;
  120507. private static _tmpMats;
  120508. /**
  120509. * The target Vector3 that the bone will look at
  120510. */
  120511. target: Vector3;
  120512. /**
  120513. * The mesh that the bone is attached to
  120514. */
  120515. mesh: AbstractMesh;
  120516. /**
  120517. * The bone that will be looking to the target
  120518. */
  120519. bone: Bone;
  120520. /**
  120521. * The up axis of the coordinate system that is used when the bone is rotated
  120522. */
  120523. upAxis: Vector3;
  120524. /**
  120525. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  120526. */
  120527. upAxisSpace: Space;
  120528. /**
  120529. * Used to make an adjustment to the yaw of the bone
  120530. */
  120531. adjustYaw: number;
  120532. /**
  120533. * Used to make an adjustment to the pitch of the bone
  120534. */
  120535. adjustPitch: number;
  120536. /**
  120537. * Used to make an adjustment to the roll of the bone
  120538. */
  120539. adjustRoll: number;
  120540. /**
  120541. * 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)
  120542. */
  120543. slerpAmount: number;
  120544. private _minYaw;
  120545. private _maxYaw;
  120546. private _minPitch;
  120547. private _maxPitch;
  120548. private _minYawSin;
  120549. private _minYawCos;
  120550. private _maxYawSin;
  120551. private _maxYawCos;
  120552. private _midYawConstraint;
  120553. private _minPitchTan;
  120554. private _maxPitchTan;
  120555. private _boneQuat;
  120556. private _slerping;
  120557. private _transformYawPitch;
  120558. private _transformYawPitchInv;
  120559. private _firstFrameSkipped;
  120560. private _yawRange;
  120561. private _fowardAxis;
  120562. /**
  120563. * Gets or sets the minimum yaw angle that the bone can look to
  120564. */
  120565. get minYaw(): number;
  120566. set minYaw(value: number);
  120567. /**
  120568. * Gets or sets the maximum yaw angle that the bone can look to
  120569. */
  120570. get maxYaw(): number;
  120571. set maxYaw(value: number);
  120572. /**
  120573. * Gets or sets the minimum pitch angle that the bone can look to
  120574. */
  120575. get minPitch(): number;
  120576. set minPitch(value: number);
  120577. /**
  120578. * Gets or sets the maximum pitch angle that the bone can look to
  120579. */
  120580. get maxPitch(): number;
  120581. set maxPitch(value: number);
  120582. /**
  120583. * Create a BoneLookController
  120584. * @param mesh the mesh that the bone belongs to
  120585. * @param bone the bone that will be looking to the target
  120586. * @param target the target Vector3 to look at
  120587. * @param options optional settings:
  120588. * * maxYaw: the maximum angle the bone will yaw to
  120589. * * minYaw: the minimum angle the bone will yaw to
  120590. * * maxPitch: the maximum angle the bone will pitch to
  120591. * * minPitch: the minimum angle the bone will yaw to
  120592. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  120593. * * upAxis: the up axis of the coordinate system
  120594. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  120595. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  120596. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  120597. * * adjustYaw: used to make an adjustment to the yaw of the bone
  120598. * * adjustPitch: used to make an adjustment to the pitch of the bone
  120599. * * adjustRoll: used to make an adjustment to the roll of the bone
  120600. **/
  120601. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  120602. maxYaw?: number;
  120603. minYaw?: number;
  120604. maxPitch?: number;
  120605. minPitch?: number;
  120606. slerpAmount?: number;
  120607. upAxis?: Vector3;
  120608. upAxisSpace?: Space;
  120609. yawAxis?: Vector3;
  120610. pitchAxis?: Vector3;
  120611. adjustYaw?: number;
  120612. adjustPitch?: number;
  120613. adjustRoll?: number;
  120614. });
  120615. /**
  120616. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  120617. */
  120618. update(): void;
  120619. private _getAngleDiff;
  120620. private _getAngleBetween;
  120621. private _isAngleBetween;
  120622. }
  120623. }
  120624. declare module BABYLON {
  120625. /**
  120626. * Manage the gamepad inputs to control an arc rotate camera.
  120627. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120628. */
  120629. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  120630. /**
  120631. * Defines the camera the input is attached to.
  120632. */
  120633. camera: ArcRotateCamera;
  120634. /**
  120635. * Defines the gamepad the input is gathering event from.
  120636. */
  120637. gamepad: Nullable<Gamepad>;
  120638. /**
  120639. * Defines the gamepad rotation sensiblity.
  120640. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  120641. */
  120642. gamepadRotationSensibility: number;
  120643. /**
  120644. * Defines the gamepad move sensiblity.
  120645. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  120646. */
  120647. gamepadMoveSensibility: number;
  120648. private _yAxisScale;
  120649. /**
  120650. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  120651. */
  120652. get invertYAxis(): boolean;
  120653. set invertYAxis(value: boolean);
  120654. private _onGamepadConnectedObserver;
  120655. private _onGamepadDisconnectedObserver;
  120656. /**
  120657. * Attach the input controls to a specific dom element to get the input from.
  120658. * @param element Defines the element the controls should be listened from
  120659. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120660. */
  120661. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120662. /**
  120663. * Detach the current controls from the specified dom element.
  120664. * @param element Defines the element to stop listening the inputs from
  120665. */
  120666. detachControl(element: Nullable<HTMLElement>): void;
  120667. /**
  120668. * Update the current camera state depending on the inputs that have been used this frame.
  120669. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120670. */
  120671. checkInputs(): void;
  120672. /**
  120673. * Gets the class name of the current intput.
  120674. * @returns the class name
  120675. */
  120676. getClassName(): string;
  120677. /**
  120678. * Get the friendly name associated with the input class.
  120679. * @returns the input friendly name
  120680. */
  120681. getSimpleName(): string;
  120682. }
  120683. }
  120684. declare module BABYLON {
  120685. interface ArcRotateCameraInputsManager {
  120686. /**
  120687. * Add orientation input support to the input manager.
  120688. * @returns the current input manager
  120689. */
  120690. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  120691. }
  120692. /**
  120693. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  120694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120695. */
  120696. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  120697. /**
  120698. * Defines the camera the input is attached to.
  120699. */
  120700. camera: ArcRotateCamera;
  120701. /**
  120702. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  120703. */
  120704. alphaCorrection: number;
  120705. /**
  120706. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  120707. */
  120708. gammaCorrection: number;
  120709. private _alpha;
  120710. private _gamma;
  120711. private _dirty;
  120712. private _deviceOrientationHandler;
  120713. /**
  120714. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  120715. */
  120716. constructor();
  120717. /**
  120718. * Attach the input controls to a specific dom element to get the input from.
  120719. * @param element Defines the element the controls should be listened from
  120720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120721. */
  120722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120723. /** @hidden */
  120724. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  120725. /**
  120726. * Update the current camera state depending on the inputs that have been used this frame.
  120727. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120728. */
  120729. checkInputs(): void;
  120730. /**
  120731. * Detach the current controls from the specified dom element.
  120732. * @param element Defines the element to stop listening the inputs from
  120733. */
  120734. detachControl(element: Nullable<HTMLElement>): void;
  120735. /**
  120736. * Gets the class name of the current intput.
  120737. * @returns the class name
  120738. */
  120739. getClassName(): string;
  120740. /**
  120741. * Get the friendly name associated with the input class.
  120742. * @returns the input friendly name
  120743. */
  120744. getSimpleName(): string;
  120745. }
  120746. }
  120747. declare module BABYLON {
  120748. /**
  120749. * Listen to mouse events to control the camera.
  120750. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120751. */
  120752. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  120753. /**
  120754. * Defines the camera the input is attached to.
  120755. */
  120756. camera: FlyCamera;
  120757. /**
  120758. * Defines if touch is enabled. (Default is true.)
  120759. */
  120760. touchEnabled: boolean;
  120761. /**
  120762. * Defines the buttons associated with the input to handle camera rotation.
  120763. */
  120764. buttons: number[];
  120765. /**
  120766. * Assign buttons for Yaw control.
  120767. */
  120768. buttonsYaw: number[];
  120769. /**
  120770. * Assign buttons for Pitch control.
  120771. */
  120772. buttonsPitch: number[];
  120773. /**
  120774. * Assign buttons for Roll control.
  120775. */
  120776. buttonsRoll: number[];
  120777. /**
  120778. * Detect if any button is being pressed while mouse is moved.
  120779. * -1 = Mouse locked.
  120780. * 0 = Left button.
  120781. * 1 = Middle Button.
  120782. * 2 = Right Button.
  120783. */
  120784. activeButton: number;
  120785. /**
  120786. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  120787. * Higher values reduce its sensitivity.
  120788. */
  120789. angularSensibility: number;
  120790. private _mousemoveCallback;
  120791. private _observer;
  120792. private _rollObserver;
  120793. private previousPosition;
  120794. private noPreventDefault;
  120795. private element;
  120796. /**
  120797. * Listen to mouse events to control the camera.
  120798. * @param touchEnabled Define if touch is enabled. (Default is true.)
  120799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120800. */
  120801. constructor(touchEnabled?: boolean);
  120802. /**
  120803. * Attach the mouse control to the HTML DOM element.
  120804. * @param element Defines the element that listens to the input events.
  120805. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  120806. */
  120807. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120808. /**
  120809. * Detach the current controls from the specified dom element.
  120810. * @param element Defines the element to stop listening the inputs from
  120811. */
  120812. detachControl(element: Nullable<HTMLElement>): void;
  120813. /**
  120814. * Gets the class name of the current input.
  120815. * @returns the class name.
  120816. */
  120817. getClassName(): string;
  120818. /**
  120819. * Get the friendly name associated with the input class.
  120820. * @returns the input's friendly name.
  120821. */
  120822. getSimpleName(): string;
  120823. private _pointerInput;
  120824. private _onMouseMove;
  120825. /**
  120826. * Rotate camera by mouse offset.
  120827. */
  120828. private rotateCamera;
  120829. }
  120830. }
  120831. declare module BABYLON {
  120832. /**
  120833. * Default Inputs manager for the FlyCamera.
  120834. * It groups all the default supported inputs for ease of use.
  120835. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  120836. */
  120837. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  120838. /**
  120839. * Instantiates a new FlyCameraInputsManager.
  120840. * @param camera Defines the camera the inputs belong to.
  120841. */
  120842. constructor(camera: FlyCamera);
  120843. /**
  120844. * Add keyboard input support to the input manager.
  120845. * @returns the new FlyCameraKeyboardMoveInput().
  120846. */
  120847. addKeyboard(): FlyCameraInputsManager;
  120848. /**
  120849. * Add mouse input support to the input manager.
  120850. * @param touchEnabled Enable touch screen support.
  120851. * @returns the new FlyCameraMouseInput().
  120852. */
  120853. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  120854. }
  120855. }
  120856. declare module BABYLON {
  120857. /**
  120858. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120859. * such as in a 3D Space Shooter or a Flight Simulator.
  120860. */
  120861. export class FlyCamera extends TargetCamera {
  120862. /**
  120863. * Define the collision ellipsoid of the camera.
  120864. * This is helpful for simulating a camera body, like a player's body.
  120865. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120866. */
  120867. ellipsoid: Vector3;
  120868. /**
  120869. * Define an offset for the position of the ellipsoid around the camera.
  120870. * This can be helpful if the camera is attached away from the player's body center,
  120871. * such as at its head.
  120872. */
  120873. ellipsoidOffset: Vector3;
  120874. /**
  120875. * Enable or disable collisions of the camera with the rest of the scene objects.
  120876. */
  120877. checkCollisions: boolean;
  120878. /**
  120879. * Enable or disable gravity on the camera.
  120880. */
  120881. applyGravity: boolean;
  120882. /**
  120883. * Define the current direction the camera is moving to.
  120884. */
  120885. cameraDirection: Vector3;
  120886. /**
  120887. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  120888. * This overrides and empties cameraRotation.
  120889. */
  120890. rotationQuaternion: Quaternion;
  120891. /**
  120892. * Track Roll to maintain the wanted Rolling when looking around.
  120893. */
  120894. _trackRoll: number;
  120895. /**
  120896. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  120897. */
  120898. rollCorrect: number;
  120899. /**
  120900. * Mimic a banked turn, Rolling the camera when Yawing.
  120901. * It's recommended to use rollCorrect = 10 for faster banking correction.
  120902. */
  120903. bankedTurn: boolean;
  120904. /**
  120905. * Limit in radians for how much Roll banking will add. (Default: 90°)
  120906. */
  120907. bankedTurnLimit: number;
  120908. /**
  120909. * Value of 0 disables the banked Roll.
  120910. * Value of 1 is equal to the Yaw angle in radians.
  120911. */
  120912. bankedTurnMultiplier: number;
  120913. /**
  120914. * The inputs manager loads all the input sources, such as keyboard and mouse.
  120915. */
  120916. inputs: FlyCameraInputsManager;
  120917. /**
  120918. * Gets the input sensibility for mouse input.
  120919. * Higher values reduce sensitivity.
  120920. */
  120921. get angularSensibility(): number;
  120922. /**
  120923. * Sets the input sensibility for a mouse input.
  120924. * Higher values reduce sensitivity.
  120925. */
  120926. set angularSensibility(value: number);
  120927. /**
  120928. * Get the keys for camera movement forward.
  120929. */
  120930. get keysForward(): number[];
  120931. /**
  120932. * Set the keys for camera movement forward.
  120933. */
  120934. set keysForward(value: number[]);
  120935. /**
  120936. * Get the keys for camera movement backward.
  120937. */
  120938. get keysBackward(): number[];
  120939. set keysBackward(value: number[]);
  120940. /**
  120941. * Get the keys for camera movement up.
  120942. */
  120943. get keysUp(): number[];
  120944. /**
  120945. * Set the keys for camera movement up.
  120946. */
  120947. set keysUp(value: number[]);
  120948. /**
  120949. * Get the keys for camera movement down.
  120950. */
  120951. get keysDown(): number[];
  120952. /**
  120953. * Set the keys for camera movement down.
  120954. */
  120955. set keysDown(value: number[]);
  120956. /**
  120957. * Get the keys for camera movement left.
  120958. */
  120959. get keysLeft(): number[];
  120960. /**
  120961. * Set the keys for camera movement left.
  120962. */
  120963. set keysLeft(value: number[]);
  120964. /**
  120965. * Set the keys for camera movement right.
  120966. */
  120967. get keysRight(): number[];
  120968. /**
  120969. * Set the keys for camera movement right.
  120970. */
  120971. set keysRight(value: number[]);
  120972. /**
  120973. * Event raised when the camera collides with a mesh in the scene.
  120974. */
  120975. onCollide: (collidedMesh: AbstractMesh) => void;
  120976. private _collider;
  120977. private _needMoveForGravity;
  120978. private _oldPosition;
  120979. private _diffPosition;
  120980. private _newPosition;
  120981. /** @hidden */
  120982. _localDirection: Vector3;
  120983. /** @hidden */
  120984. _transformedDirection: Vector3;
  120985. /**
  120986. * Instantiates a FlyCamera.
  120987. * This is a flying camera, designed for 3D movement and rotation in all directions,
  120988. * such as in a 3D Space Shooter or a Flight Simulator.
  120989. * @param name Define the name of the camera in the scene.
  120990. * @param position Define the starting position of the camera in the scene.
  120991. * @param scene Define the scene the camera belongs to.
  120992. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  120993. */
  120994. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120995. /**
  120996. * Attach a control to the HTML DOM element.
  120997. * @param element Defines the element that listens to the input events.
  120998. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  120999. */
  121000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121001. /**
  121002. * Detach a control from the HTML DOM element.
  121003. * The camera will stop reacting to that input.
  121004. * @param element Defines the element that listens to the input events.
  121005. */
  121006. detachControl(element: HTMLElement): void;
  121007. private _collisionMask;
  121008. /**
  121009. * Get the mask that the camera ignores in collision events.
  121010. */
  121011. get collisionMask(): number;
  121012. /**
  121013. * Set the mask that the camera ignores in collision events.
  121014. */
  121015. set collisionMask(mask: number);
  121016. /** @hidden */
  121017. _collideWithWorld(displacement: Vector3): void;
  121018. /** @hidden */
  121019. private _onCollisionPositionChange;
  121020. /** @hidden */
  121021. _checkInputs(): void;
  121022. /** @hidden */
  121023. _decideIfNeedsToMove(): boolean;
  121024. /** @hidden */
  121025. _updatePosition(): void;
  121026. /**
  121027. * Restore the Roll to its target value at the rate specified.
  121028. * @param rate - Higher means slower restoring.
  121029. * @hidden
  121030. */
  121031. restoreRoll(rate: number): void;
  121032. /**
  121033. * Destroy the camera and release the current resources held by it.
  121034. */
  121035. dispose(): void;
  121036. /**
  121037. * Get the current object class name.
  121038. * @returns the class name.
  121039. */
  121040. getClassName(): string;
  121041. }
  121042. }
  121043. declare module BABYLON {
  121044. /**
  121045. * Listen to keyboard events to control the camera.
  121046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121047. */
  121048. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121049. /**
  121050. * Defines the camera the input is attached to.
  121051. */
  121052. camera: FlyCamera;
  121053. /**
  121054. * The list of keyboard keys used to control the forward move of the camera.
  121055. */
  121056. keysForward: number[];
  121057. /**
  121058. * The list of keyboard keys used to control the backward move of the camera.
  121059. */
  121060. keysBackward: number[];
  121061. /**
  121062. * The list of keyboard keys used to control the forward move of the camera.
  121063. */
  121064. keysUp: number[];
  121065. /**
  121066. * The list of keyboard keys used to control the backward move of the camera.
  121067. */
  121068. keysDown: number[];
  121069. /**
  121070. * The list of keyboard keys used to control the right strafe move of the camera.
  121071. */
  121072. keysRight: number[];
  121073. /**
  121074. * The list of keyboard keys used to control the left strafe move of the camera.
  121075. */
  121076. keysLeft: number[];
  121077. private _keys;
  121078. private _onCanvasBlurObserver;
  121079. private _onKeyboardObserver;
  121080. private _engine;
  121081. private _scene;
  121082. /**
  121083. * Attach the input controls to a specific dom element to get the input from.
  121084. * @param element Defines the element the controls should be listened from
  121085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121086. */
  121087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121088. /**
  121089. * Detach the current controls from the specified dom element.
  121090. * @param element Defines the element to stop listening the inputs from
  121091. */
  121092. detachControl(element: Nullable<HTMLElement>): void;
  121093. /**
  121094. * Gets the class name of the current intput.
  121095. * @returns the class name
  121096. */
  121097. getClassName(): string;
  121098. /** @hidden */
  121099. _onLostFocus(e: FocusEvent): void;
  121100. /**
  121101. * Get the friendly name associated with the input class.
  121102. * @returns the input friendly name
  121103. */
  121104. getSimpleName(): string;
  121105. /**
  121106. * Update the current camera state depending on the inputs that have been used this frame.
  121107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121108. */
  121109. checkInputs(): void;
  121110. }
  121111. }
  121112. declare module BABYLON {
  121113. /**
  121114. * Manage the mouse wheel inputs to control a follow camera.
  121115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121116. */
  121117. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121118. /**
  121119. * Defines the camera the input is attached to.
  121120. */
  121121. camera: FollowCamera;
  121122. /**
  121123. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121124. */
  121125. axisControlRadius: boolean;
  121126. /**
  121127. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121128. */
  121129. axisControlHeight: boolean;
  121130. /**
  121131. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121132. */
  121133. axisControlRotation: boolean;
  121134. /**
  121135. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121136. * relation to mouseWheel events.
  121137. */
  121138. wheelPrecision: number;
  121139. /**
  121140. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121141. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121142. */
  121143. wheelDeltaPercentage: number;
  121144. private _wheel;
  121145. private _observer;
  121146. /**
  121147. * Attach the input controls to a specific dom element to get the input from.
  121148. * @param element Defines the element the controls should be listened from
  121149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121150. */
  121151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121152. /**
  121153. * Detach the current controls from the specified dom element.
  121154. * @param element Defines the element to stop listening the inputs from
  121155. */
  121156. detachControl(element: Nullable<HTMLElement>): void;
  121157. /**
  121158. * Gets the class name of the current intput.
  121159. * @returns the class name
  121160. */
  121161. getClassName(): string;
  121162. /**
  121163. * Get the friendly name associated with the input class.
  121164. * @returns the input friendly name
  121165. */
  121166. getSimpleName(): string;
  121167. }
  121168. }
  121169. declare module BABYLON {
  121170. /**
  121171. * Manage the pointers inputs to control an follow camera.
  121172. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121173. */
  121174. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121175. /**
  121176. * Defines the camera the input is attached to.
  121177. */
  121178. camera: FollowCamera;
  121179. /**
  121180. * Gets the class name of the current input.
  121181. * @returns the class name
  121182. */
  121183. getClassName(): string;
  121184. /**
  121185. * Defines the pointer angular sensibility along the X axis or how fast is
  121186. * the camera rotating.
  121187. * A negative number will reverse the axis direction.
  121188. */
  121189. angularSensibilityX: number;
  121190. /**
  121191. * Defines the pointer angular sensibility along the Y axis or how fast is
  121192. * the camera rotating.
  121193. * A negative number will reverse the axis direction.
  121194. */
  121195. angularSensibilityY: number;
  121196. /**
  121197. * Defines the pointer pinch precision or how fast is the camera zooming.
  121198. * A negative number will reverse the axis direction.
  121199. */
  121200. pinchPrecision: number;
  121201. /**
  121202. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121203. * from 0.
  121204. * It defines the percentage of current camera.radius to use as delta when
  121205. * pinch zoom is used.
  121206. */
  121207. pinchDeltaPercentage: number;
  121208. /**
  121209. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121210. */
  121211. axisXControlRadius: boolean;
  121212. /**
  121213. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121214. */
  121215. axisXControlHeight: boolean;
  121216. /**
  121217. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121218. */
  121219. axisXControlRotation: boolean;
  121220. /**
  121221. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121222. */
  121223. axisYControlRadius: boolean;
  121224. /**
  121225. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121226. */
  121227. axisYControlHeight: boolean;
  121228. /**
  121229. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  121230. */
  121231. axisYControlRotation: boolean;
  121232. /**
  121233. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  121234. */
  121235. axisPinchControlRadius: boolean;
  121236. /**
  121237. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  121238. */
  121239. axisPinchControlHeight: boolean;
  121240. /**
  121241. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  121242. */
  121243. axisPinchControlRotation: boolean;
  121244. /**
  121245. * Log error messages if basic misconfiguration has occurred.
  121246. */
  121247. warningEnable: boolean;
  121248. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  121249. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  121250. private _warningCounter;
  121251. private _warning;
  121252. }
  121253. }
  121254. declare module BABYLON {
  121255. /**
  121256. * Default Inputs manager for the FollowCamera.
  121257. * It groups all the default supported inputs for ease of use.
  121258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121259. */
  121260. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  121261. /**
  121262. * Instantiates a new FollowCameraInputsManager.
  121263. * @param camera Defines the camera the inputs belong to
  121264. */
  121265. constructor(camera: FollowCamera);
  121266. /**
  121267. * Add keyboard input support to the input manager.
  121268. * @returns the current input manager
  121269. */
  121270. addKeyboard(): FollowCameraInputsManager;
  121271. /**
  121272. * Add mouse wheel input support to the input manager.
  121273. * @returns the current input manager
  121274. */
  121275. addMouseWheel(): FollowCameraInputsManager;
  121276. /**
  121277. * Add pointers input support to the input manager.
  121278. * @returns the current input manager
  121279. */
  121280. addPointers(): FollowCameraInputsManager;
  121281. /**
  121282. * Add orientation input support to the input manager.
  121283. * @returns the current input manager
  121284. */
  121285. addVRDeviceOrientation(): FollowCameraInputsManager;
  121286. }
  121287. }
  121288. declare module BABYLON {
  121289. /**
  121290. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  121291. * an arc rotate version arcFollowCamera are available.
  121292. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121293. */
  121294. export class FollowCamera extends TargetCamera {
  121295. /**
  121296. * Distance the follow camera should follow an object at
  121297. */
  121298. radius: number;
  121299. /**
  121300. * Minimum allowed distance of the camera to the axis of rotation
  121301. * (The camera can not get closer).
  121302. * This can help limiting how the Camera is able to move in the scene.
  121303. */
  121304. lowerRadiusLimit: Nullable<number>;
  121305. /**
  121306. * Maximum allowed distance of the camera to the axis of rotation
  121307. * (The camera can not get further).
  121308. * This can help limiting how the Camera is able to move in the scene.
  121309. */
  121310. upperRadiusLimit: Nullable<number>;
  121311. /**
  121312. * Define a rotation offset between the camera and the object it follows
  121313. */
  121314. rotationOffset: number;
  121315. /**
  121316. * Minimum allowed angle to camera position relative to target object.
  121317. * This can help limiting how the Camera is able to move in the scene.
  121318. */
  121319. lowerRotationOffsetLimit: Nullable<number>;
  121320. /**
  121321. * Maximum allowed angle to camera position relative to target object.
  121322. * This can help limiting how the Camera is able to move in the scene.
  121323. */
  121324. upperRotationOffsetLimit: Nullable<number>;
  121325. /**
  121326. * Define a height offset between the camera and the object it follows.
  121327. * It can help following an object from the top (like a car chaing a plane)
  121328. */
  121329. heightOffset: number;
  121330. /**
  121331. * Minimum allowed height of camera position relative to target object.
  121332. * This can help limiting how the Camera is able to move in the scene.
  121333. */
  121334. lowerHeightOffsetLimit: Nullable<number>;
  121335. /**
  121336. * Maximum allowed height of camera position relative to target object.
  121337. * This can help limiting how the Camera is able to move in the scene.
  121338. */
  121339. upperHeightOffsetLimit: Nullable<number>;
  121340. /**
  121341. * Define how fast the camera can accelerate to follow it s target.
  121342. */
  121343. cameraAcceleration: number;
  121344. /**
  121345. * Define the speed limit of the camera following an object.
  121346. */
  121347. maxCameraSpeed: number;
  121348. /**
  121349. * Define the target of the camera.
  121350. */
  121351. lockedTarget: Nullable<AbstractMesh>;
  121352. /**
  121353. * Defines the input associated with the camera.
  121354. */
  121355. inputs: FollowCameraInputsManager;
  121356. /**
  121357. * Instantiates the follow camera.
  121358. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121359. * @param name Define the name of the camera in the scene
  121360. * @param position Define the position of the camera
  121361. * @param scene Define the scene the camera belong to
  121362. * @param lockedTarget Define the target of the camera
  121363. */
  121364. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  121365. private _follow;
  121366. /**
  121367. * Attached controls to the current camera.
  121368. * @param element Defines the element the controls should be listened from
  121369. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121370. */
  121371. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121372. /**
  121373. * Detach the current controls from the camera.
  121374. * The camera will stop reacting to inputs.
  121375. * @param element Defines the element to stop listening the inputs from
  121376. */
  121377. detachControl(element: HTMLElement): void;
  121378. /** @hidden */
  121379. _checkInputs(): void;
  121380. private _checkLimits;
  121381. /**
  121382. * Gets the camera class name.
  121383. * @returns the class name
  121384. */
  121385. getClassName(): string;
  121386. }
  121387. /**
  121388. * Arc Rotate version of the follow camera.
  121389. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  121390. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121391. */
  121392. export class ArcFollowCamera extends TargetCamera {
  121393. /** The longitudinal angle of the camera */
  121394. alpha: number;
  121395. /** The latitudinal angle of the camera */
  121396. beta: number;
  121397. /** The radius of the camera from its target */
  121398. radius: number;
  121399. /** Define the camera target (the mesh it should follow) */
  121400. target: Nullable<AbstractMesh>;
  121401. private _cartesianCoordinates;
  121402. /**
  121403. * Instantiates a new ArcFollowCamera
  121404. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  121405. * @param name Define the name of the camera
  121406. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  121407. * @param beta Define the rotation angle of the camera around the elevation axis
  121408. * @param radius Define the radius of the camera from its target point
  121409. * @param target Define the target of the camera
  121410. * @param scene Define the scene the camera belongs to
  121411. */
  121412. constructor(name: string,
  121413. /** The longitudinal angle of the camera */
  121414. alpha: number,
  121415. /** The latitudinal angle of the camera */
  121416. beta: number,
  121417. /** The radius of the camera from its target */
  121418. radius: number,
  121419. /** Define the camera target (the mesh it should follow) */
  121420. target: Nullable<AbstractMesh>, scene: Scene);
  121421. private _follow;
  121422. /** @hidden */
  121423. _checkInputs(): void;
  121424. /**
  121425. * Returns the class name of the object.
  121426. * It is mostly used internally for serialization purposes.
  121427. */
  121428. getClassName(): string;
  121429. }
  121430. }
  121431. declare module BABYLON {
  121432. /**
  121433. * Manage the keyboard inputs to control the movement of a follow camera.
  121434. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121435. */
  121436. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  121437. /**
  121438. * Defines the camera the input is attached to.
  121439. */
  121440. camera: FollowCamera;
  121441. /**
  121442. * Defines the list of key codes associated with the up action (increase heightOffset)
  121443. */
  121444. keysHeightOffsetIncr: number[];
  121445. /**
  121446. * Defines the list of key codes associated with the down action (decrease heightOffset)
  121447. */
  121448. keysHeightOffsetDecr: number[];
  121449. /**
  121450. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  121451. */
  121452. keysHeightOffsetModifierAlt: boolean;
  121453. /**
  121454. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  121455. */
  121456. keysHeightOffsetModifierCtrl: boolean;
  121457. /**
  121458. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  121459. */
  121460. keysHeightOffsetModifierShift: boolean;
  121461. /**
  121462. * Defines the list of key codes associated with the left action (increase rotationOffset)
  121463. */
  121464. keysRotationOffsetIncr: number[];
  121465. /**
  121466. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  121467. */
  121468. keysRotationOffsetDecr: number[];
  121469. /**
  121470. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  121471. */
  121472. keysRotationOffsetModifierAlt: boolean;
  121473. /**
  121474. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  121475. */
  121476. keysRotationOffsetModifierCtrl: boolean;
  121477. /**
  121478. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  121479. */
  121480. keysRotationOffsetModifierShift: boolean;
  121481. /**
  121482. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  121483. */
  121484. keysRadiusIncr: number[];
  121485. /**
  121486. * Defines the list of key codes associated with the zoom-out action (increase radius)
  121487. */
  121488. keysRadiusDecr: number[];
  121489. /**
  121490. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  121491. */
  121492. keysRadiusModifierAlt: boolean;
  121493. /**
  121494. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  121495. */
  121496. keysRadiusModifierCtrl: boolean;
  121497. /**
  121498. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  121499. */
  121500. keysRadiusModifierShift: boolean;
  121501. /**
  121502. * Defines the rate of change of heightOffset.
  121503. */
  121504. heightSensibility: number;
  121505. /**
  121506. * Defines the rate of change of rotationOffset.
  121507. */
  121508. rotationSensibility: number;
  121509. /**
  121510. * Defines the rate of change of radius.
  121511. */
  121512. radiusSensibility: number;
  121513. private _keys;
  121514. private _ctrlPressed;
  121515. private _altPressed;
  121516. private _shiftPressed;
  121517. private _onCanvasBlurObserver;
  121518. private _onKeyboardObserver;
  121519. private _engine;
  121520. private _scene;
  121521. /**
  121522. * Attach the input controls to a specific dom element to get the input from.
  121523. * @param element Defines the element the controls should be listened from
  121524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121525. */
  121526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121527. /**
  121528. * Detach the current controls from the specified dom element.
  121529. * @param element Defines the element to stop listening the inputs from
  121530. */
  121531. detachControl(element: Nullable<HTMLElement>): void;
  121532. /**
  121533. * Update the current camera state depending on the inputs that have been used this frame.
  121534. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121535. */
  121536. checkInputs(): void;
  121537. /**
  121538. * Gets the class name of the current input.
  121539. * @returns the class name
  121540. */
  121541. getClassName(): string;
  121542. /**
  121543. * Get the friendly name associated with the input class.
  121544. * @returns the input friendly name
  121545. */
  121546. getSimpleName(): string;
  121547. /**
  121548. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121549. * allow modification of the heightOffset value.
  121550. */
  121551. private _modifierHeightOffset;
  121552. /**
  121553. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121554. * allow modification of the rotationOffset value.
  121555. */
  121556. private _modifierRotationOffset;
  121557. /**
  121558. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  121559. * allow modification of the radius value.
  121560. */
  121561. private _modifierRadius;
  121562. }
  121563. }
  121564. declare module BABYLON {
  121565. interface FreeCameraInputsManager {
  121566. /**
  121567. * @hidden
  121568. */
  121569. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  121570. /**
  121571. * Add orientation input support to the input manager.
  121572. * @returns the current input manager
  121573. */
  121574. addDeviceOrientation(): FreeCameraInputsManager;
  121575. }
  121576. /**
  121577. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  121578. * Screen rotation is taken into account.
  121579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121580. */
  121581. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  121582. private _camera;
  121583. private _screenOrientationAngle;
  121584. private _constantTranform;
  121585. private _screenQuaternion;
  121586. private _alpha;
  121587. private _beta;
  121588. private _gamma;
  121589. /**
  121590. * Can be used to detect if a device orientation sensor is available on a device
  121591. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  121592. * @returns a promise that will resolve on orientation change
  121593. */
  121594. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  121595. /**
  121596. * @hidden
  121597. */
  121598. _onDeviceOrientationChangedObservable: Observable<void>;
  121599. /**
  121600. * Instantiates a new input
  121601. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121602. */
  121603. constructor();
  121604. /**
  121605. * Define the camera controlled by the input.
  121606. */
  121607. get camera(): FreeCamera;
  121608. set camera(camera: FreeCamera);
  121609. /**
  121610. * Attach the input controls to a specific dom element to get the input from.
  121611. * @param element Defines the element the controls should be listened from
  121612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121613. */
  121614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121615. private _orientationChanged;
  121616. private _deviceOrientation;
  121617. /**
  121618. * Detach the current controls from the specified dom element.
  121619. * @param element Defines the element to stop listening the inputs from
  121620. */
  121621. detachControl(element: Nullable<HTMLElement>): void;
  121622. /**
  121623. * Update the current camera state depending on the inputs that have been used this frame.
  121624. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121625. */
  121626. checkInputs(): void;
  121627. /**
  121628. * Gets the class name of the current intput.
  121629. * @returns the class name
  121630. */
  121631. getClassName(): string;
  121632. /**
  121633. * Get the friendly name associated with the input class.
  121634. * @returns the input friendly name
  121635. */
  121636. getSimpleName(): string;
  121637. }
  121638. }
  121639. declare module BABYLON {
  121640. /**
  121641. * Manage the gamepad inputs to control a free camera.
  121642. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121643. */
  121644. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  121645. /**
  121646. * Define the camera the input is attached to.
  121647. */
  121648. camera: FreeCamera;
  121649. /**
  121650. * Define the Gamepad controlling the input
  121651. */
  121652. gamepad: Nullable<Gamepad>;
  121653. /**
  121654. * Defines the gamepad rotation sensiblity.
  121655. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121656. */
  121657. gamepadAngularSensibility: number;
  121658. /**
  121659. * Defines the gamepad move sensiblity.
  121660. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121661. */
  121662. gamepadMoveSensibility: number;
  121663. private _yAxisScale;
  121664. /**
  121665. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121666. */
  121667. get invertYAxis(): boolean;
  121668. set invertYAxis(value: boolean);
  121669. private _onGamepadConnectedObserver;
  121670. private _onGamepadDisconnectedObserver;
  121671. private _cameraTransform;
  121672. private _deltaTransform;
  121673. private _vector3;
  121674. private _vector2;
  121675. /**
  121676. * Attach the input controls to a specific dom element to get the input from.
  121677. * @param element Defines the element the controls should be listened from
  121678. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121679. */
  121680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121681. /**
  121682. * Detach the current controls from the specified dom element.
  121683. * @param element Defines the element to stop listening the inputs from
  121684. */
  121685. detachControl(element: Nullable<HTMLElement>): void;
  121686. /**
  121687. * Update the current camera state depending on the inputs that have been used this frame.
  121688. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121689. */
  121690. checkInputs(): void;
  121691. /**
  121692. * Gets the class name of the current intput.
  121693. * @returns the class name
  121694. */
  121695. getClassName(): string;
  121696. /**
  121697. * Get the friendly name associated with the input class.
  121698. * @returns the input friendly name
  121699. */
  121700. getSimpleName(): string;
  121701. }
  121702. }
  121703. declare module BABYLON {
  121704. /**
  121705. * Defines the potential axis of a Joystick
  121706. */
  121707. export enum JoystickAxis {
  121708. /** X axis */
  121709. X = 0,
  121710. /** Y axis */
  121711. Y = 1,
  121712. /** Z axis */
  121713. Z = 2
  121714. }
  121715. /**
  121716. * Class used to define virtual joystick (used in touch mode)
  121717. */
  121718. export class VirtualJoystick {
  121719. /**
  121720. * Gets or sets a boolean indicating that left and right values must be inverted
  121721. */
  121722. reverseLeftRight: boolean;
  121723. /**
  121724. * Gets or sets a boolean indicating that up and down values must be inverted
  121725. */
  121726. reverseUpDown: boolean;
  121727. /**
  121728. * Gets the offset value for the position (ie. the change of the position value)
  121729. */
  121730. deltaPosition: Vector3;
  121731. /**
  121732. * Gets a boolean indicating if the virtual joystick was pressed
  121733. */
  121734. pressed: boolean;
  121735. /**
  121736. * Canvas the virtual joystick will render onto, default z-index of this is 5
  121737. */
  121738. static Canvas: Nullable<HTMLCanvasElement>;
  121739. private static _globalJoystickIndex;
  121740. private static vjCanvasContext;
  121741. private static vjCanvasWidth;
  121742. private static vjCanvasHeight;
  121743. private static halfWidth;
  121744. private _action;
  121745. private _axisTargetedByLeftAndRight;
  121746. private _axisTargetedByUpAndDown;
  121747. private _joystickSensibility;
  121748. private _inversedSensibility;
  121749. private _joystickPointerID;
  121750. private _joystickColor;
  121751. private _joystickPointerPos;
  121752. private _joystickPreviousPointerPos;
  121753. private _joystickPointerStartPos;
  121754. private _deltaJoystickVector;
  121755. private _leftJoystick;
  121756. private _touches;
  121757. private _onPointerDownHandlerRef;
  121758. private _onPointerMoveHandlerRef;
  121759. private _onPointerUpHandlerRef;
  121760. private _onResize;
  121761. /**
  121762. * Creates a new virtual joystick
  121763. * @param leftJoystick defines that the joystick is for left hand (false by default)
  121764. */
  121765. constructor(leftJoystick?: boolean);
  121766. /**
  121767. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  121768. * @param newJoystickSensibility defines the new sensibility
  121769. */
  121770. setJoystickSensibility(newJoystickSensibility: number): void;
  121771. private _onPointerDown;
  121772. private _onPointerMove;
  121773. private _onPointerUp;
  121774. /**
  121775. * Change the color of the virtual joystick
  121776. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  121777. */
  121778. setJoystickColor(newColor: string): void;
  121779. /**
  121780. * Defines a callback to call when the joystick is touched
  121781. * @param action defines the callback
  121782. */
  121783. setActionOnTouch(action: () => any): void;
  121784. /**
  121785. * Defines which axis you'd like to control for left & right
  121786. * @param axis defines the axis to use
  121787. */
  121788. setAxisForLeftRight(axis: JoystickAxis): void;
  121789. /**
  121790. * Defines which axis you'd like to control for up & down
  121791. * @param axis defines the axis to use
  121792. */
  121793. setAxisForUpDown(axis: JoystickAxis): void;
  121794. private _drawVirtualJoystick;
  121795. /**
  121796. * Release internal HTML canvas
  121797. */
  121798. releaseCanvas(): void;
  121799. }
  121800. }
  121801. declare module BABYLON {
  121802. interface FreeCameraInputsManager {
  121803. /**
  121804. * Add virtual joystick input support to the input manager.
  121805. * @returns the current input manager
  121806. */
  121807. addVirtualJoystick(): FreeCameraInputsManager;
  121808. }
  121809. /**
  121810. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  121811. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  121812. */
  121813. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  121814. /**
  121815. * Defines the camera the input is attached to.
  121816. */
  121817. camera: FreeCamera;
  121818. private _leftjoystick;
  121819. private _rightjoystick;
  121820. /**
  121821. * Gets the left stick of the virtual joystick.
  121822. * @returns The virtual Joystick
  121823. */
  121824. getLeftJoystick(): VirtualJoystick;
  121825. /**
  121826. * Gets the right stick of the virtual joystick.
  121827. * @returns The virtual Joystick
  121828. */
  121829. getRightJoystick(): VirtualJoystick;
  121830. /**
  121831. * Update the current camera state depending on the inputs that have been used this frame.
  121832. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121833. */
  121834. checkInputs(): void;
  121835. /**
  121836. * Attach the input controls to a specific dom element to get the input from.
  121837. * @param element Defines the element the controls should be listened from
  121838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121839. */
  121840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121841. /**
  121842. * Detach the current controls from the specified dom element.
  121843. * @param element Defines the element to stop listening the inputs from
  121844. */
  121845. detachControl(element: Nullable<HTMLElement>): void;
  121846. /**
  121847. * Gets the class name of the current intput.
  121848. * @returns the class name
  121849. */
  121850. getClassName(): string;
  121851. /**
  121852. * Get the friendly name associated with the input class.
  121853. * @returns the input friendly name
  121854. */
  121855. getSimpleName(): string;
  121856. }
  121857. }
  121858. declare module BABYLON {
  121859. /**
  121860. * This represents a FPS type of camera controlled by touch.
  121861. * This is like a universal camera minus the Gamepad controls.
  121862. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121863. */
  121864. export class TouchCamera extends FreeCamera {
  121865. /**
  121866. * Defines the touch sensibility for rotation.
  121867. * The higher the faster.
  121868. */
  121869. get touchAngularSensibility(): number;
  121870. set touchAngularSensibility(value: number);
  121871. /**
  121872. * Defines the touch sensibility for move.
  121873. * The higher the faster.
  121874. */
  121875. get touchMoveSensibility(): number;
  121876. set touchMoveSensibility(value: number);
  121877. /**
  121878. * Instantiates a new touch camera.
  121879. * This represents a FPS type of camera controlled by touch.
  121880. * This is like a universal camera minus the Gamepad controls.
  121881. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  121882. * @param name Define the name of the camera in the scene
  121883. * @param position Define the start position of the camera in the scene
  121884. * @param scene Define the scene the camera belongs to
  121885. */
  121886. constructor(name: string, position: Vector3, scene: Scene);
  121887. /**
  121888. * Gets the current object class name.
  121889. * @return the class name
  121890. */
  121891. getClassName(): string;
  121892. /** @hidden */
  121893. _setupInputs(): void;
  121894. }
  121895. }
  121896. declare module BABYLON {
  121897. /**
  121898. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  121899. * being tilted forward or back and left or right.
  121900. */
  121901. export class DeviceOrientationCamera extends FreeCamera {
  121902. private _initialQuaternion;
  121903. private _quaternionCache;
  121904. private _tmpDragQuaternion;
  121905. private _disablePointerInputWhenUsingDeviceOrientation;
  121906. /**
  121907. * Creates a new device orientation camera
  121908. * @param name The name of the camera
  121909. * @param position The start position camera
  121910. * @param scene The scene the camera belongs to
  121911. */
  121912. constructor(name: string, position: Vector3, scene: Scene);
  121913. /**
  121914. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  121915. */
  121916. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  121917. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  121918. private _dragFactor;
  121919. /**
  121920. * Enabled turning on the y axis when the orientation sensor is active
  121921. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  121922. */
  121923. enableHorizontalDragging(dragFactor?: number): void;
  121924. /**
  121925. * Gets the current instance class name ("DeviceOrientationCamera").
  121926. * This helps avoiding instanceof at run time.
  121927. * @returns the class name
  121928. */
  121929. getClassName(): string;
  121930. /**
  121931. * @hidden
  121932. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  121933. */
  121934. _checkInputs(): void;
  121935. /**
  121936. * Reset the camera to its default orientation on the specified axis only.
  121937. * @param axis The axis to reset
  121938. */
  121939. resetToCurrentRotation(axis?: Axis): void;
  121940. }
  121941. }
  121942. declare module BABYLON {
  121943. /**
  121944. * Defines supported buttons for XBox360 compatible gamepads
  121945. */
  121946. export enum Xbox360Button {
  121947. /** A */
  121948. A = 0,
  121949. /** B */
  121950. B = 1,
  121951. /** X */
  121952. X = 2,
  121953. /** Y */
  121954. Y = 3,
  121955. /** Left button */
  121956. LB = 4,
  121957. /** Right button */
  121958. RB = 5,
  121959. /** Back */
  121960. Back = 8,
  121961. /** Start */
  121962. Start = 9,
  121963. /** Left stick */
  121964. LeftStick = 10,
  121965. /** Right stick */
  121966. RightStick = 11
  121967. }
  121968. /** Defines values for XBox360 DPad */
  121969. export enum Xbox360Dpad {
  121970. /** Up */
  121971. Up = 12,
  121972. /** Down */
  121973. Down = 13,
  121974. /** Left */
  121975. Left = 14,
  121976. /** Right */
  121977. Right = 15
  121978. }
  121979. /**
  121980. * Defines a XBox360 gamepad
  121981. */
  121982. export class Xbox360Pad extends Gamepad {
  121983. private _leftTrigger;
  121984. private _rightTrigger;
  121985. private _onlefttriggerchanged;
  121986. private _onrighttriggerchanged;
  121987. private _onbuttondown;
  121988. private _onbuttonup;
  121989. private _ondpaddown;
  121990. private _ondpadup;
  121991. /** Observable raised when a button is pressed */
  121992. onButtonDownObservable: Observable<Xbox360Button>;
  121993. /** Observable raised when a button is released */
  121994. onButtonUpObservable: Observable<Xbox360Button>;
  121995. /** Observable raised when a pad is pressed */
  121996. onPadDownObservable: Observable<Xbox360Dpad>;
  121997. /** Observable raised when a pad is released */
  121998. onPadUpObservable: Observable<Xbox360Dpad>;
  121999. private _buttonA;
  122000. private _buttonB;
  122001. private _buttonX;
  122002. private _buttonY;
  122003. private _buttonBack;
  122004. private _buttonStart;
  122005. private _buttonLB;
  122006. private _buttonRB;
  122007. private _buttonLeftStick;
  122008. private _buttonRightStick;
  122009. private _dPadUp;
  122010. private _dPadDown;
  122011. private _dPadLeft;
  122012. private _dPadRight;
  122013. private _isXboxOnePad;
  122014. /**
  122015. * Creates a new XBox360 gamepad object
  122016. * @param id defines the id of this gamepad
  122017. * @param index defines its index
  122018. * @param gamepad defines the internal HTML gamepad object
  122019. * @param xboxOne defines if it is a XBox One gamepad
  122020. */
  122021. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122022. /**
  122023. * Defines the callback to call when left trigger is pressed
  122024. * @param callback defines the callback to use
  122025. */
  122026. onlefttriggerchanged(callback: (value: number) => void): void;
  122027. /**
  122028. * Defines the callback to call when right trigger is pressed
  122029. * @param callback defines the callback to use
  122030. */
  122031. onrighttriggerchanged(callback: (value: number) => void): void;
  122032. /**
  122033. * Gets the left trigger value
  122034. */
  122035. get leftTrigger(): number;
  122036. /**
  122037. * Sets the left trigger value
  122038. */
  122039. set leftTrigger(newValue: number);
  122040. /**
  122041. * Gets the right trigger value
  122042. */
  122043. get rightTrigger(): number;
  122044. /**
  122045. * Sets the right trigger value
  122046. */
  122047. set rightTrigger(newValue: number);
  122048. /**
  122049. * Defines the callback to call when a button is pressed
  122050. * @param callback defines the callback to use
  122051. */
  122052. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122053. /**
  122054. * Defines the callback to call when a button is released
  122055. * @param callback defines the callback to use
  122056. */
  122057. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122058. /**
  122059. * Defines the callback to call when a pad is pressed
  122060. * @param callback defines the callback to use
  122061. */
  122062. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122063. /**
  122064. * Defines the callback to call when a pad is released
  122065. * @param callback defines the callback to use
  122066. */
  122067. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122068. private _setButtonValue;
  122069. private _setDPadValue;
  122070. /**
  122071. * Gets the value of the `A` button
  122072. */
  122073. get buttonA(): number;
  122074. /**
  122075. * Sets the value of the `A` button
  122076. */
  122077. set buttonA(value: number);
  122078. /**
  122079. * Gets the value of the `B` button
  122080. */
  122081. get buttonB(): number;
  122082. /**
  122083. * Sets the value of the `B` button
  122084. */
  122085. set buttonB(value: number);
  122086. /**
  122087. * Gets the value of the `X` button
  122088. */
  122089. get buttonX(): number;
  122090. /**
  122091. * Sets the value of the `X` button
  122092. */
  122093. set buttonX(value: number);
  122094. /**
  122095. * Gets the value of the `Y` button
  122096. */
  122097. get buttonY(): number;
  122098. /**
  122099. * Sets the value of the `Y` button
  122100. */
  122101. set buttonY(value: number);
  122102. /**
  122103. * Gets the value of the `Start` button
  122104. */
  122105. get buttonStart(): number;
  122106. /**
  122107. * Sets the value of the `Start` button
  122108. */
  122109. set buttonStart(value: number);
  122110. /**
  122111. * Gets the value of the `Back` button
  122112. */
  122113. get buttonBack(): number;
  122114. /**
  122115. * Sets the value of the `Back` button
  122116. */
  122117. set buttonBack(value: number);
  122118. /**
  122119. * Gets the value of the `Left` button
  122120. */
  122121. get buttonLB(): number;
  122122. /**
  122123. * Sets the value of the `Left` button
  122124. */
  122125. set buttonLB(value: number);
  122126. /**
  122127. * Gets the value of the `Right` button
  122128. */
  122129. get buttonRB(): number;
  122130. /**
  122131. * Sets the value of the `Right` button
  122132. */
  122133. set buttonRB(value: number);
  122134. /**
  122135. * Gets the value of the Left joystick
  122136. */
  122137. get buttonLeftStick(): number;
  122138. /**
  122139. * Sets the value of the Left joystick
  122140. */
  122141. set buttonLeftStick(value: number);
  122142. /**
  122143. * Gets the value of the Right joystick
  122144. */
  122145. get buttonRightStick(): number;
  122146. /**
  122147. * Sets the value of the Right joystick
  122148. */
  122149. set buttonRightStick(value: number);
  122150. /**
  122151. * Gets the value of D-pad up
  122152. */
  122153. get dPadUp(): number;
  122154. /**
  122155. * Sets the value of D-pad up
  122156. */
  122157. set dPadUp(value: number);
  122158. /**
  122159. * Gets the value of D-pad down
  122160. */
  122161. get dPadDown(): number;
  122162. /**
  122163. * Sets the value of D-pad down
  122164. */
  122165. set dPadDown(value: number);
  122166. /**
  122167. * Gets the value of D-pad left
  122168. */
  122169. get dPadLeft(): number;
  122170. /**
  122171. * Sets the value of D-pad left
  122172. */
  122173. set dPadLeft(value: number);
  122174. /**
  122175. * Gets the value of D-pad right
  122176. */
  122177. get dPadRight(): number;
  122178. /**
  122179. * Sets the value of D-pad right
  122180. */
  122181. set dPadRight(value: number);
  122182. /**
  122183. * Force the gamepad to synchronize with device values
  122184. */
  122185. update(): void;
  122186. /**
  122187. * Disposes the gamepad
  122188. */
  122189. dispose(): void;
  122190. }
  122191. }
  122192. declare module BABYLON {
  122193. /**
  122194. * Defines supported buttons for DualShock compatible gamepads
  122195. */
  122196. export enum DualShockButton {
  122197. /** Cross */
  122198. Cross = 0,
  122199. /** Circle */
  122200. Circle = 1,
  122201. /** Square */
  122202. Square = 2,
  122203. /** Triangle */
  122204. Triangle = 3,
  122205. /** L1 */
  122206. L1 = 4,
  122207. /** R1 */
  122208. R1 = 5,
  122209. /** Share */
  122210. Share = 8,
  122211. /** Options */
  122212. Options = 9,
  122213. /** Left stick */
  122214. LeftStick = 10,
  122215. /** Right stick */
  122216. RightStick = 11
  122217. }
  122218. /** Defines values for DualShock DPad */
  122219. export enum DualShockDpad {
  122220. /** Up */
  122221. Up = 12,
  122222. /** Down */
  122223. Down = 13,
  122224. /** Left */
  122225. Left = 14,
  122226. /** Right */
  122227. Right = 15
  122228. }
  122229. /**
  122230. * Defines a DualShock gamepad
  122231. */
  122232. export class DualShockPad extends Gamepad {
  122233. private _leftTrigger;
  122234. private _rightTrigger;
  122235. private _onlefttriggerchanged;
  122236. private _onrighttriggerchanged;
  122237. private _onbuttondown;
  122238. private _onbuttonup;
  122239. private _ondpaddown;
  122240. private _ondpadup;
  122241. /** Observable raised when a button is pressed */
  122242. onButtonDownObservable: Observable<DualShockButton>;
  122243. /** Observable raised when a button is released */
  122244. onButtonUpObservable: Observable<DualShockButton>;
  122245. /** Observable raised when a pad is pressed */
  122246. onPadDownObservable: Observable<DualShockDpad>;
  122247. /** Observable raised when a pad is released */
  122248. onPadUpObservable: Observable<DualShockDpad>;
  122249. private _buttonCross;
  122250. private _buttonCircle;
  122251. private _buttonSquare;
  122252. private _buttonTriangle;
  122253. private _buttonShare;
  122254. private _buttonOptions;
  122255. private _buttonL1;
  122256. private _buttonR1;
  122257. private _buttonLeftStick;
  122258. private _buttonRightStick;
  122259. private _dPadUp;
  122260. private _dPadDown;
  122261. private _dPadLeft;
  122262. private _dPadRight;
  122263. /**
  122264. * Creates a new DualShock gamepad object
  122265. * @param id defines the id of this gamepad
  122266. * @param index defines its index
  122267. * @param gamepad defines the internal HTML gamepad object
  122268. */
  122269. constructor(id: string, index: number, gamepad: any);
  122270. /**
  122271. * Defines the callback to call when left trigger is pressed
  122272. * @param callback defines the callback to use
  122273. */
  122274. onlefttriggerchanged(callback: (value: number) => void): void;
  122275. /**
  122276. * Defines the callback to call when right trigger is pressed
  122277. * @param callback defines the callback to use
  122278. */
  122279. onrighttriggerchanged(callback: (value: number) => void): void;
  122280. /**
  122281. * Gets the left trigger value
  122282. */
  122283. get leftTrigger(): number;
  122284. /**
  122285. * Sets the left trigger value
  122286. */
  122287. set leftTrigger(newValue: number);
  122288. /**
  122289. * Gets the right trigger value
  122290. */
  122291. get rightTrigger(): number;
  122292. /**
  122293. * Sets the right trigger value
  122294. */
  122295. set rightTrigger(newValue: number);
  122296. /**
  122297. * Defines the callback to call when a button is pressed
  122298. * @param callback defines the callback to use
  122299. */
  122300. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  122301. /**
  122302. * Defines the callback to call when a button is released
  122303. * @param callback defines the callback to use
  122304. */
  122305. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  122306. /**
  122307. * Defines the callback to call when a pad is pressed
  122308. * @param callback defines the callback to use
  122309. */
  122310. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  122311. /**
  122312. * Defines the callback to call when a pad is released
  122313. * @param callback defines the callback to use
  122314. */
  122315. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  122316. private _setButtonValue;
  122317. private _setDPadValue;
  122318. /**
  122319. * Gets the value of the `Cross` button
  122320. */
  122321. get buttonCross(): number;
  122322. /**
  122323. * Sets the value of the `Cross` button
  122324. */
  122325. set buttonCross(value: number);
  122326. /**
  122327. * Gets the value of the `Circle` button
  122328. */
  122329. get buttonCircle(): number;
  122330. /**
  122331. * Sets the value of the `Circle` button
  122332. */
  122333. set buttonCircle(value: number);
  122334. /**
  122335. * Gets the value of the `Square` button
  122336. */
  122337. get buttonSquare(): number;
  122338. /**
  122339. * Sets the value of the `Square` button
  122340. */
  122341. set buttonSquare(value: number);
  122342. /**
  122343. * Gets the value of the `Triangle` button
  122344. */
  122345. get buttonTriangle(): number;
  122346. /**
  122347. * Sets the value of the `Triangle` button
  122348. */
  122349. set buttonTriangle(value: number);
  122350. /**
  122351. * Gets the value of the `Options` button
  122352. */
  122353. get buttonOptions(): number;
  122354. /**
  122355. * Sets the value of the `Options` button
  122356. */
  122357. set buttonOptions(value: number);
  122358. /**
  122359. * Gets the value of the `Share` button
  122360. */
  122361. get buttonShare(): number;
  122362. /**
  122363. * Sets the value of the `Share` button
  122364. */
  122365. set buttonShare(value: number);
  122366. /**
  122367. * Gets the value of the `L1` button
  122368. */
  122369. get buttonL1(): number;
  122370. /**
  122371. * Sets the value of the `L1` button
  122372. */
  122373. set buttonL1(value: number);
  122374. /**
  122375. * Gets the value of the `R1` button
  122376. */
  122377. get buttonR1(): number;
  122378. /**
  122379. * Sets the value of the `R1` button
  122380. */
  122381. set buttonR1(value: number);
  122382. /**
  122383. * Gets the value of the Left joystick
  122384. */
  122385. get buttonLeftStick(): number;
  122386. /**
  122387. * Sets the value of the Left joystick
  122388. */
  122389. set buttonLeftStick(value: number);
  122390. /**
  122391. * Gets the value of the Right joystick
  122392. */
  122393. get buttonRightStick(): number;
  122394. /**
  122395. * Sets the value of the Right joystick
  122396. */
  122397. set buttonRightStick(value: number);
  122398. /**
  122399. * Gets the value of D-pad up
  122400. */
  122401. get dPadUp(): number;
  122402. /**
  122403. * Sets the value of D-pad up
  122404. */
  122405. set dPadUp(value: number);
  122406. /**
  122407. * Gets the value of D-pad down
  122408. */
  122409. get dPadDown(): number;
  122410. /**
  122411. * Sets the value of D-pad down
  122412. */
  122413. set dPadDown(value: number);
  122414. /**
  122415. * Gets the value of D-pad left
  122416. */
  122417. get dPadLeft(): number;
  122418. /**
  122419. * Sets the value of D-pad left
  122420. */
  122421. set dPadLeft(value: number);
  122422. /**
  122423. * Gets the value of D-pad right
  122424. */
  122425. get dPadRight(): number;
  122426. /**
  122427. * Sets the value of D-pad right
  122428. */
  122429. set dPadRight(value: number);
  122430. /**
  122431. * Force the gamepad to synchronize with device values
  122432. */
  122433. update(): void;
  122434. /**
  122435. * Disposes the gamepad
  122436. */
  122437. dispose(): void;
  122438. }
  122439. }
  122440. declare module BABYLON {
  122441. /**
  122442. * Manager for handling gamepads
  122443. */
  122444. export class GamepadManager {
  122445. private _scene?;
  122446. private _babylonGamepads;
  122447. private _oneGamepadConnected;
  122448. /** @hidden */
  122449. _isMonitoring: boolean;
  122450. private _gamepadEventSupported;
  122451. private _gamepadSupport?;
  122452. /**
  122453. * observable to be triggered when the gamepad controller has been connected
  122454. */
  122455. onGamepadConnectedObservable: Observable<Gamepad>;
  122456. /**
  122457. * observable to be triggered when the gamepad controller has been disconnected
  122458. */
  122459. onGamepadDisconnectedObservable: Observable<Gamepad>;
  122460. private _onGamepadConnectedEvent;
  122461. private _onGamepadDisconnectedEvent;
  122462. /**
  122463. * Initializes the gamepad manager
  122464. * @param _scene BabylonJS scene
  122465. */
  122466. constructor(_scene?: Scene | undefined);
  122467. /**
  122468. * The gamepads in the game pad manager
  122469. */
  122470. get gamepads(): Gamepad[];
  122471. /**
  122472. * Get the gamepad controllers based on type
  122473. * @param type The type of gamepad controller
  122474. * @returns Nullable gamepad
  122475. */
  122476. getGamepadByType(type?: number): Nullable<Gamepad>;
  122477. /**
  122478. * Disposes the gamepad manager
  122479. */
  122480. dispose(): void;
  122481. private _addNewGamepad;
  122482. private _startMonitoringGamepads;
  122483. private _stopMonitoringGamepads;
  122484. /** @hidden */
  122485. _checkGamepadsStatus(): void;
  122486. private _updateGamepadObjects;
  122487. }
  122488. }
  122489. declare module BABYLON {
  122490. interface Scene {
  122491. /** @hidden */
  122492. _gamepadManager: Nullable<GamepadManager>;
  122493. /**
  122494. * Gets the gamepad manager associated with the scene
  122495. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  122496. */
  122497. gamepadManager: GamepadManager;
  122498. }
  122499. /**
  122500. * Interface representing a free camera inputs manager
  122501. */
  122502. interface FreeCameraInputsManager {
  122503. /**
  122504. * Adds gamepad input support to the FreeCameraInputsManager.
  122505. * @returns the FreeCameraInputsManager
  122506. */
  122507. addGamepad(): FreeCameraInputsManager;
  122508. }
  122509. /**
  122510. * Interface representing an arc rotate camera inputs manager
  122511. */
  122512. interface ArcRotateCameraInputsManager {
  122513. /**
  122514. * Adds gamepad input support to the ArcRotateCamera InputManager.
  122515. * @returns the camera inputs manager
  122516. */
  122517. addGamepad(): ArcRotateCameraInputsManager;
  122518. }
  122519. /**
  122520. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  122521. */
  122522. export class GamepadSystemSceneComponent implements ISceneComponent {
  122523. /**
  122524. * The component name helpfull to identify the component in the list of scene components.
  122525. */
  122526. readonly name: string;
  122527. /**
  122528. * The scene the component belongs to.
  122529. */
  122530. scene: Scene;
  122531. /**
  122532. * Creates a new instance of the component for the given scene
  122533. * @param scene Defines the scene to register the component in
  122534. */
  122535. constructor(scene: Scene);
  122536. /**
  122537. * Registers the component in a given scene
  122538. */
  122539. register(): void;
  122540. /**
  122541. * Rebuilds the elements related to this component in case of
  122542. * context lost for instance.
  122543. */
  122544. rebuild(): void;
  122545. /**
  122546. * Disposes the component and the associated ressources
  122547. */
  122548. dispose(): void;
  122549. private _beforeCameraUpdate;
  122550. }
  122551. }
  122552. declare module BABYLON {
  122553. /**
  122554. * 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,
  122555. * which still works and will still be found in many Playgrounds.
  122556. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122557. */
  122558. export class UniversalCamera extends TouchCamera {
  122559. /**
  122560. * Defines the gamepad rotation sensiblity.
  122561. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122562. */
  122563. get gamepadAngularSensibility(): number;
  122564. set gamepadAngularSensibility(value: number);
  122565. /**
  122566. * Defines the gamepad move sensiblity.
  122567. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122568. */
  122569. get gamepadMoveSensibility(): number;
  122570. set gamepadMoveSensibility(value: number);
  122571. /**
  122572. * 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,
  122573. * which still works and will still be found in many Playgrounds.
  122574. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122575. * @param name Define the name of the camera in the scene
  122576. * @param position Define the start position of the camera in the scene
  122577. * @param scene Define the scene the camera belongs to
  122578. */
  122579. constructor(name: string, position: Vector3, scene: Scene);
  122580. /**
  122581. * Gets the current object class name.
  122582. * @return the class name
  122583. */
  122584. getClassName(): string;
  122585. }
  122586. }
  122587. declare module BABYLON {
  122588. /**
  122589. * This represents a FPS type of camera. This is only here for back compat purpose.
  122590. * Please use the UniversalCamera instead as both are identical.
  122591. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122592. */
  122593. export class GamepadCamera extends UniversalCamera {
  122594. /**
  122595. * Instantiates a new Gamepad Camera
  122596. * This represents a FPS type of camera. This is only here for back compat purpose.
  122597. * Please use the UniversalCamera instead as both are identical.
  122598. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  122599. * @param name Define the name of the camera in the scene
  122600. * @param position Define the start position of the camera in the scene
  122601. * @param scene Define the scene the camera belongs to
  122602. */
  122603. constructor(name: string, position: Vector3, scene: Scene);
  122604. /**
  122605. * Gets the current object class name.
  122606. * @return the class name
  122607. */
  122608. getClassName(): string;
  122609. }
  122610. }
  122611. declare module BABYLON {
  122612. /** @hidden */
  122613. export var passPixelShader: {
  122614. name: string;
  122615. shader: string;
  122616. };
  122617. }
  122618. declare module BABYLON {
  122619. /** @hidden */
  122620. export var passCubePixelShader: {
  122621. name: string;
  122622. shader: string;
  122623. };
  122624. }
  122625. declare module BABYLON {
  122626. /**
  122627. * PassPostProcess which produces an output the same as it's input
  122628. */
  122629. export class PassPostProcess extends PostProcess {
  122630. /**
  122631. * Creates the PassPostProcess
  122632. * @param name The name of the effect.
  122633. * @param options The required width/height ratio to downsize to before computing the render pass.
  122634. * @param camera The camera to apply the render pass to.
  122635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122636. * @param engine The engine which the post process will be applied. (default: current engine)
  122637. * @param reusable If the post process can be reused on the same frame. (default: false)
  122638. * @param textureType The type of texture to be used when performing the post processing.
  122639. * @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)
  122640. */
  122641. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122642. }
  122643. /**
  122644. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  122645. */
  122646. export class PassCubePostProcess extends PostProcess {
  122647. private _face;
  122648. /**
  122649. * Gets or sets the cube face to display.
  122650. * * 0 is +X
  122651. * * 1 is -X
  122652. * * 2 is +Y
  122653. * * 3 is -Y
  122654. * * 4 is +Z
  122655. * * 5 is -Z
  122656. */
  122657. get face(): number;
  122658. set face(value: number);
  122659. /**
  122660. * Creates the PassCubePostProcess
  122661. * @param name The name of the effect.
  122662. * @param options The required width/height ratio to downsize to before computing the render pass.
  122663. * @param camera The camera to apply the render pass to.
  122664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122665. * @param engine The engine which the post process will be applied. (default: current engine)
  122666. * @param reusable If the post process can be reused on the same frame. (default: false)
  122667. * @param textureType The type of texture to be used when performing the post processing.
  122668. * @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)
  122669. */
  122670. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  122671. }
  122672. }
  122673. declare module BABYLON {
  122674. /** @hidden */
  122675. export var anaglyphPixelShader: {
  122676. name: string;
  122677. shader: string;
  122678. };
  122679. }
  122680. declare module BABYLON {
  122681. /**
  122682. * Postprocess used to generate anaglyphic rendering
  122683. */
  122684. export class AnaglyphPostProcess extends PostProcess {
  122685. private _passedProcess;
  122686. /**
  122687. * Creates a new AnaglyphPostProcess
  122688. * @param name defines postprocess name
  122689. * @param options defines creation options or target ratio scale
  122690. * @param rigCameras defines cameras using this postprocess
  122691. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122692. * @param engine defines hosting engine
  122693. * @param reusable defines if the postprocess will be reused multiple times per frame
  122694. */
  122695. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  122696. }
  122697. }
  122698. declare module BABYLON {
  122699. /**
  122700. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  122701. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122702. */
  122703. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  122704. /**
  122705. * Creates a new AnaglyphArcRotateCamera
  122706. * @param name defines camera name
  122707. * @param alpha defines alpha angle (in radians)
  122708. * @param beta defines beta angle (in radians)
  122709. * @param radius defines radius
  122710. * @param target defines camera target
  122711. * @param interaxialDistance defines distance between each color axis
  122712. * @param scene defines the hosting scene
  122713. */
  122714. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  122715. /**
  122716. * Gets camera class name
  122717. * @returns AnaglyphArcRotateCamera
  122718. */
  122719. getClassName(): string;
  122720. }
  122721. }
  122722. declare module BABYLON {
  122723. /**
  122724. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  122725. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122726. */
  122727. export class AnaglyphFreeCamera extends FreeCamera {
  122728. /**
  122729. * Creates a new AnaglyphFreeCamera
  122730. * @param name defines camera name
  122731. * @param position defines initial position
  122732. * @param interaxialDistance defines distance between each color axis
  122733. * @param scene defines the hosting scene
  122734. */
  122735. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122736. /**
  122737. * Gets camera class name
  122738. * @returns AnaglyphFreeCamera
  122739. */
  122740. getClassName(): string;
  122741. }
  122742. }
  122743. declare module BABYLON {
  122744. /**
  122745. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  122746. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122747. */
  122748. export class AnaglyphGamepadCamera extends GamepadCamera {
  122749. /**
  122750. * Creates a new AnaglyphGamepadCamera
  122751. * @param name defines camera name
  122752. * @param position defines initial position
  122753. * @param interaxialDistance defines distance between each color axis
  122754. * @param scene defines the hosting scene
  122755. */
  122756. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122757. /**
  122758. * Gets camera class name
  122759. * @returns AnaglyphGamepadCamera
  122760. */
  122761. getClassName(): string;
  122762. }
  122763. }
  122764. declare module BABYLON {
  122765. /**
  122766. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  122767. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  122768. */
  122769. export class AnaglyphUniversalCamera extends UniversalCamera {
  122770. /**
  122771. * Creates a new AnaglyphUniversalCamera
  122772. * @param name defines camera name
  122773. * @param position defines initial position
  122774. * @param interaxialDistance defines distance between each color axis
  122775. * @param scene defines the hosting scene
  122776. */
  122777. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  122778. /**
  122779. * Gets camera class name
  122780. * @returns AnaglyphUniversalCamera
  122781. */
  122782. getClassName(): string;
  122783. }
  122784. }
  122785. declare module BABYLON {
  122786. /**
  122787. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  122788. * @see http://doc.babylonjs.com/features/cameras
  122789. */
  122790. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  122791. /**
  122792. * Creates a new StereoscopicArcRotateCamera
  122793. * @param name defines camera name
  122794. * @param alpha defines alpha angle (in radians)
  122795. * @param beta defines beta angle (in radians)
  122796. * @param radius defines radius
  122797. * @param target defines camera target
  122798. * @param interaxialDistance defines distance between each color axis
  122799. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122800. * @param scene defines the hosting scene
  122801. */
  122802. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122803. /**
  122804. * Gets camera class name
  122805. * @returns StereoscopicArcRotateCamera
  122806. */
  122807. getClassName(): string;
  122808. }
  122809. }
  122810. declare module BABYLON {
  122811. /**
  122812. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  122813. * @see http://doc.babylonjs.com/features/cameras
  122814. */
  122815. export class StereoscopicFreeCamera extends FreeCamera {
  122816. /**
  122817. * Creates a new StereoscopicFreeCamera
  122818. * @param name defines camera name
  122819. * @param position defines initial position
  122820. * @param interaxialDistance defines distance between each color axis
  122821. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122822. * @param scene defines the hosting scene
  122823. */
  122824. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122825. /**
  122826. * Gets camera class name
  122827. * @returns StereoscopicFreeCamera
  122828. */
  122829. getClassName(): string;
  122830. }
  122831. }
  122832. declare module BABYLON {
  122833. /**
  122834. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  122835. * @see http://doc.babylonjs.com/features/cameras
  122836. */
  122837. export class StereoscopicGamepadCamera extends GamepadCamera {
  122838. /**
  122839. * Creates a new StereoscopicGamepadCamera
  122840. * @param name defines camera name
  122841. * @param position defines initial position
  122842. * @param interaxialDistance defines distance between each color axis
  122843. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122844. * @param scene defines the hosting scene
  122845. */
  122846. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122847. /**
  122848. * Gets camera class name
  122849. * @returns StereoscopicGamepadCamera
  122850. */
  122851. getClassName(): string;
  122852. }
  122853. }
  122854. declare module BABYLON {
  122855. /**
  122856. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  122857. * @see http://doc.babylonjs.com/features/cameras
  122858. */
  122859. export class StereoscopicUniversalCamera extends UniversalCamera {
  122860. /**
  122861. * Creates a new StereoscopicUniversalCamera
  122862. * @param name defines camera name
  122863. * @param position defines initial position
  122864. * @param interaxialDistance defines distance between each color axis
  122865. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  122866. * @param scene defines the hosting scene
  122867. */
  122868. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  122869. /**
  122870. * Gets camera class name
  122871. * @returns StereoscopicUniversalCamera
  122872. */
  122873. getClassName(): string;
  122874. }
  122875. }
  122876. declare module BABYLON {
  122877. /**
  122878. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  122879. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122880. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122881. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122882. */
  122883. export class VirtualJoysticksCamera extends FreeCamera {
  122884. /**
  122885. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  122886. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  122887. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  122888. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  122889. * @param name Define the name of the camera in the scene
  122890. * @param position Define the start position of the camera in the scene
  122891. * @param scene Define the scene the camera belongs to
  122892. */
  122893. constructor(name: string, position: Vector3, scene: Scene);
  122894. /**
  122895. * Gets the current object class name.
  122896. * @return the class name
  122897. */
  122898. getClassName(): string;
  122899. }
  122900. }
  122901. declare module BABYLON {
  122902. /**
  122903. * This represents all the required metrics to create a VR camera.
  122904. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  122905. */
  122906. export class VRCameraMetrics {
  122907. /**
  122908. * Define the horizontal resolution off the screen.
  122909. */
  122910. hResolution: number;
  122911. /**
  122912. * Define the vertical resolution off the screen.
  122913. */
  122914. vResolution: number;
  122915. /**
  122916. * Define the horizontal screen size.
  122917. */
  122918. hScreenSize: number;
  122919. /**
  122920. * Define the vertical screen size.
  122921. */
  122922. vScreenSize: number;
  122923. /**
  122924. * Define the vertical screen center position.
  122925. */
  122926. vScreenCenter: number;
  122927. /**
  122928. * Define the distance of the eyes to the screen.
  122929. */
  122930. eyeToScreenDistance: number;
  122931. /**
  122932. * Define the distance between both lenses
  122933. */
  122934. lensSeparationDistance: number;
  122935. /**
  122936. * Define the distance between both viewer's eyes.
  122937. */
  122938. interpupillaryDistance: number;
  122939. /**
  122940. * Define the distortion factor of the VR postprocess.
  122941. * Please, touch with care.
  122942. */
  122943. distortionK: number[];
  122944. /**
  122945. * Define the chromatic aberration correction factors for the VR post process.
  122946. */
  122947. chromaAbCorrection: number[];
  122948. /**
  122949. * Define the scale factor of the post process.
  122950. * The smaller the better but the slower.
  122951. */
  122952. postProcessScaleFactor: number;
  122953. /**
  122954. * Define an offset for the lens center.
  122955. */
  122956. lensCenterOffset: number;
  122957. /**
  122958. * Define if the current vr camera should compensate the distortion of the lense or not.
  122959. */
  122960. compensateDistortion: boolean;
  122961. /**
  122962. * Defines if multiview should be enabled when rendering (Default: false)
  122963. */
  122964. multiviewEnabled: boolean;
  122965. /**
  122966. * Gets the rendering aspect ratio based on the provided resolutions.
  122967. */
  122968. get aspectRatio(): number;
  122969. /**
  122970. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  122971. */
  122972. get aspectRatioFov(): number;
  122973. /**
  122974. * @hidden
  122975. */
  122976. get leftHMatrix(): Matrix;
  122977. /**
  122978. * @hidden
  122979. */
  122980. get rightHMatrix(): Matrix;
  122981. /**
  122982. * @hidden
  122983. */
  122984. get leftPreViewMatrix(): Matrix;
  122985. /**
  122986. * @hidden
  122987. */
  122988. get rightPreViewMatrix(): Matrix;
  122989. /**
  122990. * Get the default VRMetrics based on the most generic setup.
  122991. * @returns the default vr metrics
  122992. */
  122993. static GetDefault(): VRCameraMetrics;
  122994. }
  122995. }
  122996. declare module BABYLON {
  122997. /** @hidden */
  122998. export var vrDistortionCorrectionPixelShader: {
  122999. name: string;
  123000. shader: string;
  123001. };
  123002. }
  123003. declare module BABYLON {
  123004. /**
  123005. * VRDistortionCorrectionPostProcess used for mobile VR
  123006. */
  123007. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123008. private _isRightEye;
  123009. private _distortionFactors;
  123010. private _postProcessScaleFactor;
  123011. private _lensCenterOffset;
  123012. private _scaleIn;
  123013. private _scaleFactor;
  123014. private _lensCenter;
  123015. /**
  123016. * Initializes the VRDistortionCorrectionPostProcess
  123017. * @param name The name of the effect.
  123018. * @param camera The camera to apply the render pass to.
  123019. * @param isRightEye If this is for the right eye distortion
  123020. * @param vrMetrics All the required metrics for the VR camera
  123021. */
  123022. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123023. }
  123024. }
  123025. declare module BABYLON {
  123026. /**
  123027. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123028. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123029. */
  123030. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123031. /**
  123032. * Creates a new VRDeviceOrientationArcRotateCamera
  123033. * @param name defines camera name
  123034. * @param alpha defines the camera rotation along the logitudinal axis
  123035. * @param beta defines the camera rotation along the latitudinal axis
  123036. * @param radius defines the camera distance from its target
  123037. * @param target defines the camera target
  123038. * @param scene defines the scene the camera belongs to
  123039. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123040. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123041. */
  123042. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123043. /**
  123044. * Gets camera class name
  123045. * @returns VRDeviceOrientationArcRotateCamera
  123046. */
  123047. getClassName(): string;
  123048. }
  123049. }
  123050. declare module BABYLON {
  123051. /**
  123052. * Camera used to simulate VR rendering (based on FreeCamera)
  123053. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123054. */
  123055. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123056. /**
  123057. * Creates a new VRDeviceOrientationFreeCamera
  123058. * @param name defines camera name
  123059. * @param position defines the start position of the camera
  123060. * @param scene defines the scene the camera belongs to
  123061. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123062. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123063. */
  123064. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123065. /**
  123066. * Gets camera class name
  123067. * @returns VRDeviceOrientationFreeCamera
  123068. */
  123069. getClassName(): string;
  123070. }
  123071. }
  123072. declare module BABYLON {
  123073. /**
  123074. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123075. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123076. */
  123077. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123078. /**
  123079. * Creates a new VRDeviceOrientationGamepadCamera
  123080. * @param name defines camera name
  123081. * @param position defines the start position of the camera
  123082. * @param scene defines the scene the camera belongs to
  123083. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123084. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123085. */
  123086. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123087. /**
  123088. * Gets camera class name
  123089. * @returns VRDeviceOrientationGamepadCamera
  123090. */
  123091. getClassName(): string;
  123092. }
  123093. }
  123094. declare module BABYLON {
  123095. /**
  123096. * A class extending Texture allowing drawing on a texture
  123097. * @see http://doc.babylonjs.com/how_to/dynamictexture
  123098. */
  123099. export class DynamicTexture extends Texture {
  123100. private _generateMipMaps;
  123101. private _canvas;
  123102. private _context;
  123103. /**
  123104. * Creates a DynamicTexture
  123105. * @param name defines the name of the texture
  123106. * @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
  123107. * @param scene defines the scene where you want the texture
  123108. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  123109. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123110. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  123111. */
  123112. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  123113. /**
  123114. * Get the current class name of the texture useful for serialization or dynamic coding.
  123115. * @returns "DynamicTexture"
  123116. */
  123117. getClassName(): string;
  123118. /**
  123119. * Gets the current state of canRescale
  123120. */
  123121. get canRescale(): boolean;
  123122. private _recreate;
  123123. /**
  123124. * Scales the texture
  123125. * @param ratio the scale factor to apply to both width and height
  123126. */
  123127. scale(ratio: number): void;
  123128. /**
  123129. * Resizes the texture
  123130. * @param width the new width
  123131. * @param height the new height
  123132. */
  123133. scaleTo(width: number, height: number): void;
  123134. /**
  123135. * Gets the context of the canvas used by the texture
  123136. * @returns the canvas context of the dynamic texture
  123137. */
  123138. getContext(): CanvasRenderingContext2D;
  123139. /**
  123140. * Clears the texture
  123141. */
  123142. clear(): void;
  123143. /**
  123144. * Updates the texture
  123145. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123146. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  123147. */
  123148. update(invertY?: boolean, premulAlpha?: boolean): void;
  123149. /**
  123150. * Draws text onto the texture
  123151. * @param text defines the text to be drawn
  123152. * @param x defines the placement of the text from the left
  123153. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  123154. * @param font defines the font to be used with font-style, font-size, font-name
  123155. * @param color defines the color used for the text
  123156. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  123157. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  123158. * @param update defines whether texture is immediately update (default is true)
  123159. */
  123160. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  123161. /**
  123162. * Clones the texture
  123163. * @returns the clone of the texture.
  123164. */
  123165. clone(): DynamicTexture;
  123166. /**
  123167. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  123168. * @returns a serialized dynamic texture object
  123169. */
  123170. serialize(): any;
  123171. private _IsCanvasElement;
  123172. /** @hidden */
  123173. _rebuild(): void;
  123174. }
  123175. }
  123176. declare module BABYLON {
  123177. /** @hidden */
  123178. export var imageProcessingPixelShader: {
  123179. name: string;
  123180. shader: string;
  123181. };
  123182. }
  123183. declare module BABYLON {
  123184. /**
  123185. * ImageProcessingPostProcess
  123186. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123187. */
  123188. export class ImageProcessingPostProcess extends PostProcess {
  123189. /**
  123190. * Default configuration related to image processing available in the PBR Material.
  123191. */
  123192. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123193. /**
  123194. * Gets the image processing configuration used either in this material.
  123195. */
  123196. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123197. /**
  123198. * Sets the Default image processing configuration used either in the this material.
  123199. *
  123200. * If sets to null, the scene one is in use.
  123201. */
  123202. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  123203. /**
  123204. * Keep track of the image processing observer to allow dispose and replace.
  123205. */
  123206. private _imageProcessingObserver;
  123207. /**
  123208. * Attaches a new image processing configuration to the PBR Material.
  123209. * @param configuration
  123210. */
  123211. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  123212. /**
  123213. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123214. */
  123215. get colorCurves(): Nullable<ColorCurves>;
  123216. /**
  123217. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123218. */
  123219. set colorCurves(value: Nullable<ColorCurves>);
  123220. /**
  123221. * Gets wether the color curves effect is enabled.
  123222. */
  123223. get colorCurvesEnabled(): boolean;
  123224. /**
  123225. * Sets wether the color curves effect is enabled.
  123226. */
  123227. set colorCurvesEnabled(value: boolean);
  123228. /**
  123229. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123230. */
  123231. get colorGradingTexture(): Nullable<BaseTexture>;
  123232. /**
  123233. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123234. */
  123235. set colorGradingTexture(value: Nullable<BaseTexture>);
  123236. /**
  123237. * Gets wether the color grading effect is enabled.
  123238. */
  123239. get colorGradingEnabled(): boolean;
  123240. /**
  123241. * Gets wether the color grading effect is enabled.
  123242. */
  123243. set colorGradingEnabled(value: boolean);
  123244. /**
  123245. * Gets exposure used in the effect.
  123246. */
  123247. get exposure(): number;
  123248. /**
  123249. * Sets exposure used in the effect.
  123250. */
  123251. set exposure(value: number);
  123252. /**
  123253. * Gets wether tonemapping is enabled or not.
  123254. */
  123255. get toneMappingEnabled(): boolean;
  123256. /**
  123257. * Sets wether tonemapping is enabled or not
  123258. */
  123259. set toneMappingEnabled(value: boolean);
  123260. /**
  123261. * Gets the type of tone mapping effect.
  123262. */
  123263. get toneMappingType(): number;
  123264. /**
  123265. * Sets the type of tone mapping effect.
  123266. */
  123267. set toneMappingType(value: number);
  123268. /**
  123269. * Gets contrast used in the effect.
  123270. */
  123271. get contrast(): number;
  123272. /**
  123273. * Sets contrast used in the effect.
  123274. */
  123275. set contrast(value: number);
  123276. /**
  123277. * Gets Vignette stretch size.
  123278. */
  123279. get vignetteStretch(): number;
  123280. /**
  123281. * Sets Vignette stretch size.
  123282. */
  123283. set vignetteStretch(value: number);
  123284. /**
  123285. * Gets Vignette centre X Offset.
  123286. */
  123287. get vignetteCentreX(): number;
  123288. /**
  123289. * Sets Vignette centre X Offset.
  123290. */
  123291. set vignetteCentreX(value: number);
  123292. /**
  123293. * Gets Vignette centre Y Offset.
  123294. */
  123295. get vignetteCentreY(): number;
  123296. /**
  123297. * Sets Vignette centre Y Offset.
  123298. */
  123299. set vignetteCentreY(value: number);
  123300. /**
  123301. * Gets Vignette weight or intensity of the vignette effect.
  123302. */
  123303. get vignetteWeight(): number;
  123304. /**
  123305. * Sets Vignette weight or intensity of the vignette effect.
  123306. */
  123307. set vignetteWeight(value: number);
  123308. /**
  123309. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123310. * if vignetteEnabled is set to true.
  123311. */
  123312. get vignetteColor(): Color4;
  123313. /**
  123314. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123315. * if vignetteEnabled is set to true.
  123316. */
  123317. set vignetteColor(value: Color4);
  123318. /**
  123319. * Gets Camera field of view used by the Vignette effect.
  123320. */
  123321. get vignetteCameraFov(): number;
  123322. /**
  123323. * Sets Camera field of view used by the Vignette effect.
  123324. */
  123325. set vignetteCameraFov(value: number);
  123326. /**
  123327. * Gets the vignette blend mode allowing different kind of effect.
  123328. */
  123329. get vignetteBlendMode(): number;
  123330. /**
  123331. * Sets the vignette blend mode allowing different kind of effect.
  123332. */
  123333. set vignetteBlendMode(value: number);
  123334. /**
  123335. * Gets wether the vignette effect is enabled.
  123336. */
  123337. get vignetteEnabled(): boolean;
  123338. /**
  123339. * Sets wether the vignette effect is enabled.
  123340. */
  123341. set vignetteEnabled(value: boolean);
  123342. private _fromLinearSpace;
  123343. /**
  123344. * Gets wether the input of the processing is in Gamma or Linear Space.
  123345. */
  123346. get fromLinearSpace(): boolean;
  123347. /**
  123348. * Sets wether the input of the processing is in Gamma or Linear Space.
  123349. */
  123350. set fromLinearSpace(value: boolean);
  123351. /**
  123352. * Defines cache preventing GC.
  123353. */
  123354. private _defines;
  123355. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  123356. /**
  123357. * "ImageProcessingPostProcess"
  123358. * @returns "ImageProcessingPostProcess"
  123359. */
  123360. getClassName(): string;
  123361. protected _updateParameters(): void;
  123362. dispose(camera?: Camera): void;
  123363. }
  123364. }
  123365. declare module BABYLON {
  123366. /**
  123367. * Class containing static functions to help procedurally build meshes
  123368. */
  123369. export class GroundBuilder {
  123370. /**
  123371. * Creates a ground mesh
  123372. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123373. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123375. * @param name defines the name of the mesh
  123376. * @param options defines the options used to create the mesh
  123377. * @param scene defines the hosting scene
  123378. * @returns the ground mesh
  123379. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123380. */
  123381. static CreateGround(name: string, options: {
  123382. width?: number;
  123383. height?: number;
  123384. subdivisions?: number;
  123385. subdivisionsX?: number;
  123386. subdivisionsY?: number;
  123387. updatable?: boolean;
  123388. }, scene: any): Mesh;
  123389. /**
  123390. * Creates a tiled ground mesh
  123391. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123392. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123393. * * 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
  123394. * * 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
  123395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123396. * @param name defines the name of the mesh
  123397. * @param options defines the options used to create the mesh
  123398. * @param scene defines the hosting scene
  123399. * @returns the tiled ground mesh
  123400. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123401. */
  123402. static CreateTiledGround(name: string, options: {
  123403. xmin: number;
  123404. zmin: number;
  123405. xmax: number;
  123406. zmax: number;
  123407. subdivisions?: {
  123408. w: number;
  123409. h: number;
  123410. };
  123411. precision?: {
  123412. w: number;
  123413. h: number;
  123414. };
  123415. updatable?: boolean;
  123416. }, scene?: Nullable<Scene>): Mesh;
  123417. /**
  123418. * Creates a ground mesh from a height map
  123419. * * The parameter `url` sets the URL of the height map image resource.
  123420. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123421. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123422. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123423. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123424. * * 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.
  123425. * * 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).
  123426. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123428. * @param name defines the name of the mesh
  123429. * @param url defines the url to the height map
  123430. * @param options defines the options used to create the mesh
  123431. * @param scene defines the hosting scene
  123432. * @returns the ground mesh
  123433. * @see https://doc.babylonjs.com/babylon101/height_map
  123434. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123435. */
  123436. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123437. width?: number;
  123438. height?: number;
  123439. subdivisions?: number;
  123440. minHeight?: number;
  123441. maxHeight?: number;
  123442. colorFilter?: Color3;
  123443. alphaFilter?: number;
  123444. updatable?: boolean;
  123445. onReady?: (mesh: GroundMesh) => void;
  123446. }, scene?: Nullable<Scene>): GroundMesh;
  123447. }
  123448. }
  123449. declare module BABYLON {
  123450. /**
  123451. * Class containing static functions to help procedurally build meshes
  123452. */
  123453. export class TorusBuilder {
  123454. /**
  123455. * Creates a torus mesh
  123456. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123457. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123458. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123462. * @param name defines the name of the mesh
  123463. * @param options defines the options used to create the mesh
  123464. * @param scene defines the hosting scene
  123465. * @returns the torus mesh
  123466. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123467. */
  123468. static CreateTorus(name: string, options: {
  123469. diameter?: number;
  123470. thickness?: number;
  123471. tessellation?: number;
  123472. updatable?: boolean;
  123473. sideOrientation?: number;
  123474. frontUVs?: Vector4;
  123475. backUVs?: Vector4;
  123476. }, scene: any): Mesh;
  123477. }
  123478. }
  123479. declare module BABYLON {
  123480. /**
  123481. * Class containing static functions to help procedurally build meshes
  123482. */
  123483. export class CylinderBuilder {
  123484. /**
  123485. * Creates a cylinder or a cone mesh
  123486. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123487. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123488. * * 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.
  123489. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123490. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123491. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123492. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123493. * * 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).
  123494. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123495. * * 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).
  123496. * * 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
  123497. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123498. * * 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
  123499. * * 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.
  123500. * * If `enclose` is false, a ring surface is one element.
  123501. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123502. * * 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
  123503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123504. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123506. * @param name defines the name of the mesh
  123507. * @param options defines the options used to create the mesh
  123508. * @param scene defines the hosting scene
  123509. * @returns the cylinder mesh
  123510. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123511. */
  123512. static CreateCylinder(name: string, options: {
  123513. height?: number;
  123514. diameterTop?: number;
  123515. diameterBottom?: number;
  123516. diameter?: number;
  123517. tessellation?: number;
  123518. subdivisions?: number;
  123519. arc?: number;
  123520. faceColors?: Color4[];
  123521. faceUV?: Vector4[];
  123522. updatable?: boolean;
  123523. hasRings?: boolean;
  123524. enclose?: boolean;
  123525. cap?: number;
  123526. sideOrientation?: number;
  123527. frontUVs?: Vector4;
  123528. backUVs?: Vector4;
  123529. }, scene: any): Mesh;
  123530. }
  123531. }
  123532. declare module BABYLON {
  123533. /**
  123534. * States of the webXR experience
  123535. */
  123536. export enum WebXRState {
  123537. /**
  123538. * Transitioning to being in XR mode
  123539. */
  123540. ENTERING_XR = 0,
  123541. /**
  123542. * Transitioning to non XR mode
  123543. */
  123544. EXITING_XR = 1,
  123545. /**
  123546. * In XR mode and presenting
  123547. */
  123548. IN_XR = 2,
  123549. /**
  123550. * Not entered XR mode
  123551. */
  123552. NOT_IN_XR = 3
  123553. }
  123554. /**
  123555. * Abstraction of the XR render target
  123556. */
  123557. export interface WebXRRenderTarget extends IDisposable {
  123558. /**
  123559. * xrpresent context of the canvas which can be used to display/mirror xr content
  123560. */
  123561. canvasContext: WebGLRenderingContext;
  123562. /**
  123563. * xr layer for the canvas
  123564. */
  123565. xrLayer: Nullable<XRWebGLLayer>;
  123566. /**
  123567. * Initializes the xr layer for the session
  123568. * @param xrSession xr session
  123569. * @returns a promise that will resolve once the XR Layer has been created
  123570. */
  123571. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123572. }
  123573. }
  123574. declare module BABYLON {
  123575. /**
  123576. * COnfiguration object for WebXR output canvas
  123577. */
  123578. export class WebXRManagedOutputCanvasOptions {
  123579. /**
  123580. * An optional canvas in case you wish to create it yourself and provide it here.
  123581. * If not provided, a new canvas will be created
  123582. */
  123583. canvasElement?: HTMLCanvasElement;
  123584. /**
  123585. * Options for this XR Layer output
  123586. */
  123587. canvasOptions?: XRWebGLLayerOptions;
  123588. /**
  123589. * CSS styling for a newly created canvas (if not provided)
  123590. */
  123591. newCanvasCssStyle?: string;
  123592. /**
  123593. * Get the default values of the configuration object
  123594. * @returns default values of this configuration object
  123595. */
  123596. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  123597. }
  123598. /**
  123599. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  123600. */
  123601. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  123602. private _options;
  123603. private _canvas;
  123604. private _engine;
  123605. /**
  123606. * Rendering context of the canvas which can be used to display/mirror xr content
  123607. */
  123608. canvasContext: WebGLRenderingContext;
  123609. /**
  123610. * xr layer for the canvas
  123611. */
  123612. xrLayer: Nullable<XRWebGLLayer>;
  123613. /**
  123614. * Initializes the canvas to be added/removed upon entering/exiting xr
  123615. * @param _xrSessionManager The XR Session manager
  123616. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  123617. */
  123618. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  123619. /**
  123620. * Disposes of the object
  123621. */
  123622. dispose(): void;
  123623. /**
  123624. * Initializes the xr layer for the session
  123625. * @param xrSession xr session
  123626. * @returns a promise that will resolve once the XR Layer has been created
  123627. */
  123628. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  123629. private _addCanvas;
  123630. private _removeCanvas;
  123631. private _setManagedOutputCanvas;
  123632. }
  123633. }
  123634. declare module BABYLON {
  123635. /**
  123636. * Manages an XRSession to work with Babylon's engine
  123637. * @see https://doc.babylonjs.com/how_to/webxr
  123638. */
  123639. export class WebXRSessionManager implements IDisposable {
  123640. /** The scene which the session should be created for */
  123641. scene: Scene;
  123642. private _referenceSpace;
  123643. private _rttProvider;
  123644. private _sessionEnded;
  123645. private _xrNavigator;
  123646. private baseLayer;
  123647. /**
  123648. * The base reference space from which the session started. good if you want to reset your
  123649. * reference space
  123650. */
  123651. baseReferenceSpace: XRReferenceSpace;
  123652. /**
  123653. * Current XR frame
  123654. */
  123655. currentFrame: Nullable<XRFrame>;
  123656. /** WebXR timestamp updated every frame */
  123657. currentTimestamp: number;
  123658. /**
  123659. * Used just in case of a failure to initialize an immersive session.
  123660. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  123661. */
  123662. defaultHeightCompensation: number;
  123663. /**
  123664. * Fires every time a new xrFrame arrives which can be used to update the camera
  123665. */
  123666. onXRFrameObservable: Observable<XRFrame>;
  123667. /**
  123668. * Fires when the reference space changed
  123669. */
  123670. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  123671. /**
  123672. * Fires when the xr session is ended either by the device or manually done
  123673. */
  123674. onXRSessionEnded: Observable<any>;
  123675. /**
  123676. * Fires when the xr session is ended either by the device or manually done
  123677. */
  123678. onXRSessionInit: Observable<XRSession>;
  123679. /**
  123680. * Underlying xr session
  123681. */
  123682. session: XRSession;
  123683. /**
  123684. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  123685. * or get the offset the player is currently at.
  123686. */
  123687. viewerReferenceSpace: XRReferenceSpace;
  123688. /**
  123689. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  123690. * @param scene The scene which the session should be created for
  123691. */
  123692. constructor(
  123693. /** The scene which the session should be created for */
  123694. scene: Scene);
  123695. /**
  123696. * The current reference space used in this session. This reference space can constantly change!
  123697. * It is mainly used to offset the camera's position.
  123698. */
  123699. get referenceSpace(): XRReferenceSpace;
  123700. /**
  123701. * Set a new reference space and triggers the observable
  123702. */
  123703. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  123704. /**
  123705. * Disposes of the session manager
  123706. */
  123707. dispose(): void;
  123708. /**
  123709. * Stops the xrSession and restores the render loop
  123710. * @returns Promise which resolves after it exits XR
  123711. */
  123712. exitXRAsync(): Promise<void>;
  123713. /**
  123714. * Gets the correct render target texture to be rendered this frame for this eye
  123715. * @param eye the eye for which to get the render target
  123716. * @returns the render target for the specified eye
  123717. */
  123718. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  123719. /**
  123720. * Creates a WebXRRenderTarget object for the XR session
  123721. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  123722. * @param options optional options to provide when creating a new render target
  123723. * @returns a WebXR render target to which the session can render
  123724. */
  123725. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  123726. /**
  123727. * Initializes the manager
  123728. * After initialization enterXR can be called to start an XR session
  123729. * @returns Promise which resolves after it is initialized
  123730. */
  123731. initializeAsync(): Promise<void>;
  123732. /**
  123733. * Initializes an xr session
  123734. * @param xrSessionMode mode to initialize
  123735. * @param xrSessionInit defines optional and required values to pass to the session builder
  123736. * @returns a promise which will resolve once the session has been initialized
  123737. */
  123738. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  123739. /**
  123740. * Checks if a session would be supported for the creation options specified
  123741. * @param sessionMode session mode to check if supported eg. immersive-vr
  123742. * @returns A Promise that resolves to true if supported and false if not
  123743. */
  123744. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123745. /**
  123746. * Resets the reference space to the one started the session
  123747. */
  123748. resetReferenceSpace(): void;
  123749. /**
  123750. * Starts rendering to the xr layer
  123751. */
  123752. runXRRenderLoop(): void;
  123753. /**
  123754. * Sets the reference space on the xr session
  123755. * @param referenceSpaceType space to set
  123756. * @returns a promise that will resolve once the reference space has been set
  123757. */
  123758. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  123759. /**
  123760. * Updates the render state of the session
  123761. * @param state state to set
  123762. * @returns a promise that resolves once the render state has been updated
  123763. */
  123764. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  123765. /**
  123766. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  123767. * @param sessionMode defines the session to test
  123768. * @returns a promise with boolean as final value
  123769. */
  123770. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  123771. private _createRenderTargetTexture;
  123772. }
  123773. }
  123774. declare module BABYLON {
  123775. /**
  123776. * WebXR Camera which holds the views for the xrSession
  123777. * @see https://doc.babylonjs.com/how_to/webxr_camera
  123778. */
  123779. export class WebXRCamera extends FreeCamera {
  123780. private _xrSessionManager;
  123781. private _firstFrame;
  123782. private _referenceQuaternion;
  123783. private _referencedPosition;
  123784. private _xrInvPositionCache;
  123785. private _xrInvQuaternionCache;
  123786. /**
  123787. * Should position compensation execute on first frame.
  123788. * This is used when copying the position from a native (non XR) camera
  123789. */
  123790. compensateOnFirstFrame: boolean;
  123791. /**
  123792. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  123793. * @param name the name of the camera
  123794. * @param scene the scene to add the camera to
  123795. * @param _xrSessionManager a constructed xr session manager
  123796. */
  123797. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  123798. /**
  123799. * Return the user's height, unrelated to the current ground.
  123800. * This will be the y position of this camera, when ground level is 0.
  123801. */
  123802. get realWorldHeight(): number;
  123803. /** @hidden */
  123804. _updateForDualEyeDebugging(): void;
  123805. /**
  123806. * Sets this camera's transformation based on a non-vr camera
  123807. * @param otherCamera the non-vr camera to copy the transformation from
  123808. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  123809. */
  123810. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  123811. /**
  123812. * Gets the current instance class name ("WebXRCamera").
  123813. * @returns the class name
  123814. */
  123815. getClassName(): string;
  123816. /**
  123817. * Overriding the _getViewMatrix function, as it is computed by WebXR
  123818. */
  123819. _getViewMatrix(): Matrix;
  123820. private _updateFromXRSession;
  123821. private _updateNumberOfRigCameras;
  123822. private _updateReferenceSpace;
  123823. private _updateReferenceSpaceOffset;
  123824. }
  123825. }
  123826. declare module BABYLON {
  123827. /**
  123828. * Defining the interface required for a (webxr) feature
  123829. */
  123830. export interface IWebXRFeature extends IDisposable {
  123831. /**
  123832. * Is this feature attached
  123833. */
  123834. attached: boolean;
  123835. /**
  123836. * Should auto-attach be disabled?
  123837. */
  123838. disableAutoAttach: boolean;
  123839. /**
  123840. * Attach the feature to the session
  123841. * Will usually be called by the features manager
  123842. *
  123843. * @param force should attachment be forced (even when already attached)
  123844. * @returns true if successful.
  123845. */
  123846. attach(force?: boolean): boolean;
  123847. /**
  123848. * Detach the feature from the session
  123849. * Will usually be called by the features manager
  123850. *
  123851. * @returns true if successful.
  123852. */
  123853. detach(): boolean;
  123854. }
  123855. /**
  123856. * A list of the currently available features without referencing them
  123857. */
  123858. export class WebXRFeatureName {
  123859. /**
  123860. * The name of the anchor system feature
  123861. */
  123862. static ANCHOR_SYSTEM: string;
  123863. /**
  123864. * The name of the background remover feature
  123865. */
  123866. static BACKGROUND_REMOVER: string;
  123867. /**
  123868. * The name of the hit test feature
  123869. */
  123870. static HIT_TEST: string;
  123871. /**
  123872. * physics impostors for xr controllers feature
  123873. */
  123874. static PHYSICS_CONTROLLERS: string;
  123875. /**
  123876. * The name of the plane detection feature
  123877. */
  123878. static PLANE_DETECTION: string;
  123879. /**
  123880. * The name of the pointer selection feature
  123881. */
  123882. static POINTER_SELECTION: string;
  123883. /**
  123884. * The name of the teleportation feature
  123885. */
  123886. static TELEPORTATION: string;
  123887. }
  123888. /**
  123889. * Defining the constructor of a feature. Used to register the modules.
  123890. */
  123891. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  123892. /**
  123893. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  123894. * It is mainly used in AR sessions.
  123895. *
  123896. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  123897. */
  123898. export class WebXRFeaturesManager implements IDisposable {
  123899. private _xrSessionManager;
  123900. private static readonly _AvailableFeatures;
  123901. private _features;
  123902. /**
  123903. * constructs a new features manages.
  123904. *
  123905. * @param _xrSessionManager an instance of WebXRSessionManager
  123906. */
  123907. constructor(_xrSessionManager: WebXRSessionManager);
  123908. /**
  123909. * Used to register a module. After calling this function a developer can use this feature in the scene.
  123910. * Mainly used internally.
  123911. *
  123912. * @param featureName the name of the feature to register
  123913. * @param constructorFunction the function used to construct the module
  123914. * @param version the (babylon) version of the module
  123915. * @param stable is that a stable version of this module
  123916. */
  123917. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  123918. /**
  123919. * Returns a constructor of a specific feature.
  123920. *
  123921. * @param featureName the name of the feature to construct
  123922. * @param version the version of the feature to load
  123923. * @param xrSessionManager the xrSessionManager. Used to construct the module
  123924. * @param options optional options provided to the module.
  123925. * @returns a function that, when called, will return a new instance of this feature
  123926. */
  123927. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  123928. /**
  123929. * Can be used to return the list of features currently registered
  123930. *
  123931. * @returns an Array of available features
  123932. */
  123933. static GetAvailableFeatures(): string[];
  123934. /**
  123935. * Gets the versions available for a specific feature
  123936. * @param featureName the name of the feature
  123937. * @returns an array with the available versions
  123938. */
  123939. static GetAvailableVersions(featureName: string): string[];
  123940. /**
  123941. * Return the latest unstable version of this feature
  123942. * @param featureName the name of the feature to search
  123943. * @returns the version number. if not found will return -1
  123944. */
  123945. static GetLatestVersionOfFeature(featureName: string): number;
  123946. /**
  123947. * Return the latest stable version of this feature
  123948. * @param featureName the name of the feature to search
  123949. * @returns the version number. if not found will return -1
  123950. */
  123951. static GetStableVersionOfFeature(featureName: string): number;
  123952. /**
  123953. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  123954. * Can be used during a session to start a feature
  123955. * @param featureName the name of feature to attach
  123956. */
  123957. attachFeature(featureName: string): void;
  123958. /**
  123959. * Can be used inside a session or when the session ends to detach a specific feature
  123960. * @param featureName the name of the feature to detach
  123961. */
  123962. detachFeature(featureName: string): void;
  123963. /**
  123964. * Used to disable an already-enabled feature
  123965. * The feature will be disposed and will be recreated once enabled.
  123966. * @param featureName the feature to disable
  123967. * @returns true if disable was successful
  123968. */
  123969. disableFeature(featureName: string | {
  123970. Name: string;
  123971. }): boolean;
  123972. /**
  123973. * dispose this features manager
  123974. */
  123975. dispose(): void;
  123976. /**
  123977. * 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.
  123978. * 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.
  123979. *
  123980. * @param featureName the name of the feature to load or the class of the feature
  123981. * @param version optional version to load. if not provided the latest version will be enabled
  123982. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  123983. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  123984. * @returns a new constructed feature or throws an error if feature not found.
  123985. */
  123986. enableFeature(featureName: string | {
  123987. Name: string;
  123988. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  123989. /**
  123990. * get the implementation of an enabled feature.
  123991. * @param featureName the name of the feature to load
  123992. * @returns the feature class, if found
  123993. */
  123994. getEnabledFeature(featureName: string): IWebXRFeature;
  123995. /**
  123996. * Get the list of enabled features
  123997. * @returns an array of enabled features
  123998. */
  123999. getEnabledFeatures(): string[];
  124000. }
  124001. }
  124002. declare module BABYLON {
  124003. /**
  124004. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124005. * @see https://doc.babylonjs.com/how_to/webxr
  124006. */
  124007. export class WebXRExperienceHelper implements IDisposable {
  124008. private scene;
  124009. private _nonVRCamera;
  124010. private _originalSceneAutoClear;
  124011. private _supported;
  124012. /**
  124013. * Camera used to render xr content
  124014. */
  124015. camera: WebXRCamera;
  124016. /** A features manager for this xr session */
  124017. featuresManager: WebXRFeaturesManager;
  124018. /**
  124019. * Observers registered here will be triggered after the camera's initial transformation is set
  124020. * This can be used to set a different ground level or an extra rotation.
  124021. *
  124022. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124023. * to the position set after this observable is done executing.
  124024. */
  124025. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124026. /**
  124027. * Fires when the state of the experience helper has changed
  124028. */
  124029. onStateChangedObservable: Observable<WebXRState>;
  124030. /** Session manager used to keep track of xr session */
  124031. sessionManager: WebXRSessionManager;
  124032. /**
  124033. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124034. */
  124035. state: WebXRState;
  124036. /**
  124037. * Creates a WebXRExperienceHelper
  124038. * @param scene The scene the helper should be created in
  124039. */
  124040. private constructor();
  124041. /**
  124042. * Creates the experience helper
  124043. * @param scene the scene to attach the experience helper to
  124044. * @returns a promise for the experience helper
  124045. */
  124046. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124047. /**
  124048. * Disposes of the experience helper
  124049. */
  124050. dispose(): void;
  124051. /**
  124052. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124053. * @param sessionMode options for the XR session
  124054. * @param referenceSpaceType frame of reference of the XR session
  124055. * @param renderTarget the output canvas that will be used to enter XR mode
  124056. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124057. * @returns promise that resolves after xr mode has entered
  124058. */
  124059. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124060. /**
  124061. * Exits XR mode and returns the scene to its original state
  124062. * @returns promise that resolves after xr mode has exited
  124063. */
  124064. exitXRAsync(): Promise<void>;
  124065. private _nonXRToXRCamera;
  124066. private _setState;
  124067. }
  124068. }
  124069. declare module BABYLON {
  124070. /**
  124071. * X-Y values for axes in WebXR
  124072. */
  124073. export interface IWebXRMotionControllerAxesValue {
  124074. /**
  124075. * The value of the x axis
  124076. */
  124077. x: number;
  124078. /**
  124079. * The value of the y-axis
  124080. */
  124081. y: number;
  124082. }
  124083. /**
  124084. * changed / previous values for the values of this component
  124085. */
  124086. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124087. /**
  124088. * current (this frame) value
  124089. */
  124090. current: T;
  124091. /**
  124092. * previous (last change) value
  124093. */
  124094. previous: T;
  124095. }
  124096. /**
  124097. * Represents changes in the component between current frame and last values recorded
  124098. */
  124099. export interface IWebXRMotionControllerComponentChanges {
  124100. /**
  124101. * will be populated with previous and current values if axes changed
  124102. */
  124103. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124104. /**
  124105. * will be populated with previous and current values if pressed changed
  124106. */
  124107. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124108. /**
  124109. * will be populated with previous and current values if touched changed
  124110. */
  124111. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124112. /**
  124113. * will be populated with previous and current values if value changed
  124114. */
  124115. value?: IWebXRMotionControllerComponentChangesValues<number>;
  124116. }
  124117. /**
  124118. * This class represents a single component (for example button or thumbstick) of a motion controller
  124119. */
  124120. export class WebXRControllerComponent implements IDisposable {
  124121. /**
  124122. * the id of this component
  124123. */
  124124. id: string;
  124125. /**
  124126. * the type of the component
  124127. */
  124128. type: MotionControllerComponentType;
  124129. private _buttonIndex;
  124130. private _axesIndices;
  124131. private _axes;
  124132. private _changes;
  124133. private _currentValue;
  124134. private _hasChanges;
  124135. private _pressed;
  124136. private _touched;
  124137. /**
  124138. * button component type
  124139. */
  124140. static BUTTON_TYPE: MotionControllerComponentType;
  124141. /**
  124142. * squeeze component type
  124143. */
  124144. static SQUEEZE_TYPE: MotionControllerComponentType;
  124145. /**
  124146. * Thumbstick component type
  124147. */
  124148. static THUMBSTICK_TYPE: MotionControllerComponentType;
  124149. /**
  124150. * Touchpad component type
  124151. */
  124152. static TOUCHPAD_TYPE: MotionControllerComponentType;
  124153. /**
  124154. * trigger component type
  124155. */
  124156. static TRIGGER_TYPE: MotionControllerComponentType;
  124157. /**
  124158. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  124159. * the axes data changes
  124160. */
  124161. onAxisValueChangedObservable: Observable<{
  124162. x: number;
  124163. y: number;
  124164. }>;
  124165. /**
  124166. * Observers registered here will be triggered when the state of a button changes
  124167. * State change is either pressed / touched / value
  124168. */
  124169. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  124170. /**
  124171. * Creates a new component for a motion controller.
  124172. * It is created by the motion controller itself
  124173. *
  124174. * @param id the id of this component
  124175. * @param type the type of the component
  124176. * @param _buttonIndex index in the buttons array of the gamepad
  124177. * @param _axesIndices indices of the values in the axes array of the gamepad
  124178. */
  124179. constructor(
  124180. /**
  124181. * the id of this component
  124182. */
  124183. id: string,
  124184. /**
  124185. * the type of the component
  124186. */
  124187. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  124188. /**
  124189. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  124190. */
  124191. get axes(): IWebXRMotionControllerAxesValue;
  124192. /**
  124193. * Get the changes. Elements will be populated only if they changed with their previous and current value
  124194. */
  124195. get changes(): IWebXRMotionControllerComponentChanges;
  124196. /**
  124197. * Return whether or not the component changed the last frame
  124198. */
  124199. get hasChanges(): boolean;
  124200. /**
  124201. * is the button currently pressed
  124202. */
  124203. get pressed(): boolean;
  124204. /**
  124205. * is the button currently touched
  124206. */
  124207. get touched(): boolean;
  124208. /**
  124209. * Get the current value of this component
  124210. */
  124211. get value(): number;
  124212. /**
  124213. * Dispose this component
  124214. */
  124215. dispose(): void;
  124216. /**
  124217. * Are there axes correlating to this component
  124218. * @return true is axes data is available
  124219. */
  124220. isAxes(): boolean;
  124221. /**
  124222. * Is this component a button (hence - pressable)
  124223. * @returns true if can be pressed
  124224. */
  124225. isButton(): boolean;
  124226. /**
  124227. * update this component using the gamepad object it is in. Called on every frame
  124228. * @param nativeController the native gamepad controller object
  124229. */
  124230. update(nativeController: IMinimalMotionControllerObject): void;
  124231. }
  124232. }
  124233. declare module BABYLON {
  124234. /**
  124235. * Interface used to represent data loading progression
  124236. */
  124237. export interface ISceneLoaderProgressEvent {
  124238. /**
  124239. * Defines if data length to load can be evaluated
  124240. */
  124241. readonly lengthComputable: boolean;
  124242. /**
  124243. * Defines the loaded data length
  124244. */
  124245. readonly loaded: number;
  124246. /**
  124247. * Defines the data length to load
  124248. */
  124249. readonly total: number;
  124250. }
  124251. /**
  124252. * Interface used by SceneLoader plugins to define supported file extensions
  124253. */
  124254. export interface ISceneLoaderPluginExtensions {
  124255. /**
  124256. * Defines the list of supported extensions
  124257. */
  124258. [extension: string]: {
  124259. isBinary: boolean;
  124260. };
  124261. }
  124262. /**
  124263. * Interface used by SceneLoader plugin factory
  124264. */
  124265. export interface ISceneLoaderPluginFactory {
  124266. /**
  124267. * Defines the name of the factory
  124268. */
  124269. name: string;
  124270. /**
  124271. * Function called to create a new plugin
  124272. * @return the new plugin
  124273. */
  124274. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  124275. /**
  124276. * The callback that returns true if the data can be directly loaded.
  124277. * @param data string containing the file data
  124278. * @returns if the data can be loaded directly
  124279. */
  124280. canDirectLoad?(data: string): boolean;
  124281. }
  124282. /**
  124283. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  124284. */
  124285. export interface ISceneLoaderPluginBase {
  124286. /**
  124287. * The friendly name of this plugin.
  124288. */
  124289. name: string;
  124290. /**
  124291. * The file extensions supported by this plugin.
  124292. */
  124293. extensions: string | ISceneLoaderPluginExtensions;
  124294. /**
  124295. * The callback called when loading from a url.
  124296. * @param scene scene loading this url
  124297. * @param url url to load
  124298. * @param onSuccess callback called when the file successfully loads
  124299. * @param onProgress callback called while file is loading (if the server supports this mode)
  124300. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  124301. * @param onError callback called when the file fails to load
  124302. * @returns a file request object
  124303. */
  124304. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124305. /**
  124306. * The callback called when loading from a file object.
  124307. * @param scene scene loading this file
  124308. * @param file defines the file to load
  124309. * @param onSuccess defines the callback to call when data is loaded
  124310. * @param onProgress defines the callback to call during loading process
  124311. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  124312. * @param onError defines the callback to call when an error occurs
  124313. * @returns a file request object
  124314. */
  124315. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  124316. /**
  124317. * The callback that returns true if the data can be directly loaded.
  124318. * @param data string containing the file data
  124319. * @returns if the data can be loaded directly
  124320. */
  124321. canDirectLoad?(data: string): boolean;
  124322. /**
  124323. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  124324. * @param scene scene loading this data
  124325. * @param data string containing the data
  124326. * @returns data to pass to the plugin
  124327. */
  124328. directLoad?(scene: Scene, data: string): any;
  124329. /**
  124330. * The callback that allows custom handling of the root url based on the response url.
  124331. * @param rootUrl the original root url
  124332. * @param responseURL the response url if available
  124333. * @returns the new root url
  124334. */
  124335. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  124336. }
  124337. /**
  124338. * Interface used to define a SceneLoader plugin
  124339. */
  124340. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  124341. /**
  124342. * Import meshes into a scene.
  124343. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124344. * @param scene The scene to import into
  124345. * @param data The data to import
  124346. * @param rootUrl The root url for scene and resources
  124347. * @param meshes The meshes array to import into
  124348. * @param particleSystems The particle systems array to import into
  124349. * @param skeletons The skeletons array to import into
  124350. * @param onError The callback when import fails
  124351. * @returns True if successful or false otherwise
  124352. */
  124353. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  124354. /**
  124355. * Load into a scene.
  124356. * @param scene The scene to load into
  124357. * @param data The data to import
  124358. * @param rootUrl The root url for scene and resources
  124359. * @param onError The callback when import fails
  124360. * @returns True if successful or false otherwise
  124361. */
  124362. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  124363. /**
  124364. * Load into an asset container.
  124365. * @param scene The scene to load into
  124366. * @param data The data to import
  124367. * @param rootUrl The root url for scene and resources
  124368. * @param onError The callback when import fails
  124369. * @returns The loaded asset container
  124370. */
  124371. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  124372. }
  124373. /**
  124374. * Interface used to define an async SceneLoader plugin
  124375. */
  124376. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  124377. /**
  124378. * Import meshes into a scene.
  124379. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124380. * @param scene The scene to import into
  124381. * @param data The data to import
  124382. * @param rootUrl The root url for scene and resources
  124383. * @param onProgress The callback when the load progresses
  124384. * @param fileName Defines the name of the file to load
  124385. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  124386. */
  124387. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  124388. meshes: AbstractMesh[];
  124389. particleSystems: IParticleSystem[];
  124390. skeletons: Skeleton[];
  124391. animationGroups: AnimationGroup[];
  124392. }>;
  124393. /**
  124394. * Load into a scene.
  124395. * @param scene The scene to load into
  124396. * @param data The data to import
  124397. * @param rootUrl The root url for scene and resources
  124398. * @param onProgress The callback when the load progresses
  124399. * @param fileName Defines the name of the file to load
  124400. * @returns Nothing
  124401. */
  124402. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  124403. /**
  124404. * Load into an asset container.
  124405. * @param scene The scene to load into
  124406. * @param data The data to import
  124407. * @param rootUrl The root url for scene and resources
  124408. * @param onProgress The callback when the load progresses
  124409. * @param fileName Defines the name of the file to load
  124410. * @returns The loaded asset container
  124411. */
  124412. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  124413. }
  124414. /**
  124415. * Mode that determines how to handle old animation groups before loading new ones.
  124416. */
  124417. export enum SceneLoaderAnimationGroupLoadingMode {
  124418. /**
  124419. * Reset all old animations to initial state then dispose them.
  124420. */
  124421. Clean = 0,
  124422. /**
  124423. * Stop all old animations.
  124424. */
  124425. Stop = 1,
  124426. /**
  124427. * Restart old animations from first frame.
  124428. */
  124429. Sync = 2,
  124430. /**
  124431. * Old animations remains untouched.
  124432. */
  124433. NoSync = 3
  124434. }
  124435. /**
  124436. * Class used to load scene from various file formats using registered plugins
  124437. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  124438. */
  124439. export class SceneLoader {
  124440. /**
  124441. * No logging while loading
  124442. */
  124443. static readonly NO_LOGGING: number;
  124444. /**
  124445. * Minimal logging while loading
  124446. */
  124447. static readonly MINIMAL_LOGGING: number;
  124448. /**
  124449. * Summary logging while loading
  124450. */
  124451. static readonly SUMMARY_LOGGING: number;
  124452. /**
  124453. * Detailled logging while loading
  124454. */
  124455. static readonly DETAILED_LOGGING: number;
  124456. /**
  124457. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  124458. */
  124459. static get ForceFullSceneLoadingForIncremental(): boolean;
  124460. static set ForceFullSceneLoadingForIncremental(value: boolean);
  124461. /**
  124462. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  124463. */
  124464. static get ShowLoadingScreen(): boolean;
  124465. static set ShowLoadingScreen(value: boolean);
  124466. /**
  124467. * Defines the current logging level (while loading the scene)
  124468. * @ignorenaming
  124469. */
  124470. static get loggingLevel(): number;
  124471. static set loggingLevel(value: number);
  124472. /**
  124473. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  124474. */
  124475. static get CleanBoneMatrixWeights(): boolean;
  124476. static set CleanBoneMatrixWeights(value: boolean);
  124477. /**
  124478. * Event raised when a plugin is used to load a scene
  124479. */
  124480. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124481. private static _registeredPlugins;
  124482. private static _getDefaultPlugin;
  124483. private static _getPluginForExtension;
  124484. private static _getPluginForDirectLoad;
  124485. private static _getPluginForFilename;
  124486. private static _getDirectLoad;
  124487. private static _loadData;
  124488. private static _getFileInfo;
  124489. /**
  124490. * Gets a plugin that can load the given extension
  124491. * @param extension defines the extension to load
  124492. * @returns a plugin or null if none works
  124493. */
  124494. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  124495. /**
  124496. * Gets a boolean indicating that the given extension can be loaded
  124497. * @param extension defines the extension to load
  124498. * @returns true if the extension is supported
  124499. */
  124500. static IsPluginForExtensionAvailable(extension: string): boolean;
  124501. /**
  124502. * Adds a new plugin to the list of registered plugins
  124503. * @param plugin defines the plugin to add
  124504. */
  124505. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  124506. /**
  124507. * Import meshes into a scene
  124508. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124509. * @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)
  124510. * @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)
  124511. * @param scene the instance of BABYLON.Scene to append to
  124512. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  124513. * @param onProgress a callback with a progress event for each file being loaded
  124514. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124515. * @param pluginExtension the extension used to determine the plugin
  124516. * @returns The loaded plugin
  124517. */
  124518. 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: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124519. /**
  124520. * Import meshes into a scene
  124521. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  124522. * @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)
  124523. * @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)
  124524. * @param scene the instance of BABYLON.Scene to append to
  124525. * @param onProgress a callback with a progress event for each file being loaded
  124526. * @param pluginExtension the extension used to determine the plugin
  124527. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  124528. */
  124529. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  124530. meshes: AbstractMesh[];
  124531. particleSystems: IParticleSystem[];
  124532. skeletons: Skeleton[];
  124533. animationGroups: AnimationGroup[];
  124534. }>;
  124535. /**
  124536. * Load a scene
  124537. * @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)
  124538. * @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)
  124539. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124540. * @param onSuccess a callback with the scene when import succeeds
  124541. * @param onProgress a callback with a progress event for each file being loaded
  124542. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124543. * @param pluginExtension the extension used to determine the plugin
  124544. * @returns The loaded plugin
  124545. */
  124546. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124547. /**
  124548. * Load a scene
  124549. * @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)
  124550. * @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)
  124551. * @param engine is the instance of BABYLON.Engine to use to create the scene
  124552. * @param onProgress a callback with a progress event for each file being loaded
  124553. * @param pluginExtension the extension used to determine the plugin
  124554. * @returns The loaded scene
  124555. */
  124556. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124557. /**
  124558. * Append a scene
  124559. * @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)
  124560. * @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)
  124561. * @param scene is the instance of BABYLON.Scene to append to
  124562. * @param onSuccess a callback with the scene when import succeeds
  124563. * @param onProgress a callback with a progress event for each file being loaded
  124564. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124565. * @param pluginExtension the extension used to determine the plugin
  124566. * @returns The loaded plugin
  124567. */
  124568. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124569. /**
  124570. * Append a scene
  124571. * @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)
  124572. * @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)
  124573. * @param scene is the instance of BABYLON.Scene to append to
  124574. * @param onProgress a callback with a progress event for each file being loaded
  124575. * @param pluginExtension the extension used to determine the plugin
  124576. * @returns The given scene
  124577. */
  124578. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  124579. /**
  124580. * Load a scene into an asset container
  124581. * @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)
  124582. * @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)
  124583. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124584. * @param onSuccess a callback with the scene when import succeeds
  124585. * @param onProgress a callback with a progress event for each file being loaded
  124586. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124587. * @param pluginExtension the extension used to determine the plugin
  124588. * @returns The loaded plugin
  124589. */
  124590. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  124591. /**
  124592. * Load a scene into an asset container
  124593. * @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)
  124594. * @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)
  124595. * @param scene is the instance of Scene to append to
  124596. * @param onProgress a callback with a progress event for each file being loaded
  124597. * @param pluginExtension the extension used to determine the plugin
  124598. * @returns The loaded asset container
  124599. */
  124600. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  124601. /**
  124602. * Import animations from a file into a scene
  124603. * @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)
  124604. * @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)
  124605. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124606. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124607. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124608. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124609. * @param onSuccess a callback with the scene when import succeeds
  124610. * @param onProgress a callback with a progress event for each file being loaded
  124611. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124612. */
  124613. 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: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  124614. /**
  124615. * Import animations from a file into a scene
  124616. * @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)
  124617. * @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)
  124618. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  124619. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  124620. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  124621. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  124622. * @param onSuccess a callback with the scene when import succeeds
  124623. * @param onProgress a callback with a progress event for each file being loaded
  124624. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  124625. * @returns the updated scene with imported animations
  124626. */
  124627. 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: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  124628. }
  124629. }
  124630. declare module BABYLON {
  124631. /**
  124632. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  124633. */
  124634. export type MotionControllerHandedness = "none" | "left" | "right";
  124635. /**
  124636. * The type of components available in motion controllers.
  124637. * This is not the name of the component.
  124638. */
  124639. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  124640. /**
  124641. * The state of a controller component
  124642. */
  124643. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  124644. /**
  124645. * The schema of motion controller layout.
  124646. * No object will be initialized using this interface
  124647. * This is used just to define the profile.
  124648. */
  124649. export interface IMotionControllerLayout {
  124650. /**
  124651. * Path to load the assets. Usually relative to the base path
  124652. */
  124653. assetPath: string;
  124654. /**
  124655. * Available components (unsorted)
  124656. */
  124657. components: {
  124658. /**
  124659. * A map of component Ids
  124660. */
  124661. [componentId: string]: {
  124662. /**
  124663. * The type of input the component outputs
  124664. */
  124665. type: MotionControllerComponentType;
  124666. /**
  124667. * The indices of this component in the gamepad object
  124668. */
  124669. gamepadIndices: {
  124670. /**
  124671. * Index of button
  124672. */
  124673. button?: number;
  124674. /**
  124675. * If available, index of x-axis
  124676. */
  124677. xAxis?: number;
  124678. /**
  124679. * If available, index of y-axis
  124680. */
  124681. yAxis?: number;
  124682. };
  124683. /**
  124684. * The mesh's root node name
  124685. */
  124686. rootNodeName: string;
  124687. /**
  124688. * Animation definitions for this model
  124689. */
  124690. visualResponses: {
  124691. [stateKey: string]: {
  124692. /**
  124693. * What property will be animated
  124694. */
  124695. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  124696. /**
  124697. * What states influence this visual response
  124698. */
  124699. states: MotionControllerComponentStateType[];
  124700. /**
  124701. * Type of animation - movement or visibility
  124702. */
  124703. valueNodeProperty: "transform" | "visibility";
  124704. /**
  124705. * Base node name to move. Its position will be calculated according to the min and max nodes
  124706. */
  124707. valueNodeName?: string;
  124708. /**
  124709. * Minimum movement node
  124710. */
  124711. minNodeName?: string;
  124712. /**
  124713. * Max movement node
  124714. */
  124715. maxNodeName?: string;
  124716. };
  124717. };
  124718. /**
  124719. * If touch enabled, what is the name of node to display user feedback
  124720. */
  124721. touchPointNodeName?: string;
  124722. };
  124723. };
  124724. /**
  124725. * Is it xr standard mapping or not
  124726. */
  124727. gamepadMapping: "" | "xr-standard";
  124728. /**
  124729. * Base root node of this entire model
  124730. */
  124731. rootNodeName: string;
  124732. /**
  124733. * Defines the main button component id
  124734. */
  124735. selectComponentId: string;
  124736. }
  124737. /**
  124738. * A definition for the layout map in the input profile
  124739. */
  124740. export interface IMotionControllerLayoutMap {
  124741. /**
  124742. * Layouts with handedness type as a key
  124743. */
  124744. [handedness: string]: IMotionControllerLayout;
  124745. }
  124746. /**
  124747. * The XR Input profile schema
  124748. * Profiles can be found here:
  124749. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  124750. */
  124751. export interface IMotionControllerProfile {
  124752. /**
  124753. * fallback profiles for this profileId
  124754. */
  124755. fallbackProfileIds: string[];
  124756. /**
  124757. * The layout map, with handedness as key
  124758. */
  124759. layouts: IMotionControllerLayoutMap;
  124760. /**
  124761. * The id of this profile
  124762. * correlates to the profile(s) in the xrInput.profiles array
  124763. */
  124764. profileId: string;
  124765. }
  124766. /**
  124767. * A helper-interface for the 3 meshes needed for controller button animation
  124768. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  124769. */
  124770. export interface IMotionControllerButtonMeshMap {
  124771. /**
  124772. * the mesh that defines the pressed value mesh position.
  124773. * This is used to find the max-position of this button
  124774. */
  124775. pressedMesh: AbstractMesh;
  124776. /**
  124777. * the mesh that defines the unpressed value mesh position.
  124778. * This is used to find the min (or initial) position of this button
  124779. */
  124780. unpressedMesh: AbstractMesh;
  124781. /**
  124782. * The mesh that will be changed when value changes
  124783. */
  124784. valueMesh: AbstractMesh;
  124785. }
  124786. /**
  124787. * A helper-interface for the 3 meshes needed for controller axis animation.
  124788. * This will be expanded when touchpad animations are fully supported
  124789. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  124790. */
  124791. export interface IMotionControllerMeshMap {
  124792. /**
  124793. * the mesh that defines the maximum value mesh position.
  124794. */
  124795. maxMesh?: AbstractMesh;
  124796. /**
  124797. * the mesh that defines the minimum value mesh position.
  124798. */
  124799. minMesh?: AbstractMesh;
  124800. /**
  124801. * The mesh that will be changed when axis value changes
  124802. */
  124803. valueMesh: AbstractMesh;
  124804. }
  124805. /**
  124806. * The elements needed for change-detection of the gamepad objects in motion controllers
  124807. */
  124808. export interface IMinimalMotionControllerObject {
  124809. /**
  124810. * Available axes of this controller
  124811. */
  124812. axes: number[];
  124813. /**
  124814. * An array of available buttons
  124815. */
  124816. buttons: Array<{
  124817. /**
  124818. * Value of the button/trigger
  124819. */
  124820. value: number;
  124821. /**
  124822. * If the button/trigger is currently touched
  124823. */
  124824. touched: boolean;
  124825. /**
  124826. * If the button/trigger is currently pressed
  124827. */
  124828. pressed: boolean;
  124829. }>;
  124830. /**
  124831. * EXPERIMENTAL haptic support.
  124832. */
  124833. hapticActuators?: Array<{
  124834. pulse: (value: number, duration: number) => Promise<boolean>;
  124835. }>;
  124836. }
  124837. /**
  124838. * An Abstract Motion controller
  124839. * This class receives an xrInput and a profile layout and uses those to initialize the components
  124840. * Each component has an observable to check for changes in value and state
  124841. */
  124842. export abstract class WebXRAbstractMotionController implements IDisposable {
  124843. protected scene: Scene;
  124844. protected layout: IMotionControllerLayout;
  124845. /**
  124846. * The gamepad object correlating to this controller
  124847. */
  124848. gamepadObject: IMinimalMotionControllerObject;
  124849. /**
  124850. * handedness (left/right/none) of this controller
  124851. */
  124852. handedness: MotionControllerHandedness;
  124853. private _initComponent;
  124854. private _modelReady;
  124855. /**
  124856. * A map of components (WebXRControllerComponent) in this motion controller
  124857. * Components have a ComponentType and can also have both button and axis definitions
  124858. */
  124859. readonly components: {
  124860. [id: string]: WebXRControllerComponent;
  124861. };
  124862. /**
  124863. * Disable the model's animation. Can be set at any time.
  124864. */
  124865. disableAnimation: boolean;
  124866. /**
  124867. * Observers registered here will be triggered when the model of this controller is done loading
  124868. */
  124869. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  124870. /**
  124871. * The profile id of this motion controller
  124872. */
  124873. abstract profileId: string;
  124874. /**
  124875. * The root mesh of the model. It is null if the model was not yet initialized
  124876. */
  124877. rootMesh: Nullable<AbstractMesh>;
  124878. /**
  124879. * constructs a new abstract motion controller
  124880. * @param scene the scene to which the model of the controller will be added
  124881. * @param layout The profile layout to load
  124882. * @param gamepadObject The gamepad object correlating to this controller
  124883. * @param handedness handedness (left/right/none) of this controller
  124884. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  124885. */
  124886. constructor(scene: Scene, layout: IMotionControllerLayout,
  124887. /**
  124888. * The gamepad object correlating to this controller
  124889. */
  124890. gamepadObject: IMinimalMotionControllerObject,
  124891. /**
  124892. * handedness (left/right/none) of this controller
  124893. */
  124894. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  124895. /**
  124896. * Dispose this controller, the model mesh and all its components
  124897. */
  124898. dispose(): void;
  124899. /**
  124900. * Returns all components of specific type
  124901. * @param type the type to search for
  124902. * @return an array of components with this type
  124903. */
  124904. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  124905. /**
  124906. * get a component based an its component id as defined in layout.components
  124907. * @param id the id of the component
  124908. * @returns the component correlates to the id or undefined if not found
  124909. */
  124910. getComponent(id: string): WebXRControllerComponent;
  124911. /**
  124912. * Get the list of components available in this motion controller
  124913. * @returns an array of strings correlating to available components
  124914. */
  124915. getComponentIds(): string[];
  124916. /**
  124917. * Get the first component of specific type
  124918. * @param type type of component to find
  124919. * @return a controller component or null if not found
  124920. */
  124921. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  124922. /**
  124923. * Get the main (Select) component of this controller as defined in the layout
  124924. * @returns the main component of this controller
  124925. */
  124926. getMainComponent(): WebXRControllerComponent;
  124927. /**
  124928. * Loads the model correlating to this controller
  124929. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  124930. * @returns A promise fulfilled with the result of the model loading
  124931. */
  124932. loadModel(): Promise<boolean>;
  124933. /**
  124934. * Update this model using the current XRFrame
  124935. * @param xrFrame the current xr frame to use and update the model
  124936. */
  124937. updateFromXRFrame(xrFrame: XRFrame): void;
  124938. /**
  124939. * Backwards compatibility due to a deeply-integrated typo
  124940. */
  124941. get handness(): XREye;
  124942. /**
  124943. * Pulse (vibrate) this controller
  124944. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  124945. * Consecutive calls to this function will cancel the last pulse call
  124946. *
  124947. * @param value the strength of the pulse in 0.0...1.0 range
  124948. * @param duration Duration of the pulse in milliseconds
  124949. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  124950. * @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
  124951. */
  124952. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  124953. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124954. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  124955. /**
  124956. * Moves the axis on the controller mesh based on its current state
  124957. * @param axis the index of the axis
  124958. * @param axisValue the value of the axis which determines the meshes new position
  124959. * @hidden
  124960. */
  124961. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  124962. /**
  124963. * Update the model itself with the current frame data
  124964. * @param xrFrame the frame to use for updating the model mesh
  124965. */
  124966. protected updateModel(xrFrame: XRFrame): void;
  124967. /**
  124968. * Get the filename and path for this controller's model
  124969. * @returns a map of filename and path
  124970. */
  124971. protected abstract _getFilenameAndPath(): {
  124972. filename: string;
  124973. path: string;
  124974. };
  124975. /**
  124976. * This function is called before the mesh is loaded. It checks for loading constraints.
  124977. * For example, this function can check if the GLB loader is available
  124978. * If this function returns false, the generic controller will be loaded instead
  124979. * @returns Is the client ready to load the mesh
  124980. */
  124981. protected abstract _getModelLoadingConstraints(): boolean;
  124982. /**
  124983. * This function will be called after the model was successfully loaded and can be used
  124984. * for mesh transformations before it is available for the user
  124985. * @param meshes the loaded meshes
  124986. */
  124987. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  124988. /**
  124989. * Set the root mesh for this controller. Important for the WebXR controller class
  124990. * @param meshes the loaded meshes
  124991. */
  124992. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  124993. /**
  124994. * A function executed each frame that updates the mesh (if needed)
  124995. * @param xrFrame the current xrFrame
  124996. */
  124997. protected abstract _updateModel(xrFrame: XRFrame): void;
  124998. private _getGenericFilenameAndPath;
  124999. private _getGenericParentMesh;
  125000. }
  125001. }
  125002. declare module BABYLON {
  125003. /**
  125004. * A generic trigger-only motion controller for WebXR
  125005. */
  125006. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125007. /**
  125008. * Static version of the profile id of this controller
  125009. */
  125010. static ProfileId: string;
  125011. profileId: string;
  125012. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125013. protected _getFilenameAndPath(): {
  125014. filename: string;
  125015. path: string;
  125016. };
  125017. protected _getModelLoadingConstraints(): boolean;
  125018. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125019. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125020. protected _updateModel(): void;
  125021. }
  125022. }
  125023. declare module BABYLON {
  125024. /**
  125025. * Class containing static functions to help procedurally build meshes
  125026. */
  125027. export class SphereBuilder {
  125028. /**
  125029. * Creates a sphere mesh
  125030. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125031. * * 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`)
  125032. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125033. * * 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
  125034. * * 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)
  125035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125038. * @param name defines the name of the mesh
  125039. * @param options defines the options used to create the mesh
  125040. * @param scene defines the hosting scene
  125041. * @returns the sphere mesh
  125042. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125043. */
  125044. static CreateSphere(name: string, options: {
  125045. segments?: number;
  125046. diameter?: number;
  125047. diameterX?: number;
  125048. diameterY?: number;
  125049. diameterZ?: number;
  125050. arc?: number;
  125051. slice?: number;
  125052. sideOrientation?: number;
  125053. frontUVs?: Vector4;
  125054. backUVs?: Vector4;
  125055. updatable?: boolean;
  125056. }, scene?: Nullable<Scene>): Mesh;
  125057. }
  125058. }
  125059. declare module BABYLON {
  125060. /**
  125061. * A profiled motion controller has its profile loaded from an online repository.
  125062. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125063. */
  125064. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125065. private _repositoryUrl;
  125066. private _buttonMeshMapping;
  125067. private _touchDots;
  125068. /**
  125069. * The profile ID of this controller. Will be populated when the controller initializes.
  125070. */
  125071. profileId: string;
  125072. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125073. dispose(): void;
  125074. protected _getFilenameAndPath(): {
  125075. filename: string;
  125076. path: string;
  125077. };
  125078. protected _getModelLoadingConstraints(): boolean;
  125079. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125080. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125081. protected _updateModel(_xrFrame: XRFrame): void;
  125082. }
  125083. }
  125084. declare module BABYLON {
  125085. /**
  125086. * A construction function type to create a new controller based on an xrInput object
  125087. */
  125088. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125089. /**
  125090. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125091. *
  125092. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125093. * it should be replaced with auto-loaded controllers.
  125094. *
  125095. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125096. */
  125097. export class WebXRMotionControllerManager {
  125098. private static _AvailableControllers;
  125099. private static _Fallbacks;
  125100. private static _ProfileLoadingPromises;
  125101. private static _ProfilesList;
  125102. /**
  125103. * The base URL of the online controller repository. Can be changed at any time.
  125104. */
  125105. static BaseRepositoryUrl: string;
  125106. /**
  125107. * Which repository gets priority - local or online
  125108. */
  125109. static PrioritizeOnlineRepository: boolean;
  125110. /**
  125111. * Use the online repository, or use only locally-defined controllers
  125112. */
  125113. static UseOnlineRepository: boolean;
  125114. /**
  125115. * Clear the cache used for profile loading and reload when requested again
  125116. */
  125117. static ClearProfilesCache(): void;
  125118. /**
  125119. * Register the default fallbacks.
  125120. * This function is called automatically when this file is imported.
  125121. */
  125122. static DefaultFallbacks(): void;
  125123. /**
  125124. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  125125. * @param profileId the profile to which a fallback needs to be found
  125126. * @return an array with corresponding fallback profiles
  125127. */
  125128. static FindFallbackWithProfileId(profileId: string): string[];
  125129. /**
  125130. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  125131. * The order of search:
  125132. *
  125133. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  125134. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  125135. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  125136. * 4) return the generic trigger controller if none were found
  125137. *
  125138. * @param xrInput the xrInput to which a new controller is initialized
  125139. * @param scene the scene to which the model will be added
  125140. * @param forceProfile force a certain profile for this controller
  125141. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  125142. */
  125143. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  125144. /**
  125145. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  125146. *
  125147. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  125148. *
  125149. * @param type the profile type to register
  125150. * @param constructFunction the function to be called when loading this profile
  125151. */
  125152. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  125153. /**
  125154. * Register a fallback to a specific profile.
  125155. * @param profileId the profileId that will receive the fallbacks
  125156. * @param fallbacks A list of fallback profiles
  125157. */
  125158. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  125159. /**
  125160. * Will update the list of profiles available in the repository
  125161. * @return a promise that resolves to a map of profiles available online
  125162. */
  125163. static UpdateProfilesList(): Promise<{
  125164. [profile: string]: string;
  125165. }>;
  125166. private static _LoadProfileFromRepository;
  125167. private static _LoadProfilesFromAvailableControllers;
  125168. }
  125169. }
  125170. declare module BABYLON {
  125171. /**
  125172. * Configuration options for the WebXR controller creation
  125173. */
  125174. export interface IWebXRControllerOptions {
  125175. /**
  125176. * Should the controller mesh be animated when a user interacts with it
  125177. * The pressed buttons / thumbstick and touchpad animations will be disabled
  125178. */
  125179. disableMotionControllerAnimation?: boolean;
  125180. /**
  125181. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  125182. */
  125183. doNotLoadControllerMesh?: boolean;
  125184. /**
  125185. * Force a specific controller type for this controller.
  125186. * This can be used when creating your own profile or when testing different controllers
  125187. */
  125188. forceControllerProfile?: string;
  125189. /**
  125190. * Defines a rendering group ID for meshes that will be loaded.
  125191. * This is for the default controllers only.
  125192. */
  125193. renderingGroupId?: number;
  125194. }
  125195. /**
  125196. * Represents an XR controller
  125197. */
  125198. export class WebXRInputSource {
  125199. private _scene;
  125200. /** The underlying input source for the controller */
  125201. inputSource: XRInputSource;
  125202. private _options;
  125203. private _tmpVector;
  125204. private _uniqueId;
  125205. /**
  125206. * 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
  125207. */
  125208. grip?: AbstractMesh;
  125209. /**
  125210. * If available, this is the gamepad object related to this controller.
  125211. * Using this object it is possible to get click events and trackpad changes of the
  125212. * webxr controller that is currently being used.
  125213. */
  125214. motionController?: WebXRAbstractMotionController;
  125215. /**
  125216. * Event that fires when the controller is removed/disposed.
  125217. * The object provided as event data is this controller, after associated assets were disposed.
  125218. * uniqueId is still available.
  125219. */
  125220. onDisposeObservable: Observable<WebXRInputSource>;
  125221. /**
  125222. * Will be triggered when the mesh associated with the motion controller is done loading.
  125223. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  125224. * A shortened version of controller -> motion controller -> on mesh loaded.
  125225. */
  125226. onMeshLoadedObservable: Observable<AbstractMesh>;
  125227. /**
  125228. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  125229. */
  125230. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  125231. /**
  125232. * Pointer which can be used to select objects or attach a visible laser to
  125233. */
  125234. pointer: AbstractMesh;
  125235. /**
  125236. * Creates the controller
  125237. * @see https://doc.babylonjs.com/how_to/webxr
  125238. * @param _scene the scene which the controller should be associated to
  125239. * @param inputSource the underlying input source for the controller
  125240. * @param _options options for this controller creation
  125241. */
  125242. constructor(_scene: Scene,
  125243. /** The underlying input source for the controller */
  125244. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  125245. /**
  125246. * Get this controllers unique id
  125247. */
  125248. get uniqueId(): string;
  125249. /**
  125250. * Disposes of the object
  125251. */
  125252. dispose(): void;
  125253. /**
  125254. * Gets a world space ray coming from the pointer or grip
  125255. * @param result the resulting ray
  125256. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  125257. */
  125258. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  125259. /**
  125260. * Updates the controller pose based on the given XRFrame
  125261. * @param xrFrame xr frame to update the pose with
  125262. * @param referenceSpace reference space to use
  125263. */
  125264. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  125265. }
  125266. }
  125267. declare module BABYLON {
  125268. /**
  125269. * The schema for initialization options of the XR Input class
  125270. */
  125271. export interface IWebXRInputOptions {
  125272. /**
  125273. * If set to true no model will be automatically loaded
  125274. */
  125275. doNotLoadControllerMeshes?: boolean;
  125276. /**
  125277. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  125278. * If not found, the xr input profile data will be used.
  125279. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  125280. */
  125281. forceInputProfile?: string;
  125282. /**
  125283. * Do not send a request to the controller repository to load the profile.
  125284. *
  125285. * Instead, use the controllers available in babylon itself.
  125286. */
  125287. disableOnlineControllerRepository?: boolean;
  125288. /**
  125289. * A custom URL for the controllers repository
  125290. */
  125291. customControllersRepositoryURL?: string;
  125292. /**
  125293. * Should the controller model's components not move according to the user input
  125294. */
  125295. disableControllerAnimation?: boolean;
  125296. /**
  125297. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  125298. */
  125299. controllerOptions?: IWebXRControllerOptions;
  125300. }
  125301. /**
  125302. * XR input used to track XR inputs such as controllers/rays
  125303. */
  125304. export class WebXRInput implements IDisposable {
  125305. /**
  125306. * the xr session manager for this session
  125307. */
  125308. xrSessionManager: WebXRSessionManager;
  125309. /**
  125310. * the WebXR camera for this session. Mainly used for teleportation
  125311. */
  125312. xrCamera: WebXRCamera;
  125313. private readonly options;
  125314. /**
  125315. * XR controllers being tracked
  125316. */
  125317. controllers: Array<WebXRInputSource>;
  125318. private _frameObserver;
  125319. private _sessionEndedObserver;
  125320. private _sessionInitObserver;
  125321. /**
  125322. * Event when a controller has been connected/added
  125323. */
  125324. onControllerAddedObservable: Observable<WebXRInputSource>;
  125325. /**
  125326. * Event when a controller has been removed/disconnected
  125327. */
  125328. onControllerRemovedObservable: Observable<WebXRInputSource>;
  125329. /**
  125330. * Initializes the WebXRInput
  125331. * @param xrSessionManager the xr session manager for this session
  125332. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  125333. * @param options = initialization options for this xr input
  125334. */
  125335. constructor(
  125336. /**
  125337. * the xr session manager for this session
  125338. */
  125339. xrSessionManager: WebXRSessionManager,
  125340. /**
  125341. * the WebXR camera for this session. Mainly used for teleportation
  125342. */
  125343. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  125344. private _onInputSourcesChange;
  125345. private _addAndRemoveControllers;
  125346. /**
  125347. * Disposes of the object
  125348. */
  125349. dispose(): void;
  125350. }
  125351. }
  125352. declare module BABYLON {
  125353. /**
  125354. * This is the base class for all WebXR features.
  125355. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  125356. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  125357. */
  125358. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  125359. protected _xrSessionManager: WebXRSessionManager;
  125360. private _attached;
  125361. private _removeOnDetach;
  125362. /**
  125363. * Should auto-attach be disabled?
  125364. */
  125365. disableAutoAttach: boolean;
  125366. /**
  125367. * Construct a new (abstract) WebXR feature
  125368. * @param _xrSessionManager the xr session manager for this feature
  125369. */
  125370. constructor(_xrSessionManager: WebXRSessionManager);
  125371. /**
  125372. * Is this feature attached
  125373. */
  125374. get attached(): boolean;
  125375. /**
  125376. * attach this feature
  125377. *
  125378. * @param force should attachment be forced (even when already attached)
  125379. * @returns true if successful, false is failed or already attached
  125380. */
  125381. attach(force?: boolean): boolean;
  125382. /**
  125383. * detach this feature.
  125384. *
  125385. * @returns true if successful, false if failed or already detached
  125386. */
  125387. detach(): boolean;
  125388. /**
  125389. * Dispose this feature and all of the resources attached
  125390. */
  125391. dispose(): void;
  125392. /**
  125393. * This is used to register callbacks that will automatically be removed when detach is called.
  125394. * @param observable the observable to which the observer will be attached
  125395. * @param callback the callback to register
  125396. */
  125397. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  125398. /**
  125399. * Code in this function will be executed on each xrFrame received from the browser.
  125400. * This function will not execute after the feature is detached.
  125401. * @param _xrFrame the current frame
  125402. */
  125403. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  125404. }
  125405. }
  125406. declare module BABYLON {
  125407. /**
  125408. * Renders a layer on top of an existing scene
  125409. */
  125410. export class UtilityLayerRenderer implements IDisposable {
  125411. /** the original scene that will be rendered on top of */
  125412. originalScene: Scene;
  125413. private _pointerCaptures;
  125414. private _lastPointerEvents;
  125415. private static _DefaultUtilityLayer;
  125416. private static _DefaultKeepDepthUtilityLayer;
  125417. private _sharedGizmoLight;
  125418. private _renderCamera;
  125419. /**
  125420. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  125421. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  125422. * @returns the camera that is used when rendering the utility layer
  125423. */
  125424. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  125425. /**
  125426. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  125427. * @param cam the camera that should be used when rendering the utility layer
  125428. */
  125429. setRenderCamera(cam: Nullable<Camera>): void;
  125430. /**
  125431. * @hidden
  125432. * Light which used by gizmos to get light shading
  125433. */
  125434. _getSharedGizmoLight(): HemisphericLight;
  125435. /**
  125436. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  125437. */
  125438. pickUtilitySceneFirst: boolean;
  125439. /**
  125440. * 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)
  125441. */
  125442. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  125443. /**
  125444. * 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)
  125445. */
  125446. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  125447. /**
  125448. * The scene that is rendered on top of the original scene
  125449. */
  125450. utilityLayerScene: Scene;
  125451. /**
  125452. * If the utility layer should automatically be rendered on top of existing scene
  125453. */
  125454. shouldRender: boolean;
  125455. /**
  125456. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  125457. */
  125458. onlyCheckPointerDownEvents: boolean;
  125459. /**
  125460. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  125461. */
  125462. processAllEvents: boolean;
  125463. /**
  125464. * Observable raised when the pointer move from the utility layer scene to the main scene
  125465. */
  125466. onPointerOutObservable: Observable<number>;
  125467. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  125468. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  125469. private _afterRenderObserver;
  125470. private _sceneDisposeObserver;
  125471. private _originalPointerObserver;
  125472. /**
  125473. * Instantiates a UtilityLayerRenderer
  125474. * @param originalScene the original scene that will be rendered on top of
  125475. * @param handleEvents boolean indicating if the utility layer should handle events
  125476. */
  125477. constructor(
  125478. /** the original scene that will be rendered on top of */
  125479. originalScene: Scene, handleEvents?: boolean);
  125480. private _notifyObservers;
  125481. /**
  125482. * Renders the utility layers scene on top of the original scene
  125483. */
  125484. render(): void;
  125485. /**
  125486. * Disposes of the renderer
  125487. */
  125488. dispose(): void;
  125489. private _updateCamera;
  125490. }
  125491. }
  125492. declare module BABYLON {
  125493. /**
  125494. * Options interface for the pointer selection module
  125495. */
  125496. export interface IWebXRControllerPointerSelectionOptions {
  125497. /**
  125498. * if provided, this scene will be used to render meshes.
  125499. */
  125500. customUtilityLayerScene?: Scene;
  125501. /**
  125502. * 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)
  125503. * If not disabled, the last picked point will be used to execute a pointer up event
  125504. * If disabled, pointer up event will be triggered right after the pointer down event.
  125505. * Used in screen and gaze target ray mode only
  125506. */
  125507. disablePointerUpOnTouchOut: boolean;
  125508. /**
  125509. * For gaze mode (time to select instead of press)
  125510. */
  125511. forceGazeMode: boolean;
  125512. /**
  125513. * 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
  125514. * to start a new countdown to the pointer down event.
  125515. * Defaults to 1.
  125516. */
  125517. gazeModePointerMovedFactor?: number;
  125518. /**
  125519. * Different button type to use instead of the main component
  125520. */
  125521. overrideButtonId?: string;
  125522. /**
  125523. * use this rendering group id for the meshes (optional)
  125524. */
  125525. renderingGroupId?: number;
  125526. /**
  125527. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  125528. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  125529. * 3000 means 3 seconds between pointing at something and selecting it
  125530. */
  125531. timeToSelect?: number;
  125532. /**
  125533. * Should meshes created here be added to a utility layer or the main scene
  125534. */
  125535. useUtilityLayer?: boolean;
  125536. /**
  125537. * the xr input to use with this pointer selection
  125538. */
  125539. xrInput: WebXRInput;
  125540. }
  125541. /**
  125542. * A module that will enable pointer selection for motion controllers of XR Input Sources
  125543. */
  125544. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  125545. private readonly _options;
  125546. private static _idCounter;
  125547. private _attachController;
  125548. private _controllers;
  125549. private _scene;
  125550. private _tmpVectorForPickCompare;
  125551. /**
  125552. * The module's name
  125553. */
  125554. static readonly Name: string;
  125555. /**
  125556. * The (Babylon) version of this module.
  125557. * This is an integer representing the implementation version.
  125558. * This number does not correspond to the WebXR specs version
  125559. */
  125560. static readonly Version: number;
  125561. /**
  125562. * Disable lighting on the laser pointer (so it will always be visible)
  125563. */
  125564. disablePointerLighting: boolean;
  125565. /**
  125566. * Disable lighting on the selection mesh (so it will always be visible)
  125567. */
  125568. disableSelectionMeshLighting: boolean;
  125569. /**
  125570. * Should the laser pointer be displayed
  125571. */
  125572. displayLaserPointer: boolean;
  125573. /**
  125574. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  125575. */
  125576. displaySelectionMesh: boolean;
  125577. /**
  125578. * This color will be set to the laser pointer when selection is triggered
  125579. */
  125580. laserPointerPickedColor: Color3;
  125581. /**
  125582. * Default color of the laser pointer
  125583. */
  125584. laserPointerDefaultColor: Color3;
  125585. /**
  125586. * default color of the selection ring
  125587. */
  125588. selectionMeshDefaultColor: Color3;
  125589. /**
  125590. * This color will be applied to the selection ring when selection is triggered
  125591. */
  125592. selectionMeshPickedColor: Color3;
  125593. /**
  125594. * Optional filter to be used for ray selection. This predicate shares behavior with
  125595. * scene.pointerMovePredicate which takes priority if it is also assigned.
  125596. */
  125597. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  125598. /**
  125599. * constructs a new background remover module
  125600. * @param _xrSessionManager the session manager for this module
  125601. * @param _options read-only options to be used in this module
  125602. */
  125603. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  125604. /**
  125605. * attach this feature
  125606. * Will usually be called by the features manager
  125607. *
  125608. * @returns true if successful.
  125609. */
  125610. attach(): boolean;
  125611. /**
  125612. * detach this feature.
  125613. * Will usually be called by the features manager
  125614. *
  125615. * @returns true if successful.
  125616. */
  125617. detach(): boolean;
  125618. /**
  125619. * Will get the mesh under a specific pointer.
  125620. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  125621. * @param controllerId the controllerId to check
  125622. * @returns The mesh under pointer or null if no mesh is under the pointer
  125623. */
  125624. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  125625. /**
  125626. * Get the xr controller that correlates to the pointer id in the pointer event
  125627. *
  125628. * @param id the pointer id to search for
  125629. * @returns the controller that correlates to this id or null if not found
  125630. */
  125631. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  125632. protected _onXRFrame(_xrFrame: XRFrame): void;
  125633. private _attachGazeMode;
  125634. private _attachScreenRayMode;
  125635. private _attachTrackedPointerRayMode;
  125636. private _convertNormalToDirectionOfRay;
  125637. private _detachController;
  125638. private _generateNewMeshPair;
  125639. private _pickingMoved;
  125640. private _updatePointerDistance;
  125641. /** @hidden */
  125642. get lasterPointerDefaultColor(): Color3;
  125643. }
  125644. }
  125645. declare module BABYLON {
  125646. /**
  125647. * Button which can be used to enter a different mode of XR
  125648. */
  125649. export class WebXREnterExitUIButton {
  125650. /** button element */
  125651. element: HTMLElement;
  125652. /** XR initialization options for the button */
  125653. sessionMode: XRSessionMode;
  125654. /** Reference space type */
  125655. referenceSpaceType: XRReferenceSpaceType;
  125656. /**
  125657. * Creates a WebXREnterExitUIButton
  125658. * @param element button element
  125659. * @param sessionMode XR initialization session mode
  125660. * @param referenceSpaceType the type of reference space to be used
  125661. */
  125662. constructor(
  125663. /** button element */
  125664. element: HTMLElement,
  125665. /** XR initialization options for the button */
  125666. sessionMode: XRSessionMode,
  125667. /** Reference space type */
  125668. referenceSpaceType: XRReferenceSpaceType);
  125669. /**
  125670. * Extendable function which can be used to update the button's visuals when the state changes
  125671. * @param activeButton the current active button in the UI
  125672. */
  125673. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  125674. }
  125675. /**
  125676. * Options to create the webXR UI
  125677. */
  125678. export class WebXREnterExitUIOptions {
  125679. /**
  125680. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  125681. */
  125682. customButtons?: Array<WebXREnterExitUIButton>;
  125683. /**
  125684. * A reference space type to use when creating the default button.
  125685. * Default is local-floor
  125686. */
  125687. referenceSpaceType?: XRReferenceSpaceType;
  125688. /**
  125689. * Context to enter xr with
  125690. */
  125691. renderTarget?: Nullable<WebXRRenderTarget>;
  125692. /**
  125693. * A session mode to use when creating the default button.
  125694. * Default is immersive-vr
  125695. */
  125696. sessionMode?: XRSessionMode;
  125697. /**
  125698. * A list of optional features to init the session with
  125699. */
  125700. optionalFeatures?: string[];
  125701. }
  125702. /**
  125703. * UI to allow the user to enter/exit XR mode
  125704. */
  125705. export class WebXREnterExitUI implements IDisposable {
  125706. private scene;
  125707. /** version of the options passed to this UI */
  125708. options: WebXREnterExitUIOptions;
  125709. private _activeButton;
  125710. private _buttons;
  125711. private _overlay;
  125712. /**
  125713. * Fired every time the active button is changed.
  125714. *
  125715. * When xr is entered via a button that launches xr that button will be the callback parameter
  125716. *
  125717. * When exiting xr the callback parameter will be null)
  125718. */
  125719. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  125720. /**
  125721. *
  125722. * @param scene babylon scene object to use
  125723. * @param options (read-only) version of the options passed to this UI
  125724. */
  125725. private constructor();
  125726. /**
  125727. * Creates UI to allow the user to enter/exit XR mode
  125728. * @param scene the scene to add the ui to
  125729. * @param helper the xr experience helper to enter/exit xr with
  125730. * @param options options to configure the UI
  125731. * @returns the created ui
  125732. */
  125733. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  125734. /**
  125735. * Disposes of the XR UI component
  125736. */
  125737. dispose(): void;
  125738. private _updateButtons;
  125739. }
  125740. }
  125741. declare module BABYLON {
  125742. /**
  125743. * Class containing static functions to help procedurally build meshes
  125744. */
  125745. export class LinesBuilder {
  125746. /**
  125747. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  125748. * * 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
  125749. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  125750. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  125751. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  125752. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  125753. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125754. * * 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
  125755. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  125756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  125758. * @param name defines the name of the new line system
  125759. * @param options defines the options used to create the line system
  125760. * @param scene defines the hosting scene
  125761. * @returns a new line system mesh
  125762. */
  125763. static CreateLineSystem(name: string, options: {
  125764. lines: Vector3[][];
  125765. updatable?: boolean;
  125766. instance?: Nullable<LinesMesh>;
  125767. colors?: Nullable<Color4[][]>;
  125768. useVertexAlpha?: boolean;
  125769. }, scene: Nullable<Scene>): LinesMesh;
  125770. /**
  125771. * Creates a line mesh
  125772. * 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
  125773. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125774. * * The parameter `points` is an array successive Vector3
  125775. * * 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
  125776. * * The optional parameter `colors` is an array of successive Color4, one per line point
  125777. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  125778. * * When updating an instance, remember that only point positions can change, not the number of points
  125779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  125781. * @param name defines the name of the new line system
  125782. * @param options defines the options used to create the line system
  125783. * @param scene defines the hosting scene
  125784. * @returns a new line mesh
  125785. */
  125786. static CreateLines(name: string, options: {
  125787. points: Vector3[];
  125788. updatable?: boolean;
  125789. instance?: Nullable<LinesMesh>;
  125790. colors?: Color4[];
  125791. useVertexAlpha?: boolean;
  125792. }, scene?: Nullable<Scene>): LinesMesh;
  125793. /**
  125794. * Creates a dashed line mesh
  125795. * * 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
  125796. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  125797. * * The parameter `points` is an array successive Vector3
  125798. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  125799. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  125800. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  125801. * * 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
  125802. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  125803. * * When updating an instance, remember that only point positions can change, not the number of points
  125804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125805. * @param name defines the name of the mesh
  125806. * @param options defines the options used to create the mesh
  125807. * @param scene defines the hosting scene
  125808. * @returns the dashed line mesh
  125809. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  125810. */
  125811. static CreateDashedLines(name: string, options: {
  125812. points: Vector3[];
  125813. dashSize?: number;
  125814. gapSize?: number;
  125815. dashNb?: number;
  125816. updatable?: boolean;
  125817. instance?: LinesMesh;
  125818. useVertexAlpha?: boolean;
  125819. }, scene?: Nullable<Scene>): LinesMesh;
  125820. }
  125821. }
  125822. declare module BABYLON {
  125823. /**
  125824. * Construction options for a timer
  125825. */
  125826. export interface ITimerOptions<T> {
  125827. /**
  125828. * Time-to-end
  125829. */
  125830. timeout: number;
  125831. /**
  125832. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  125833. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  125834. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  125835. */
  125836. contextObservable: Observable<T>;
  125837. /**
  125838. * Optional parameters when adding an observer to the observable
  125839. */
  125840. observableParameters?: {
  125841. mask?: number;
  125842. insertFirst?: boolean;
  125843. scope?: any;
  125844. };
  125845. /**
  125846. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  125847. */
  125848. breakCondition?: (data?: ITimerData<T>) => boolean;
  125849. /**
  125850. * Will be triggered when the time condition has met
  125851. */
  125852. onEnded?: (data: ITimerData<any>) => void;
  125853. /**
  125854. * Will be triggered when the break condition has met (prematurely ended)
  125855. */
  125856. onAborted?: (data: ITimerData<any>) => void;
  125857. /**
  125858. * Optional function to execute on each tick (or count)
  125859. */
  125860. onTick?: (data: ITimerData<any>) => void;
  125861. }
  125862. /**
  125863. * An interface defining the data sent by the timer
  125864. */
  125865. export interface ITimerData<T> {
  125866. /**
  125867. * When did it start
  125868. */
  125869. startTime: number;
  125870. /**
  125871. * Time now
  125872. */
  125873. currentTime: number;
  125874. /**
  125875. * Time passed since started
  125876. */
  125877. deltaTime: number;
  125878. /**
  125879. * How much is completed, in [0.0...1.0].
  125880. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  125881. */
  125882. completeRate: number;
  125883. /**
  125884. * What the registered observable sent in the last count
  125885. */
  125886. payload: T;
  125887. }
  125888. /**
  125889. * The current state of the timer
  125890. */
  125891. export enum TimerState {
  125892. /**
  125893. * Timer initialized, not yet started
  125894. */
  125895. INIT = 0,
  125896. /**
  125897. * Timer started and counting
  125898. */
  125899. STARTED = 1,
  125900. /**
  125901. * Timer ended (whether aborted or time reached)
  125902. */
  125903. ENDED = 2
  125904. }
  125905. /**
  125906. * A simple version of the timer. Will take options and start the timer immediately after calling it
  125907. *
  125908. * @param options options with which to initialize this timer
  125909. */
  125910. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  125911. /**
  125912. * An advanced implementation of a timer class
  125913. */
  125914. export class AdvancedTimer<T = any> implements IDisposable {
  125915. /**
  125916. * Will notify each time the timer calculates the remaining time
  125917. */
  125918. onEachCountObservable: Observable<ITimerData<T>>;
  125919. /**
  125920. * Will trigger when the timer was aborted due to the break condition
  125921. */
  125922. onTimerAbortedObservable: Observable<ITimerData<T>>;
  125923. /**
  125924. * Will trigger when the timer ended successfully
  125925. */
  125926. onTimerEndedObservable: Observable<ITimerData<T>>;
  125927. /**
  125928. * Will trigger when the timer state has changed
  125929. */
  125930. onStateChangedObservable: Observable<TimerState>;
  125931. private _observer;
  125932. private _contextObservable;
  125933. private _observableParameters;
  125934. private _startTime;
  125935. private _timer;
  125936. private _state;
  125937. private _breakCondition;
  125938. private _timeToEnd;
  125939. private _breakOnNextTick;
  125940. /**
  125941. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  125942. * @param options construction options for this advanced timer
  125943. */
  125944. constructor(options: ITimerOptions<T>);
  125945. /**
  125946. * set a breaking condition for this timer. Default is to never break during count
  125947. * @param predicate the new break condition. Returns true to break, false otherwise
  125948. */
  125949. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  125950. /**
  125951. * Reset ALL associated observables in this advanced timer
  125952. */
  125953. clearObservables(): void;
  125954. /**
  125955. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  125956. *
  125957. * @param timeToEnd how much time to measure until timer ended
  125958. */
  125959. start(timeToEnd?: number): void;
  125960. /**
  125961. * Will force a stop on the next tick.
  125962. */
  125963. stop(): void;
  125964. /**
  125965. * Dispose this timer, clearing all resources
  125966. */
  125967. dispose(): void;
  125968. private _setState;
  125969. private _tick;
  125970. private _stop;
  125971. }
  125972. }
  125973. declare module BABYLON {
  125974. /**
  125975. * The options container for the teleportation module
  125976. */
  125977. export interface IWebXRTeleportationOptions {
  125978. /**
  125979. * if provided, this scene will be used to render meshes.
  125980. */
  125981. customUtilityLayerScene?: Scene;
  125982. /**
  125983. * Values to configure the default target mesh
  125984. */
  125985. defaultTargetMeshOptions?: {
  125986. /**
  125987. * Fill color of the teleportation area
  125988. */
  125989. teleportationFillColor?: string;
  125990. /**
  125991. * Border color for the teleportation area
  125992. */
  125993. teleportationBorderColor?: string;
  125994. /**
  125995. * Disable the mesh's animation sequence
  125996. */
  125997. disableAnimation?: boolean;
  125998. /**
  125999. * Disable lighting on the material or the ring and arrow
  126000. */
  126001. disableLighting?: boolean;
  126002. /**
  126003. * Override the default material of the torus and arrow
  126004. */
  126005. torusArrowMaterial?: Material;
  126006. };
  126007. /**
  126008. * A list of meshes to use as floor meshes.
  126009. * Meshes can be added and removed after initializing the feature using the
  126010. * addFloorMesh and removeFloorMesh functions
  126011. * If empty, rotation will still work
  126012. */
  126013. floorMeshes?: AbstractMesh[];
  126014. /**
  126015. * use this rendering group id for the meshes (optional)
  126016. */
  126017. renderingGroupId?: number;
  126018. /**
  126019. * Should teleportation move only to snap points
  126020. */
  126021. snapPointsOnly?: boolean;
  126022. /**
  126023. * An array of points to which the teleportation will snap to.
  126024. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126025. */
  126026. snapPositions?: Vector3[];
  126027. /**
  126028. * How close should the teleportation ray be in order to snap to position.
  126029. * Default to 0.8 units (meters)
  126030. */
  126031. snapToPositionRadius?: number;
  126032. /**
  126033. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126034. * If you want to support rotation, make sure your mesh has a direction indicator.
  126035. *
  126036. * When left untouched, the default mesh will be initialized.
  126037. */
  126038. teleportationTargetMesh?: AbstractMesh;
  126039. /**
  126040. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126041. */
  126042. timeToTeleport?: number;
  126043. /**
  126044. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126045. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126046. */
  126047. useMainComponentOnly?: boolean;
  126048. /**
  126049. * Should meshes created here be added to a utility layer or the main scene
  126050. */
  126051. useUtilityLayer?: boolean;
  126052. /**
  126053. * Babylon XR Input class for controller
  126054. */
  126055. xrInput: WebXRInput;
  126056. }
  126057. /**
  126058. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126059. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126060. * the input of the attached controllers.
  126061. */
  126062. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126063. private _options;
  126064. private _controllers;
  126065. private _currentTeleportationControllerId;
  126066. private _floorMeshes;
  126067. private _quadraticBezierCurve;
  126068. private _selectionFeature;
  126069. private _snapToPositions;
  126070. private _snappedToPoint;
  126071. private _teleportationRingMaterial?;
  126072. private _tmpRay;
  126073. private _tmpVector;
  126074. /**
  126075. * The module's name
  126076. */
  126077. static readonly Name: string;
  126078. /**
  126079. * The (Babylon) version of this module.
  126080. * This is an integer representing the implementation version.
  126081. * This number does not correspond to the webxr specs version
  126082. */
  126083. static readonly Version: number;
  126084. /**
  126085. * Is movement backwards enabled
  126086. */
  126087. backwardsMovementEnabled: boolean;
  126088. /**
  126089. * Distance to travel when moving backwards
  126090. */
  126091. backwardsTeleportationDistance: number;
  126092. /**
  126093. * The distance from the user to the inspection point in the direction of the controller
  126094. * A higher number will allow the user to move further
  126095. * defaults to 5 (meters, in xr units)
  126096. */
  126097. parabolicCheckRadius: number;
  126098. /**
  126099. * Should the module support parabolic ray on top of direct ray
  126100. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126101. * Very helpful when moving between floors / different heights
  126102. */
  126103. parabolicRayEnabled: boolean;
  126104. /**
  126105. * How much rotation should be applied when rotating right and left
  126106. */
  126107. rotationAngle: number;
  126108. /**
  126109. * Is rotation enabled when moving forward?
  126110. * Disabling this feature will prevent the user from deciding the direction when teleporting
  126111. */
  126112. rotationEnabled: boolean;
  126113. /**
  126114. * constructs a new anchor system
  126115. * @param _xrSessionManager an instance of WebXRSessionManager
  126116. * @param _options configuration object for this feature
  126117. */
  126118. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  126119. /**
  126120. * Get the snapPointsOnly flag
  126121. */
  126122. get snapPointsOnly(): boolean;
  126123. /**
  126124. * Sets the snapPointsOnly flag
  126125. * @param snapToPoints should teleportation be exclusively to snap points
  126126. */
  126127. set snapPointsOnly(snapToPoints: boolean);
  126128. /**
  126129. * Add a new mesh to the floor meshes array
  126130. * @param mesh the mesh to use as floor mesh
  126131. */
  126132. addFloorMesh(mesh: AbstractMesh): void;
  126133. /**
  126134. * Add a new snap-to point to fix teleportation to this position
  126135. * @param newSnapPoint The new Snap-To point
  126136. */
  126137. addSnapPoint(newSnapPoint: Vector3): void;
  126138. attach(): boolean;
  126139. detach(): boolean;
  126140. dispose(): void;
  126141. /**
  126142. * Remove a mesh from the floor meshes array
  126143. * @param mesh the mesh to remove
  126144. */
  126145. removeFloorMesh(mesh: AbstractMesh): void;
  126146. /**
  126147. * Remove a mesh from the floor meshes array using its name
  126148. * @param name the mesh name to remove
  126149. */
  126150. removeFloorMeshByName(name: string): void;
  126151. /**
  126152. * 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
  126153. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  126154. * @returns was the point found and removed or not
  126155. */
  126156. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  126157. /**
  126158. * This function sets a selection feature that will be disabled when
  126159. * the forward ray is shown and will be reattached when hidden.
  126160. * This is used to remove the selection rays when moving.
  126161. * @param selectionFeature the feature to disable when forward movement is enabled
  126162. */
  126163. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  126164. protected _onXRFrame(_xrFrame: XRFrame): void;
  126165. private _attachController;
  126166. private _createDefaultTargetMesh;
  126167. private _detachController;
  126168. private _findClosestSnapPointWithRadius;
  126169. private _setTargetMeshPosition;
  126170. private _setTargetMeshVisibility;
  126171. private _showParabolicPath;
  126172. private _teleportForward;
  126173. }
  126174. }
  126175. declare module BABYLON {
  126176. /**
  126177. * Options for the default xr helper
  126178. */
  126179. export class WebXRDefaultExperienceOptions {
  126180. /**
  126181. * Enable or disable default UI to enter XR
  126182. */
  126183. disableDefaultUI?: boolean;
  126184. /**
  126185. * Should teleportation not initialize. defaults to false.
  126186. */
  126187. disableTeleportation?: boolean;
  126188. /**
  126189. * Floor meshes that will be used for teleport
  126190. */
  126191. floorMeshes?: Array<AbstractMesh>;
  126192. /**
  126193. * If set to true, the first frame will not be used to reset position
  126194. * The first frame is mainly used when copying transformation from the old camera
  126195. * Mainly used in AR
  126196. */
  126197. ignoreNativeCameraTransformation?: boolean;
  126198. /**
  126199. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  126200. */
  126201. inputOptions?: IWebXRInputOptions;
  126202. /**
  126203. * optional configuration for the output canvas
  126204. */
  126205. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  126206. /**
  126207. * optional UI options. This can be used among other to change session mode and reference space type
  126208. */
  126209. uiOptions?: WebXREnterExitUIOptions;
  126210. /**
  126211. * When loading teleportation and pointer select, use stable versions instead of latest.
  126212. */
  126213. useStablePlugins?: boolean;
  126214. /**
  126215. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  126216. */
  126217. renderingGroupId?: number;
  126218. /**
  126219. * A list of optional features to init the session with
  126220. * If set to true, all features we support will be added
  126221. */
  126222. optionalFeatures?: boolean | string[];
  126223. }
  126224. /**
  126225. * Default experience which provides a similar setup to the previous webVRExperience
  126226. */
  126227. export class WebXRDefaultExperience {
  126228. /**
  126229. * Base experience
  126230. */
  126231. baseExperience: WebXRExperienceHelper;
  126232. /**
  126233. * Enables ui for entering/exiting xr
  126234. */
  126235. enterExitUI: WebXREnterExitUI;
  126236. /**
  126237. * Input experience extension
  126238. */
  126239. input: WebXRInput;
  126240. /**
  126241. * Enables laser pointer and selection
  126242. */
  126243. pointerSelection: WebXRControllerPointerSelection;
  126244. /**
  126245. * Default target xr should render to
  126246. */
  126247. renderTarget: WebXRRenderTarget;
  126248. /**
  126249. * Enables teleportation
  126250. */
  126251. teleportation: WebXRMotionControllerTeleportation;
  126252. private constructor();
  126253. /**
  126254. * Creates the default xr experience
  126255. * @param scene scene
  126256. * @param options options for basic configuration
  126257. * @returns resulting WebXRDefaultExperience
  126258. */
  126259. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  126260. /**
  126261. * DIsposes of the experience helper
  126262. */
  126263. dispose(): void;
  126264. }
  126265. }
  126266. declare module BABYLON {
  126267. /**
  126268. * Options to modify the vr teleportation behavior.
  126269. */
  126270. export interface VRTeleportationOptions {
  126271. /**
  126272. * The name of the mesh which should be used as the teleportation floor. (default: null)
  126273. */
  126274. floorMeshName?: string;
  126275. /**
  126276. * A list of meshes to be used as the teleportation floor. (default: empty)
  126277. */
  126278. floorMeshes?: Mesh[];
  126279. /**
  126280. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  126281. */
  126282. teleportationMode?: number;
  126283. /**
  126284. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  126285. */
  126286. teleportationTime?: number;
  126287. /**
  126288. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  126289. */
  126290. teleportationSpeed?: number;
  126291. /**
  126292. * The easing function used in the animation or null for Linear. (default CircleEase)
  126293. */
  126294. easingFunction?: EasingFunction;
  126295. }
  126296. /**
  126297. * Options to modify the vr experience helper's behavior.
  126298. */
  126299. export interface VRExperienceHelperOptions extends WebVROptions {
  126300. /**
  126301. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  126302. */
  126303. createDeviceOrientationCamera?: boolean;
  126304. /**
  126305. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  126306. */
  126307. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  126308. /**
  126309. * Uses the main button on the controller to toggle the laser casted. (default: true)
  126310. */
  126311. laserToggle?: boolean;
  126312. /**
  126313. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  126314. */
  126315. floorMeshes?: Mesh[];
  126316. /**
  126317. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  126318. */
  126319. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  126320. /**
  126321. * Defines if WebXR should be used instead of WebVR (if available)
  126322. */
  126323. useXR?: boolean;
  126324. }
  126325. /**
  126326. * Event containing information after VR has been entered
  126327. */
  126328. export class OnAfterEnteringVRObservableEvent {
  126329. /**
  126330. * If entering vr was successful
  126331. */
  126332. success: boolean;
  126333. }
  126334. /**
  126335. * Helps to quickly add VR support to an existing scene.
  126336. * See http://doc.babylonjs.com/how_to/webvr_helper
  126337. */
  126338. export class VRExperienceHelper {
  126339. /** Options to modify the vr experience helper's behavior. */
  126340. webVROptions: VRExperienceHelperOptions;
  126341. private _scene;
  126342. private _position;
  126343. private _btnVR;
  126344. private _btnVRDisplayed;
  126345. private _webVRsupported;
  126346. private _webVRready;
  126347. private _webVRrequesting;
  126348. private _webVRpresenting;
  126349. private _hasEnteredVR;
  126350. private _fullscreenVRpresenting;
  126351. private _inputElement;
  126352. private _webVRCamera;
  126353. private _vrDeviceOrientationCamera;
  126354. private _deviceOrientationCamera;
  126355. private _existingCamera;
  126356. private _onKeyDown;
  126357. private _onVrDisplayPresentChange;
  126358. private _onVRDisplayChanged;
  126359. private _onVRRequestPresentStart;
  126360. private _onVRRequestPresentComplete;
  126361. /**
  126362. * 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)
  126363. */
  126364. enableGazeEvenWhenNoPointerLock: boolean;
  126365. /**
  126366. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  126367. */
  126368. exitVROnDoubleTap: boolean;
  126369. /**
  126370. * Observable raised right before entering VR.
  126371. */
  126372. onEnteringVRObservable: Observable<VRExperienceHelper>;
  126373. /**
  126374. * Observable raised when entering VR has completed.
  126375. */
  126376. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  126377. /**
  126378. * Observable raised when exiting VR.
  126379. */
  126380. onExitingVRObservable: Observable<VRExperienceHelper>;
  126381. /**
  126382. * Observable raised when controller mesh is loaded.
  126383. */
  126384. onControllerMeshLoadedObservable: Observable<WebVRController>;
  126385. /** Return this.onEnteringVRObservable
  126386. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  126387. */
  126388. get onEnteringVR(): Observable<VRExperienceHelper>;
  126389. /** Return this.onExitingVRObservable
  126390. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  126391. */
  126392. get onExitingVR(): Observable<VRExperienceHelper>;
  126393. /** Return this.onControllerMeshLoadedObservable
  126394. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  126395. */
  126396. get onControllerMeshLoaded(): Observable<WebVRController>;
  126397. private _rayLength;
  126398. private _useCustomVRButton;
  126399. private _teleportationRequested;
  126400. private _teleportActive;
  126401. private _floorMeshName;
  126402. private _floorMeshesCollection;
  126403. private _teleportationMode;
  126404. private _teleportationTime;
  126405. private _teleportationSpeed;
  126406. private _teleportationEasing;
  126407. private _rotationAllowed;
  126408. private _teleportBackwardsVector;
  126409. private _teleportationTarget;
  126410. private _isDefaultTeleportationTarget;
  126411. private _postProcessMove;
  126412. private _teleportationFillColor;
  126413. private _teleportationBorderColor;
  126414. private _rotationAngle;
  126415. private _haloCenter;
  126416. private _cameraGazer;
  126417. private _padSensibilityUp;
  126418. private _padSensibilityDown;
  126419. private _leftController;
  126420. private _rightController;
  126421. private _gazeColor;
  126422. private _laserColor;
  126423. private _pickedLaserColor;
  126424. private _pickedGazeColor;
  126425. /**
  126426. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  126427. */
  126428. onNewMeshSelected: Observable<AbstractMesh>;
  126429. /**
  126430. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  126431. * This observable will provide the mesh and the controller used to select the mesh
  126432. */
  126433. onMeshSelectedWithController: Observable<{
  126434. mesh: AbstractMesh;
  126435. controller: WebVRController;
  126436. }>;
  126437. /**
  126438. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  126439. */
  126440. onNewMeshPicked: Observable<PickingInfo>;
  126441. private _circleEase;
  126442. /**
  126443. * Observable raised before camera teleportation
  126444. */
  126445. onBeforeCameraTeleport: Observable<Vector3>;
  126446. /**
  126447. * Observable raised after camera teleportation
  126448. */
  126449. onAfterCameraTeleport: Observable<Vector3>;
  126450. /**
  126451. * Observable raised when current selected mesh gets unselected
  126452. */
  126453. onSelectedMeshUnselected: Observable<AbstractMesh>;
  126454. private _raySelectionPredicate;
  126455. /**
  126456. * To be optionaly changed by user to define custom ray selection
  126457. */
  126458. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126459. /**
  126460. * To be optionaly changed by user to define custom selection logic (after ray selection)
  126461. */
  126462. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126463. /**
  126464. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  126465. */
  126466. teleportationEnabled: boolean;
  126467. private _defaultHeight;
  126468. private _teleportationInitialized;
  126469. private _interactionsEnabled;
  126470. private _interactionsRequested;
  126471. private _displayGaze;
  126472. private _displayLaserPointer;
  126473. /**
  126474. * The mesh used to display where the user is going to teleport.
  126475. */
  126476. get teleportationTarget(): Mesh;
  126477. /**
  126478. * Sets the mesh to be used to display where the user is going to teleport.
  126479. */
  126480. set teleportationTarget(value: Mesh);
  126481. /**
  126482. * 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
  126483. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  126484. * See http://doc.babylonjs.com/resources/baking_transformations
  126485. */
  126486. get gazeTrackerMesh(): Mesh;
  126487. set gazeTrackerMesh(value: Mesh);
  126488. /**
  126489. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  126490. */
  126491. updateGazeTrackerScale: boolean;
  126492. /**
  126493. * If the gaze trackers color should be updated when selecting meshes
  126494. */
  126495. updateGazeTrackerColor: boolean;
  126496. /**
  126497. * If the controller laser color should be updated when selecting meshes
  126498. */
  126499. updateControllerLaserColor: boolean;
  126500. /**
  126501. * The gaze tracking mesh corresponding to the left controller
  126502. */
  126503. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  126504. /**
  126505. * The gaze tracking mesh corresponding to the right controller
  126506. */
  126507. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  126508. /**
  126509. * If the ray of the gaze should be displayed.
  126510. */
  126511. get displayGaze(): boolean;
  126512. /**
  126513. * Sets if the ray of the gaze should be displayed.
  126514. */
  126515. set displayGaze(value: boolean);
  126516. /**
  126517. * If the ray of the LaserPointer should be displayed.
  126518. */
  126519. get displayLaserPointer(): boolean;
  126520. /**
  126521. * Sets if the ray of the LaserPointer should be displayed.
  126522. */
  126523. set displayLaserPointer(value: boolean);
  126524. /**
  126525. * The deviceOrientationCamera used as the camera when not in VR.
  126526. */
  126527. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  126528. /**
  126529. * Based on the current WebVR support, returns the current VR camera used.
  126530. */
  126531. get currentVRCamera(): Nullable<Camera>;
  126532. /**
  126533. * The webVRCamera which is used when in VR.
  126534. */
  126535. get webVRCamera(): WebVRFreeCamera;
  126536. /**
  126537. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  126538. */
  126539. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  126540. /**
  126541. * The html button that is used to trigger entering into VR.
  126542. */
  126543. get vrButton(): Nullable<HTMLButtonElement>;
  126544. private get _teleportationRequestInitiated();
  126545. /**
  126546. * Defines whether or not Pointer lock should be requested when switching to
  126547. * full screen.
  126548. */
  126549. requestPointerLockOnFullScreen: boolean;
  126550. /**
  126551. * If asking to force XR, this will be populated with the default xr experience
  126552. */
  126553. xr: WebXRDefaultExperience;
  126554. /**
  126555. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  126556. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  126557. */
  126558. xrTestDone: boolean;
  126559. /**
  126560. * Instantiates a VRExperienceHelper.
  126561. * Helps to quickly add VR support to an existing scene.
  126562. * @param scene The scene the VRExperienceHelper belongs to.
  126563. * @param webVROptions Options to modify the vr experience helper's behavior.
  126564. */
  126565. constructor(scene: Scene,
  126566. /** Options to modify the vr experience helper's behavior. */
  126567. webVROptions?: VRExperienceHelperOptions);
  126568. private completeVRInit;
  126569. private _onDefaultMeshLoaded;
  126570. private _onResize;
  126571. private _onFullscreenChange;
  126572. /**
  126573. * Gets a value indicating if we are currently in VR mode.
  126574. */
  126575. get isInVRMode(): boolean;
  126576. private onVrDisplayPresentChange;
  126577. private onVRDisplayChanged;
  126578. private moveButtonToBottomRight;
  126579. private displayVRButton;
  126580. private updateButtonVisibility;
  126581. private _cachedAngularSensibility;
  126582. /**
  126583. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  126584. * Otherwise, will use the fullscreen API.
  126585. */
  126586. enterVR(): void;
  126587. /**
  126588. * Attempt to exit VR, or fullscreen.
  126589. */
  126590. exitVR(): void;
  126591. /**
  126592. * The position of the vr experience helper.
  126593. */
  126594. get position(): Vector3;
  126595. /**
  126596. * Sets the position of the vr experience helper.
  126597. */
  126598. set position(value: Vector3);
  126599. /**
  126600. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  126601. */
  126602. enableInteractions(): void;
  126603. private get _noControllerIsActive();
  126604. private beforeRender;
  126605. private _isTeleportationFloor;
  126606. /**
  126607. * Adds a floor mesh to be used for teleportation.
  126608. * @param floorMesh the mesh to be used for teleportation.
  126609. */
  126610. addFloorMesh(floorMesh: Mesh): void;
  126611. /**
  126612. * Removes a floor mesh from being used for teleportation.
  126613. * @param floorMesh the mesh to be removed.
  126614. */
  126615. removeFloorMesh(floorMesh: Mesh): void;
  126616. /**
  126617. * Enables interactions and teleportation using the VR controllers and gaze.
  126618. * @param vrTeleportationOptions options to modify teleportation behavior.
  126619. */
  126620. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  126621. private _onNewGamepadConnected;
  126622. private _tryEnableInteractionOnController;
  126623. private _onNewGamepadDisconnected;
  126624. private _enableInteractionOnController;
  126625. private _checkTeleportWithRay;
  126626. private _checkRotate;
  126627. private _checkTeleportBackwards;
  126628. private _enableTeleportationOnController;
  126629. private _createTeleportationCircles;
  126630. private _displayTeleportationTarget;
  126631. private _hideTeleportationTarget;
  126632. private _rotateCamera;
  126633. private _moveTeleportationSelectorTo;
  126634. private _workingVector;
  126635. private _workingQuaternion;
  126636. private _workingMatrix;
  126637. /**
  126638. * Time Constant Teleportation Mode
  126639. */
  126640. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  126641. /**
  126642. * Speed Constant Teleportation Mode
  126643. */
  126644. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  126645. /**
  126646. * Teleports the users feet to the desired location
  126647. * @param location The location where the user's feet should be placed
  126648. */
  126649. teleportCamera(location: Vector3): void;
  126650. private _convertNormalToDirectionOfRay;
  126651. private _castRayAndSelectObject;
  126652. private _notifySelectedMeshUnselected;
  126653. /**
  126654. * Permanently set new colors for the laser pointer
  126655. * @param color the new laser color
  126656. * @param pickedColor the new laser color when picked mesh detected
  126657. */
  126658. setLaserColor(color: Color3, pickedColor?: Color3): void;
  126659. /**
  126660. * Set lighting enabled / disabled on the laser pointer of both controllers
  126661. * @param enabled should the lighting be enabled on the laser pointer
  126662. */
  126663. setLaserLightingState(enabled?: boolean): void;
  126664. /**
  126665. * Permanently set new colors for the gaze pointer
  126666. * @param color the new gaze color
  126667. * @param pickedColor the new gaze color when picked mesh detected
  126668. */
  126669. setGazeColor(color: Color3, pickedColor?: Color3): void;
  126670. /**
  126671. * Sets the color of the laser ray from the vr controllers.
  126672. * @param color new color for the ray.
  126673. */
  126674. changeLaserColor(color: Color3): void;
  126675. /**
  126676. * Sets the color of the ray from the vr headsets gaze.
  126677. * @param color new color for the ray.
  126678. */
  126679. changeGazeColor(color: Color3): void;
  126680. /**
  126681. * Exits VR and disposes of the vr experience helper
  126682. */
  126683. dispose(): void;
  126684. /**
  126685. * Gets the name of the VRExperienceHelper class
  126686. * @returns "VRExperienceHelper"
  126687. */
  126688. getClassName(): string;
  126689. }
  126690. }
  126691. declare module BABYLON {
  126692. /**
  126693. * Contains an array of blocks representing the octree
  126694. */
  126695. export interface IOctreeContainer<T> {
  126696. /**
  126697. * Blocks within the octree
  126698. */
  126699. blocks: Array<OctreeBlock<T>>;
  126700. }
  126701. /**
  126702. * Class used to store a cell in an octree
  126703. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126704. */
  126705. export class OctreeBlock<T> {
  126706. /**
  126707. * Gets the content of the current block
  126708. */
  126709. entries: T[];
  126710. /**
  126711. * Gets the list of block children
  126712. */
  126713. blocks: Array<OctreeBlock<T>>;
  126714. private _depth;
  126715. private _maxDepth;
  126716. private _capacity;
  126717. private _minPoint;
  126718. private _maxPoint;
  126719. private _boundingVectors;
  126720. private _creationFunc;
  126721. /**
  126722. * Creates a new block
  126723. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  126724. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  126725. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126726. * @param depth defines the current depth of this block in the octree
  126727. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  126728. * @param creationFunc defines a callback to call when an element is added to the block
  126729. */
  126730. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  126731. /**
  126732. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  126733. */
  126734. get capacity(): number;
  126735. /**
  126736. * Gets the minimum vector (in world space) of the block's bounding box
  126737. */
  126738. get minPoint(): Vector3;
  126739. /**
  126740. * Gets the maximum vector (in world space) of the block's bounding box
  126741. */
  126742. get maxPoint(): Vector3;
  126743. /**
  126744. * Add a new element to this block
  126745. * @param entry defines the element to add
  126746. */
  126747. addEntry(entry: T): void;
  126748. /**
  126749. * Remove an element from this block
  126750. * @param entry defines the element to remove
  126751. */
  126752. removeEntry(entry: T): void;
  126753. /**
  126754. * Add an array of elements to this block
  126755. * @param entries defines the array of elements to add
  126756. */
  126757. addEntries(entries: T[]): void;
  126758. /**
  126759. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  126760. * @param frustumPlanes defines the frustum planes to test
  126761. * @param selection defines the array to store current content if selection is positive
  126762. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126763. */
  126764. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  126765. /**
  126766. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  126767. * @param sphereCenter defines the bounding sphere center
  126768. * @param sphereRadius defines the bounding sphere radius
  126769. * @param selection defines the array to store current content if selection is positive
  126770. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126771. */
  126772. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  126773. /**
  126774. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  126775. * @param ray defines the ray to test with
  126776. * @param selection defines the array to store current content if selection is positive
  126777. */
  126778. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  126779. /**
  126780. * Subdivide the content into child blocks (this block will then be empty)
  126781. */
  126782. createInnerBlocks(): void;
  126783. /**
  126784. * @hidden
  126785. */
  126786. 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;
  126787. }
  126788. }
  126789. declare module BABYLON {
  126790. /**
  126791. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  126792. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126793. */
  126794. export class Octree<T> {
  126795. /** 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.) */
  126796. maxDepth: number;
  126797. /**
  126798. * Blocks within the octree containing objects
  126799. */
  126800. blocks: Array<OctreeBlock<T>>;
  126801. /**
  126802. * Content stored in the octree
  126803. */
  126804. dynamicContent: T[];
  126805. private _maxBlockCapacity;
  126806. private _selectionContent;
  126807. private _creationFunc;
  126808. /**
  126809. * Creates a octree
  126810. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126811. * @param creationFunc function to be used to instatiate the octree
  126812. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  126813. * @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.)
  126814. */
  126815. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  126816. /** 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.) */
  126817. maxDepth?: number);
  126818. /**
  126819. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  126820. * @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);
  126821. * @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);
  126822. * @param entries meshes to be added to the octree blocks
  126823. */
  126824. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  126825. /**
  126826. * Adds a mesh to the octree
  126827. * @param entry Mesh to add to the octree
  126828. */
  126829. addMesh(entry: T): void;
  126830. /**
  126831. * Remove an element from the octree
  126832. * @param entry defines the element to remove
  126833. */
  126834. removeMesh(entry: T): void;
  126835. /**
  126836. * Selects an array of meshes within the frustum
  126837. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  126838. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  126839. * @returns array of meshes within the frustum
  126840. */
  126841. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  126842. /**
  126843. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  126844. * @param sphereCenter defines the bounding sphere center
  126845. * @param sphereRadius defines the bounding sphere radius
  126846. * @param allowDuplicate defines if the selection array can contains duplicated entries
  126847. * @returns an array of objects that intersect the sphere
  126848. */
  126849. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  126850. /**
  126851. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  126852. * @param ray defines the ray to test with
  126853. * @returns array of intersected objects
  126854. */
  126855. intersectsRay(ray: Ray): SmartArray<T>;
  126856. /**
  126857. * Adds a mesh into the octree block if it intersects the block
  126858. */
  126859. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  126860. /**
  126861. * Adds a submesh into the octree block if it intersects the block
  126862. */
  126863. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  126864. }
  126865. }
  126866. declare module BABYLON {
  126867. interface Scene {
  126868. /**
  126869. * @hidden
  126870. * Backing Filed
  126871. */
  126872. _selectionOctree: Octree<AbstractMesh>;
  126873. /**
  126874. * Gets the octree used to boost mesh selection (picking)
  126875. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126876. */
  126877. selectionOctree: Octree<AbstractMesh>;
  126878. /**
  126879. * Creates or updates the octree used to boost selection (picking)
  126880. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126881. * @param maxCapacity defines the maximum capacity per leaf
  126882. * @param maxDepth defines the maximum depth of the octree
  126883. * @returns an octree of AbstractMesh
  126884. */
  126885. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  126886. }
  126887. interface AbstractMesh {
  126888. /**
  126889. * @hidden
  126890. * Backing Field
  126891. */
  126892. _submeshesOctree: Octree<SubMesh>;
  126893. /**
  126894. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  126895. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  126896. * @param maxCapacity defines the maximum size of each block (64 by default)
  126897. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  126898. * @returns the new octree
  126899. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  126900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  126901. */
  126902. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  126903. }
  126904. /**
  126905. * Defines the octree scene component responsible to manage any octrees
  126906. * in a given scene.
  126907. */
  126908. export class OctreeSceneComponent {
  126909. /**
  126910. * The component name help to identify the component in the list of scene components.
  126911. */
  126912. readonly name: string;
  126913. /**
  126914. * The scene the component belongs to.
  126915. */
  126916. scene: Scene;
  126917. /**
  126918. * Indicates if the meshes have been checked to make sure they are isEnabled()
  126919. */
  126920. readonly checksIsEnabled: boolean;
  126921. /**
  126922. * Creates a new instance of the component for the given scene
  126923. * @param scene Defines the scene to register the component in
  126924. */
  126925. constructor(scene: Scene);
  126926. /**
  126927. * Registers the component in a given scene
  126928. */
  126929. register(): void;
  126930. /**
  126931. * Return the list of active meshes
  126932. * @returns the list of active meshes
  126933. */
  126934. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  126935. /**
  126936. * Return the list of active sub meshes
  126937. * @param mesh The mesh to get the candidates sub meshes from
  126938. * @returns the list of active sub meshes
  126939. */
  126940. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  126941. private _tempRay;
  126942. /**
  126943. * Return the list of sub meshes intersecting with a given local ray
  126944. * @param mesh defines the mesh to find the submesh for
  126945. * @param localRay defines the ray in local space
  126946. * @returns the list of intersecting sub meshes
  126947. */
  126948. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  126949. /**
  126950. * Return the list of sub meshes colliding with a collider
  126951. * @param mesh defines the mesh to find the submesh for
  126952. * @param collider defines the collider to evaluate the collision against
  126953. * @returns the list of colliding sub meshes
  126954. */
  126955. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  126956. /**
  126957. * Rebuilds the elements related to this component in case of
  126958. * context lost for instance.
  126959. */
  126960. rebuild(): void;
  126961. /**
  126962. * Disposes the component and the associated ressources.
  126963. */
  126964. dispose(): void;
  126965. }
  126966. }
  126967. declare module BABYLON {
  126968. /**
  126969. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  126970. */
  126971. export class Gizmo implements IDisposable {
  126972. /** The utility layer the gizmo will be added to */
  126973. gizmoLayer: UtilityLayerRenderer;
  126974. /**
  126975. * The root mesh of the gizmo
  126976. */
  126977. _rootMesh: Mesh;
  126978. private _attachedMesh;
  126979. /**
  126980. * Ratio for the scale of the gizmo (Default: 1)
  126981. */
  126982. scaleRatio: number;
  126983. /**
  126984. * If a custom mesh has been set (Default: false)
  126985. */
  126986. protected _customMeshSet: boolean;
  126987. /**
  126988. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  126989. * * When set, interactions will be enabled
  126990. */
  126991. get attachedMesh(): Nullable<AbstractMesh>;
  126992. set attachedMesh(value: Nullable<AbstractMesh>);
  126993. /**
  126994. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  126995. * @param mesh The mesh to replace the default mesh of the gizmo
  126996. */
  126997. setCustomMesh(mesh: Mesh): void;
  126998. /**
  126999. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127000. */
  127001. updateGizmoRotationToMatchAttachedMesh: boolean;
  127002. /**
  127003. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127004. */
  127005. updateGizmoPositionToMatchAttachedMesh: boolean;
  127006. /**
  127007. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127008. */
  127009. updateScale: boolean;
  127010. protected _interactionsEnabled: boolean;
  127011. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127012. private _beforeRenderObserver;
  127013. private _tempVector;
  127014. /**
  127015. * Creates a gizmo
  127016. * @param gizmoLayer The utility layer the gizmo will be added to
  127017. */
  127018. constructor(
  127019. /** The utility layer the gizmo will be added to */
  127020. gizmoLayer?: UtilityLayerRenderer);
  127021. /**
  127022. * Updates the gizmo to match the attached mesh's position/rotation
  127023. */
  127024. protected _update(): void;
  127025. /**
  127026. * Disposes of the gizmo
  127027. */
  127028. dispose(): void;
  127029. }
  127030. }
  127031. declare module BABYLON {
  127032. /**
  127033. * Single plane drag gizmo
  127034. */
  127035. export class PlaneDragGizmo extends Gizmo {
  127036. /**
  127037. * Drag behavior responsible for the gizmos dragging interactions
  127038. */
  127039. dragBehavior: PointerDragBehavior;
  127040. private _pointerObserver;
  127041. /**
  127042. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127043. */
  127044. snapDistance: number;
  127045. /**
  127046. * Event that fires each time the gizmo snaps to a new location.
  127047. * * snapDistance is the the change in distance
  127048. */
  127049. onSnapObservable: Observable<{
  127050. snapDistance: number;
  127051. }>;
  127052. private _plane;
  127053. private _coloredMaterial;
  127054. private _hoverMaterial;
  127055. private _isEnabled;
  127056. private _parent;
  127057. /** @hidden */
  127058. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127059. /** @hidden */
  127060. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127061. /**
  127062. * Creates a PlaneDragGizmo
  127063. * @param gizmoLayer The utility layer the gizmo will be added to
  127064. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127065. * @param color The color of the gizmo
  127066. */
  127067. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127068. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127069. /**
  127070. * If the gizmo is enabled
  127071. */
  127072. set isEnabled(value: boolean);
  127073. get isEnabled(): boolean;
  127074. /**
  127075. * Disposes of the gizmo
  127076. */
  127077. dispose(): void;
  127078. }
  127079. }
  127080. declare module BABYLON {
  127081. /**
  127082. * Gizmo that enables dragging a mesh along 3 axis
  127083. */
  127084. export class PositionGizmo extends Gizmo {
  127085. /**
  127086. * Internal gizmo used for interactions on the x axis
  127087. */
  127088. xGizmo: AxisDragGizmo;
  127089. /**
  127090. * Internal gizmo used for interactions on the y axis
  127091. */
  127092. yGizmo: AxisDragGizmo;
  127093. /**
  127094. * Internal gizmo used for interactions on the z axis
  127095. */
  127096. zGizmo: AxisDragGizmo;
  127097. /**
  127098. * Internal gizmo used for interactions on the yz plane
  127099. */
  127100. xPlaneGizmo: PlaneDragGizmo;
  127101. /**
  127102. * Internal gizmo used for interactions on the xz plane
  127103. */
  127104. yPlaneGizmo: PlaneDragGizmo;
  127105. /**
  127106. * Internal gizmo used for interactions on the xy plane
  127107. */
  127108. zPlaneGizmo: PlaneDragGizmo;
  127109. /**
  127110. * private variables
  127111. */
  127112. private _meshAttached;
  127113. private _updateGizmoRotationToMatchAttachedMesh;
  127114. private _snapDistance;
  127115. private _scaleRatio;
  127116. /** Fires an event when any of it's sub gizmos are dragged */
  127117. onDragStartObservable: Observable<unknown>;
  127118. /** Fires an event when any of it's sub gizmos are released from dragging */
  127119. onDragEndObservable: Observable<unknown>;
  127120. /**
  127121. * If set to true, planar drag is enabled
  127122. */
  127123. private _planarGizmoEnabled;
  127124. get attachedMesh(): Nullable<AbstractMesh>;
  127125. set attachedMesh(mesh: Nullable<AbstractMesh>);
  127126. /**
  127127. * Creates a PositionGizmo
  127128. * @param gizmoLayer The utility layer the gizmo will be added to
  127129. */
  127130. constructor(gizmoLayer?: UtilityLayerRenderer);
  127131. /**
  127132. * If the planar drag gizmo is enabled
  127133. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  127134. */
  127135. set planarGizmoEnabled(value: boolean);
  127136. get planarGizmoEnabled(): boolean;
  127137. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  127138. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  127139. /**
  127140. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127141. */
  127142. set snapDistance(value: number);
  127143. get snapDistance(): number;
  127144. /**
  127145. * Ratio for the scale of the gizmo (Default: 1)
  127146. */
  127147. set scaleRatio(value: number);
  127148. get scaleRatio(): number;
  127149. /**
  127150. * Disposes of the gizmo
  127151. */
  127152. dispose(): void;
  127153. /**
  127154. * CustomMeshes are not supported by this gizmo
  127155. * @param mesh The mesh to replace the default mesh of the gizmo
  127156. */
  127157. setCustomMesh(mesh: Mesh): void;
  127158. }
  127159. }
  127160. declare module BABYLON {
  127161. /**
  127162. * Single axis drag gizmo
  127163. */
  127164. export class AxisDragGizmo extends Gizmo {
  127165. /**
  127166. * Drag behavior responsible for the gizmos dragging interactions
  127167. */
  127168. dragBehavior: PointerDragBehavior;
  127169. private _pointerObserver;
  127170. /**
  127171. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127172. */
  127173. snapDistance: number;
  127174. /**
  127175. * Event that fires each time the gizmo snaps to a new location.
  127176. * * snapDistance is the the change in distance
  127177. */
  127178. onSnapObservable: Observable<{
  127179. snapDistance: number;
  127180. }>;
  127181. private _isEnabled;
  127182. private _parent;
  127183. private _arrow;
  127184. private _coloredMaterial;
  127185. private _hoverMaterial;
  127186. /** @hidden */
  127187. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  127188. /** @hidden */
  127189. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127190. /**
  127191. * Creates an AxisDragGizmo
  127192. * @param gizmoLayer The utility layer the gizmo will be added to
  127193. * @param dragAxis The axis which the gizmo will be able to drag on
  127194. * @param color The color of the gizmo
  127195. */
  127196. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127197. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127198. /**
  127199. * If the gizmo is enabled
  127200. */
  127201. set isEnabled(value: boolean);
  127202. get isEnabled(): boolean;
  127203. /**
  127204. * Disposes of the gizmo
  127205. */
  127206. dispose(): void;
  127207. }
  127208. }
  127209. declare module BABYLON.Debug {
  127210. /**
  127211. * The Axes viewer will show 3 axes in a specific point in space
  127212. */
  127213. export class AxesViewer {
  127214. private _xAxis;
  127215. private _yAxis;
  127216. private _zAxis;
  127217. private _scaleLinesFactor;
  127218. private _instanced;
  127219. /**
  127220. * Gets the hosting scene
  127221. */
  127222. scene: Scene;
  127223. /**
  127224. * Gets or sets a number used to scale line length
  127225. */
  127226. scaleLines: number;
  127227. /** Gets the node hierarchy used to render x-axis */
  127228. get xAxis(): TransformNode;
  127229. /** Gets the node hierarchy used to render y-axis */
  127230. get yAxis(): TransformNode;
  127231. /** Gets the node hierarchy used to render z-axis */
  127232. get zAxis(): TransformNode;
  127233. /**
  127234. * Creates a new AxesViewer
  127235. * @param scene defines the hosting scene
  127236. * @param scaleLines defines a number used to scale line length (1 by default)
  127237. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  127238. * @param xAxis defines the node hierarchy used to render the x-axis
  127239. * @param yAxis defines the node hierarchy used to render the y-axis
  127240. * @param zAxis defines the node hierarchy used to render the z-axis
  127241. */
  127242. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  127243. /**
  127244. * Force the viewer to update
  127245. * @param position defines the position of the viewer
  127246. * @param xaxis defines the x axis of the viewer
  127247. * @param yaxis defines the y axis of the viewer
  127248. * @param zaxis defines the z axis of the viewer
  127249. */
  127250. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  127251. /**
  127252. * Creates an instance of this axes viewer.
  127253. * @returns a new axes viewer with instanced meshes
  127254. */
  127255. createInstance(): AxesViewer;
  127256. /** Releases resources */
  127257. dispose(): void;
  127258. private static _SetRenderingGroupId;
  127259. }
  127260. }
  127261. declare module BABYLON.Debug {
  127262. /**
  127263. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  127264. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  127265. */
  127266. export class BoneAxesViewer extends AxesViewer {
  127267. /**
  127268. * Gets or sets the target mesh where to display the axes viewer
  127269. */
  127270. mesh: Nullable<Mesh>;
  127271. /**
  127272. * Gets or sets the target bone where to display the axes viewer
  127273. */
  127274. bone: Nullable<Bone>;
  127275. /** Gets current position */
  127276. pos: Vector3;
  127277. /** Gets direction of X axis */
  127278. xaxis: Vector3;
  127279. /** Gets direction of Y axis */
  127280. yaxis: Vector3;
  127281. /** Gets direction of Z axis */
  127282. zaxis: Vector3;
  127283. /**
  127284. * Creates a new BoneAxesViewer
  127285. * @param scene defines the hosting scene
  127286. * @param bone defines the target bone
  127287. * @param mesh defines the target mesh
  127288. * @param scaleLines defines a scaling factor for line length (1 by default)
  127289. */
  127290. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  127291. /**
  127292. * Force the viewer to update
  127293. */
  127294. update(): void;
  127295. /** Releases resources */
  127296. dispose(): void;
  127297. }
  127298. }
  127299. declare module BABYLON {
  127300. /**
  127301. * Interface used to define scene explorer extensibility option
  127302. */
  127303. export interface IExplorerExtensibilityOption {
  127304. /**
  127305. * Define the option label
  127306. */
  127307. label: string;
  127308. /**
  127309. * Defines the action to execute on click
  127310. */
  127311. action: (entity: any) => void;
  127312. }
  127313. /**
  127314. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  127315. */
  127316. export interface IExplorerExtensibilityGroup {
  127317. /**
  127318. * Defines a predicate to test if a given type mut be extended
  127319. */
  127320. predicate: (entity: any) => boolean;
  127321. /**
  127322. * Gets the list of options added to a type
  127323. */
  127324. entries: IExplorerExtensibilityOption[];
  127325. }
  127326. /**
  127327. * Interface used to define the options to use to create the Inspector
  127328. */
  127329. export interface IInspectorOptions {
  127330. /**
  127331. * Display in overlay mode (default: false)
  127332. */
  127333. overlay?: boolean;
  127334. /**
  127335. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  127336. */
  127337. globalRoot?: HTMLElement;
  127338. /**
  127339. * Display the Scene explorer
  127340. */
  127341. showExplorer?: boolean;
  127342. /**
  127343. * Display the property inspector
  127344. */
  127345. showInspector?: boolean;
  127346. /**
  127347. * Display in embed mode (both panes on the right)
  127348. */
  127349. embedMode?: boolean;
  127350. /**
  127351. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  127352. */
  127353. handleResize?: boolean;
  127354. /**
  127355. * Allow the panes to popup (default: true)
  127356. */
  127357. enablePopup?: boolean;
  127358. /**
  127359. * Allow the panes to be closed by users (default: true)
  127360. */
  127361. enableClose?: boolean;
  127362. /**
  127363. * Optional list of extensibility entries
  127364. */
  127365. explorerExtensibility?: IExplorerExtensibilityGroup[];
  127366. /**
  127367. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  127368. */
  127369. inspectorURL?: string;
  127370. /**
  127371. * Optional initial tab (default to DebugLayerTab.Properties)
  127372. */
  127373. initialTab?: DebugLayerTab;
  127374. }
  127375. interface Scene {
  127376. /**
  127377. * @hidden
  127378. * Backing field
  127379. */
  127380. _debugLayer: DebugLayer;
  127381. /**
  127382. * Gets the debug layer (aka Inspector) associated with the scene
  127383. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127384. */
  127385. debugLayer: DebugLayer;
  127386. }
  127387. /**
  127388. * Enum of inspector action tab
  127389. */
  127390. export enum DebugLayerTab {
  127391. /**
  127392. * Properties tag (default)
  127393. */
  127394. Properties = 0,
  127395. /**
  127396. * Debug tab
  127397. */
  127398. Debug = 1,
  127399. /**
  127400. * Statistics tab
  127401. */
  127402. Statistics = 2,
  127403. /**
  127404. * Tools tab
  127405. */
  127406. Tools = 3,
  127407. /**
  127408. * Settings tab
  127409. */
  127410. Settings = 4
  127411. }
  127412. /**
  127413. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127414. * what is happening in your scene
  127415. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127416. */
  127417. export class DebugLayer {
  127418. /**
  127419. * Define the url to get the inspector script from.
  127420. * By default it uses the babylonjs CDN.
  127421. * @ignoreNaming
  127422. */
  127423. static InspectorURL: string;
  127424. private _scene;
  127425. private BJSINSPECTOR;
  127426. private _onPropertyChangedObservable?;
  127427. /**
  127428. * Observable triggered when a property is changed through the inspector.
  127429. */
  127430. get onPropertyChangedObservable(): any;
  127431. /**
  127432. * Instantiates a new debug layer.
  127433. * The debug layer (aka Inspector) is the go to tool in order to better understand
  127434. * what is happening in your scene
  127435. * @see http://doc.babylonjs.com/features/playground_debuglayer
  127436. * @param scene Defines the scene to inspect
  127437. */
  127438. constructor(scene: Scene);
  127439. /** Creates the inspector window. */
  127440. private _createInspector;
  127441. /**
  127442. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  127443. * @param entity defines the entity to select
  127444. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  127445. */
  127446. select(entity: any, lineContainerTitles?: string | string[]): void;
  127447. /** Get the inspector from bundle or global */
  127448. private _getGlobalInspector;
  127449. /**
  127450. * Get if the inspector is visible or not.
  127451. * @returns true if visible otherwise, false
  127452. */
  127453. isVisible(): boolean;
  127454. /**
  127455. * Hide the inspector and close its window.
  127456. */
  127457. hide(): void;
  127458. /**
  127459. * Update the scene in the inspector
  127460. */
  127461. setAsActiveScene(): void;
  127462. /**
  127463. * Launch the debugLayer.
  127464. * @param config Define the configuration of the inspector
  127465. * @return a promise fulfilled when the debug layer is visible
  127466. */
  127467. show(config?: IInspectorOptions): Promise<DebugLayer>;
  127468. }
  127469. }
  127470. declare module BABYLON {
  127471. /**
  127472. * Class containing static functions to help procedurally build meshes
  127473. */
  127474. export class BoxBuilder {
  127475. /**
  127476. * Creates a box mesh
  127477. * * The parameter `size` sets the size (float) of each box side (default 1)
  127478. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  127479. * * 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)
  127480. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  127481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127482. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127484. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  127485. * @param name defines the name of the mesh
  127486. * @param options defines the options used to create the mesh
  127487. * @param scene defines the hosting scene
  127488. * @returns the box mesh
  127489. */
  127490. static CreateBox(name: string, options: {
  127491. size?: number;
  127492. width?: number;
  127493. height?: number;
  127494. depth?: number;
  127495. faceUV?: Vector4[];
  127496. faceColors?: Color4[];
  127497. sideOrientation?: number;
  127498. frontUVs?: Vector4;
  127499. backUVs?: Vector4;
  127500. wrap?: boolean;
  127501. topBaseAt?: number;
  127502. bottomBaseAt?: number;
  127503. updatable?: boolean;
  127504. }, scene?: Nullable<Scene>): Mesh;
  127505. }
  127506. }
  127507. declare module BABYLON.Debug {
  127508. /**
  127509. * Used to show the physics impostor around the specific mesh
  127510. */
  127511. export class PhysicsViewer {
  127512. /** @hidden */
  127513. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  127514. /** @hidden */
  127515. protected _meshes: Array<Nullable<AbstractMesh>>;
  127516. /** @hidden */
  127517. protected _scene: Nullable<Scene>;
  127518. /** @hidden */
  127519. protected _numMeshes: number;
  127520. /** @hidden */
  127521. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  127522. private _renderFunction;
  127523. private _utilityLayer;
  127524. private _debugBoxMesh;
  127525. private _debugSphereMesh;
  127526. private _debugCylinderMesh;
  127527. private _debugMaterial;
  127528. private _debugMeshMeshes;
  127529. /**
  127530. * Creates a new PhysicsViewer
  127531. * @param scene defines the hosting scene
  127532. */
  127533. constructor(scene: Scene);
  127534. /** @hidden */
  127535. protected _updateDebugMeshes(): void;
  127536. /**
  127537. * Renders a specified physic impostor
  127538. * @param impostor defines the impostor to render
  127539. * @param targetMesh defines the mesh represented by the impostor
  127540. * @returns the new debug mesh used to render the impostor
  127541. */
  127542. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  127543. /**
  127544. * Hides a specified physic impostor
  127545. * @param impostor defines the impostor to hide
  127546. */
  127547. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  127548. private _getDebugMaterial;
  127549. private _getDebugBoxMesh;
  127550. private _getDebugSphereMesh;
  127551. private _getDebugCylinderMesh;
  127552. private _getDebugMeshMesh;
  127553. private _getDebugMesh;
  127554. /** Releases all resources */
  127555. dispose(): void;
  127556. }
  127557. }
  127558. declare module BABYLON {
  127559. /**
  127560. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127561. * in order to better appreciate the issue one might have.
  127562. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127563. */
  127564. export class RayHelper {
  127565. /**
  127566. * Defines the ray we are currently tryin to visualize.
  127567. */
  127568. ray: Nullable<Ray>;
  127569. private _renderPoints;
  127570. private _renderLine;
  127571. private _renderFunction;
  127572. private _scene;
  127573. private _updateToMeshFunction;
  127574. private _attachedToMesh;
  127575. private _meshSpaceDirection;
  127576. private _meshSpaceOrigin;
  127577. /**
  127578. * Helper function to create a colored helper in a scene in one line.
  127579. * @param ray Defines the ray we are currently tryin to visualize
  127580. * @param scene Defines the scene the ray is used in
  127581. * @param color Defines the color we want to see the ray in
  127582. * @returns The newly created ray helper.
  127583. */
  127584. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  127585. /**
  127586. * Instantiate a new ray helper.
  127587. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  127588. * in order to better appreciate the issue one might have.
  127589. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  127590. * @param ray Defines the ray we are currently tryin to visualize
  127591. */
  127592. constructor(ray: Ray);
  127593. /**
  127594. * Shows the ray we are willing to debug.
  127595. * @param scene Defines the scene the ray needs to be rendered in
  127596. * @param color Defines the color the ray needs to be rendered in
  127597. */
  127598. show(scene: Scene, color?: Color3): void;
  127599. /**
  127600. * Hides the ray we are debugging.
  127601. */
  127602. hide(): void;
  127603. private _render;
  127604. /**
  127605. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  127606. * @param mesh Defines the mesh we want the helper attached to
  127607. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  127608. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  127609. * @param length Defines the length of the ray
  127610. */
  127611. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  127612. /**
  127613. * Detach the ray helper from the mesh it has previously been attached to.
  127614. */
  127615. detachFromMesh(): void;
  127616. private _updateToMesh;
  127617. /**
  127618. * Dispose the helper and release its associated resources.
  127619. */
  127620. dispose(): void;
  127621. }
  127622. }
  127623. declare module BABYLON.Debug {
  127624. /**
  127625. * Class used to render a debug view of a given skeleton
  127626. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  127627. */
  127628. export class SkeletonViewer {
  127629. /** defines the skeleton to render */
  127630. skeleton: Skeleton;
  127631. /** defines the mesh attached to the skeleton */
  127632. mesh: AbstractMesh;
  127633. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127634. autoUpdateBonesMatrices: boolean;
  127635. /** defines the rendering group id to use with the viewer */
  127636. renderingGroupId: number;
  127637. /** Gets or sets the color used to render the skeleton */
  127638. color: Color3;
  127639. private _scene;
  127640. private _debugLines;
  127641. private _debugMesh;
  127642. private _isEnabled;
  127643. private _renderFunction;
  127644. private _utilityLayer;
  127645. /**
  127646. * Returns the mesh used to render the bones
  127647. */
  127648. get debugMesh(): Nullable<LinesMesh>;
  127649. /**
  127650. * Creates a new SkeletonViewer
  127651. * @param skeleton defines the skeleton to render
  127652. * @param mesh defines the mesh attached to the skeleton
  127653. * @param scene defines the hosting scene
  127654. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  127655. * @param renderingGroupId defines the rendering group id to use with the viewer
  127656. */
  127657. constructor(
  127658. /** defines the skeleton to render */
  127659. skeleton: Skeleton,
  127660. /** defines the mesh attached to the skeleton */
  127661. mesh: AbstractMesh, scene: Scene,
  127662. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  127663. autoUpdateBonesMatrices?: boolean,
  127664. /** defines the rendering group id to use with the viewer */
  127665. renderingGroupId?: number);
  127666. /** Gets or sets a boolean indicating if the viewer is enabled */
  127667. set isEnabled(value: boolean);
  127668. get isEnabled(): boolean;
  127669. private _getBonePosition;
  127670. private _getLinesForBonesWithLength;
  127671. private _getLinesForBonesNoLength;
  127672. /** Update the viewer to sync with current skeleton state */
  127673. update(): void;
  127674. /** Release associated resources */
  127675. dispose(): void;
  127676. }
  127677. }
  127678. declare module BABYLON {
  127679. /**
  127680. * Enum for Device Types
  127681. */
  127682. export enum DeviceType {
  127683. /** Generic */
  127684. Generic = 0,
  127685. /** Keyboard */
  127686. Keyboard = 1,
  127687. /** Mouse */
  127688. Mouse = 2,
  127689. /** Touch Pointers */
  127690. Touch = 3,
  127691. /** PS4 Dual Shock */
  127692. DualShock = 4,
  127693. /** Xbox */
  127694. Xbox = 5,
  127695. /** Switch Controller */
  127696. Switch = 6
  127697. }
  127698. /**
  127699. * Enum for All Pointers (Touch/Mouse)
  127700. */
  127701. export enum PointerInput {
  127702. /** Horizontal Axis */
  127703. Horizontal = 0,
  127704. /** Vertical Axis */
  127705. Vertical = 1,
  127706. /** Left Click or Touch */
  127707. LeftClick = 2,
  127708. /** Middle Click */
  127709. MiddleClick = 3,
  127710. /** Right Click */
  127711. RightClick = 4,
  127712. /** Browser Back */
  127713. BrowserBack = 5,
  127714. /** Browser Forward */
  127715. BrowserForward = 6
  127716. }
  127717. /**
  127718. * Enum for Dual Shock Gamepad
  127719. */
  127720. export enum DualShockInput {
  127721. /** Cross */
  127722. Cross = 0,
  127723. /** Circle */
  127724. Circle = 1,
  127725. /** Square */
  127726. Square = 2,
  127727. /** Triangle */
  127728. Triangle = 3,
  127729. /** L1 */
  127730. L1 = 4,
  127731. /** R1 */
  127732. R1 = 5,
  127733. /** L2 */
  127734. L2 = 6,
  127735. /** R2 */
  127736. R2 = 7,
  127737. /** Share */
  127738. Share = 8,
  127739. /** Options */
  127740. Options = 9,
  127741. /** L3 */
  127742. L3 = 10,
  127743. /** R3 */
  127744. R3 = 11,
  127745. /** DPadUp */
  127746. DPadUp = 12,
  127747. /** DPadDown */
  127748. DPadDown = 13,
  127749. /** DPadLeft */
  127750. DPadLeft = 14,
  127751. /** DRight */
  127752. DPadRight = 15,
  127753. /** Home */
  127754. Home = 16,
  127755. /** TouchPad */
  127756. TouchPad = 17,
  127757. /** LStickXAxis */
  127758. LStickXAxis = 18,
  127759. /** LStickYAxis */
  127760. LStickYAxis = 19,
  127761. /** RStickXAxis */
  127762. RStickXAxis = 20,
  127763. /** RStickYAxis */
  127764. RStickYAxis = 21
  127765. }
  127766. /**
  127767. * Enum for Xbox Gamepad
  127768. */
  127769. export enum XboxInput {
  127770. /** A */
  127771. A = 0,
  127772. /** B */
  127773. B = 1,
  127774. /** X */
  127775. X = 2,
  127776. /** Y */
  127777. Y = 3,
  127778. /** LB */
  127779. LB = 4,
  127780. /** RB */
  127781. RB = 5,
  127782. /** LT */
  127783. LT = 6,
  127784. /** RT */
  127785. RT = 7,
  127786. /** Back */
  127787. Back = 8,
  127788. /** Start */
  127789. Start = 9,
  127790. /** LS */
  127791. LS = 10,
  127792. /** RS */
  127793. RS = 11,
  127794. /** DPadUp */
  127795. DPadUp = 12,
  127796. /** DPadDown */
  127797. DPadDown = 13,
  127798. /** DPadLeft */
  127799. DPadLeft = 14,
  127800. /** DRight */
  127801. DPadRight = 15,
  127802. /** Home */
  127803. Home = 16,
  127804. /** LStickXAxis */
  127805. LStickXAxis = 17,
  127806. /** LStickYAxis */
  127807. LStickYAxis = 18,
  127808. /** RStickXAxis */
  127809. RStickXAxis = 19,
  127810. /** RStickYAxis */
  127811. RStickYAxis = 20
  127812. }
  127813. /**
  127814. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  127815. */
  127816. export enum SwitchInput {
  127817. /** B */
  127818. B = 0,
  127819. /** A */
  127820. A = 1,
  127821. /** Y */
  127822. Y = 2,
  127823. /** X */
  127824. X = 3,
  127825. /** L */
  127826. L = 4,
  127827. /** R */
  127828. R = 5,
  127829. /** ZL */
  127830. ZL = 6,
  127831. /** ZR */
  127832. ZR = 7,
  127833. /** Minus */
  127834. Minus = 8,
  127835. /** Plus */
  127836. Plus = 9,
  127837. /** LS */
  127838. LS = 10,
  127839. /** RS */
  127840. RS = 11,
  127841. /** DPadUp */
  127842. DPadUp = 12,
  127843. /** DPadDown */
  127844. DPadDown = 13,
  127845. /** DPadLeft */
  127846. DPadLeft = 14,
  127847. /** DRight */
  127848. DPadRight = 15,
  127849. /** Home */
  127850. Home = 16,
  127851. /** Capture */
  127852. Capture = 17,
  127853. /** LStickXAxis */
  127854. LStickXAxis = 18,
  127855. /** LStickYAxis */
  127856. LStickYAxis = 19,
  127857. /** RStickXAxis */
  127858. RStickXAxis = 20,
  127859. /** RStickYAxis */
  127860. RStickYAxis = 21
  127861. }
  127862. }
  127863. declare module BABYLON {
  127864. /**
  127865. * This class will take all inputs from Keyboard, Pointer, and
  127866. * any Gamepads and provide a polling system that all devices
  127867. * will use. This class assumes that there will only be one
  127868. * pointer device and one keyboard.
  127869. */
  127870. export class DeviceInputSystem implements IDisposable {
  127871. /**
  127872. * Callback to be triggered when a device is connected
  127873. */
  127874. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127875. /**
  127876. * Callback to be triggered when a device is disconnected
  127877. */
  127878. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  127879. /**
  127880. * Callback to be triggered when event driven input is updated
  127881. */
  127882. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  127883. private _inputs;
  127884. private _gamepads;
  127885. private _keyboardActive;
  127886. private _pointerActive;
  127887. private _elementToAttachTo;
  127888. private _keyboardDownEvent;
  127889. private _keyboardUpEvent;
  127890. private _pointerMoveEvent;
  127891. private _pointerDownEvent;
  127892. private _pointerUpEvent;
  127893. private _gamepadConnectedEvent;
  127894. private _gamepadDisconnectedEvent;
  127895. private static _MAX_KEYCODES;
  127896. private static _MAX_POINTER_INPUTS;
  127897. private constructor();
  127898. /**
  127899. * Creates a new DeviceInputSystem instance
  127900. * @param engine Engine to pull input element from
  127901. * @returns The new instance
  127902. */
  127903. static Create(engine: Engine): DeviceInputSystem;
  127904. /**
  127905. * Checks for current device input value, given an id and input index
  127906. * @param deviceName Id of connected device
  127907. * @param inputIndex Index of device input
  127908. * @returns Current value of input
  127909. */
  127910. /**
  127911. * Checks for current device input value, given an id and input index
  127912. * @param deviceType Enum specifiying device type
  127913. * @param deviceSlot "Slot" or index that device is referenced in
  127914. * @param inputIndex Id of input to be checked
  127915. * @returns Current value of input
  127916. */
  127917. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  127918. /**
  127919. * Dispose of all the eventlisteners
  127920. */
  127921. dispose(): void;
  127922. /**
  127923. * Add device and inputs to device array
  127924. * @param deviceType Enum specifiying device type
  127925. * @param deviceSlot "Slot" or index that device is referenced in
  127926. * @param numberOfInputs Number of input entries to create for given device
  127927. */
  127928. private _registerDevice;
  127929. /**
  127930. * Given a specific device name, remove that device from the device map
  127931. * @param deviceType Enum specifiying device type
  127932. * @param deviceSlot "Slot" or index that device is referenced in
  127933. */
  127934. private _unregisterDevice;
  127935. /**
  127936. * Handle all actions that come from keyboard interaction
  127937. */
  127938. private _handleKeyActions;
  127939. /**
  127940. * Handle all actions that come from pointer interaction
  127941. */
  127942. private _handlePointerActions;
  127943. /**
  127944. * Handle all actions that come from gamepad interaction
  127945. */
  127946. private _handleGamepadActions;
  127947. /**
  127948. * Update all non-event based devices with each frame
  127949. * @param deviceType Enum specifiying device type
  127950. * @param deviceSlot "Slot" or index that device is referenced in
  127951. * @param inputIndex Id of input to be checked
  127952. */
  127953. private _updateDevice;
  127954. /**
  127955. * Gets DeviceType from the device name
  127956. * @param deviceName Name of Device from DeviceInputSystem
  127957. * @returns DeviceType enum value
  127958. */
  127959. private _getGamepadDeviceType;
  127960. }
  127961. }
  127962. declare module BABYLON {
  127963. /**
  127964. * Type to handle enforcement of inputs
  127965. */
  127966. export type DeviceInput<T extends DeviceType> = T extends DeviceType.Keyboard | DeviceType.Generic ? number : T extends DeviceType.Mouse | DeviceType.Touch ? PointerInput : T extends DeviceType.DualShock ? DualShockInput : T extends DeviceType.Xbox ? XboxInput : T extends DeviceType.Switch ? SwitchInput : never;
  127967. }
  127968. declare module BABYLON {
  127969. /**
  127970. * Class that handles all input for a specific device
  127971. */
  127972. export class DeviceSource<T extends DeviceType> {
  127973. /** Type of device */
  127974. readonly deviceType: DeviceType;
  127975. /** "Slot" or index that device is referenced in */
  127976. readonly deviceSlot: number;
  127977. /**
  127978. * Observable to handle device input changes per device
  127979. */
  127980. readonly onInputChangedObservable: Observable<{
  127981. inputIndex: DeviceInput<T>;
  127982. previousState: Nullable<number>;
  127983. currentState: Nullable<number>;
  127984. }>;
  127985. private readonly _deviceInputSystem;
  127986. /**
  127987. * Default Constructor
  127988. * @param deviceInputSystem Reference to DeviceInputSystem
  127989. * @param deviceType Type of device
  127990. * @param deviceSlot "Slot" or index that device is referenced in
  127991. */
  127992. constructor(deviceInputSystem: DeviceInputSystem,
  127993. /** Type of device */
  127994. deviceType: DeviceType,
  127995. /** "Slot" or index that device is referenced in */
  127996. deviceSlot?: number);
  127997. /**
  127998. * Get input for specific input
  127999. * @param inputIndex index of specific input on device
  128000. * @returns Input value from DeviceInputSystem
  128001. */
  128002. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128003. }
  128004. /**
  128005. * Class to keep track of devices
  128006. */
  128007. export class DeviceSourceManager implements IDisposable {
  128008. /**
  128009. * Observable to be triggered when before a device is connected
  128010. */
  128011. readonly onBeforeDeviceConnectedObservable: Observable<{
  128012. deviceType: DeviceType;
  128013. deviceSlot: number;
  128014. }>;
  128015. /**
  128016. * Observable to be triggered when before a device is disconnected
  128017. */
  128018. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128019. deviceType: DeviceType;
  128020. deviceSlot: number;
  128021. }>;
  128022. /**
  128023. * Observable to be triggered when after a device is connected
  128024. */
  128025. readonly onAfterDeviceConnectedObservable: Observable<{
  128026. deviceType: DeviceType;
  128027. deviceSlot: number;
  128028. }>;
  128029. /**
  128030. * Observable to be triggered when after a device is disconnected
  128031. */
  128032. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128033. deviceType: DeviceType;
  128034. deviceSlot: number;
  128035. }>;
  128036. private readonly _devices;
  128037. private readonly _firstDevice;
  128038. private readonly _deviceInputSystem;
  128039. /**
  128040. * Default Constructor
  128041. * @param engine engine to pull input element from
  128042. */
  128043. constructor(engine: Engine);
  128044. /**
  128045. * Gets a DeviceSource, given a type and slot
  128046. * @param deviceType Enum specifying device type
  128047. * @param deviceSlot "Slot" or index that device is referenced in
  128048. * @returns DeviceSource object
  128049. */
  128050. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128051. /**
  128052. * Gets an array of DeviceSource objects for a given device type
  128053. * @param deviceType Enum specifying device type
  128054. * @returns Array of DeviceSource objects
  128055. */
  128056. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128057. /**
  128058. * Dispose of DeviceInputSystem and other parts
  128059. */
  128060. dispose(): void;
  128061. /**
  128062. * Function to add device name to device list
  128063. * @param deviceType Enum specifying device type
  128064. * @param deviceSlot "Slot" or index that device is referenced in
  128065. */
  128066. private _addDevice;
  128067. /**
  128068. * Function to remove device name to device list
  128069. * @param deviceType Enum specifying device type
  128070. * @param deviceSlot "Slot" or index that device is referenced in
  128071. */
  128072. private _removeDevice;
  128073. /**
  128074. * Updates array storing first connected device of each type
  128075. * @param type Type of Device
  128076. */
  128077. private _updateFirstDevices;
  128078. }
  128079. }
  128080. declare module BABYLON {
  128081. /**
  128082. * Options to create the null engine
  128083. */
  128084. export class NullEngineOptions {
  128085. /**
  128086. * Render width (Default: 512)
  128087. */
  128088. renderWidth: number;
  128089. /**
  128090. * Render height (Default: 256)
  128091. */
  128092. renderHeight: number;
  128093. /**
  128094. * Texture size (Default: 512)
  128095. */
  128096. textureSize: number;
  128097. /**
  128098. * If delta time between frames should be constant
  128099. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128100. */
  128101. deterministicLockstep: boolean;
  128102. /**
  128103. * Maximum about of steps between frames (Default: 4)
  128104. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128105. */
  128106. lockstepMaxSteps: number;
  128107. }
  128108. /**
  128109. * The null engine class provides support for headless version of babylon.js.
  128110. * This can be used in server side scenario or for testing purposes
  128111. */
  128112. export class NullEngine extends Engine {
  128113. private _options;
  128114. /**
  128115. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  128116. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128117. * @returns true if engine is in deterministic lock step mode
  128118. */
  128119. isDeterministicLockStep(): boolean;
  128120. /**
  128121. * Gets the max steps when engine is running in deterministic lock step
  128122. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128123. * @returns the max steps
  128124. */
  128125. getLockstepMaxSteps(): number;
  128126. /**
  128127. * Gets the current hardware scaling level.
  128128. * By default the hardware scaling level is computed from the window device ratio.
  128129. * 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.
  128130. * @returns a number indicating the current hardware scaling level
  128131. */
  128132. getHardwareScalingLevel(): number;
  128133. constructor(options?: NullEngineOptions);
  128134. /**
  128135. * Creates a vertex buffer
  128136. * @param vertices the data for the vertex buffer
  128137. * @returns the new WebGL static buffer
  128138. */
  128139. createVertexBuffer(vertices: FloatArray): DataBuffer;
  128140. /**
  128141. * Creates a new index buffer
  128142. * @param indices defines the content of the index buffer
  128143. * @param updatable defines if the index buffer must be updatable
  128144. * @returns a new webGL buffer
  128145. */
  128146. createIndexBuffer(indices: IndicesArray): DataBuffer;
  128147. /**
  128148. * Clear the current render buffer or the current render target (if any is set up)
  128149. * @param color defines the color to use
  128150. * @param backBuffer defines if the back buffer must be cleared
  128151. * @param depth defines if the depth buffer must be cleared
  128152. * @param stencil defines if the stencil buffer must be cleared
  128153. */
  128154. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  128155. /**
  128156. * Gets the current render width
  128157. * @param useScreen defines if screen size must be used (or the current render target if any)
  128158. * @returns a number defining the current render width
  128159. */
  128160. getRenderWidth(useScreen?: boolean): number;
  128161. /**
  128162. * Gets the current render height
  128163. * @param useScreen defines if screen size must be used (or the current render target if any)
  128164. * @returns a number defining the current render height
  128165. */
  128166. getRenderHeight(useScreen?: boolean): number;
  128167. /**
  128168. * Set the WebGL's viewport
  128169. * @param viewport defines the viewport element to be used
  128170. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  128171. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  128172. */
  128173. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  128174. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  128175. /**
  128176. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  128177. * @param pipelineContext defines the pipeline context to use
  128178. * @param uniformsNames defines the list of uniform names
  128179. * @returns an array of webGL uniform locations
  128180. */
  128181. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  128182. /**
  128183. * Gets the lsit of active attributes for a given webGL program
  128184. * @param pipelineContext defines the pipeline context to use
  128185. * @param attributesNames defines the list of attribute names to get
  128186. * @returns an array of indices indicating the offset of each attribute
  128187. */
  128188. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  128189. /**
  128190. * Binds an effect to the webGL context
  128191. * @param effect defines the effect to bind
  128192. */
  128193. bindSamplers(effect: Effect): void;
  128194. /**
  128195. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  128196. * @param effect defines the effect to activate
  128197. */
  128198. enableEffect(effect: Effect): void;
  128199. /**
  128200. * Set various states to the webGL context
  128201. * @param culling defines backface culling state
  128202. * @param zOffset defines the value to apply to zOffset (0 by default)
  128203. * @param force defines if states must be applied even if cache is up to date
  128204. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  128205. */
  128206. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  128207. /**
  128208. * Set the value of an uniform to an array of int32
  128209. * @param uniform defines the webGL uniform location where to store the value
  128210. * @param array defines the array of int32 to store
  128211. */
  128212. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  128213. /**
  128214. * Set the value of an uniform to an array of int32 (stored as vec2)
  128215. * @param uniform defines the webGL uniform location where to store the value
  128216. * @param array defines the array of int32 to store
  128217. */
  128218. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  128219. /**
  128220. * Set the value of an uniform to an array of int32 (stored as vec3)
  128221. * @param uniform defines the webGL uniform location where to store the value
  128222. * @param array defines the array of int32 to store
  128223. */
  128224. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  128225. /**
  128226. * Set the value of an uniform to an array of int32 (stored as vec4)
  128227. * @param uniform defines the webGL uniform location where to store the value
  128228. * @param array defines the array of int32 to store
  128229. */
  128230. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  128231. /**
  128232. * Set the value of an uniform to an array of float32
  128233. * @param uniform defines the webGL uniform location where to store the value
  128234. * @param array defines the array of float32 to store
  128235. */
  128236. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  128237. /**
  128238. * Set the value of an uniform to an array of float32 (stored as vec2)
  128239. * @param uniform defines the webGL uniform location where to store the value
  128240. * @param array defines the array of float32 to store
  128241. */
  128242. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  128243. /**
  128244. * Set the value of an uniform to an array of float32 (stored as vec3)
  128245. * @param uniform defines the webGL uniform location where to store the value
  128246. * @param array defines the array of float32 to store
  128247. */
  128248. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  128249. /**
  128250. * Set the value of an uniform to an array of float32 (stored as vec4)
  128251. * @param uniform defines the webGL uniform location where to store the value
  128252. * @param array defines the array of float32 to store
  128253. */
  128254. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  128255. /**
  128256. * Set the value of an uniform to an array of number
  128257. * @param uniform defines the webGL uniform location where to store the value
  128258. * @param array defines the array of number to store
  128259. */
  128260. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  128261. /**
  128262. * Set the value of an uniform to an array of number (stored as vec2)
  128263. * @param uniform defines the webGL uniform location where to store the value
  128264. * @param array defines the array of number to store
  128265. */
  128266. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  128267. /**
  128268. * Set the value of an uniform to an array of number (stored as vec3)
  128269. * @param uniform defines the webGL uniform location where to store the value
  128270. * @param array defines the array of number to store
  128271. */
  128272. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  128273. /**
  128274. * Set the value of an uniform to an array of number (stored as vec4)
  128275. * @param uniform defines the webGL uniform location where to store the value
  128276. * @param array defines the array of number to store
  128277. */
  128278. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  128279. /**
  128280. * Set the value of an uniform to an array of float32 (stored as matrices)
  128281. * @param uniform defines the webGL uniform location where to store the value
  128282. * @param matrices defines the array of float32 to store
  128283. */
  128284. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  128285. /**
  128286. * Set the value of an uniform to a matrix (3x3)
  128287. * @param uniform defines the webGL uniform location where to store the value
  128288. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  128289. */
  128290. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128291. /**
  128292. * Set the value of an uniform to a matrix (2x2)
  128293. * @param uniform defines the webGL uniform location where to store the value
  128294. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  128295. */
  128296. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  128297. /**
  128298. * Set the value of an uniform to a number (float)
  128299. * @param uniform defines the webGL uniform location where to store the value
  128300. * @param value defines the float number to store
  128301. */
  128302. setFloat(uniform: WebGLUniformLocation, value: number): void;
  128303. /**
  128304. * Set the value of an uniform to a vec2
  128305. * @param uniform defines the webGL uniform location where to store the value
  128306. * @param x defines the 1st component of the value
  128307. * @param y defines the 2nd component of the value
  128308. */
  128309. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  128310. /**
  128311. * Set the value of an uniform to a vec3
  128312. * @param uniform defines the webGL uniform location where to store the value
  128313. * @param x defines the 1st component of the value
  128314. * @param y defines the 2nd component of the value
  128315. * @param z defines the 3rd component of the value
  128316. */
  128317. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  128318. /**
  128319. * Set the value of an uniform to a boolean
  128320. * @param uniform defines the webGL uniform location where to store the value
  128321. * @param bool defines the boolean to store
  128322. */
  128323. setBool(uniform: WebGLUniformLocation, bool: number): void;
  128324. /**
  128325. * Set the value of an uniform to a vec4
  128326. * @param uniform defines the webGL uniform location where to store the value
  128327. * @param x defines the 1st component of the value
  128328. * @param y defines the 2nd component of the value
  128329. * @param z defines the 3rd component of the value
  128330. * @param w defines the 4th component of the value
  128331. */
  128332. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  128333. /**
  128334. * Sets the current alpha mode
  128335. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  128336. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  128337. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  128338. */
  128339. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  128340. /**
  128341. * Bind webGl buffers directly to the webGL context
  128342. * @param vertexBuffers defines the vertex buffer to bind
  128343. * @param indexBuffer defines the index buffer to bind
  128344. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  128345. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  128346. * @param effect defines the effect associated with the vertex buffer
  128347. */
  128348. bindBuffers(vertexBuffers: {
  128349. [key: string]: VertexBuffer;
  128350. }, indexBuffer: DataBuffer, effect: Effect): void;
  128351. /**
  128352. * Force the entire cache to be cleared
  128353. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  128354. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  128355. */
  128356. wipeCaches(bruteForce?: boolean): void;
  128357. /**
  128358. * Send a draw order
  128359. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  128360. * @param indexStart defines the starting index
  128361. * @param indexCount defines the number of index to draw
  128362. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128363. */
  128364. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  128365. /**
  128366. * Draw a list of indexed primitives
  128367. * @param fillMode defines the primitive to use
  128368. * @param indexStart defines the starting index
  128369. * @param indexCount defines the number of index to draw
  128370. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128371. */
  128372. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  128373. /**
  128374. * Draw a list of unindexed primitives
  128375. * @param fillMode defines the primitive to use
  128376. * @param verticesStart defines the index of first vertex to draw
  128377. * @param verticesCount defines the count of vertices to draw
  128378. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  128379. */
  128380. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  128381. /** @hidden */
  128382. _createTexture(): WebGLTexture;
  128383. /** @hidden */
  128384. _releaseTexture(texture: InternalTexture): void;
  128385. /**
  128386. * Usually called from Texture.ts.
  128387. * Passed information to create a WebGLTexture
  128388. * @param urlArg defines a value which contains one of the following:
  128389. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  128390. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  128391. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  128392. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  128393. * @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)
  128394. * @param scene needed for loading to the correct scene
  128395. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  128396. * @param onLoad optional callback to be called upon successful completion
  128397. * @param onError optional callback to be called upon failure
  128398. * @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
  128399. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  128400. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  128401. * @param forcedExtension defines the extension to use to pick the right loader
  128402. * @param mimeType defines an optional mime type
  128403. * @returns a InternalTexture for assignment back into BABYLON.Texture
  128404. */
  128405. 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;
  128406. /**
  128407. * Creates a new render target texture
  128408. * @param size defines the size of the texture
  128409. * @param options defines the options used to create the texture
  128410. * @returns a new render target texture stored in an InternalTexture
  128411. */
  128412. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  128413. /**
  128414. * Update the sampling mode of a given texture
  128415. * @param samplingMode defines the required sampling mode
  128416. * @param texture defines the texture to update
  128417. */
  128418. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  128419. /**
  128420. * Binds the frame buffer to the specified texture.
  128421. * @param texture The texture to render to or null for the default canvas
  128422. * @param faceIndex The face of the texture to render to in case of cube texture
  128423. * @param requiredWidth The width of the target to render to
  128424. * @param requiredHeight The height of the target to render to
  128425. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  128426. * @param lodLevel defines le lod level to bind to the frame buffer
  128427. */
  128428. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  128429. /**
  128430. * Unbind the current render target texture from the webGL context
  128431. * @param texture defines the render target texture to unbind
  128432. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128433. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128434. */
  128435. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  128436. /**
  128437. * Creates a dynamic vertex buffer
  128438. * @param vertices the data for the dynamic vertex buffer
  128439. * @returns the new WebGL dynamic buffer
  128440. */
  128441. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  128442. /**
  128443. * Update the content of a dynamic texture
  128444. * @param texture defines the texture to update
  128445. * @param canvas defines the canvas containing the source
  128446. * @param invertY defines if data must be stored with Y axis inverted
  128447. * @param premulAlpha defines if alpha is stored as premultiplied
  128448. * @param format defines the format of the data
  128449. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  128450. */
  128451. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  128452. /**
  128453. * Gets a boolean indicating if all created effects are ready
  128454. * @returns true if all effects are ready
  128455. */
  128456. areAllEffectsReady(): boolean;
  128457. /**
  128458. * @hidden
  128459. * Get the current error code of the webGL context
  128460. * @returns the error code
  128461. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  128462. */
  128463. getError(): number;
  128464. /** @hidden */
  128465. _getUnpackAlignement(): number;
  128466. /** @hidden */
  128467. _unpackFlipY(value: boolean): void;
  128468. /**
  128469. * Update a dynamic index buffer
  128470. * @param indexBuffer defines the target index buffer
  128471. * @param indices defines the data to update
  128472. * @param offset defines the offset in the target index buffer where update should start
  128473. */
  128474. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  128475. /**
  128476. * Updates a dynamic vertex buffer.
  128477. * @param vertexBuffer the vertex buffer to update
  128478. * @param vertices the data used to update the vertex buffer
  128479. * @param byteOffset the byte offset of the data (optional)
  128480. * @param byteLength the byte length of the data (optional)
  128481. */
  128482. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  128483. /** @hidden */
  128484. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  128485. /** @hidden */
  128486. _bindTexture(channel: number, texture: InternalTexture): void;
  128487. protected _deleteBuffer(buffer: WebGLBuffer): void;
  128488. /**
  128489. * 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
  128490. */
  128491. releaseEffects(): void;
  128492. displayLoadingUI(): void;
  128493. hideLoadingUI(): void;
  128494. /** @hidden */
  128495. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128496. /** @hidden */
  128497. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128498. /** @hidden */
  128499. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  128500. /** @hidden */
  128501. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  128502. }
  128503. }
  128504. declare module BABYLON {
  128505. /**
  128506. * @hidden
  128507. **/
  128508. export class _TimeToken {
  128509. _startTimeQuery: Nullable<WebGLQuery>;
  128510. _endTimeQuery: Nullable<WebGLQuery>;
  128511. _timeElapsedQuery: Nullable<WebGLQuery>;
  128512. _timeElapsedQueryEnded: boolean;
  128513. }
  128514. }
  128515. declare module BABYLON {
  128516. /** @hidden */
  128517. export class _OcclusionDataStorage {
  128518. /** @hidden */
  128519. occlusionInternalRetryCounter: number;
  128520. /** @hidden */
  128521. isOcclusionQueryInProgress: boolean;
  128522. /** @hidden */
  128523. isOccluded: boolean;
  128524. /** @hidden */
  128525. occlusionRetryCount: number;
  128526. /** @hidden */
  128527. occlusionType: number;
  128528. /** @hidden */
  128529. occlusionQueryAlgorithmType: number;
  128530. }
  128531. interface Engine {
  128532. /**
  128533. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  128534. * @return the new query
  128535. */
  128536. createQuery(): WebGLQuery;
  128537. /**
  128538. * Delete and release a webGL query
  128539. * @param query defines the query to delete
  128540. * @return the current engine
  128541. */
  128542. deleteQuery(query: WebGLQuery): Engine;
  128543. /**
  128544. * Check if a given query has resolved and got its value
  128545. * @param query defines the query to check
  128546. * @returns true if the query got its value
  128547. */
  128548. isQueryResultAvailable(query: WebGLQuery): boolean;
  128549. /**
  128550. * Gets the value of a given query
  128551. * @param query defines the query to check
  128552. * @returns the value of the query
  128553. */
  128554. getQueryResult(query: WebGLQuery): number;
  128555. /**
  128556. * Initiates an occlusion query
  128557. * @param algorithmType defines the algorithm to use
  128558. * @param query defines the query to use
  128559. * @returns the current engine
  128560. * @see http://doc.babylonjs.com/features/occlusionquery
  128561. */
  128562. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  128563. /**
  128564. * Ends an occlusion query
  128565. * @see http://doc.babylonjs.com/features/occlusionquery
  128566. * @param algorithmType defines the algorithm to use
  128567. * @returns the current engine
  128568. */
  128569. endOcclusionQuery(algorithmType: number): Engine;
  128570. /**
  128571. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  128572. * Please note that only one query can be issued at a time
  128573. * @returns a time token used to track the time span
  128574. */
  128575. startTimeQuery(): Nullable<_TimeToken>;
  128576. /**
  128577. * Ends a time query
  128578. * @param token defines the token used to measure the time span
  128579. * @returns the time spent (in ns)
  128580. */
  128581. endTimeQuery(token: _TimeToken): int;
  128582. /** @hidden */
  128583. _currentNonTimestampToken: Nullable<_TimeToken>;
  128584. /** @hidden */
  128585. _createTimeQuery(): WebGLQuery;
  128586. /** @hidden */
  128587. _deleteTimeQuery(query: WebGLQuery): void;
  128588. /** @hidden */
  128589. _getGlAlgorithmType(algorithmType: number): number;
  128590. /** @hidden */
  128591. _getTimeQueryResult(query: WebGLQuery): any;
  128592. /** @hidden */
  128593. _getTimeQueryAvailability(query: WebGLQuery): any;
  128594. }
  128595. interface AbstractMesh {
  128596. /**
  128597. * Backing filed
  128598. * @hidden
  128599. */
  128600. __occlusionDataStorage: _OcclusionDataStorage;
  128601. /**
  128602. * Access property
  128603. * @hidden
  128604. */
  128605. _occlusionDataStorage: _OcclusionDataStorage;
  128606. /**
  128607. * 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.
  128608. * The default value is -1 which means don't break the query and wait till the result
  128609. * @see http://doc.babylonjs.com/features/occlusionquery
  128610. */
  128611. occlusionRetryCount: number;
  128612. /**
  128613. * 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:
  128614. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  128615. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  128616. * * 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.
  128617. * @see http://doc.babylonjs.com/features/occlusionquery
  128618. */
  128619. occlusionType: number;
  128620. /**
  128621. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  128622. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  128623. * * 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.
  128624. * @see http://doc.babylonjs.com/features/occlusionquery
  128625. */
  128626. occlusionQueryAlgorithmType: number;
  128627. /**
  128628. * 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
  128629. * @see http://doc.babylonjs.com/features/occlusionquery
  128630. */
  128631. isOccluded: boolean;
  128632. /**
  128633. * Flag to check the progress status of the query
  128634. * @see http://doc.babylonjs.com/features/occlusionquery
  128635. */
  128636. isOcclusionQueryInProgress: boolean;
  128637. }
  128638. }
  128639. declare module BABYLON {
  128640. /** @hidden */
  128641. export var _forceTransformFeedbackToBundle: boolean;
  128642. interface Engine {
  128643. /**
  128644. * Creates a webGL transform feedback object
  128645. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  128646. * @returns the webGL transform feedback object
  128647. */
  128648. createTransformFeedback(): WebGLTransformFeedback;
  128649. /**
  128650. * Delete a webGL transform feedback object
  128651. * @param value defines the webGL transform feedback object to delete
  128652. */
  128653. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  128654. /**
  128655. * Bind a webGL transform feedback object to the webgl context
  128656. * @param value defines the webGL transform feedback object to bind
  128657. */
  128658. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  128659. /**
  128660. * Begins a transform feedback operation
  128661. * @param usePoints defines if points or triangles must be used
  128662. */
  128663. beginTransformFeedback(usePoints: boolean): void;
  128664. /**
  128665. * Ends a transform feedback operation
  128666. */
  128667. endTransformFeedback(): void;
  128668. /**
  128669. * Specify the varyings to use with transform feedback
  128670. * @param program defines the associated webGL program
  128671. * @param value defines the list of strings representing the varying names
  128672. */
  128673. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  128674. /**
  128675. * Bind a webGL buffer for a transform feedback operation
  128676. * @param value defines the webGL buffer to bind
  128677. */
  128678. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  128679. }
  128680. }
  128681. declare module BABYLON {
  128682. /**
  128683. * Creation options of the multi render target texture.
  128684. */
  128685. export interface IMultiRenderTargetOptions {
  128686. /**
  128687. * Define if the texture needs to create mip maps after render.
  128688. */
  128689. generateMipMaps?: boolean;
  128690. /**
  128691. * Define the types of all the draw buffers we want to create
  128692. */
  128693. types?: number[];
  128694. /**
  128695. * Define the sampling modes of all the draw buffers we want to create
  128696. */
  128697. samplingModes?: number[];
  128698. /**
  128699. * Define if a depth buffer is required
  128700. */
  128701. generateDepthBuffer?: boolean;
  128702. /**
  128703. * Define if a stencil buffer is required
  128704. */
  128705. generateStencilBuffer?: boolean;
  128706. /**
  128707. * Define if a depth texture is required instead of a depth buffer
  128708. */
  128709. generateDepthTexture?: boolean;
  128710. /**
  128711. * Define the number of desired draw buffers
  128712. */
  128713. textureCount?: number;
  128714. /**
  128715. * Define if aspect ratio should be adapted to the texture or stay the scene one
  128716. */
  128717. doNotChangeAspectRatio?: boolean;
  128718. /**
  128719. * Define the default type of the buffers we are creating
  128720. */
  128721. defaultType?: number;
  128722. }
  128723. /**
  128724. * A multi render target, like a render target provides the ability to render to a texture.
  128725. * Unlike the render target, it can render to several draw buffers in one draw.
  128726. * This is specially interesting in deferred rendering or for any effects requiring more than
  128727. * just one color from a single pass.
  128728. */
  128729. export class MultiRenderTarget extends RenderTargetTexture {
  128730. private _internalTextures;
  128731. private _textures;
  128732. private _multiRenderTargetOptions;
  128733. /**
  128734. * Get if draw buffers are currently supported by the used hardware and browser.
  128735. */
  128736. get isSupported(): boolean;
  128737. /**
  128738. * Get the list of textures generated by the multi render target.
  128739. */
  128740. get textures(): Texture[];
  128741. /**
  128742. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  128743. */
  128744. get depthTexture(): Texture;
  128745. /**
  128746. * Set the wrapping mode on U of all the textures we are rendering to.
  128747. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128748. */
  128749. set wrapU(wrap: number);
  128750. /**
  128751. * Set the wrapping mode on V of all the textures we are rendering to.
  128752. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  128753. */
  128754. set wrapV(wrap: number);
  128755. /**
  128756. * Instantiate a new multi render target texture.
  128757. * A multi render target, like a render target provides the ability to render to a texture.
  128758. * Unlike the render target, it can render to several draw buffers in one draw.
  128759. * This is specially interesting in deferred rendering or for any effects requiring more than
  128760. * just one color from a single pass.
  128761. * @param name Define the name of the texture
  128762. * @param size Define the size of the buffers to render to
  128763. * @param count Define the number of target we are rendering into
  128764. * @param scene Define the scene the texture belongs to
  128765. * @param options Define the options used to create the multi render target
  128766. */
  128767. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  128768. /** @hidden */
  128769. _rebuild(): void;
  128770. private _createInternalTextures;
  128771. private _createTextures;
  128772. /**
  128773. * Define the number of samples used if MSAA is enabled.
  128774. */
  128775. get samples(): number;
  128776. set samples(value: number);
  128777. /**
  128778. * Resize all the textures in the multi render target.
  128779. * Be carrefull as it will recreate all the data in the new texture.
  128780. * @param size Define the new size
  128781. */
  128782. resize(size: any): void;
  128783. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  128784. /**
  128785. * Dispose the render targets and their associated resources
  128786. */
  128787. dispose(): void;
  128788. /**
  128789. * Release all the underlying texture used as draw buffers.
  128790. */
  128791. releaseInternalTextures(): void;
  128792. }
  128793. }
  128794. declare module BABYLON {
  128795. interface ThinEngine {
  128796. /**
  128797. * Unbind a list of render target textures from the webGL context
  128798. * This is used only when drawBuffer extension or webGL2 are active
  128799. * @param textures defines the render target textures to unbind
  128800. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  128801. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  128802. */
  128803. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  128804. /**
  128805. * Create a multi render target texture
  128806. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  128807. * @param size defines the size of the texture
  128808. * @param options defines the creation options
  128809. * @returns the cube texture as an InternalTexture
  128810. */
  128811. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  128812. /**
  128813. * Update the sample count for a given multiple render target texture
  128814. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  128815. * @param textures defines the textures to update
  128816. * @param samples defines the sample count to set
  128817. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  128818. */
  128819. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  128820. }
  128821. }
  128822. declare module BABYLON {
  128823. /**
  128824. * Class used to define an additional view for the engine
  128825. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128826. */
  128827. export class EngineView {
  128828. /** Defines the canvas where to render the view */
  128829. target: HTMLCanvasElement;
  128830. /** Defines an optional camera used to render the view (will use active camera else) */
  128831. camera?: Camera;
  128832. }
  128833. interface Engine {
  128834. /**
  128835. * Gets or sets the HTML element to use for attaching events
  128836. */
  128837. inputElement: Nullable<HTMLElement>;
  128838. /**
  128839. * Gets the current engine view
  128840. * @see https://doc.babylonjs.com/how_to/multi_canvases
  128841. */
  128842. activeView: Nullable<EngineView>;
  128843. /** Gets or sets the list of views */
  128844. views: EngineView[];
  128845. /**
  128846. * Register a new child canvas
  128847. * @param canvas defines the canvas to register
  128848. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  128849. * @returns the associated view
  128850. */
  128851. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  128852. /**
  128853. * Remove a registered child canvas
  128854. * @param canvas defines the canvas to remove
  128855. * @returns the current engine
  128856. */
  128857. unRegisterView(canvas: HTMLCanvasElement): Engine;
  128858. }
  128859. }
  128860. declare module BABYLON {
  128861. interface Engine {
  128862. /** @hidden */
  128863. _excludedCompressedTextures: string[];
  128864. /** @hidden */
  128865. _textureFormatInUse: string;
  128866. /**
  128867. * Gets the list of texture formats supported
  128868. */
  128869. readonly texturesSupported: Array<string>;
  128870. /**
  128871. * Gets the texture format in use
  128872. */
  128873. readonly textureFormatInUse: Nullable<string>;
  128874. /**
  128875. * Set the compressed texture extensions or file names to skip.
  128876. *
  128877. * @param skippedFiles defines the list of those texture files you want to skip
  128878. * Example: [".dds", ".env", "myfile.png"]
  128879. */
  128880. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  128881. /**
  128882. * Set the compressed texture format to use, based on the formats you have, and the formats
  128883. * supported by the hardware / browser.
  128884. *
  128885. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  128886. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  128887. * to API arguments needed to compressed textures. This puts the burden on the container
  128888. * generator to house the arcane code for determining these for current & future formats.
  128889. *
  128890. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  128891. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  128892. *
  128893. * Note: The result of this call is not taken into account when a texture is base64.
  128894. *
  128895. * @param formatsAvailable defines the list of those format families you have created
  128896. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  128897. *
  128898. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  128899. * @returns The extension selected.
  128900. */
  128901. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  128902. }
  128903. }
  128904. declare module BABYLON {
  128905. /**
  128906. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  128907. */
  128908. export interface CubeMapInfo {
  128909. /**
  128910. * The pixel array for the front face.
  128911. * This is stored in format, left to right, up to down format.
  128912. */
  128913. front: Nullable<ArrayBufferView>;
  128914. /**
  128915. * The pixel array for the back face.
  128916. * This is stored in format, left to right, up to down format.
  128917. */
  128918. back: Nullable<ArrayBufferView>;
  128919. /**
  128920. * The pixel array for the left face.
  128921. * This is stored in format, left to right, up to down format.
  128922. */
  128923. left: Nullable<ArrayBufferView>;
  128924. /**
  128925. * The pixel array for the right face.
  128926. * This is stored in format, left to right, up to down format.
  128927. */
  128928. right: Nullable<ArrayBufferView>;
  128929. /**
  128930. * The pixel array for the up face.
  128931. * This is stored in format, left to right, up to down format.
  128932. */
  128933. up: Nullable<ArrayBufferView>;
  128934. /**
  128935. * The pixel array for the down face.
  128936. * This is stored in format, left to right, up to down format.
  128937. */
  128938. down: Nullable<ArrayBufferView>;
  128939. /**
  128940. * The size of the cubemap stored.
  128941. *
  128942. * Each faces will be size * size pixels.
  128943. */
  128944. size: number;
  128945. /**
  128946. * The format of the texture.
  128947. *
  128948. * RGBA, RGB.
  128949. */
  128950. format: number;
  128951. /**
  128952. * The type of the texture data.
  128953. *
  128954. * UNSIGNED_INT, FLOAT.
  128955. */
  128956. type: number;
  128957. /**
  128958. * Specifies whether the texture is in gamma space.
  128959. */
  128960. gammaSpace: boolean;
  128961. }
  128962. /**
  128963. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  128964. */
  128965. export class PanoramaToCubeMapTools {
  128966. private static FACE_LEFT;
  128967. private static FACE_RIGHT;
  128968. private static FACE_FRONT;
  128969. private static FACE_BACK;
  128970. private static FACE_DOWN;
  128971. private static FACE_UP;
  128972. /**
  128973. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  128974. *
  128975. * @param float32Array The source data.
  128976. * @param inputWidth The width of the input panorama.
  128977. * @param inputHeight The height of the input panorama.
  128978. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  128979. * @return The cubemap data
  128980. */
  128981. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  128982. private static CreateCubemapTexture;
  128983. private static CalcProjectionSpherical;
  128984. }
  128985. }
  128986. declare module BABYLON {
  128987. /**
  128988. * Helper class dealing with the extraction of spherical polynomial dataArray
  128989. * from a cube map.
  128990. */
  128991. export class CubeMapToSphericalPolynomialTools {
  128992. private static FileFaces;
  128993. /**
  128994. * Converts a texture to the according Spherical Polynomial data.
  128995. * This extracts the first 3 orders only as they are the only one used in the lighting.
  128996. *
  128997. * @param texture The texture to extract the information from.
  128998. * @return The Spherical Polynomial data.
  128999. */
  129000. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129001. /**
  129002. * Converts a cubemap to the according Spherical Polynomial data.
  129003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129004. *
  129005. * @param cubeInfo The Cube map to extract the information from.
  129006. * @return The Spherical Polynomial data.
  129007. */
  129008. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129009. }
  129010. }
  129011. declare module BABYLON {
  129012. interface BaseTexture {
  129013. /**
  129014. * Get the polynomial representation of the texture data.
  129015. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129016. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129017. */
  129018. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129019. }
  129020. }
  129021. declare module BABYLON {
  129022. /** @hidden */
  129023. export var rgbdEncodePixelShader: {
  129024. name: string;
  129025. shader: string;
  129026. };
  129027. }
  129028. declare module BABYLON {
  129029. /** @hidden */
  129030. export var rgbdDecodePixelShader: {
  129031. name: string;
  129032. shader: string;
  129033. };
  129034. }
  129035. declare module BABYLON {
  129036. /**
  129037. * Raw texture data and descriptor sufficient for WebGL texture upload
  129038. */
  129039. export interface EnvironmentTextureInfo {
  129040. /**
  129041. * Version of the environment map
  129042. */
  129043. version: number;
  129044. /**
  129045. * Width of image
  129046. */
  129047. width: number;
  129048. /**
  129049. * Irradiance information stored in the file.
  129050. */
  129051. irradiance: any;
  129052. /**
  129053. * Specular information stored in the file.
  129054. */
  129055. specular: any;
  129056. }
  129057. /**
  129058. * Defines One Image in the file. It requires only the position in the file
  129059. * as well as the length.
  129060. */
  129061. interface BufferImageData {
  129062. /**
  129063. * Length of the image data.
  129064. */
  129065. length: number;
  129066. /**
  129067. * Position of the data from the null terminator delimiting the end of the JSON.
  129068. */
  129069. position: number;
  129070. }
  129071. /**
  129072. * Defines the specular data enclosed in the file.
  129073. * This corresponds to the version 1 of the data.
  129074. */
  129075. export interface EnvironmentTextureSpecularInfoV1 {
  129076. /**
  129077. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129078. */
  129079. specularDataPosition?: number;
  129080. /**
  129081. * This contains all the images data needed to reconstruct the cubemap.
  129082. */
  129083. mipmaps: Array<BufferImageData>;
  129084. /**
  129085. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129086. */
  129087. lodGenerationScale: number;
  129088. }
  129089. /**
  129090. * Sets of helpers addressing the serialization and deserialization of environment texture
  129091. * stored in a BabylonJS env file.
  129092. * Those files are usually stored as .env files.
  129093. */
  129094. export class EnvironmentTextureTools {
  129095. /**
  129096. * Magic number identifying the env file.
  129097. */
  129098. private static _MagicBytes;
  129099. /**
  129100. * Gets the environment info from an env file.
  129101. * @param data The array buffer containing the .env bytes.
  129102. * @returns the environment file info (the json header) if successfully parsed.
  129103. */
  129104. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  129105. /**
  129106. * Creates an environment texture from a loaded cube texture.
  129107. * @param texture defines the cube texture to convert in env file
  129108. * @return a promise containing the environment data if succesfull.
  129109. */
  129110. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  129111. /**
  129112. * Creates a JSON representation of the spherical data.
  129113. * @param texture defines the texture containing the polynomials
  129114. * @return the JSON representation of the spherical info
  129115. */
  129116. private static _CreateEnvTextureIrradiance;
  129117. /**
  129118. * Creates the ArrayBufferViews used for initializing environment texture image data.
  129119. * @param data the image data
  129120. * @param info parameters that determine what views will be created for accessing the underlying buffer
  129121. * @return the views described by info providing access to the underlying buffer
  129122. */
  129123. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  129124. /**
  129125. * Uploads the texture info contained in the env file to the GPU.
  129126. * @param texture defines the internal texture to upload to
  129127. * @param data defines the data to load
  129128. * @param info defines the texture info retrieved through the GetEnvInfo method
  129129. * @returns a promise
  129130. */
  129131. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  129132. private static _OnImageReadyAsync;
  129133. /**
  129134. * Uploads the levels of image data to the GPU.
  129135. * @param texture defines the internal texture to upload to
  129136. * @param imageData defines the array buffer views of image data [mipmap][face]
  129137. * @returns a promise
  129138. */
  129139. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  129140. /**
  129141. * Uploads spherical polynomials information to the texture.
  129142. * @param texture defines the texture we are trying to upload the information to
  129143. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  129144. */
  129145. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  129146. /** @hidden */
  129147. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129148. }
  129149. }
  129150. declare module BABYLON {
  129151. /** @hidden */
  129152. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  129153. private _genericAttributeLocation;
  129154. private _varyingLocationCount;
  129155. private _varyingLocationMap;
  129156. private _replacements;
  129157. private _textureCount;
  129158. private _uniforms;
  129159. lineProcessor(line: string): string;
  129160. attributeProcessor(attribute: string): string;
  129161. varyingProcessor(varying: string, isFragment: boolean): string;
  129162. uniformProcessor(uniform: string): string;
  129163. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  129164. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  129165. }
  129166. }
  129167. declare module BABYLON {
  129168. /**
  129169. * Class used to inline functions in shader code
  129170. */
  129171. export class ShaderCodeInliner {
  129172. private static readonly _RegexpFindFunctionNameAndType;
  129173. private _sourceCode;
  129174. private _functionDescr;
  129175. private _numMaxIterations;
  129176. /** Gets or sets the token used to mark the functions to inline */
  129177. inlineToken: string;
  129178. /** Gets or sets the debug mode */
  129179. debug: boolean;
  129180. /** Gets the code after the inlining process */
  129181. get code(): string;
  129182. /**
  129183. * Initializes the inliner
  129184. * @param sourceCode shader code source to inline
  129185. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  129186. */
  129187. constructor(sourceCode: string, numMaxIterations?: number);
  129188. /**
  129189. * Start the processing of the shader code
  129190. */
  129191. processCode(): void;
  129192. private _collectFunctions;
  129193. private _processInlining;
  129194. private _extractBetweenMarkers;
  129195. private _skipWhitespaces;
  129196. private _removeComments;
  129197. private _replaceFunctionCallsByCode;
  129198. private _findBackward;
  129199. private _escapeRegExp;
  129200. private _replaceNames;
  129201. }
  129202. }
  129203. declare module BABYLON {
  129204. /**
  129205. * Container for accessors for natively-stored mesh data buffers.
  129206. */
  129207. class NativeDataBuffer extends DataBuffer {
  129208. /**
  129209. * Accessor value used to identify/retrieve a natively-stored index buffer.
  129210. */
  129211. nativeIndexBuffer?: any;
  129212. /**
  129213. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  129214. */
  129215. nativeVertexBuffer?: any;
  129216. }
  129217. /** @hidden */
  129218. class NativeTexture extends InternalTexture {
  129219. getInternalTexture(): InternalTexture;
  129220. getViewCount(): number;
  129221. }
  129222. /** @hidden */
  129223. export class NativeEngine extends Engine {
  129224. private readonly _native;
  129225. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  129226. private readonly INVALID_HANDLE;
  129227. getHardwareScalingLevel(): number;
  129228. constructor();
  129229. dispose(): void;
  129230. /**
  129231. * Can be used to override the current requestAnimationFrame requester.
  129232. * @hidden
  129233. */
  129234. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  129235. /**
  129236. * Override default engine behavior.
  129237. * @param color
  129238. * @param backBuffer
  129239. * @param depth
  129240. * @param stencil
  129241. */
  129242. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  129243. /**
  129244. * Gets host document
  129245. * @returns the host document object
  129246. */
  129247. getHostDocument(): Nullable<Document>;
  129248. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129249. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  129250. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  129251. recordVertexArrayObject(vertexBuffers: {
  129252. [key: string]: VertexBuffer;
  129253. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  129254. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129255. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  129256. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129257. /**
  129258. * Draw a list of indexed primitives
  129259. * @param fillMode defines the primitive to use
  129260. * @param indexStart defines the starting index
  129261. * @param indexCount defines the number of index to draw
  129262. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129263. */
  129264. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129265. /**
  129266. * Draw a list of unindexed primitives
  129267. * @param fillMode defines the primitive to use
  129268. * @param verticesStart defines the index of first vertex to draw
  129269. * @param verticesCount defines the count of vertices to draw
  129270. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129271. */
  129272. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129273. createPipelineContext(): IPipelineContext;
  129274. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  129275. /** @hidden */
  129276. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  129277. /** @hidden */
  129278. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  129279. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129280. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  129281. protected _setProgram(program: WebGLProgram): void;
  129282. _releaseEffect(effect: Effect): void;
  129283. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  129284. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  129285. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  129286. bindSamplers(effect: Effect): void;
  129287. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  129288. getRenderWidth(useScreen?: boolean): number;
  129289. getRenderHeight(useScreen?: boolean): number;
  129290. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  129291. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129292. /**
  129293. * Set the z offset to apply to current rendering
  129294. * @param value defines the offset to apply
  129295. */
  129296. setZOffset(value: number): void;
  129297. /**
  129298. * Gets the current value of the zOffset
  129299. * @returns the current zOffset state
  129300. */
  129301. getZOffset(): number;
  129302. /**
  129303. * Enable or disable depth buffering
  129304. * @param enable defines the state to set
  129305. */
  129306. setDepthBuffer(enable: boolean): void;
  129307. /**
  129308. * Gets a boolean indicating if depth writing is enabled
  129309. * @returns the current depth writing state
  129310. */
  129311. getDepthWrite(): boolean;
  129312. /**
  129313. * Enable or disable depth writing
  129314. * @param enable defines the state to set
  129315. */
  129316. setDepthWrite(enable: boolean): void;
  129317. /**
  129318. * Enable or disable color writing
  129319. * @param enable defines the state to set
  129320. */
  129321. setColorWrite(enable: boolean): void;
  129322. /**
  129323. * Gets a boolean indicating if color writing is enabled
  129324. * @returns the current color writing state
  129325. */
  129326. getColorWrite(): boolean;
  129327. /**
  129328. * Sets alpha constants used by some alpha blending modes
  129329. * @param r defines the red component
  129330. * @param g defines the green component
  129331. * @param b defines the blue component
  129332. * @param a defines the alpha component
  129333. */
  129334. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  129335. /**
  129336. * Sets the current alpha mode
  129337. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  129338. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129339. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129340. */
  129341. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129342. /**
  129343. * Gets the current alpha mode
  129344. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129345. * @returns the current alpha mode
  129346. */
  129347. getAlphaMode(): number;
  129348. setInt(uniform: WebGLUniformLocation, int: number): void;
  129349. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  129350. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  129351. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  129352. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  129353. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  129354. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  129355. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  129356. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  129357. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  129358. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  129359. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  129360. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  129361. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  129362. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129363. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129364. setFloat(uniform: WebGLUniformLocation, value: number): void;
  129365. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  129366. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129367. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129368. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  129369. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  129370. wipeCaches(bruteForce?: boolean): void;
  129371. _createTexture(): WebGLTexture;
  129372. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  129373. /**
  129374. * Usually called from Texture.ts.
  129375. * Passed information to create a WebGLTexture
  129376. * @param url defines a value which contains one of the following:
  129377. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129378. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129379. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129380. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129381. * @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)
  129382. * @param scene needed for loading to the correct scene
  129383. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129384. * @param onLoad optional callback to be called upon successful completion
  129385. * @param onError optional callback to be called upon failure
  129386. * @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
  129387. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129388. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129389. * @param forcedExtension defines the extension to use to pick the right loader
  129390. * @param mimeType defines an optional mime type
  129391. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129392. */
  129393. 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;
  129394. /**
  129395. * Creates a cube texture
  129396. * @param rootUrl defines the url where the files to load is located
  129397. * @param scene defines the current scene
  129398. * @param files defines the list of files to load (1 per face)
  129399. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  129400. * @param onLoad defines an optional callback raised when the texture is loaded
  129401. * @param onError defines an optional callback raised if there is an issue to load the texture
  129402. * @param format defines the format of the data
  129403. * @param forcedExtension defines the extension to use to pick the right loader
  129404. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  129405. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129406. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129407. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  129408. * @returns the cube texture as an InternalTexture
  129409. */
  129410. 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;
  129411. private _getSamplingFilter;
  129412. private static _GetNativeTextureFormat;
  129413. createRenderTargetTexture(size: number | {
  129414. width: number;
  129415. height: number;
  129416. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  129417. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129418. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129419. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129420. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  129421. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  129422. /**
  129423. * Updates a dynamic vertex buffer.
  129424. * @param vertexBuffer the vertex buffer to update
  129425. * @param data the data used to update the vertex buffer
  129426. * @param byteOffset the byte offset of the data (optional)
  129427. * @param byteLength the byte length of the data (optional)
  129428. */
  129429. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  129430. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  129431. private _updateAnisotropicLevel;
  129432. private _getAddressMode;
  129433. /** @hidden */
  129434. _bindTexture(channel: number, texture: InternalTexture): void;
  129435. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  129436. releaseEffects(): void;
  129437. /** @hidden */
  129438. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129439. /** @hidden */
  129440. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129441. /** @hidden */
  129442. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129443. /** @hidden */
  129444. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129445. }
  129446. }
  129447. declare module BABYLON {
  129448. /**
  129449. * Gather the list of clipboard event types as constants.
  129450. */
  129451. export class ClipboardEventTypes {
  129452. /**
  129453. * The clipboard event is fired when a copy command is active (pressed).
  129454. */
  129455. static readonly COPY: number;
  129456. /**
  129457. * The clipboard event is fired when a cut command is active (pressed).
  129458. */
  129459. static readonly CUT: number;
  129460. /**
  129461. * The clipboard event is fired when a paste command is active (pressed).
  129462. */
  129463. static readonly PASTE: number;
  129464. }
  129465. /**
  129466. * This class is used to store clipboard related info for the onClipboardObservable event.
  129467. */
  129468. export class ClipboardInfo {
  129469. /**
  129470. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129471. */
  129472. type: number;
  129473. /**
  129474. * Defines the related dom event
  129475. */
  129476. event: ClipboardEvent;
  129477. /**
  129478. *Creates an instance of ClipboardInfo.
  129479. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  129480. * @param event Defines the related dom event
  129481. */
  129482. constructor(
  129483. /**
  129484. * Defines the type of event (BABYLON.ClipboardEventTypes)
  129485. */
  129486. type: number,
  129487. /**
  129488. * Defines the related dom event
  129489. */
  129490. event: ClipboardEvent);
  129491. /**
  129492. * Get the clipboard event's type from the keycode.
  129493. * @param keyCode Defines the keyCode for the current keyboard event.
  129494. * @return {number}
  129495. */
  129496. static GetTypeFromCharacter(keyCode: number): number;
  129497. }
  129498. }
  129499. declare module BABYLON {
  129500. /**
  129501. * Google Daydream controller
  129502. */
  129503. export class DaydreamController extends WebVRController {
  129504. /**
  129505. * Base Url for the controller model.
  129506. */
  129507. static MODEL_BASE_URL: string;
  129508. /**
  129509. * File name for the controller model.
  129510. */
  129511. static MODEL_FILENAME: string;
  129512. /**
  129513. * Gamepad Id prefix used to identify Daydream Controller.
  129514. */
  129515. static readonly GAMEPAD_ID_PREFIX: string;
  129516. /**
  129517. * Creates a new DaydreamController from a gamepad
  129518. * @param vrGamepad the gamepad that the controller should be created from
  129519. */
  129520. constructor(vrGamepad: any);
  129521. /**
  129522. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129523. * @param scene scene in which to add meshes
  129524. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129525. */
  129526. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129527. /**
  129528. * Called once for each button that changed state since the last frame
  129529. * @param buttonIdx Which button index changed
  129530. * @param state New state of the button
  129531. * @param changes Which properties on the state changed since last frame
  129532. */
  129533. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129534. }
  129535. }
  129536. declare module BABYLON {
  129537. /**
  129538. * Gear VR Controller
  129539. */
  129540. export class GearVRController extends WebVRController {
  129541. /**
  129542. * Base Url for the controller model.
  129543. */
  129544. static MODEL_BASE_URL: string;
  129545. /**
  129546. * File name for the controller model.
  129547. */
  129548. static MODEL_FILENAME: string;
  129549. /**
  129550. * Gamepad Id prefix used to identify this controller.
  129551. */
  129552. static readonly GAMEPAD_ID_PREFIX: string;
  129553. private readonly _buttonIndexToObservableNameMap;
  129554. /**
  129555. * Creates a new GearVRController from a gamepad
  129556. * @param vrGamepad the gamepad that the controller should be created from
  129557. */
  129558. constructor(vrGamepad: any);
  129559. /**
  129560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129561. * @param scene scene in which to add meshes
  129562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129563. */
  129564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129565. /**
  129566. * Called once for each button that changed state since the last frame
  129567. * @param buttonIdx Which button index changed
  129568. * @param state New state of the button
  129569. * @param changes Which properties on the state changed since last frame
  129570. */
  129571. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129572. }
  129573. }
  129574. declare module BABYLON {
  129575. /**
  129576. * Generic Controller
  129577. */
  129578. export class GenericController extends WebVRController {
  129579. /**
  129580. * Base Url for the controller model.
  129581. */
  129582. static readonly MODEL_BASE_URL: string;
  129583. /**
  129584. * File name for the controller model.
  129585. */
  129586. static readonly MODEL_FILENAME: string;
  129587. /**
  129588. * Creates a new GenericController from a gamepad
  129589. * @param vrGamepad the gamepad that the controller should be created from
  129590. */
  129591. constructor(vrGamepad: any);
  129592. /**
  129593. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129594. * @param scene scene in which to add meshes
  129595. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129596. */
  129597. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129598. /**
  129599. * Called once for each button that changed state since the last frame
  129600. * @param buttonIdx Which button index changed
  129601. * @param state New state of the button
  129602. * @param changes Which properties on the state changed since last frame
  129603. */
  129604. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129605. }
  129606. }
  129607. declare module BABYLON {
  129608. /**
  129609. * Oculus Touch Controller
  129610. */
  129611. export class OculusTouchController extends WebVRController {
  129612. /**
  129613. * Base Url for the controller model.
  129614. */
  129615. static MODEL_BASE_URL: string;
  129616. /**
  129617. * File name for the left controller model.
  129618. */
  129619. static MODEL_LEFT_FILENAME: string;
  129620. /**
  129621. * File name for the right controller model.
  129622. */
  129623. static MODEL_RIGHT_FILENAME: string;
  129624. /**
  129625. * Base Url for the Quest controller model.
  129626. */
  129627. static QUEST_MODEL_BASE_URL: string;
  129628. /**
  129629. * @hidden
  129630. * If the controllers are running on a device that needs the updated Quest controller models
  129631. */
  129632. static _IsQuest: boolean;
  129633. /**
  129634. * Fired when the secondary trigger on this controller is modified
  129635. */
  129636. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  129637. /**
  129638. * Fired when the thumb rest on this controller is modified
  129639. */
  129640. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  129641. /**
  129642. * Creates a new OculusTouchController from a gamepad
  129643. * @param vrGamepad the gamepad that the controller should be created from
  129644. */
  129645. constructor(vrGamepad: any);
  129646. /**
  129647. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129648. * @param scene scene in which to add meshes
  129649. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129650. */
  129651. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129652. /**
  129653. * Fired when the A button on this controller is modified
  129654. */
  129655. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129656. /**
  129657. * Fired when the B button on this controller is modified
  129658. */
  129659. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129660. /**
  129661. * Fired when the X button on this controller is modified
  129662. */
  129663. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129664. /**
  129665. * Fired when the Y button on this controller is modified
  129666. */
  129667. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129668. /**
  129669. * Called once for each button that changed state since the last frame
  129670. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  129671. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  129672. * 2) secondary trigger (same)
  129673. * 3) A (right) X (left), touch, pressed = value
  129674. * 4) B / Y
  129675. * 5) thumb rest
  129676. * @param buttonIdx Which button index changed
  129677. * @param state New state of the button
  129678. * @param changes Which properties on the state changed since last frame
  129679. */
  129680. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129681. }
  129682. }
  129683. declare module BABYLON {
  129684. /**
  129685. * Vive Controller
  129686. */
  129687. export class ViveController extends WebVRController {
  129688. /**
  129689. * Base Url for the controller model.
  129690. */
  129691. static MODEL_BASE_URL: string;
  129692. /**
  129693. * File name for the controller model.
  129694. */
  129695. static MODEL_FILENAME: string;
  129696. /**
  129697. * Creates a new ViveController from a gamepad
  129698. * @param vrGamepad the gamepad that the controller should be created from
  129699. */
  129700. constructor(vrGamepad: any);
  129701. /**
  129702. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129703. * @param scene scene in which to add meshes
  129704. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129705. */
  129706. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  129707. /**
  129708. * Fired when the left button on this controller is modified
  129709. */
  129710. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129711. /**
  129712. * Fired when the right button on this controller is modified
  129713. */
  129714. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129715. /**
  129716. * Fired when the menu button on this controller is modified
  129717. */
  129718. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129719. /**
  129720. * Called once for each button that changed state since the last frame
  129721. * Vive mapping:
  129722. * 0: touchpad
  129723. * 1: trigger
  129724. * 2: left AND right buttons
  129725. * 3: menu button
  129726. * @param buttonIdx Which button index changed
  129727. * @param state New state of the button
  129728. * @param changes Which properties on the state changed since last frame
  129729. */
  129730. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129731. }
  129732. }
  129733. declare module BABYLON {
  129734. /**
  129735. * Defines the WindowsMotionController object that the state of the windows motion controller
  129736. */
  129737. export class WindowsMotionController extends WebVRController {
  129738. /**
  129739. * The base url used to load the left and right controller models
  129740. */
  129741. static MODEL_BASE_URL: string;
  129742. /**
  129743. * The name of the left controller model file
  129744. */
  129745. static MODEL_LEFT_FILENAME: string;
  129746. /**
  129747. * The name of the right controller model file
  129748. */
  129749. static MODEL_RIGHT_FILENAME: string;
  129750. /**
  129751. * The controller name prefix for this controller type
  129752. */
  129753. static readonly GAMEPAD_ID_PREFIX: string;
  129754. /**
  129755. * The controller id pattern for this controller type
  129756. */
  129757. private static readonly GAMEPAD_ID_PATTERN;
  129758. private _loadedMeshInfo;
  129759. protected readonly _mapping: {
  129760. buttons: string[];
  129761. buttonMeshNames: {
  129762. trigger: string;
  129763. menu: string;
  129764. grip: string;
  129765. thumbstick: string;
  129766. trackpad: string;
  129767. };
  129768. buttonObservableNames: {
  129769. trigger: string;
  129770. menu: string;
  129771. grip: string;
  129772. thumbstick: string;
  129773. trackpad: string;
  129774. };
  129775. axisMeshNames: string[];
  129776. pointingPoseMeshName: string;
  129777. };
  129778. /**
  129779. * Fired when the trackpad on this controller is clicked
  129780. */
  129781. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129782. /**
  129783. * Fired when the trackpad on this controller is modified
  129784. */
  129785. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129786. /**
  129787. * The current x and y values of this controller's trackpad
  129788. */
  129789. trackpad: StickValues;
  129790. /**
  129791. * Creates a new WindowsMotionController from a gamepad
  129792. * @param vrGamepad the gamepad that the controller should be created from
  129793. */
  129794. constructor(vrGamepad: any);
  129795. /**
  129796. * Fired when the trigger on this controller is modified
  129797. */
  129798. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129799. /**
  129800. * Fired when the menu button on this controller is modified
  129801. */
  129802. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129803. /**
  129804. * Fired when the grip button on this controller is modified
  129805. */
  129806. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129807. /**
  129808. * Fired when the thumbstick button on this controller is modified
  129809. */
  129810. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129811. /**
  129812. * Fired when the touchpad button on this controller is modified
  129813. */
  129814. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129815. /**
  129816. * Fired when the touchpad values on this controller are modified
  129817. */
  129818. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  129819. protected _updateTrackpad(): void;
  129820. /**
  129821. * Called once per frame by the engine.
  129822. */
  129823. update(): void;
  129824. /**
  129825. * Called once for each button that changed state since the last frame
  129826. * @param buttonIdx Which button index changed
  129827. * @param state New state of the button
  129828. * @param changes Which properties on the state changed since last frame
  129829. */
  129830. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  129831. /**
  129832. * Moves the buttons on the controller mesh based on their current state
  129833. * @param buttonName the name of the button to move
  129834. * @param buttonValue the value of the button which determines the buttons new position
  129835. */
  129836. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  129837. /**
  129838. * Moves the axis on the controller mesh based on its current state
  129839. * @param axis the index of the axis
  129840. * @param axisValue the value of the axis which determines the meshes new position
  129841. * @hidden
  129842. */
  129843. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  129844. /**
  129845. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  129846. * @param scene scene in which to add meshes
  129847. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  129848. */
  129849. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  129850. /**
  129851. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  129852. * can be transformed by button presses and axes values, based on this._mapping.
  129853. *
  129854. * @param scene scene in which the meshes exist
  129855. * @param meshes list of meshes that make up the controller model to process
  129856. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  129857. */
  129858. private processModel;
  129859. private createMeshInfo;
  129860. /**
  129861. * Gets the ray of the controller in the direction the controller is pointing
  129862. * @param length the length the resulting ray should be
  129863. * @returns a ray in the direction the controller is pointing
  129864. */
  129865. getForwardRay(length?: number): Ray;
  129866. /**
  129867. * Disposes of the controller
  129868. */
  129869. dispose(): void;
  129870. }
  129871. /**
  129872. * This class represents a new windows motion controller in XR.
  129873. */
  129874. export class XRWindowsMotionController extends WindowsMotionController {
  129875. /**
  129876. * Changing the original WIndowsMotionController mapping to fir the new mapping
  129877. */
  129878. protected readonly _mapping: {
  129879. buttons: string[];
  129880. buttonMeshNames: {
  129881. trigger: string;
  129882. menu: string;
  129883. grip: string;
  129884. thumbstick: string;
  129885. trackpad: string;
  129886. };
  129887. buttonObservableNames: {
  129888. trigger: string;
  129889. menu: string;
  129890. grip: string;
  129891. thumbstick: string;
  129892. trackpad: string;
  129893. };
  129894. axisMeshNames: string[];
  129895. pointingPoseMeshName: string;
  129896. };
  129897. /**
  129898. * Construct a new XR-Based windows motion controller
  129899. *
  129900. * @param gamepadInfo the gamepad object from the browser
  129901. */
  129902. constructor(gamepadInfo: any);
  129903. /**
  129904. * holds the thumbstick values (X,Y)
  129905. */
  129906. thumbstickValues: StickValues;
  129907. /**
  129908. * Fired when the thumbstick on this controller is clicked
  129909. */
  129910. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  129911. /**
  129912. * Fired when the thumbstick on this controller is modified
  129913. */
  129914. onThumbstickValuesChangedObservable: Observable<StickValues>;
  129915. /**
  129916. * Fired when the touchpad button on this controller is modified
  129917. */
  129918. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  129919. /**
  129920. * Fired when the touchpad values on this controller are modified
  129921. */
  129922. onTrackpadValuesChangedObservable: Observable<StickValues>;
  129923. /**
  129924. * Fired when the thumbstick button on this controller is modified
  129925. * here to prevent breaking changes
  129926. */
  129927. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  129928. /**
  129929. * updating the thumbstick(!) and not the trackpad.
  129930. * This is named this way due to the difference between WebVR and XR and to avoid
  129931. * changing the parent class.
  129932. */
  129933. protected _updateTrackpad(): void;
  129934. /**
  129935. * Disposes the class with joy
  129936. */
  129937. dispose(): void;
  129938. }
  129939. }
  129940. declare module BABYLON {
  129941. /**
  129942. * Class containing static functions to help procedurally build meshes
  129943. */
  129944. export class PolyhedronBuilder {
  129945. /**
  129946. * Creates a polyhedron mesh
  129947. * * 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
  129948. * * The parameter `size` (positive float, default 1) sets the polygon size
  129949. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  129950. * * 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`
  129951. * * 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
  129952. * * 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)`)
  129953. * * 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
  129954. * * 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
  129955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129958. * @param name defines the name of the mesh
  129959. * @param options defines the options used to create the mesh
  129960. * @param scene defines the hosting scene
  129961. * @returns the polyhedron mesh
  129962. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  129963. */
  129964. static CreatePolyhedron(name: string, options: {
  129965. type?: number;
  129966. size?: number;
  129967. sizeX?: number;
  129968. sizeY?: number;
  129969. sizeZ?: number;
  129970. custom?: any;
  129971. faceUV?: Vector4[];
  129972. faceColors?: Color4[];
  129973. flat?: boolean;
  129974. updatable?: boolean;
  129975. sideOrientation?: number;
  129976. frontUVs?: Vector4;
  129977. backUVs?: Vector4;
  129978. }, scene?: Nullable<Scene>): Mesh;
  129979. }
  129980. }
  129981. declare module BABYLON {
  129982. /**
  129983. * Gizmo that enables scaling a mesh along 3 axis
  129984. */
  129985. export class ScaleGizmo extends Gizmo {
  129986. /**
  129987. * Internal gizmo used for interactions on the x axis
  129988. */
  129989. xGizmo: AxisScaleGizmo;
  129990. /**
  129991. * Internal gizmo used for interactions on the y axis
  129992. */
  129993. yGizmo: AxisScaleGizmo;
  129994. /**
  129995. * Internal gizmo used for interactions on the z axis
  129996. */
  129997. zGizmo: AxisScaleGizmo;
  129998. /**
  129999. * Internal gizmo used to scale all axis equally
  130000. */
  130001. uniformScaleGizmo: AxisScaleGizmo;
  130002. private _meshAttached;
  130003. private _updateGizmoRotationToMatchAttachedMesh;
  130004. private _snapDistance;
  130005. private _scaleRatio;
  130006. private _uniformScalingMesh;
  130007. private _octahedron;
  130008. private _sensitivity;
  130009. /** Fires an event when any of it's sub gizmos are dragged */
  130010. onDragStartObservable: Observable<unknown>;
  130011. /** Fires an event when any of it's sub gizmos are released from dragging */
  130012. onDragEndObservable: Observable<unknown>;
  130013. get attachedMesh(): Nullable<AbstractMesh>;
  130014. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130015. /**
  130016. * Creates a ScaleGizmo
  130017. * @param gizmoLayer The utility layer the gizmo will be added to
  130018. */
  130019. constructor(gizmoLayer?: UtilityLayerRenderer);
  130020. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130021. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130022. /**
  130023. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130024. */
  130025. set snapDistance(value: number);
  130026. get snapDistance(): number;
  130027. /**
  130028. * Ratio for the scale of the gizmo (Default: 1)
  130029. */
  130030. set scaleRatio(value: number);
  130031. get scaleRatio(): number;
  130032. /**
  130033. * Sensitivity factor for dragging (Default: 1)
  130034. */
  130035. set sensitivity(value: number);
  130036. get sensitivity(): number;
  130037. /**
  130038. * Disposes of the gizmo
  130039. */
  130040. dispose(): void;
  130041. }
  130042. }
  130043. declare module BABYLON {
  130044. /**
  130045. * Single axis scale gizmo
  130046. */
  130047. export class AxisScaleGizmo extends Gizmo {
  130048. /**
  130049. * Drag behavior responsible for the gizmos dragging interactions
  130050. */
  130051. dragBehavior: PointerDragBehavior;
  130052. private _pointerObserver;
  130053. /**
  130054. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130055. */
  130056. snapDistance: number;
  130057. /**
  130058. * Event that fires each time the gizmo snaps to a new location.
  130059. * * snapDistance is the the change in distance
  130060. */
  130061. onSnapObservable: Observable<{
  130062. snapDistance: number;
  130063. }>;
  130064. /**
  130065. * If the scaling operation should be done on all axis (default: false)
  130066. */
  130067. uniformScaling: boolean;
  130068. /**
  130069. * Custom sensitivity value for the drag strength
  130070. */
  130071. sensitivity: number;
  130072. private _isEnabled;
  130073. private _parent;
  130074. private _arrow;
  130075. private _coloredMaterial;
  130076. private _hoverMaterial;
  130077. /**
  130078. * Creates an AxisScaleGizmo
  130079. * @param gizmoLayer The utility layer the gizmo will be added to
  130080. * @param dragAxis The axis which the gizmo will be able to scale on
  130081. * @param color The color of the gizmo
  130082. */
  130083. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130084. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130085. /**
  130086. * If the gizmo is enabled
  130087. */
  130088. set isEnabled(value: boolean);
  130089. get isEnabled(): boolean;
  130090. /**
  130091. * Disposes of the gizmo
  130092. */
  130093. dispose(): void;
  130094. /**
  130095. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130096. * @param mesh The mesh to replace the default mesh of the gizmo
  130097. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130098. */
  130099. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130100. }
  130101. }
  130102. declare module BABYLON {
  130103. /**
  130104. * Bounding box gizmo
  130105. */
  130106. export class BoundingBoxGizmo extends Gizmo {
  130107. private _lineBoundingBox;
  130108. private _rotateSpheresParent;
  130109. private _scaleBoxesParent;
  130110. private _boundingDimensions;
  130111. private _renderObserver;
  130112. private _pointerObserver;
  130113. private _scaleDragSpeed;
  130114. private _tmpQuaternion;
  130115. private _tmpVector;
  130116. private _tmpRotationMatrix;
  130117. /**
  130118. * 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)
  130119. */
  130120. ignoreChildren: boolean;
  130121. /**
  130122. * 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)
  130123. */
  130124. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  130125. /**
  130126. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  130127. */
  130128. rotationSphereSize: number;
  130129. /**
  130130. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  130131. */
  130132. scaleBoxSize: number;
  130133. /**
  130134. * 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)
  130135. */
  130136. fixedDragMeshScreenSize: boolean;
  130137. /**
  130138. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  130139. */
  130140. fixedDragMeshScreenSizeDistanceFactor: number;
  130141. /**
  130142. * Fired when a rotation sphere or scale box is dragged
  130143. */
  130144. onDragStartObservable: Observable<{}>;
  130145. /**
  130146. * Fired when a scale box is dragged
  130147. */
  130148. onScaleBoxDragObservable: Observable<{}>;
  130149. /**
  130150. * Fired when a scale box drag is ended
  130151. */
  130152. onScaleBoxDragEndObservable: Observable<{}>;
  130153. /**
  130154. * Fired when a rotation sphere is dragged
  130155. */
  130156. onRotationSphereDragObservable: Observable<{}>;
  130157. /**
  130158. * Fired when a rotation sphere drag is ended
  130159. */
  130160. onRotationSphereDragEndObservable: Observable<{}>;
  130161. /**
  130162. * 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)
  130163. */
  130164. scalePivot: Nullable<Vector3>;
  130165. /**
  130166. * Mesh used as a pivot to rotate the attached mesh
  130167. */
  130168. private _anchorMesh;
  130169. private _existingMeshScale;
  130170. private _dragMesh;
  130171. private pointerDragBehavior;
  130172. private coloredMaterial;
  130173. private hoverColoredMaterial;
  130174. /**
  130175. * Sets the color of the bounding box gizmo
  130176. * @param color the color to set
  130177. */
  130178. setColor(color: Color3): void;
  130179. /**
  130180. * Creates an BoundingBoxGizmo
  130181. * @param gizmoLayer The utility layer the gizmo will be added to
  130182. * @param color The color of the gizmo
  130183. */
  130184. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  130185. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130186. private _selectNode;
  130187. /**
  130188. * Updates the bounding box information for the Gizmo
  130189. */
  130190. updateBoundingBox(): void;
  130191. private _updateRotationSpheres;
  130192. private _updateScaleBoxes;
  130193. /**
  130194. * Enables rotation on the specified axis and disables rotation on the others
  130195. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  130196. */
  130197. setEnabledRotationAxis(axis: string): void;
  130198. /**
  130199. * Enables/disables scaling
  130200. * @param enable if scaling should be enabled
  130201. * @param homogeneousScaling defines if scaling should only be homogeneous
  130202. */
  130203. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  130204. private _updateDummy;
  130205. /**
  130206. * Enables a pointer drag behavior on the bounding box of the gizmo
  130207. */
  130208. enableDragBehavior(): void;
  130209. /**
  130210. * Disposes of the gizmo
  130211. */
  130212. dispose(): void;
  130213. /**
  130214. * 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)
  130215. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  130216. * @returns the bounding box mesh with the passed in mesh as a child
  130217. */
  130218. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  130219. /**
  130220. * CustomMeshes are not supported by this gizmo
  130221. * @param mesh The mesh to replace the default mesh of the gizmo
  130222. */
  130223. setCustomMesh(mesh: Mesh): void;
  130224. }
  130225. }
  130226. declare module BABYLON {
  130227. /**
  130228. * Single plane rotation gizmo
  130229. */
  130230. export class PlaneRotationGizmo extends Gizmo {
  130231. /**
  130232. * Drag behavior responsible for the gizmos dragging interactions
  130233. */
  130234. dragBehavior: PointerDragBehavior;
  130235. private _pointerObserver;
  130236. /**
  130237. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  130238. */
  130239. snapDistance: number;
  130240. /**
  130241. * Event that fires each time the gizmo snaps to a new location.
  130242. * * snapDistance is the the change in distance
  130243. */
  130244. onSnapObservable: Observable<{
  130245. snapDistance: number;
  130246. }>;
  130247. private _isEnabled;
  130248. private _parent;
  130249. /**
  130250. * Creates a PlaneRotationGizmo
  130251. * @param gizmoLayer The utility layer the gizmo will be added to
  130252. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  130253. * @param color The color of the gizmo
  130254. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130255. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130256. */
  130257. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  130258. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130259. /**
  130260. * If the gizmo is enabled
  130261. */
  130262. set isEnabled(value: boolean);
  130263. get isEnabled(): boolean;
  130264. /**
  130265. * Disposes of the gizmo
  130266. */
  130267. dispose(): void;
  130268. }
  130269. }
  130270. declare module BABYLON {
  130271. /**
  130272. * Gizmo that enables rotating a mesh along 3 axis
  130273. */
  130274. export class RotationGizmo extends Gizmo {
  130275. /**
  130276. * Internal gizmo used for interactions on the x axis
  130277. */
  130278. xGizmo: PlaneRotationGizmo;
  130279. /**
  130280. * Internal gizmo used for interactions on the y axis
  130281. */
  130282. yGizmo: PlaneRotationGizmo;
  130283. /**
  130284. * Internal gizmo used for interactions on the z axis
  130285. */
  130286. zGizmo: PlaneRotationGizmo;
  130287. /** Fires an event when any of it's sub gizmos are dragged */
  130288. onDragStartObservable: Observable<unknown>;
  130289. /** Fires an event when any of it's sub gizmos are released from dragging */
  130290. onDragEndObservable: Observable<unknown>;
  130291. private _meshAttached;
  130292. get attachedMesh(): Nullable<AbstractMesh>;
  130293. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130294. /**
  130295. * Creates a RotationGizmo
  130296. * @param gizmoLayer The utility layer the gizmo will be added to
  130297. * @param tessellation Amount of tessellation to be used when creating rotation circles
  130298. * @param useEulerRotation Use and update Euler angle instead of quaternion
  130299. */
  130300. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  130301. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130302. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130303. /**
  130304. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130305. */
  130306. set snapDistance(value: number);
  130307. get snapDistance(): number;
  130308. /**
  130309. * Ratio for the scale of the gizmo (Default: 1)
  130310. */
  130311. set scaleRatio(value: number);
  130312. get scaleRatio(): number;
  130313. /**
  130314. * Disposes of the gizmo
  130315. */
  130316. dispose(): void;
  130317. /**
  130318. * CustomMeshes are not supported by this gizmo
  130319. * @param mesh The mesh to replace the default mesh of the gizmo
  130320. */
  130321. setCustomMesh(mesh: Mesh): void;
  130322. }
  130323. }
  130324. declare module BABYLON {
  130325. /**
  130326. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  130327. */
  130328. export class GizmoManager implements IDisposable {
  130329. private scene;
  130330. /**
  130331. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  130332. */
  130333. gizmos: {
  130334. positionGizmo: Nullable<PositionGizmo>;
  130335. rotationGizmo: Nullable<RotationGizmo>;
  130336. scaleGizmo: Nullable<ScaleGizmo>;
  130337. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  130338. };
  130339. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  130340. clearGizmoOnEmptyPointerEvent: boolean;
  130341. /** Fires an event when the manager is attached to a mesh */
  130342. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  130343. private _gizmosEnabled;
  130344. private _pointerObserver;
  130345. private _attachedMesh;
  130346. private _boundingBoxColor;
  130347. private _defaultUtilityLayer;
  130348. private _defaultKeepDepthUtilityLayer;
  130349. /**
  130350. * When bounding box gizmo is enabled, this can be used to track drag/end events
  130351. */
  130352. boundingBoxDragBehavior: SixDofDragBehavior;
  130353. /**
  130354. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  130355. */
  130356. attachableMeshes: Nullable<Array<AbstractMesh>>;
  130357. /**
  130358. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  130359. */
  130360. usePointerToAttachGizmos: boolean;
  130361. /**
  130362. * Utility layer that the bounding box gizmo belongs to
  130363. */
  130364. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  130365. /**
  130366. * Utility layer that all gizmos besides bounding box belong to
  130367. */
  130368. get utilityLayer(): UtilityLayerRenderer;
  130369. /**
  130370. * Instatiates a gizmo manager
  130371. * @param scene the scene to overlay the gizmos on top of
  130372. */
  130373. constructor(scene: Scene);
  130374. /**
  130375. * Attaches a set of gizmos to the specified mesh
  130376. * @param mesh The mesh the gizmo's should be attached to
  130377. */
  130378. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130379. /**
  130380. * If the position gizmo is enabled
  130381. */
  130382. set positionGizmoEnabled(value: boolean);
  130383. get positionGizmoEnabled(): boolean;
  130384. /**
  130385. * If the rotation gizmo is enabled
  130386. */
  130387. set rotationGizmoEnabled(value: boolean);
  130388. get rotationGizmoEnabled(): boolean;
  130389. /**
  130390. * If the scale gizmo is enabled
  130391. */
  130392. set scaleGizmoEnabled(value: boolean);
  130393. get scaleGizmoEnabled(): boolean;
  130394. /**
  130395. * If the boundingBox gizmo is enabled
  130396. */
  130397. set boundingBoxGizmoEnabled(value: boolean);
  130398. get boundingBoxGizmoEnabled(): boolean;
  130399. /**
  130400. * Disposes of the gizmo manager
  130401. */
  130402. dispose(): void;
  130403. }
  130404. }
  130405. declare module BABYLON {
  130406. /**
  130407. * A directional light is defined by a direction (what a surprise!).
  130408. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  130409. * 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.
  130410. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130411. */
  130412. export class DirectionalLight extends ShadowLight {
  130413. private _shadowFrustumSize;
  130414. /**
  130415. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  130416. */
  130417. get shadowFrustumSize(): number;
  130418. /**
  130419. * Specifies a fix frustum size for the shadow generation.
  130420. */
  130421. set shadowFrustumSize(value: number);
  130422. private _shadowOrthoScale;
  130423. /**
  130424. * Gets the shadow projection scale against the optimal computed one.
  130425. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130426. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130427. */
  130428. get shadowOrthoScale(): number;
  130429. /**
  130430. * Sets the shadow projection scale against the optimal computed one.
  130431. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  130432. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  130433. */
  130434. set shadowOrthoScale(value: number);
  130435. /**
  130436. * Automatically compute the projection matrix to best fit (including all the casters)
  130437. * on each frame.
  130438. */
  130439. autoUpdateExtends: boolean;
  130440. /**
  130441. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  130442. * on each frame. autoUpdateExtends must be set to true for this to work
  130443. */
  130444. autoCalcShadowZBounds: boolean;
  130445. private _orthoLeft;
  130446. private _orthoRight;
  130447. private _orthoTop;
  130448. private _orthoBottom;
  130449. /**
  130450. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  130451. * The directional light is emitted from everywhere in the given direction.
  130452. * It can cast shadows.
  130453. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130454. * @param name The friendly name of the light
  130455. * @param direction The direction of the light
  130456. * @param scene The scene the light belongs to
  130457. */
  130458. constructor(name: string, direction: Vector3, scene: Scene);
  130459. /**
  130460. * Returns the string "DirectionalLight".
  130461. * @return The class name
  130462. */
  130463. getClassName(): string;
  130464. /**
  130465. * Returns the integer 1.
  130466. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130467. */
  130468. getTypeID(): number;
  130469. /**
  130470. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  130471. * Returns the DirectionalLight Shadow projection matrix.
  130472. */
  130473. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130474. /**
  130475. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  130476. * Returns the DirectionalLight Shadow projection matrix.
  130477. */
  130478. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  130479. /**
  130480. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  130481. * Returns the DirectionalLight Shadow projection matrix.
  130482. */
  130483. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130484. protected _buildUniformLayout(): void;
  130485. /**
  130486. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  130487. * @param effect The effect to update
  130488. * @param lightIndex The index of the light in the effect to update
  130489. * @returns The directional light
  130490. */
  130491. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  130492. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  130493. /**
  130494. * Gets the minZ used for shadow according to both the scene and the light.
  130495. *
  130496. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130497. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130498. * @param activeCamera The camera we are returning the min for
  130499. * @returns the depth min z
  130500. */
  130501. getDepthMinZ(activeCamera: Camera): number;
  130502. /**
  130503. * Gets the maxZ used for shadow according to both the scene and the light.
  130504. *
  130505. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  130506. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  130507. * @param activeCamera The camera we are returning the max for
  130508. * @returns the depth max z
  130509. */
  130510. getDepthMaxZ(activeCamera: Camera): number;
  130511. /**
  130512. * Prepares the list of defines specific to the light type.
  130513. * @param defines the list of defines
  130514. * @param lightIndex defines the index of the light for the effect
  130515. */
  130516. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130517. }
  130518. }
  130519. declare module BABYLON {
  130520. /**
  130521. * Class containing static functions to help procedurally build meshes
  130522. */
  130523. export class HemisphereBuilder {
  130524. /**
  130525. * Creates a hemisphere mesh
  130526. * @param name defines the name of the mesh
  130527. * @param options defines the options used to create the mesh
  130528. * @param scene defines the hosting scene
  130529. * @returns the hemisphere mesh
  130530. */
  130531. static CreateHemisphere(name: string, options: {
  130532. segments?: number;
  130533. diameter?: number;
  130534. sideOrientation?: number;
  130535. }, scene: any): Mesh;
  130536. }
  130537. }
  130538. declare module BABYLON {
  130539. /**
  130540. * A spot light is defined by a position, a direction, an angle, and an exponent.
  130541. * These values define a cone of light starting from the position, emitting toward the direction.
  130542. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  130543. * and the exponent defines the speed of the decay of the light with distance (reach).
  130544. * Documentation: https://doc.babylonjs.com/babylon101/lights
  130545. */
  130546. export class SpotLight extends ShadowLight {
  130547. private _angle;
  130548. private _innerAngle;
  130549. private _cosHalfAngle;
  130550. private _lightAngleScale;
  130551. private _lightAngleOffset;
  130552. /**
  130553. * Gets the cone angle of the spot light in Radians.
  130554. */
  130555. get angle(): number;
  130556. /**
  130557. * Sets the cone angle of the spot light in Radians.
  130558. */
  130559. set angle(value: number);
  130560. /**
  130561. * Only used in gltf falloff mode, this defines the angle where
  130562. * the directional falloff will start before cutting at angle which could be seen
  130563. * as outer angle.
  130564. */
  130565. get innerAngle(): number;
  130566. /**
  130567. * Only used in gltf falloff mode, this defines the angle where
  130568. * the directional falloff will start before cutting at angle which could be seen
  130569. * as outer angle.
  130570. */
  130571. set innerAngle(value: number);
  130572. private _shadowAngleScale;
  130573. /**
  130574. * Allows scaling the angle of the light for shadow generation only.
  130575. */
  130576. get shadowAngleScale(): number;
  130577. /**
  130578. * Allows scaling the angle of the light for shadow generation only.
  130579. */
  130580. set shadowAngleScale(value: number);
  130581. /**
  130582. * The light decay speed with the distance from the emission spot.
  130583. */
  130584. exponent: number;
  130585. private _projectionTextureMatrix;
  130586. /**
  130587. * Allows reading the projecton texture
  130588. */
  130589. get projectionTextureMatrix(): Matrix;
  130590. protected _projectionTextureLightNear: number;
  130591. /**
  130592. * Gets the near clip of the Spotlight for texture projection.
  130593. */
  130594. get projectionTextureLightNear(): number;
  130595. /**
  130596. * Sets the near clip of the Spotlight for texture projection.
  130597. */
  130598. set projectionTextureLightNear(value: number);
  130599. protected _projectionTextureLightFar: number;
  130600. /**
  130601. * Gets the far clip of the Spotlight for texture projection.
  130602. */
  130603. get projectionTextureLightFar(): number;
  130604. /**
  130605. * Sets the far clip of the Spotlight for texture projection.
  130606. */
  130607. set projectionTextureLightFar(value: number);
  130608. protected _projectionTextureUpDirection: Vector3;
  130609. /**
  130610. * Gets the Up vector of the Spotlight for texture projection.
  130611. */
  130612. get projectionTextureUpDirection(): Vector3;
  130613. /**
  130614. * Sets the Up vector of the Spotlight for texture projection.
  130615. */
  130616. set projectionTextureUpDirection(value: Vector3);
  130617. private _projectionTexture;
  130618. /**
  130619. * Gets the projection texture of the light.
  130620. */
  130621. get projectionTexture(): Nullable<BaseTexture>;
  130622. /**
  130623. * Sets the projection texture of the light.
  130624. */
  130625. set projectionTexture(value: Nullable<BaseTexture>);
  130626. private _projectionTextureViewLightDirty;
  130627. private _projectionTextureProjectionLightDirty;
  130628. private _projectionTextureDirty;
  130629. private _projectionTextureViewTargetVector;
  130630. private _projectionTextureViewLightMatrix;
  130631. private _projectionTextureProjectionLightMatrix;
  130632. private _projectionTextureScalingMatrix;
  130633. /**
  130634. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  130635. * It can cast shadows.
  130636. * Documentation : https://doc.babylonjs.com/babylon101/lights
  130637. * @param name The light friendly name
  130638. * @param position The position of the spot light in the scene
  130639. * @param direction The direction of the light in the scene
  130640. * @param angle The cone angle of the light in Radians
  130641. * @param exponent The light decay speed with the distance from the emission spot
  130642. * @param scene The scene the lights belongs to
  130643. */
  130644. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  130645. /**
  130646. * Returns the string "SpotLight".
  130647. * @returns the class name
  130648. */
  130649. getClassName(): string;
  130650. /**
  130651. * Returns the integer 2.
  130652. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  130653. */
  130654. getTypeID(): number;
  130655. /**
  130656. * Overrides the direction setter to recompute the projection texture view light Matrix.
  130657. */
  130658. protected _setDirection(value: Vector3): void;
  130659. /**
  130660. * Overrides the position setter to recompute the projection texture view light Matrix.
  130661. */
  130662. protected _setPosition(value: Vector3): void;
  130663. /**
  130664. * 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.
  130665. * Returns the SpotLight.
  130666. */
  130667. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  130668. protected _computeProjectionTextureViewLightMatrix(): void;
  130669. protected _computeProjectionTextureProjectionLightMatrix(): void;
  130670. /**
  130671. * Main function for light texture projection matrix computing.
  130672. */
  130673. protected _computeProjectionTextureMatrix(): void;
  130674. protected _buildUniformLayout(): void;
  130675. private _computeAngleValues;
  130676. /**
  130677. * Sets the passed Effect "effect" with the Light textures.
  130678. * @param effect The effect to update
  130679. * @param lightIndex The index of the light in the effect to update
  130680. * @returns The light
  130681. */
  130682. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  130683. /**
  130684. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  130685. * @param effect The effect to update
  130686. * @param lightIndex The index of the light in the effect to update
  130687. * @returns The spot light
  130688. */
  130689. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  130690. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  130691. /**
  130692. * Disposes the light and the associated resources.
  130693. */
  130694. dispose(): void;
  130695. /**
  130696. * Prepares the list of defines specific to the light type.
  130697. * @param defines the list of defines
  130698. * @param lightIndex defines the index of the light for the effect
  130699. */
  130700. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  130701. }
  130702. }
  130703. declare module BABYLON {
  130704. /**
  130705. * Gizmo that enables viewing a light
  130706. */
  130707. export class LightGizmo extends Gizmo {
  130708. private _lightMesh;
  130709. private _material;
  130710. private _cachedPosition;
  130711. private _cachedForward;
  130712. private _attachedMeshParent;
  130713. /**
  130714. * Creates a LightGizmo
  130715. * @param gizmoLayer The utility layer the gizmo will be added to
  130716. */
  130717. constructor(gizmoLayer?: UtilityLayerRenderer);
  130718. private _light;
  130719. /**
  130720. * The light that the gizmo is attached to
  130721. */
  130722. set light(light: Nullable<Light>);
  130723. get light(): Nullable<Light>;
  130724. /**
  130725. * Gets the material used to render the light gizmo
  130726. */
  130727. get material(): StandardMaterial;
  130728. /**
  130729. * @hidden
  130730. * Updates the gizmo to match the attached mesh's position/rotation
  130731. */
  130732. protected _update(): void;
  130733. private static _Scale;
  130734. /**
  130735. * Creates the lines for a light mesh
  130736. */
  130737. private static _CreateLightLines;
  130738. /**
  130739. * Disposes of the light gizmo
  130740. */
  130741. dispose(): void;
  130742. private static _CreateHemisphericLightMesh;
  130743. private static _CreatePointLightMesh;
  130744. private static _CreateSpotLightMesh;
  130745. private static _CreateDirectionalLightMesh;
  130746. }
  130747. }
  130748. declare module BABYLON {
  130749. /** @hidden */
  130750. export var backgroundFragmentDeclaration: {
  130751. name: string;
  130752. shader: string;
  130753. };
  130754. }
  130755. declare module BABYLON {
  130756. /** @hidden */
  130757. export var backgroundUboDeclaration: {
  130758. name: string;
  130759. shader: string;
  130760. };
  130761. }
  130762. declare module BABYLON {
  130763. /** @hidden */
  130764. export var backgroundPixelShader: {
  130765. name: string;
  130766. shader: string;
  130767. };
  130768. }
  130769. declare module BABYLON {
  130770. /** @hidden */
  130771. export var backgroundVertexDeclaration: {
  130772. name: string;
  130773. shader: string;
  130774. };
  130775. }
  130776. declare module BABYLON {
  130777. /** @hidden */
  130778. export var backgroundVertexShader: {
  130779. name: string;
  130780. shader: string;
  130781. };
  130782. }
  130783. declare module BABYLON {
  130784. /**
  130785. * Background material used to create an efficient environement around your scene.
  130786. */
  130787. export class BackgroundMaterial extends PushMaterial {
  130788. /**
  130789. * Standard reflectance value at parallel view angle.
  130790. */
  130791. static StandardReflectance0: number;
  130792. /**
  130793. * Standard reflectance value at grazing angle.
  130794. */
  130795. static StandardReflectance90: number;
  130796. protected _primaryColor: Color3;
  130797. /**
  130798. * Key light Color (multiply against the environement texture)
  130799. */
  130800. primaryColor: Color3;
  130801. protected __perceptualColor: Nullable<Color3>;
  130802. /**
  130803. * Experimental Internal Use Only.
  130804. *
  130805. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  130806. * This acts as a helper to set the primary color to a more "human friendly" value.
  130807. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  130808. * output color as close as possible from the chosen value.
  130809. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  130810. * part of lighting setup.)
  130811. */
  130812. get _perceptualColor(): Nullable<Color3>;
  130813. set _perceptualColor(value: Nullable<Color3>);
  130814. protected _primaryColorShadowLevel: float;
  130815. /**
  130816. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  130817. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  130818. */
  130819. get primaryColorShadowLevel(): float;
  130820. set primaryColorShadowLevel(value: float);
  130821. protected _primaryColorHighlightLevel: float;
  130822. /**
  130823. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  130824. * The primary color is used at the level chosen to define what the white area would look.
  130825. */
  130826. get primaryColorHighlightLevel(): float;
  130827. set primaryColorHighlightLevel(value: float);
  130828. protected _reflectionTexture: Nullable<BaseTexture>;
  130829. /**
  130830. * Reflection Texture used in the material.
  130831. * Should be author in a specific way for the best result (refer to the documentation).
  130832. */
  130833. reflectionTexture: Nullable<BaseTexture>;
  130834. protected _reflectionBlur: float;
  130835. /**
  130836. * Reflection Texture level of blur.
  130837. *
  130838. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  130839. * texture twice.
  130840. */
  130841. reflectionBlur: float;
  130842. protected _diffuseTexture: Nullable<BaseTexture>;
  130843. /**
  130844. * Diffuse Texture used in the material.
  130845. * Should be author in a specific way for the best result (refer to the documentation).
  130846. */
  130847. diffuseTexture: Nullable<BaseTexture>;
  130848. protected _shadowLights: Nullable<IShadowLight[]>;
  130849. /**
  130850. * Specify the list of lights casting shadow on the material.
  130851. * All scene shadow lights will be included if null.
  130852. */
  130853. shadowLights: Nullable<IShadowLight[]>;
  130854. protected _shadowLevel: float;
  130855. /**
  130856. * Helps adjusting the shadow to a softer level if required.
  130857. * 0 means black shadows and 1 means no shadows.
  130858. */
  130859. shadowLevel: float;
  130860. protected _sceneCenter: Vector3;
  130861. /**
  130862. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  130863. * It is usually zero but might be interesting to modify according to your setup.
  130864. */
  130865. sceneCenter: Vector3;
  130866. protected _opacityFresnel: boolean;
  130867. /**
  130868. * This helps specifying that the material is falling off to the sky box at grazing angle.
  130869. * This helps ensuring a nice transition when the camera goes under the ground.
  130870. */
  130871. opacityFresnel: boolean;
  130872. protected _reflectionFresnel: boolean;
  130873. /**
  130874. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  130875. * This helps adding a mirror texture on the ground.
  130876. */
  130877. reflectionFresnel: boolean;
  130878. protected _reflectionFalloffDistance: number;
  130879. /**
  130880. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  130881. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  130882. */
  130883. reflectionFalloffDistance: number;
  130884. protected _reflectionAmount: number;
  130885. /**
  130886. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  130887. */
  130888. reflectionAmount: number;
  130889. protected _reflectionReflectance0: number;
  130890. /**
  130891. * This specifies the weight of the reflection at grazing angle.
  130892. */
  130893. reflectionReflectance0: number;
  130894. protected _reflectionReflectance90: number;
  130895. /**
  130896. * This specifies the weight of the reflection at a perpendicular point of view.
  130897. */
  130898. reflectionReflectance90: number;
  130899. /**
  130900. * Sets the reflection reflectance fresnel values according to the default standard
  130901. * empirically know to work well :-)
  130902. */
  130903. set reflectionStandardFresnelWeight(value: number);
  130904. protected _useRGBColor: boolean;
  130905. /**
  130906. * Helps to directly use the maps channels instead of their level.
  130907. */
  130908. useRGBColor: boolean;
  130909. protected _enableNoise: boolean;
  130910. /**
  130911. * This helps reducing the banding effect that could occur on the background.
  130912. */
  130913. enableNoise: boolean;
  130914. /**
  130915. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  130916. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  130917. * Recommended to be keep at 1.0 except for special cases.
  130918. */
  130919. get fovMultiplier(): number;
  130920. set fovMultiplier(value: number);
  130921. private _fovMultiplier;
  130922. /**
  130923. * Enable the FOV adjustment feature controlled by fovMultiplier.
  130924. */
  130925. useEquirectangularFOV: boolean;
  130926. private _maxSimultaneousLights;
  130927. /**
  130928. * Number of Simultaneous lights allowed on the material.
  130929. */
  130930. maxSimultaneousLights: int;
  130931. /**
  130932. * Default configuration related to image processing available in the Background Material.
  130933. */
  130934. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130935. /**
  130936. * Keep track of the image processing observer to allow dispose and replace.
  130937. */
  130938. private _imageProcessingObserver;
  130939. /**
  130940. * Attaches a new image processing configuration to the PBR Material.
  130941. * @param configuration (if null the scene configuration will be use)
  130942. */
  130943. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130944. /**
  130945. * Gets the image processing configuration used either in this material.
  130946. */
  130947. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  130948. /**
  130949. * Sets the Default image processing configuration used either in the this material.
  130950. *
  130951. * If sets to null, the scene one is in use.
  130952. */
  130953. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  130954. /**
  130955. * Gets wether the color curves effect is enabled.
  130956. */
  130957. get cameraColorCurvesEnabled(): boolean;
  130958. /**
  130959. * Sets wether the color curves effect is enabled.
  130960. */
  130961. set cameraColorCurvesEnabled(value: boolean);
  130962. /**
  130963. * Gets wether the color grading effect is enabled.
  130964. */
  130965. get cameraColorGradingEnabled(): boolean;
  130966. /**
  130967. * Gets wether the color grading effect is enabled.
  130968. */
  130969. set cameraColorGradingEnabled(value: boolean);
  130970. /**
  130971. * Gets wether tonemapping is enabled or not.
  130972. */
  130973. get cameraToneMappingEnabled(): boolean;
  130974. /**
  130975. * Sets wether tonemapping is enabled or not
  130976. */
  130977. set cameraToneMappingEnabled(value: boolean);
  130978. /**
  130979. * The camera exposure used on this material.
  130980. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130981. * This corresponds to a photographic exposure.
  130982. */
  130983. get cameraExposure(): float;
  130984. /**
  130985. * The camera exposure used on this material.
  130986. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  130987. * This corresponds to a photographic exposure.
  130988. */
  130989. set cameraExposure(value: float);
  130990. /**
  130991. * Gets The camera contrast used on this material.
  130992. */
  130993. get cameraContrast(): float;
  130994. /**
  130995. * Sets The camera contrast used on this material.
  130996. */
  130997. set cameraContrast(value: float);
  130998. /**
  130999. * Gets the Color Grading 2D Lookup Texture.
  131000. */
  131001. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  131002. /**
  131003. * Sets the Color Grading 2D Lookup Texture.
  131004. */
  131005. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  131006. /**
  131007. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131008. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131009. * 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;
  131010. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131011. */
  131012. get cameraColorCurves(): Nullable<ColorCurves>;
  131013. /**
  131014. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131015. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131016. * 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;
  131017. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131018. */
  131019. set cameraColorCurves(value: Nullable<ColorCurves>);
  131020. /**
  131021. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131022. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131023. */
  131024. switchToBGR: boolean;
  131025. private _renderTargets;
  131026. private _reflectionControls;
  131027. private _white;
  131028. private _primaryShadowColor;
  131029. private _primaryHighlightColor;
  131030. /**
  131031. * Instantiates a Background Material in the given scene
  131032. * @param name The friendly name of the material
  131033. * @param scene The scene to add the material to
  131034. */
  131035. constructor(name: string, scene: Scene);
  131036. /**
  131037. * Gets a boolean indicating that current material needs to register RTT
  131038. */
  131039. get hasRenderTargetTextures(): boolean;
  131040. /**
  131041. * The entire material has been created in order to prevent overdraw.
  131042. * @returns false
  131043. */
  131044. needAlphaTesting(): boolean;
  131045. /**
  131046. * The entire material has been created in order to prevent overdraw.
  131047. * @returns true if blending is enable
  131048. */
  131049. needAlphaBlending(): boolean;
  131050. /**
  131051. * Checks wether the material is ready to be rendered for a given mesh.
  131052. * @param mesh The mesh to render
  131053. * @param subMesh The submesh to check against
  131054. * @param useInstances Specify wether or not the material is used with instances
  131055. * @returns true if all the dependencies are ready (Textures, Effects...)
  131056. */
  131057. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131058. /**
  131059. * Compute the primary color according to the chosen perceptual color.
  131060. */
  131061. private _computePrimaryColorFromPerceptualColor;
  131062. /**
  131063. * Compute the highlights and shadow colors according to their chosen levels.
  131064. */
  131065. private _computePrimaryColors;
  131066. /**
  131067. * Build the uniform buffer used in the material.
  131068. */
  131069. buildUniformLayout(): void;
  131070. /**
  131071. * Unbind the material.
  131072. */
  131073. unbind(): void;
  131074. /**
  131075. * Bind only the world matrix to the material.
  131076. * @param world The world matrix to bind.
  131077. */
  131078. bindOnlyWorldMatrix(world: Matrix): void;
  131079. /**
  131080. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131081. * @param world The world matrix to bind.
  131082. * @param subMesh The submesh to bind for.
  131083. */
  131084. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131085. /**
  131086. * Checks to see if a texture is used in the material.
  131087. * @param texture - Base texture to use.
  131088. * @returns - Boolean specifying if a texture is used in the material.
  131089. */
  131090. hasTexture(texture: BaseTexture): boolean;
  131091. /**
  131092. * Dispose the material.
  131093. * @param forceDisposeEffect Force disposal of the associated effect.
  131094. * @param forceDisposeTextures Force disposal of the associated textures.
  131095. */
  131096. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131097. /**
  131098. * Clones the material.
  131099. * @param name The cloned name.
  131100. * @returns The cloned material.
  131101. */
  131102. clone(name: string): BackgroundMaterial;
  131103. /**
  131104. * Serializes the current material to its JSON representation.
  131105. * @returns The JSON representation.
  131106. */
  131107. serialize(): any;
  131108. /**
  131109. * Gets the class name of the material
  131110. * @returns "BackgroundMaterial"
  131111. */
  131112. getClassName(): string;
  131113. /**
  131114. * Parse a JSON input to create back a background material.
  131115. * @param source The JSON data to parse
  131116. * @param scene The scene to create the parsed material in
  131117. * @param rootUrl The root url of the assets the material depends upon
  131118. * @returns the instantiated BackgroundMaterial.
  131119. */
  131120. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  131121. }
  131122. }
  131123. declare module BABYLON {
  131124. /**
  131125. * Represents the different options available during the creation of
  131126. * a Environment helper.
  131127. *
  131128. * This can control the default ground, skybox and image processing setup of your scene.
  131129. */
  131130. export interface IEnvironmentHelperOptions {
  131131. /**
  131132. * Specifies whether or not to create a ground.
  131133. * True by default.
  131134. */
  131135. createGround: boolean;
  131136. /**
  131137. * Specifies the ground size.
  131138. * 15 by default.
  131139. */
  131140. groundSize: number;
  131141. /**
  131142. * The texture used on the ground for the main color.
  131143. * Comes from the BabylonJS CDN by default.
  131144. *
  131145. * Remarks: Can be either a texture or a url.
  131146. */
  131147. groundTexture: string | BaseTexture;
  131148. /**
  131149. * The color mixed in the ground texture by default.
  131150. * BabylonJS clearColor by default.
  131151. */
  131152. groundColor: Color3;
  131153. /**
  131154. * Specifies the ground opacity.
  131155. * 1 by default.
  131156. */
  131157. groundOpacity: number;
  131158. /**
  131159. * Enables the ground to receive shadows.
  131160. * True by default.
  131161. */
  131162. enableGroundShadow: boolean;
  131163. /**
  131164. * Helps preventing the shadow to be fully black on the ground.
  131165. * 0.5 by default.
  131166. */
  131167. groundShadowLevel: number;
  131168. /**
  131169. * Creates a mirror texture attach to the ground.
  131170. * false by default.
  131171. */
  131172. enableGroundMirror: boolean;
  131173. /**
  131174. * Specifies the ground mirror size ratio.
  131175. * 0.3 by default as the default kernel is 64.
  131176. */
  131177. groundMirrorSizeRatio: number;
  131178. /**
  131179. * Specifies the ground mirror blur kernel size.
  131180. * 64 by default.
  131181. */
  131182. groundMirrorBlurKernel: number;
  131183. /**
  131184. * Specifies the ground mirror visibility amount.
  131185. * 1 by default
  131186. */
  131187. groundMirrorAmount: number;
  131188. /**
  131189. * Specifies the ground mirror reflectance weight.
  131190. * This uses the standard weight of the background material to setup the fresnel effect
  131191. * of the mirror.
  131192. * 1 by default.
  131193. */
  131194. groundMirrorFresnelWeight: number;
  131195. /**
  131196. * Specifies the ground mirror Falloff distance.
  131197. * This can helps reducing the size of the reflection.
  131198. * 0 by Default.
  131199. */
  131200. groundMirrorFallOffDistance: number;
  131201. /**
  131202. * Specifies the ground mirror texture type.
  131203. * Unsigned Int by Default.
  131204. */
  131205. groundMirrorTextureType: number;
  131206. /**
  131207. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  131208. * the shown objects.
  131209. */
  131210. groundYBias: number;
  131211. /**
  131212. * Specifies whether or not to create a skybox.
  131213. * True by default.
  131214. */
  131215. createSkybox: boolean;
  131216. /**
  131217. * Specifies the skybox size.
  131218. * 20 by default.
  131219. */
  131220. skyboxSize: number;
  131221. /**
  131222. * The texture used on the skybox for the main color.
  131223. * Comes from the BabylonJS CDN by default.
  131224. *
  131225. * Remarks: Can be either a texture or a url.
  131226. */
  131227. skyboxTexture: string | BaseTexture;
  131228. /**
  131229. * The color mixed in the skybox texture by default.
  131230. * BabylonJS clearColor by default.
  131231. */
  131232. skyboxColor: Color3;
  131233. /**
  131234. * The background rotation around the Y axis of the scene.
  131235. * This helps aligning the key lights of your scene with the background.
  131236. * 0 by default.
  131237. */
  131238. backgroundYRotation: number;
  131239. /**
  131240. * Compute automatically the size of the elements to best fit with the scene.
  131241. */
  131242. sizeAuto: boolean;
  131243. /**
  131244. * Default position of the rootMesh if autoSize is not true.
  131245. */
  131246. rootPosition: Vector3;
  131247. /**
  131248. * Sets up the image processing in the scene.
  131249. * true by default.
  131250. */
  131251. setupImageProcessing: boolean;
  131252. /**
  131253. * The texture used as your environment texture in the scene.
  131254. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  131255. *
  131256. * Remarks: Can be either a texture or a url.
  131257. */
  131258. environmentTexture: string | BaseTexture;
  131259. /**
  131260. * The value of the exposure to apply to the scene.
  131261. * 0.6 by default if setupImageProcessing is true.
  131262. */
  131263. cameraExposure: number;
  131264. /**
  131265. * The value of the contrast to apply to the scene.
  131266. * 1.6 by default if setupImageProcessing is true.
  131267. */
  131268. cameraContrast: number;
  131269. /**
  131270. * Specifies whether or not tonemapping should be enabled in the scene.
  131271. * true by default if setupImageProcessing is true.
  131272. */
  131273. toneMappingEnabled: boolean;
  131274. }
  131275. /**
  131276. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  131277. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  131278. * It also helps with the default setup of your imageProcessing configuration.
  131279. */
  131280. export class EnvironmentHelper {
  131281. /**
  131282. * Default ground texture URL.
  131283. */
  131284. private static _groundTextureCDNUrl;
  131285. /**
  131286. * Default skybox texture URL.
  131287. */
  131288. private static _skyboxTextureCDNUrl;
  131289. /**
  131290. * Default environment texture URL.
  131291. */
  131292. private static _environmentTextureCDNUrl;
  131293. /**
  131294. * Creates the default options for the helper.
  131295. */
  131296. private static _getDefaultOptions;
  131297. private _rootMesh;
  131298. /**
  131299. * Gets the root mesh created by the helper.
  131300. */
  131301. get rootMesh(): Mesh;
  131302. private _skybox;
  131303. /**
  131304. * Gets the skybox created by the helper.
  131305. */
  131306. get skybox(): Nullable<Mesh>;
  131307. private _skyboxTexture;
  131308. /**
  131309. * Gets the skybox texture created by the helper.
  131310. */
  131311. get skyboxTexture(): Nullable<BaseTexture>;
  131312. private _skyboxMaterial;
  131313. /**
  131314. * Gets the skybox material created by the helper.
  131315. */
  131316. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  131317. private _ground;
  131318. /**
  131319. * Gets the ground mesh created by the helper.
  131320. */
  131321. get ground(): Nullable<Mesh>;
  131322. private _groundTexture;
  131323. /**
  131324. * Gets the ground texture created by the helper.
  131325. */
  131326. get groundTexture(): Nullable<BaseTexture>;
  131327. private _groundMirror;
  131328. /**
  131329. * Gets the ground mirror created by the helper.
  131330. */
  131331. get groundMirror(): Nullable<MirrorTexture>;
  131332. /**
  131333. * Gets the ground mirror render list to helps pushing the meshes
  131334. * you wish in the ground reflection.
  131335. */
  131336. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  131337. private _groundMaterial;
  131338. /**
  131339. * Gets the ground material created by the helper.
  131340. */
  131341. get groundMaterial(): Nullable<BackgroundMaterial>;
  131342. /**
  131343. * Stores the creation options.
  131344. */
  131345. private readonly _scene;
  131346. private _options;
  131347. /**
  131348. * This observable will be notified with any error during the creation of the environment,
  131349. * mainly texture creation errors.
  131350. */
  131351. onErrorObservable: Observable<{
  131352. message?: string;
  131353. exception?: any;
  131354. }>;
  131355. /**
  131356. * constructor
  131357. * @param options Defines the options we want to customize the helper
  131358. * @param scene The scene to add the material to
  131359. */
  131360. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  131361. /**
  131362. * Updates the background according to the new options
  131363. * @param options
  131364. */
  131365. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  131366. /**
  131367. * Sets the primary color of all the available elements.
  131368. * @param color the main color to affect to the ground and the background
  131369. */
  131370. setMainColor(color: Color3): void;
  131371. /**
  131372. * Setup the image processing according to the specified options.
  131373. */
  131374. private _setupImageProcessing;
  131375. /**
  131376. * Setup the environment texture according to the specified options.
  131377. */
  131378. private _setupEnvironmentTexture;
  131379. /**
  131380. * Setup the background according to the specified options.
  131381. */
  131382. private _setupBackground;
  131383. /**
  131384. * Get the scene sizes according to the setup.
  131385. */
  131386. private _getSceneSize;
  131387. /**
  131388. * Setup the ground according to the specified options.
  131389. */
  131390. private _setupGround;
  131391. /**
  131392. * Setup the ground material according to the specified options.
  131393. */
  131394. private _setupGroundMaterial;
  131395. /**
  131396. * Setup the ground diffuse texture according to the specified options.
  131397. */
  131398. private _setupGroundDiffuseTexture;
  131399. /**
  131400. * Setup the ground mirror texture according to the specified options.
  131401. */
  131402. private _setupGroundMirrorTexture;
  131403. /**
  131404. * Setup the ground to receive the mirror texture.
  131405. */
  131406. private _setupMirrorInGroundMaterial;
  131407. /**
  131408. * Setup the skybox according to the specified options.
  131409. */
  131410. private _setupSkybox;
  131411. /**
  131412. * Setup the skybox material according to the specified options.
  131413. */
  131414. private _setupSkyboxMaterial;
  131415. /**
  131416. * Setup the skybox reflection texture according to the specified options.
  131417. */
  131418. private _setupSkyboxReflectionTexture;
  131419. private _errorHandler;
  131420. /**
  131421. * Dispose all the elements created by the Helper.
  131422. */
  131423. dispose(): void;
  131424. }
  131425. }
  131426. declare module BABYLON {
  131427. /**
  131428. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  131429. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  131430. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  131431. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  131432. */
  131433. export class PhotoDome extends TransformNode {
  131434. /**
  131435. * Define the image as a Monoscopic panoramic 360 image.
  131436. */
  131437. static readonly MODE_MONOSCOPIC: number;
  131438. /**
  131439. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131440. */
  131441. static readonly MODE_TOPBOTTOM: number;
  131442. /**
  131443. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131444. */
  131445. static readonly MODE_SIDEBYSIDE: number;
  131446. private _useDirectMapping;
  131447. /**
  131448. * The texture being displayed on the sphere
  131449. */
  131450. protected _photoTexture: Texture;
  131451. /**
  131452. * Gets or sets the texture being displayed on the sphere
  131453. */
  131454. get photoTexture(): Texture;
  131455. set photoTexture(value: Texture);
  131456. /**
  131457. * Observable raised when an error occured while loading the 360 image
  131458. */
  131459. onLoadErrorObservable: Observable<string>;
  131460. /**
  131461. * The skybox material
  131462. */
  131463. protected _material: BackgroundMaterial;
  131464. /**
  131465. * The surface used for the skybox
  131466. */
  131467. protected _mesh: Mesh;
  131468. /**
  131469. * Gets the mesh used for the skybox.
  131470. */
  131471. get mesh(): Mesh;
  131472. /**
  131473. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131474. * Also see the options.resolution property.
  131475. */
  131476. get fovMultiplier(): number;
  131477. set fovMultiplier(value: number);
  131478. private _imageMode;
  131479. /**
  131480. * Gets or set the current video mode for the video. It can be:
  131481. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  131482. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  131483. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  131484. */
  131485. get imageMode(): number;
  131486. set imageMode(value: number);
  131487. /**
  131488. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  131489. * @param name Element's name, child elements will append suffixes for their own names.
  131490. * @param urlsOfPhoto defines the url of the photo to display
  131491. * @param options defines an object containing optional or exposed sub element properties
  131492. * @param onError defines a callback called when an error occured while loading the texture
  131493. */
  131494. constructor(name: string, urlOfPhoto: string, options: {
  131495. resolution?: number;
  131496. size?: number;
  131497. useDirectMapping?: boolean;
  131498. faceForward?: boolean;
  131499. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  131500. private _onBeforeCameraRenderObserver;
  131501. private _changeImageMode;
  131502. /**
  131503. * Releases resources associated with this node.
  131504. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  131505. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  131506. */
  131507. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  131508. }
  131509. }
  131510. declare module BABYLON {
  131511. /**
  131512. * Class used to host RGBD texture specific utilities
  131513. */
  131514. export class RGBDTextureTools {
  131515. /**
  131516. * Expand the RGBD Texture from RGBD to Half Float if possible.
  131517. * @param texture the texture to expand.
  131518. */
  131519. static ExpandRGBDTexture(texture: Texture): void;
  131520. }
  131521. }
  131522. declare module BABYLON {
  131523. /**
  131524. * Class used to host texture specific utilities
  131525. */
  131526. export class BRDFTextureTools {
  131527. /**
  131528. * Prevents texture cache collision
  131529. */
  131530. private static _instanceNumber;
  131531. /**
  131532. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  131533. * @param scene defines the hosting scene
  131534. * @returns the environment BRDF texture
  131535. */
  131536. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  131537. private static _environmentBRDFBase64Texture;
  131538. }
  131539. }
  131540. declare module BABYLON {
  131541. /**
  131542. * @hidden
  131543. */
  131544. export interface IMaterialClearCoatDefines {
  131545. CLEARCOAT: boolean;
  131546. CLEARCOAT_DEFAULTIOR: boolean;
  131547. CLEARCOAT_TEXTURE: boolean;
  131548. CLEARCOAT_TEXTUREDIRECTUV: number;
  131549. CLEARCOAT_BUMP: boolean;
  131550. CLEARCOAT_BUMPDIRECTUV: number;
  131551. CLEARCOAT_TINT: boolean;
  131552. CLEARCOAT_TINT_TEXTURE: boolean;
  131553. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  131554. /** @hidden */
  131555. _areTexturesDirty: boolean;
  131556. }
  131557. /**
  131558. * Define the code related to the clear coat parameters of the pbr material.
  131559. */
  131560. export class PBRClearCoatConfiguration {
  131561. /**
  131562. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131563. * The default fits with a polyurethane material.
  131564. */
  131565. private static readonly _DefaultIndexOfRefraction;
  131566. private _isEnabled;
  131567. /**
  131568. * Defines if the clear coat is enabled in the material.
  131569. */
  131570. isEnabled: boolean;
  131571. /**
  131572. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  131573. */
  131574. intensity: number;
  131575. /**
  131576. * Defines the clear coat layer roughness.
  131577. */
  131578. roughness: number;
  131579. private _indexOfRefraction;
  131580. /**
  131581. * Defines the index of refraction of the clear coat.
  131582. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  131583. * The default fits with a polyurethane material.
  131584. * Changing the default value is more performance intensive.
  131585. */
  131586. indexOfRefraction: number;
  131587. private _texture;
  131588. /**
  131589. * Stores the clear coat values in a texture.
  131590. */
  131591. texture: Nullable<BaseTexture>;
  131592. private _bumpTexture;
  131593. /**
  131594. * Define the clear coat specific bump texture.
  131595. */
  131596. bumpTexture: Nullable<BaseTexture>;
  131597. private _isTintEnabled;
  131598. /**
  131599. * Defines if the clear coat tint is enabled in the material.
  131600. */
  131601. isTintEnabled: boolean;
  131602. /**
  131603. * Defines the clear coat tint of the material.
  131604. * This is only use if tint is enabled
  131605. */
  131606. tintColor: Color3;
  131607. /**
  131608. * Defines the distance at which the tint color should be found in the
  131609. * clear coat media.
  131610. * This is only use if tint is enabled
  131611. */
  131612. tintColorAtDistance: number;
  131613. /**
  131614. * Defines the clear coat layer thickness.
  131615. * This is only use if tint is enabled
  131616. */
  131617. tintThickness: number;
  131618. private _tintTexture;
  131619. /**
  131620. * Stores the clear tint values in a texture.
  131621. * rgb is tint
  131622. * a is a thickness factor
  131623. */
  131624. tintTexture: Nullable<BaseTexture>;
  131625. /** @hidden */
  131626. private _internalMarkAllSubMeshesAsTexturesDirty;
  131627. /** @hidden */
  131628. _markAllSubMeshesAsTexturesDirty(): void;
  131629. /**
  131630. * Instantiate a new istance of clear coat configuration.
  131631. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131632. */
  131633. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131634. /**
  131635. * Gets wehter the submesh is ready to be used or not.
  131636. * @param defines the list of "defines" to update.
  131637. * @param scene defines the scene the material belongs to.
  131638. * @param engine defines the engine the material belongs to.
  131639. * @param disableBumpMap defines wether the material disables bump or not.
  131640. * @returns - boolean indicating that the submesh is ready or not.
  131641. */
  131642. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  131643. /**
  131644. * Checks to see if a texture is used in the material.
  131645. * @param defines the list of "defines" to update.
  131646. * @param scene defines the scene to the material belongs to.
  131647. */
  131648. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  131649. /**
  131650. * Binds the material data.
  131651. * @param uniformBuffer defines the Uniform buffer to fill in.
  131652. * @param scene defines the scene the material belongs to.
  131653. * @param engine defines the engine the material belongs to.
  131654. * @param disableBumpMap defines wether the material disables bump or not.
  131655. * @param isFrozen defines wether the material is frozen or not.
  131656. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  131657. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  131658. */
  131659. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  131660. /**
  131661. * Checks to see if a texture is used in the material.
  131662. * @param texture - Base texture to use.
  131663. * @returns - Boolean specifying if a texture is used in the material.
  131664. */
  131665. hasTexture(texture: BaseTexture): boolean;
  131666. /**
  131667. * Returns an array of the actively used textures.
  131668. * @param activeTextures Array of BaseTextures
  131669. */
  131670. getActiveTextures(activeTextures: BaseTexture[]): void;
  131671. /**
  131672. * Returns the animatable textures.
  131673. * @param animatables Array of animatable textures.
  131674. */
  131675. getAnimatables(animatables: IAnimatable[]): void;
  131676. /**
  131677. * Disposes the resources of the material.
  131678. * @param forceDisposeTextures - Forces the disposal of all textures.
  131679. */
  131680. dispose(forceDisposeTextures?: boolean): void;
  131681. /**
  131682. * Get the current class name of the texture useful for serialization or dynamic coding.
  131683. * @returns "PBRClearCoatConfiguration"
  131684. */
  131685. getClassName(): string;
  131686. /**
  131687. * Add fallbacks to the effect fallbacks list.
  131688. * @param defines defines the Base texture to use.
  131689. * @param fallbacks defines the current fallback list.
  131690. * @param currentRank defines the current fallback rank.
  131691. * @returns the new fallback rank.
  131692. */
  131693. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131694. /**
  131695. * Add the required uniforms to the current list.
  131696. * @param uniforms defines the current uniform list.
  131697. */
  131698. static AddUniforms(uniforms: string[]): void;
  131699. /**
  131700. * Add the required samplers to the current list.
  131701. * @param samplers defines the current sampler list.
  131702. */
  131703. static AddSamplers(samplers: string[]): void;
  131704. /**
  131705. * Add the required uniforms to the current buffer.
  131706. * @param uniformBuffer defines the current uniform buffer.
  131707. */
  131708. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131709. /**
  131710. * Makes a duplicate of the current configuration into another one.
  131711. * @param clearCoatConfiguration define the config where to copy the info
  131712. */
  131713. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  131714. /**
  131715. * Serializes this clear coat configuration.
  131716. * @returns - An object with the serialized config.
  131717. */
  131718. serialize(): any;
  131719. /**
  131720. * Parses a anisotropy Configuration from a serialized object.
  131721. * @param source - Serialized object.
  131722. * @param scene Defines the scene we are parsing for
  131723. * @param rootUrl Defines the rootUrl to load from
  131724. */
  131725. parse(source: any, scene: Scene, rootUrl: string): void;
  131726. }
  131727. }
  131728. declare module BABYLON {
  131729. /**
  131730. * @hidden
  131731. */
  131732. export interface IMaterialAnisotropicDefines {
  131733. ANISOTROPIC: boolean;
  131734. ANISOTROPIC_TEXTURE: boolean;
  131735. ANISOTROPIC_TEXTUREDIRECTUV: number;
  131736. MAINUV1: boolean;
  131737. _areTexturesDirty: boolean;
  131738. _needUVs: boolean;
  131739. }
  131740. /**
  131741. * Define the code related to the anisotropic parameters of the pbr material.
  131742. */
  131743. export class PBRAnisotropicConfiguration {
  131744. private _isEnabled;
  131745. /**
  131746. * Defines if the anisotropy is enabled in the material.
  131747. */
  131748. isEnabled: boolean;
  131749. /**
  131750. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  131751. */
  131752. intensity: number;
  131753. /**
  131754. * Defines if the effect is along the tangents, bitangents or in between.
  131755. * By default, the effect is "strectching" the highlights along the tangents.
  131756. */
  131757. direction: Vector2;
  131758. private _texture;
  131759. /**
  131760. * Stores the anisotropy values in a texture.
  131761. * rg is direction (like normal from -1 to 1)
  131762. * b is a intensity
  131763. */
  131764. texture: Nullable<BaseTexture>;
  131765. /** @hidden */
  131766. private _internalMarkAllSubMeshesAsTexturesDirty;
  131767. /** @hidden */
  131768. _markAllSubMeshesAsTexturesDirty(): void;
  131769. /**
  131770. * Instantiate a new istance of anisotropy configuration.
  131771. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  131772. */
  131773. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  131774. /**
  131775. * Specifies that the submesh is ready to be used.
  131776. * @param defines the list of "defines" to update.
  131777. * @param scene defines the scene the material belongs to.
  131778. * @returns - boolean indicating that the submesh is ready or not.
  131779. */
  131780. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  131781. /**
  131782. * Checks to see if a texture is used in the material.
  131783. * @param defines the list of "defines" to update.
  131784. * @param mesh the mesh we are preparing the defines for.
  131785. * @param scene defines the scene the material belongs to.
  131786. */
  131787. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  131788. /**
  131789. * Binds the material data.
  131790. * @param uniformBuffer defines the Uniform buffer to fill in.
  131791. * @param scene defines the scene the material belongs to.
  131792. * @param isFrozen defines wether the material is frozen or not.
  131793. */
  131794. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  131795. /**
  131796. * Checks to see if a texture is used in the material.
  131797. * @param texture - Base texture to use.
  131798. * @returns - Boolean specifying if a texture is used in the material.
  131799. */
  131800. hasTexture(texture: BaseTexture): boolean;
  131801. /**
  131802. * Returns an array of the actively used textures.
  131803. * @param activeTextures Array of BaseTextures
  131804. */
  131805. getActiveTextures(activeTextures: BaseTexture[]): void;
  131806. /**
  131807. * Returns the animatable textures.
  131808. * @param animatables Array of animatable textures.
  131809. */
  131810. getAnimatables(animatables: IAnimatable[]): void;
  131811. /**
  131812. * Disposes the resources of the material.
  131813. * @param forceDisposeTextures - Forces the disposal of all textures.
  131814. */
  131815. dispose(forceDisposeTextures?: boolean): void;
  131816. /**
  131817. * Get the current class name of the texture useful for serialization or dynamic coding.
  131818. * @returns "PBRAnisotropicConfiguration"
  131819. */
  131820. getClassName(): string;
  131821. /**
  131822. * Add fallbacks to the effect fallbacks list.
  131823. * @param defines defines the Base texture to use.
  131824. * @param fallbacks defines the current fallback list.
  131825. * @param currentRank defines the current fallback rank.
  131826. * @returns the new fallback rank.
  131827. */
  131828. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  131829. /**
  131830. * Add the required uniforms to the current list.
  131831. * @param uniforms defines the current uniform list.
  131832. */
  131833. static AddUniforms(uniforms: string[]): void;
  131834. /**
  131835. * Add the required uniforms to the current buffer.
  131836. * @param uniformBuffer defines the current uniform buffer.
  131837. */
  131838. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  131839. /**
  131840. * Add the required samplers to the current list.
  131841. * @param samplers defines the current sampler list.
  131842. */
  131843. static AddSamplers(samplers: string[]): void;
  131844. /**
  131845. * Makes a duplicate of the current configuration into another one.
  131846. * @param anisotropicConfiguration define the config where to copy the info
  131847. */
  131848. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  131849. /**
  131850. * Serializes this anisotropy configuration.
  131851. * @returns - An object with the serialized config.
  131852. */
  131853. serialize(): any;
  131854. /**
  131855. * Parses a anisotropy Configuration from a serialized object.
  131856. * @param source - Serialized object.
  131857. * @param scene Defines the scene we are parsing for
  131858. * @param rootUrl Defines the rootUrl to load from
  131859. */
  131860. parse(source: any, scene: Scene, rootUrl: string): void;
  131861. }
  131862. }
  131863. declare module BABYLON {
  131864. /**
  131865. * @hidden
  131866. */
  131867. export interface IMaterialBRDFDefines {
  131868. BRDF_V_HEIGHT_CORRELATED: boolean;
  131869. MS_BRDF_ENERGY_CONSERVATION: boolean;
  131870. SPHERICAL_HARMONICS: boolean;
  131871. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  131872. /** @hidden */
  131873. _areMiscDirty: boolean;
  131874. }
  131875. /**
  131876. * Define the code related to the BRDF parameters of the pbr material.
  131877. */
  131878. export class PBRBRDFConfiguration {
  131879. /**
  131880. * Default value used for the energy conservation.
  131881. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131882. */
  131883. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  131884. /**
  131885. * Default value used for the Smith Visibility Height Correlated mode.
  131886. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  131887. */
  131888. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  131889. /**
  131890. * Default value used for the IBL diffuse part.
  131891. * This can help switching back to the polynomials mode globally which is a tiny bit
  131892. * less GPU intensive at the drawback of a lower quality.
  131893. */
  131894. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  131895. /**
  131896. * Default value used for activating energy conservation for the specular workflow.
  131897. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131898. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131899. */
  131900. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  131901. private _useEnergyConservation;
  131902. /**
  131903. * Defines if the material uses energy conservation.
  131904. */
  131905. useEnergyConservation: boolean;
  131906. private _useSmithVisibilityHeightCorrelated;
  131907. /**
  131908. * LEGACY Mode set to false
  131909. * Defines if the material uses height smith correlated visibility term.
  131910. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  131911. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  131912. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  131913. * Not relying on height correlated will also disable energy conservation.
  131914. */
  131915. useSmithVisibilityHeightCorrelated: boolean;
  131916. private _useSphericalHarmonics;
  131917. /**
  131918. * LEGACY Mode set to false
  131919. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  131920. * diffuse part of the IBL.
  131921. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  131922. * to the ground truth.
  131923. */
  131924. useSphericalHarmonics: boolean;
  131925. private _useSpecularGlossinessInputEnergyConservation;
  131926. /**
  131927. * Defines if the material uses energy conservation, when the specular workflow is active.
  131928. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  131929. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  131930. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  131931. */
  131932. useSpecularGlossinessInputEnergyConservation: boolean;
  131933. /** @hidden */
  131934. private _internalMarkAllSubMeshesAsMiscDirty;
  131935. /** @hidden */
  131936. _markAllSubMeshesAsMiscDirty(): void;
  131937. /**
  131938. * Instantiate a new istance of clear coat configuration.
  131939. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  131940. */
  131941. constructor(markAllSubMeshesAsMiscDirty: () => void);
  131942. /**
  131943. * Checks to see if a texture is used in the material.
  131944. * @param defines the list of "defines" to update.
  131945. */
  131946. prepareDefines(defines: IMaterialBRDFDefines): void;
  131947. /**
  131948. * Get the current class name of the texture useful for serialization or dynamic coding.
  131949. * @returns "PBRClearCoatConfiguration"
  131950. */
  131951. getClassName(): string;
  131952. /**
  131953. * Makes a duplicate of the current configuration into another one.
  131954. * @param brdfConfiguration define the config where to copy the info
  131955. */
  131956. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  131957. /**
  131958. * Serializes this BRDF configuration.
  131959. * @returns - An object with the serialized config.
  131960. */
  131961. serialize(): any;
  131962. /**
  131963. * Parses a anisotropy Configuration from a serialized object.
  131964. * @param source - Serialized object.
  131965. * @param scene Defines the scene we are parsing for
  131966. * @param rootUrl Defines the rootUrl to load from
  131967. */
  131968. parse(source: any, scene: Scene, rootUrl: string): void;
  131969. }
  131970. }
  131971. declare module BABYLON {
  131972. /**
  131973. * @hidden
  131974. */
  131975. export interface IMaterialSheenDefines {
  131976. SHEEN: boolean;
  131977. SHEEN_TEXTURE: boolean;
  131978. SHEEN_TEXTUREDIRECTUV: number;
  131979. SHEEN_LINKWITHALBEDO: boolean;
  131980. SHEEN_ROUGHNESS: boolean;
  131981. SHEEN_ALBEDOSCALING: boolean;
  131982. /** @hidden */
  131983. _areTexturesDirty: boolean;
  131984. }
  131985. /**
  131986. * Define the code related to the Sheen parameters of the pbr material.
  131987. */
  131988. export class PBRSheenConfiguration {
  131989. private _isEnabled;
  131990. /**
  131991. * Defines if the material uses sheen.
  131992. */
  131993. isEnabled: boolean;
  131994. private _linkSheenWithAlbedo;
  131995. /**
  131996. * Defines if the sheen is linked to the sheen color.
  131997. */
  131998. linkSheenWithAlbedo: boolean;
  131999. /**
  132000. * Defines the sheen intensity.
  132001. */
  132002. intensity: number;
  132003. /**
  132004. * Defines the sheen color.
  132005. */
  132006. color: Color3;
  132007. private _texture;
  132008. /**
  132009. * Stores the sheen tint values in a texture.
  132010. * rgb is tint
  132011. * a is a intensity
  132012. */
  132013. texture: Nullable<BaseTexture>;
  132014. private _roughness;
  132015. /**
  132016. * Defines the sheen roughness.
  132017. * It is not taken into account if linkSheenWithAlbedo is true.
  132018. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132019. */
  132020. roughness: Nullable<number>;
  132021. private _albedoScaling;
  132022. /**
  132023. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132024. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132025. * making it easier to setup and tweak the effect
  132026. */
  132027. albedoScaling: boolean;
  132028. /** @hidden */
  132029. private _internalMarkAllSubMeshesAsTexturesDirty;
  132030. /** @hidden */
  132031. _markAllSubMeshesAsTexturesDirty(): void;
  132032. /**
  132033. * Instantiate a new istance of clear coat configuration.
  132034. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132035. */
  132036. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132037. /**
  132038. * Specifies that the submesh is ready to be used.
  132039. * @param defines the list of "defines" to update.
  132040. * @param scene defines the scene the material belongs to.
  132041. * @returns - boolean indicating that the submesh is ready or not.
  132042. */
  132043. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132044. /**
  132045. * Checks to see if a texture is used in the material.
  132046. * @param defines the list of "defines" to update.
  132047. * @param scene defines the scene the material belongs to.
  132048. */
  132049. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132050. /**
  132051. * Binds the material data.
  132052. * @param uniformBuffer defines the Uniform buffer to fill in.
  132053. * @param scene defines the scene the material belongs to.
  132054. * @param isFrozen defines wether the material is frozen or not.
  132055. */
  132056. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132057. /**
  132058. * Checks to see if a texture is used in the material.
  132059. * @param texture - Base texture to use.
  132060. * @returns - Boolean specifying if a texture is used in the material.
  132061. */
  132062. hasTexture(texture: BaseTexture): boolean;
  132063. /**
  132064. * Returns an array of the actively used textures.
  132065. * @param activeTextures Array of BaseTextures
  132066. */
  132067. getActiveTextures(activeTextures: BaseTexture[]): void;
  132068. /**
  132069. * Returns the animatable textures.
  132070. * @param animatables Array of animatable textures.
  132071. */
  132072. getAnimatables(animatables: IAnimatable[]): void;
  132073. /**
  132074. * Disposes the resources of the material.
  132075. * @param forceDisposeTextures - Forces the disposal of all textures.
  132076. */
  132077. dispose(forceDisposeTextures?: boolean): void;
  132078. /**
  132079. * Get the current class name of the texture useful for serialization or dynamic coding.
  132080. * @returns "PBRSheenConfiguration"
  132081. */
  132082. getClassName(): string;
  132083. /**
  132084. * Add fallbacks to the effect fallbacks list.
  132085. * @param defines defines the Base texture to use.
  132086. * @param fallbacks defines the current fallback list.
  132087. * @param currentRank defines the current fallback rank.
  132088. * @returns the new fallback rank.
  132089. */
  132090. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132091. /**
  132092. * Add the required uniforms to the current list.
  132093. * @param uniforms defines the current uniform list.
  132094. */
  132095. static AddUniforms(uniforms: string[]): void;
  132096. /**
  132097. * Add the required uniforms to the current buffer.
  132098. * @param uniformBuffer defines the current uniform buffer.
  132099. */
  132100. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132101. /**
  132102. * Add the required samplers to the current list.
  132103. * @param samplers defines the current sampler list.
  132104. */
  132105. static AddSamplers(samplers: string[]): void;
  132106. /**
  132107. * Makes a duplicate of the current configuration into another one.
  132108. * @param sheenConfiguration define the config where to copy the info
  132109. */
  132110. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  132111. /**
  132112. * Serializes this BRDF configuration.
  132113. * @returns - An object with the serialized config.
  132114. */
  132115. serialize(): any;
  132116. /**
  132117. * Parses a anisotropy Configuration from a serialized object.
  132118. * @param source - Serialized object.
  132119. * @param scene Defines the scene we are parsing for
  132120. * @param rootUrl Defines the rootUrl to load from
  132121. */
  132122. parse(source: any, scene: Scene, rootUrl: string): void;
  132123. }
  132124. }
  132125. declare module BABYLON {
  132126. /**
  132127. * @hidden
  132128. */
  132129. export interface IMaterialSubSurfaceDefines {
  132130. SUBSURFACE: boolean;
  132131. SS_REFRACTION: boolean;
  132132. SS_TRANSLUCENCY: boolean;
  132133. SS_SCATTERING: boolean;
  132134. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132135. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132136. SS_REFRACTIONMAP_3D: boolean;
  132137. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132138. SS_LODINREFRACTIONALPHA: boolean;
  132139. SS_GAMMAREFRACTION: boolean;
  132140. SS_RGBDREFRACTION: boolean;
  132141. SS_LINEARSPECULARREFRACTION: boolean;
  132142. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132143. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132144. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132145. /** @hidden */
  132146. _areTexturesDirty: boolean;
  132147. }
  132148. /**
  132149. * Define the code related to the sub surface parameters of the pbr material.
  132150. */
  132151. export class PBRSubSurfaceConfiguration {
  132152. private _isRefractionEnabled;
  132153. /**
  132154. * Defines if the refraction is enabled in the material.
  132155. */
  132156. isRefractionEnabled: boolean;
  132157. private _isTranslucencyEnabled;
  132158. /**
  132159. * Defines if the translucency is enabled in the material.
  132160. */
  132161. isTranslucencyEnabled: boolean;
  132162. private _isScatteringEnabled;
  132163. /**
  132164. * Defines the refraction intensity of the material.
  132165. * The refraction when enabled replaces the Diffuse part of the material.
  132166. * The intensity helps transitionning between diffuse and refraction.
  132167. */
  132168. refractionIntensity: number;
  132169. /**
  132170. * Defines the translucency intensity of the material.
  132171. * When translucency has been enabled, this defines how much of the "translucency"
  132172. * is addded to the diffuse part of the material.
  132173. */
  132174. translucencyIntensity: number;
  132175. /**
  132176. * Defines the scattering intensity of the material.
  132177. * When scattering has been enabled, this defines how much of the "scattered light"
  132178. * is addded to the diffuse part of the material.
  132179. */
  132180. scatteringIntensity: number;
  132181. /**
  132182. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  132183. */
  132184. useAlbedoToTintRefraction: boolean;
  132185. private _thicknessTexture;
  132186. /**
  132187. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  132188. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  132189. * 0 would mean minimumThickness
  132190. * 1 would mean maximumThickness
  132191. * The other channels might be use as a mask to vary the different effects intensity.
  132192. */
  132193. thicknessTexture: Nullable<BaseTexture>;
  132194. private _refractionTexture;
  132195. /**
  132196. * Defines the texture to use for refraction.
  132197. */
  132198. refractionTexture: Nullable<BaseTexture>;
  132199. private _indexOfRefraction;
  132200. /**
  132201. * Index of refraction of the material base layer.
  132202. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132203. *
  132204. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  132205. *
  132206. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  132207. */
  132208. indexOfRefraction: number;
  132209. private _volumeIndexOfRefraction;
  132210. /**
  132211. * Index of refraction of the material's volume.
  132212. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  132213. *
  132214. * This ONLY impacts refraction. If not provided or given a non-valid value,
  132215. * the volume will use the same IOR as the surface.
  132216. */
  132217. get volumeIndexOfRefraction(): number;
  132218. set volumeIndexOfRefraction(value: number);
  132219. private _invertRefractionY;
  132220. /**
  132221. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  132222. */
  132223. invertRefractionY: boolean;
  132224. private _linkRefractionWithTransparency;
  132225. /**
  132226. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  132227. * Materials half opaque for instance using refraction could benefit from this control.
  132228. */
  132229. linkRefractionWithTransparency: boolean;
  132230. /**
  132231. * Defines the minimum thickness stored in the thickness map.
  132232. * If no thickness map is defined, this value will be used to simulate thickness.
  132233. */
  132234. minimumThickness: number;
  132235. /**
  132236. * Defines the maximum thickness stored in the thickness map.
  132237. */
  132238. maximumThickness: number;
  132239. /**
  132240. * Defines the volume tint of the material.
  132241. * This is used for both translucency and scattering.
  132242. */
  132243. tintColor: Color3;
  132244. /**
  132245. * Defines the distance at which the tint color should be found in the media.
  132246. * This is used for refraction only.
  132247. */
  132248. tintColorAtDistance: number;
  132249. /**
  132250. * Defines how far each channel transmit through the media.
  132251. * It is defined as a color to simplify it selection.
  132252. */
  132253. diffusionDistance: Color3;
  132254. private _useMaskFromThicknessTexture;
  132255. /**
  132256. * Stores the intensity of the different subsurface effects in the thickness texture.
  132257. * * the green channel is the translucency intensity.
  132258. * * the blue channel is the scattering intensity.
  132259. * * the alpha channel is the refraction intensity.
  132260. */
  132261. useMaskFromThicknessTexture: boolean;
  132262. /** @hidden */
  132263. private _internalMarkAllSubMeshesAsTexturesDirty;
  132264. /** @hidden */
  132265. _markAllSubMeshesAsTexturesDirty(): void;
  132266. /**
  132267. * Instantiate a new istance of sub surface configuration.
  132268. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132269. */
  132270. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132271. /**
  132272. * Gets wehter the submesh is ready to be used or not.
  132273. * @param defines the list of "defines" to update.
  132274. * @param scene defines the scene the material belongs to.
  132275. * @returns - boolean indicating that the submesh is ready or not.
  132276. */
  132277. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  132278. /**
  132279. * Checks to see if a texture is used in the material.
  132280. * @param defines the list of "defines" to update.
  132281. * @param scene defines the scene to the material belongs to.
  132282. */
  132283. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  132284. /**
  132285. * Binds the material data.
  132286. * @param uniformBuffer defines the Uniform buffer to fill in.
  132287. * @param scene defines the scene the material belongs to.
  132288. * @param engine defines the engine the material belongs to.
  132289. * @param isFrozen defines whether the material is frozen or not.
  132290. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  132291. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  132292. */
  132293. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  132294. /**
  132295. * Unbinds the material from the mesh.
  132296. * @param activeEffect defines the effect that should be unbound from.
  132297. * @returns true if unbound, otherwise false
  132298. */
  132299. unbind(activeEffect: Effect): boolean;
  132300. /**
  132301. * Returns the texture used for refraction or null if none is used.
  132302. * @param scene defines the scene the material belongs to.
  132303. * @returns - Refraction texture if present. If no refraction texture and refraction
  132304. * is linked with transparency, returns environment texture. Otherwise, returns null.
  132305. */
  132306. private _getRefractionTexture;
  132307. /**
  132308. * Returns true if alpha blending should be disabled.
  132309. */
  132310. get disableAlphaBlending(): boolean;
  132311. /**
  132312. * Fills the list of render target textures.
  132313. * @param renderTargets the list of render targets to update
  132314. */
  132315. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  132316. /**
  132317. * Checks to see if a texture is used in the material.
  132318. * @param texture - Base texture to use.
  132319. * @returns - Boolean specifying if a texture is used in the material.
  132320. */
  132321. hasTexture(texture: BaseTexture): boolean;
  132322. /**
  132323. * Gets a boolean indicating that current material needs to register RTT
  132324. * @returns true if this uses a render target otherwise false.
  132325. */
  132326. hasRenderTargetTextures(): boolean;
  132327. /**
  132328. * Returns an array of the actively used textures.
  132329. * @param activeTextures Array of BaseTextures
  132330. */
  132331. getActiveTextures(activeTextures: BaseTexture[]): void;
  132332. /**
  132333. * Returns the animatable textures.
  132334. * @param animatables Array of animatable textures.
  132335. */
  132336. getAnimatables(animatables: IAnimatable[]): void;
  132337. /**
  132338. * Disposes the resources of the material.
  132339. * @param forceDisposeTextures - Forces the disposal of all textures.
  132340. */
  132341. dispose(forceDisposeTextures?: boolean): void;
  132342. /**
  132343. * Get the current class name of the texture useful for serialization or dynamic coding.
  132344. * @returns "PBRSubSurfaceConfiguration"
  132345. */
  132346. getClassName(): string;
  132347. /**
  132348. * Add fallbacks to the effect fallbacks list.
  132349. * @param defines defines the Base texture to use.
  132350. * @param fallbacks defines the current fallback list.
  132351. * @param currentRank defines the current fallback rank.
  132352. * @returns the new fallback rank.
  132353. */
  132354. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132355. /**
  132356. * Add the required uniforms to the current list.
  132357. * @param uniforms defines the current uniform list.
  132358. */
  132359. static AddUniforms(uniforms: string[]): void;
  132360. /**
  132361. * Add the required samplers to the current list.
  132362. * @param samplers defines the current sampler list.
  132363. */
  132364. static AddSamplers(samplers: string[]): void;
  132365. /**
  132366. * Add the required uniforms to the current buffer.
  132367. * @param uniformBuffer defines the current uniform buffer.
  132368. */
  132369. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132370. /**
  132371. * Makes a duplicate of the current configuration into another one.
  132372. * @param configuration define the config where to copy the info
  132373. */
  132374. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  132375. /**
  132376. * Serializes this Sub Surface configuration.
  132377. * @returns - An object with the serialized config.
  132378. */
  132379. serialize(): any;
  132380. /**
  132381. * Parses a anisotropy Configuration from a serialized object.
  132382. * @param source - Serialized object.
  132383. * @param scene Defines the scene we are parsing for
  132384. * @param rootUrl Defines the rootUrl to load from
  132385. */
  132386. parse(source: any, scene: Scene, rootUrl: string): void;
  132387. }
  132388. }
  132389. declare module BABYLON {
  132390. /** @hidden */
  132391. export var pbrFragmentDeclaration: {
  132392. name: string;
  132393. shader: string;
  132394. };
  132395. }
  132396. declare module BABYLON {
  132397. /** @hidden */
  132398. export var pbrUboDeclaration: {
  132399. name: string;
  132400. shader: string;
  132401. };
  132402. }
  132403. declare module BABYLON {
  132404. /** @hidden */
  132405. export var pbrFragmentExtraDeclaration: {
  132406. name: string;
  132407. shader: string;
  132408. };
  132409. }
  132410. declare module BABYLON {
  132411. /** @hidden */
  132412. export var pbrFragmentSamplersDeclaration: {
  132413. name: string;
  132414. shader: string;
  132415. };
  132416. }
  132417. declare module BABYLON {
  132418. /** @hidden */
  132419. export var importanceSampling: {
  132420. name: string;
  132421. shader: string;
  132422. };
  132423. }
  132424. declare module BABYLON {
  132425. /** @hidden */
  132426. export var pbrHelperFunctions: {
  132427. name: string;
  132428. shader: string;
  132429. };
  132430. }
  132431. declare module BABYLON {
  132432. /** @hidden */
  132433. export var harmonicsFunctions: {
  132434. name: string;
  132435. shader: string;
  132436. };
  132437. }
  132438. declare module BABYLON {
  132439. /** @hidden */
  132440. export var pbrDirectLightingSetupFunctions: {
  132441. name: string;
  132442. shader: string;
  132443. };
  132444. }
  132445. declare module BABYLON {
  132446. /** @hidden */
  132447. export var pbrDirectLightingFalloffFunctions: {
  132448. name: string;
  132449. shader: string;
  132450. };
  132451. }
  132452. declare module BABYLON {
  132453. /** @hidden */
  132454. export var pbrBRDFFunctions: {
  132455. name: string;
  132456. shader: string;
  132457. };
  132458. }
  132459. declare module BABYLON {
  132460. /** @hidden */
  132461. export var hdrFilteringFunctions: {
  132462. name: string;
  132463. shader: string;
  132464. };
  132465. }
  132466. declare module BABYLON {
  132467. /** @hidden */
  132468. export var pbrDirectLightingFunctions: {
  132469. name: string;
  132470. shader: string;
  132471. };
  132472. }
  132473. declare module BABYLON {
  132474. /** @hidden */
  132475. export var pbrIBLFunctions: {
  132476. name: string;
  132477. shader: string;
  132478. };
  132479. }
  132480. declare module BABYLON {
  132481. /** @hidden */
  132482. export var pbrBlockAlbedoOpacity: {
  132483. name: string;
  132484. shader: string;
  132485. };
  132486. }
  132487. declare module BABYLON {
  132488. /** @hidden */
  132489. export var pbrBlockReflectivity: {
  132490. name: string;
  132491. shader: string;
  132492. };
  132493. }
  132494. declare module BABYLON {
  132495. /** @hidden */
  132496. export var pbrBlockAmbientOcclusion: {
  132497. name: string;
  132498. shader: string;
  132499. };
  132500. }
  132501. declare module BABYLON {
  132502. /** @hidden */
  132503. export var pbrBlockAlphaFresnel: {
  132504. name: string;
  132505. shader: string;
  132506. };
  132507. }
  132508. declare module BABYLON {
  132509. /** @hidden */
  132510. export var pbrBlockAnisotropic: {
  132511. name: string;
  132512. shader: string;
  132513. };
  132514. }
  132515. declare module BABYLON {
  132516. /** @hidden */
  132517. export var pbrBlockReflection: {
  132518. name: string;
  132519. shader: string;
  132520. };
  132521. }
  132522. declare module BABYLON {
  132523. /** @hidden */
  132524. export var pbrBlockSheen: {
  132525. name: string;
  132526. shader: string;
  132527. };
  132528. }
  132529. declare module BABYLON {
  132530. /** @hidden */
  132531. export var pbrBlockClearcoat: {
  132532. name: string;
  132533. shader: string;
  132534. };
  132535. }
  132536. declare module BABYLON {
  132537. /** @hidden */
  132538. export var pbrBlockSubSurface: {
  132539. name: string;
  132540. shader: string;
  132541. };
  132542. }
  132543. declare module BABYLON {
  132544. /** @hidden */
  132545. export var pbrBlockNormalGeometric: {
  132546. name: string;
  132547. shader: string;
  132548. };
  132549. }
  132550. declare module BABYLON {
  132551. /** @hidden */
  132552. export var pbrBlockNormalFinal: {
  132553. name: string;
  132554. shader: string;
  132555. };
  132556. }
  132557. declare module BABYLON {
  132558. /** @hidden */
  132559. export var pbrBlockGeometryInfo: {
  132560. name: string;
  132561. shader: string;
  132562. };
  132563. }
  132564. declare module BABYLON {
  132565. /** @hidden */
  132566. export var pbrBlockReflectance0: {
  132567. name: string;
  132568. shader: string;
  132569. };
  132570. }
  132571. declare module BABYLON {
  132572. /** @hidden */
  132573. export var pbrBlockReflectance: {
  132574. name: string;
  132575. shader: string;
  132576. };
  132577. }
  132578. declare module BABYLON {
  132579. /** @hidden */
  132580. export var pbrBlockDirectLighting: {
  132581. name: string;
  132582. shader: string;
  132583. };
  132584. }
  132585. declare module BABYLON {
  132586. /** @hidden */
  132587. export var pbrBlockFinalLitComponents: {
  132588. name: string;
  132589. shader: string;
  132590. };
  132591. }
  132592. declare module BABYLON {
  132593. /** @hidden */
  132594. export var pbrBlockFinalUnlitComponents: {
  132595. name: string;
  132596. shader: string;
  132597. };
  132598. }
  132599. declare module BABYLON {
  132600. /** @hidden */
  132601. export var pbrBlockFinalColorComposition: {
  132602. name: string;
  132603. shader: string;
  132604. };
  132605. }
  132606. declare module BABYLON {
  132607. /** @hidden */
  132608. export var pbrBlockImageProcessing: {
  132609. name: string;
  132610. shader: string;
  132611. };
  132612. }
  132613. declare module BABYLON {
  132614. /** @hidden */
  132615. export var pbrDebug: {
  132616. name: string;
  132617. shader: string;
  132618. };
  132619. }
  132620. declare module BABYLON {
  132621. /** @hidden */
  132622. export var pbrPixelShader: {
  132623. name: string;
  132624. shader: string;
  132625. };
  132626. }
  132627. declare module BABYLON {
  132628. /** @hidden */
  132629. export var pbrVertexDeclaration: {
  132630. name: string;
  132631. shader: string;
  132632. };
  132633. }
  132634. declare module BABYLON {
  132635. /** @hidden */
  132636. export var pbrVertexShader: {
  132637. name: string;
  132638. shader: string;
  132639. };
  132640. }
  132641. declare module BABYLON {
  132642. /**
  132643. * Manages the defines for the PBR Material.
  132644. * @hidden
  132645. */
  132646. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  132647. PBR: boolean;
  132648. NUM_SAMPLES: string;
  132649. REALTIME_FILTERING: boolean;
  132650. MAINUV1: boolean;
  132651. MAINUV2: boolean;
  132652. UV1: boolean;
  132653. UV2: boolean;
  132654. ALBEDO: boolean;
  132655. GAMMAALBEDO: boolean;
  132656. ALBEDODIRECTUV: number;
  132657. VERTEXCOLOR: boolean;
  132658. DETAIL: boolean;
  132659. DETAILDIRECTUV: number;
  132660. DETAIL_NORMALBLENDMETHOD: number;
  132661. AMBIENT: boolean;
  132662. AMBIENTDIRECTUV: number;
  132663. AMBIENTINGRAYSCALE: boolean;
  132664. OPACITY: boolean;
  132665. VERTEXALPHA: boolean;
  132666. OPACITYDIRECTUV: number;
  132667. OPACITYRGB: boolean;
  132668. ALPHATEST: boolean;
  132669. DEPTHPREPASS: boolean;
  132670. ALPHABLEND: boolean;
  132671. ALPHAFROMALBEDO: boolean;
  132672. ALPHATESTVALUE: string;
  132673. SPECULAROVERALPHA: boolean;
  132674. RADIANCEOVERALPHA: boolean;
  132675. ALPHAFRESNEL: boolean;
  132676. LINEARALPHAFRESNEL: boolean;
  132677. PREMULTIPLYALPHA: boolean;
  132678. EMISSIVE: boolean;
  132679. EMISSIVEDIRECTUV: number;
  132680. REFLECTIVITY: boolean;
  132681. REFLECTIVITYDIRECTUV: number;
  132682. SPECULARTERM: boolean;
  132683. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  132684. MICROSURFACEAUTOMATIC: boolean;
  132685. LODBASEDMICROSFURACE: boolean;
  132686. MICROSURFACEMAP: boolean;
  132687. MICROSURFACEMAPDIRECTUV: number;
  132688. METALLICWORKFLOW: boolean;
  132689. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  132690. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  132691. METALLNESSSTOREINMETALMAPBLUE: boolean;
  132692. AOSTOREINMETALMAPRED: boolean;
  132693. METALLIC_REFLECTANCE: boolean;
  132694. METALLIC_REFLECTANCEDIRECTUV: number;
  132695. ENVIRONMENTBRDF: boolean;
  132696. ENVIRONMENTBRDF_RGBD: boolean;
  132697. NORMAL: boolean;
  132698. TANGENT: boolean;
  132699. BUMP: boolean;
  132700. BUMPDIRECTUV: number;
  132701. OBJECTSPACE_NORMALMAP: boolean;
  132702. PARALLAX: boolean;
  132703. PARALLAXOCCLUSION: boolean;
  132704. NORMALXYSCALE: boolean;
  132705. LIGHTMAP: boolean;
  132706. LIGHTMAPDIRECTUV: number;
  132707. USELIGHTMAPASSHADOWMAP: boolean;
  132708. GAMMALIGHTMAP: boolean;
  132709. RGBDLIGHTMAP: boolean;
  132710. REFLECTION: boolean;
  132711. REFLECTIONMAP_3D: boolean;
  132712. REFLECTIONMAP_SPHERICAL: boolean;
  132713. REFLECTIONMAP_PLANAR: boolean;
  132714. REFLECTIONMAP_CUBIC: boolean;
  132715. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  132716. REFLECTIONMAP_PROJECTION: boolean;
  132717. REFLECTIONMAP_SKYBOX: boolean;
  132718. REFLECTIONMAP_EXPLICIT: boolean;
  132719. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  132720. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  132721. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  132722. INVERTCUBICMAP: boolean;
  132723. USESPHERICALFROMREFLECTIONMAP: boolean;
  132724. USEIRRADIANCEMAP: boolean;
  132725. SPHERICAL_HARMONICS: boolean;
  132726. USESPHERICALINVERTEX: boolean;
  132727. REFLECTIONMAP_OPPOSITEZ: boolean;
  132728. LODINREFLECTIONALPHA: boolean;
  132729. GAMMAREFLECTION: boolean;
  132730. RGBDREFLECTION: boolean;
  132731. LINEARSPECULARREFLECTION: boolean;
  132732. RADIANCEOCCLUSION: boolean;
  132733. HORIZONOCCLUSION: boolean;
  132734. INSTANCES: boolean;
  132735. THIN_INSTANCES: boolean;
  132736. NUM_BONE_INFLUENCERS: number;
  132737. BonesPerMesh: number;
  132738. BONETEXTURE: boolean;
  132739. NONUNIFORMSCALING: boolean;
  132740. MORPHTARGETS: boolean;
  132741. MORPHTARGETS_NORMAL: boolean;
  132742. MORPHTARGETS_TANGENT: boolean;
  132743. MORPHTARGETS_UV: boolean;
  132744. NUM_MORPH_INFLUENCERS: number;
  132745. IMAGEPROCESSING: boolean;
  132746. VIGNETTE: boolean;
  132747. VIGNETTEBLENDMODEMULTIPLY: boolean;
  132748. VIGNETTEBLENDMODEOPAQUE: boolean;
  132749. TONEMAPPING: boolean;
  132750. TONEMAPPING_ACES: boolean;
  132751. CONTRAST: boolean;
  132752. COLORCURVES: boolean;
  132753. COLORGRADING: boolean;
  132754. COLORGRADING3D: boolean;
  132755. SAMPLER3DGREENDEPTH: boolean;
  132756. SAMPLER3DBGRMAP: boolean;
  132757. IMAGEPROCESSINGPOSTPROCESS: boolean;
  132758. EXPOSURE: boolean;
  132759. MULTIVIEW: boolean;
  132760. USEPHYSICALLIGHTFALLOFF: boolean;
  132761. USEGLTFLIGHTFALLOFF: boolean;
  132762. TWOSIDEDLIGHTING: boolean;
  132763. SHADOWFLOAT: boolean;
  132764. CLIPPLANE: boolean;
  132765. CLIPPLANE2: boolean;
  132766. CLIPPLANE3: boolean;
  132767. CLIPPLANE4: boolean;
  132768. CLIPPLANE5: boolean;
  132769. CLIPPLANE6: boolean;
  132770. POINTSIZE: boolean;
  132771. FOG: boolean;
  132772. LOGARITHMICDEPTH: boolean;
  132773. FORCENORMALFORWARD: boolean;
  132774. SPECULARAA: boolean;
  132775. CLEARCOAT: boolean;
  132776. CLEARCOAT_DEFAULTIOR: boolean;
  132777. CLEARCOAT_TEXTURE: boolean;
  132778. CLEARCOAT_TEXTUREDIRECTUV: number;
  132779. CLEARCOAT_BUMP: boolean;
  132780. CLEARCOAT_BUMPDIRECTUV: number;
  132781. CLEARCOAT_TINT: boolean;
  132782. CLEARCOAT_TINT_TEXTURE: boolean;
  132783. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132784. ANISOTROPIC: boolean;
  132785. ANISOTROPIC_TEXTURE: boolean;
  132786. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132787. BRDF_V_HEIGHT_CORRELATED: boolean;
  132788. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132789. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132790. SHEEN: boolean;
  132791. SHEEN_TEXTURE: boolean;
  132792. SHEEN_TEXTUREDIRECTUV: number;
  132793. SHEEN_LINKWITHALBEDO: boolean;
  132794. SHEEN_ROUGHNESS: boolean;
  132795. SHEEN_ALBEDOSCALING: boolean;
  132796. SUBSURFACE: boolean;
  132797. SS_REFRACTION: boolean;
  132798. SS_TRANSLUCENCY: boolean;
  132799. SS_SCATTERING: boolean;
  132800. SS_THICKNESSANDMASK_TEXTURE: boolean;
  132801. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  132802. SS_REFRACTIONMAP_3D: boolean;
  132803. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  132804. SS_LODINREFRACTIONALPHA: boolean;
  132805. SS_GAMMAREFRACTION: boolean;
  132806. SS_RGBDREFRACTION: boolean;
  132807. SS_LINEARSPECULARREFRACTION: boolean;
  132808. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  132809. SS_ALBEDOFORREFRACTIONTINT: boolean;
  132810. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  132811. UNLIT: boolean;
  132812. DEBUGMODE: number;
  132813. /**
  132814. * Initializes the PBR Material defines.
  132815. */
  132816. constructor();
  132817. /**
  132818. * Resets the PBR Material defines.
  132819. */
  132820. reset(): void;
  132821. }
  132822. /**
  132823. * The Physically based material base class of BJS.
  132824. *
  132825. * This offers the main features of a standard PBR material.
  132826. * For more information, please refer to the documentation :
  132827. * https://doc.babylonjs.com/how_to/physically_based_rendering
  132828. */
  132829. export abstract class PBRBaseMaterial extends PushMaterial {
  132830. /**
  132831. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  132832. */
  132833. static readonly PBRMATERIAL_OPAQUE: number;
  132834. /**
  132835. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  132836. */
  132837. static readonly PBRMATERIAL_ALPHATEST: number;
  132838. /**
  132839. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132840. */
  132841. static readonly PBRMATERIAL_ALPHABLEND: number;
  132842. /**
  132843. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  132844. * They are also discarded below the alpha cutoff threshold to improve performances.
  132845. */
  132846. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  132847. /**
  132848. * Defines the default value of how much AO map is occluding the analytical lights
  132849. * (point spot...).
  132850. */
  132851. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  132852. /**
  132853. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  132854. */
  132855. static readonly LIGHTFALLOFF_PHYSICAL: number;
  132856. /**
  132857. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  132858. * to enhance interoperability with other engines.
  132859. */
  132860. static readonly LIGHTFALLOFF_GLTF: number;
  132861. /**
  132862. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  132863. * to enhance interoperability with other materials.
  132864. */
  132865. static readonly LIGHTFALLOFF_STANDARD: number;
  132866. /**
  132867. * Intensity of the direct lights e.g. the four lights available in your scene.
  132868. * This impacts both the direct diffuse and specular highlights.
  132869. */
  132870. protected _directIntensity: number;
  132871. /**
  132872. * Intensity of the emissive part of the material.
  132873. * This helps controlling the emissive effect without modifying the emissive color.
  132874. */
  132875. protected _emissiveIntensity: number;
  132876. /**
  132877. * Intensity of the environment e.g. how much the environment will light the object
  132878. * either through harmonics for rough material or through the refelction for shiny ones.
  132879. */
  132880. protected _environmentIntensity: number;
  132881. /**
  132882. * This is a special control allowing the reduction of the specular highlights coming from the
  132883. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  132884. */
  132885. protected _specularIntensity: number;
  132886. /**
  132887. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  132888. */
  132889. private _lightingInfos;
  132890. /**
  132891. * Debug Control allowing disabling the bump map on this material.
  132892. */
  132893. protected _disableBumpMap: boolean;
  132894. /**
  132895. * AKA Diffuse Texture in standard nomenclature.
  132896. */
  132897. protected _albedoTexture: Nullable<BaseTexture>;
  132898. /**
  132899. * AKA Occlusion Texture in other nomenclature.
  132900. */
  132901. protected _ambientTexture: Nullable<BaseTexture>;
  132902. /**
  132903. * AKA Occlusion Texture Intensity in other nomenclature.
  132904. */
  132905. protected _ambientTextureStrength: number;
  132906. /**
  132907. * Defines how much the AO map is occluding the analytical lights (point spot...).
  132908. * 1 means it completely occludes it
  132909. * 0 mean it has no impact
  132910. */
  132911. protected _ambientTextureImpactOnAnalyticalLights: number;
  132912. /**
  132913. * Stores the alpha values in a texture.
  132914. */
  132915. protected _opacityTexture: Nullable<BaseTexture>;
  132916. /**
  132917. * Stores the reflection values in a texture.
  132918. */
  132919. protected _reflectionTexture: Nullable<BaseTexture>;
  132920. /**
  132921. * Stores the emissive values in a texture.
  132922. */
  132923. protected _emissiveTexture: Nullable<BaseTexture>;
  132924. /**
  132925. * AKA Specular texture in other nomenclature.
  132926. */
  132927. protected _reflectivityTexture: Nullable<BaseTexture>;
  132928. /**
  132929. * Used to switch from specular/glossiness to metallic/roughness workflow.
  132930. */
  132931. protected _metallicTexture: Nullable<BaseTexture>;
  132932. /**
  132933. * Specifies the metallic scalar of the metallic/roughness workflow.
  132934. * Can also be used to scale the metalness values of the metallic texture.
  132935. */
  132936. protected _metallic: Nullable<number>;
  132937. /**
  132938. * Specifies the roughness scalar of the metallic/roughness workflow.
  132939. * Can also be used to scale the roughness values of the metallic texture.
  132940. */
  132941. protected _roughness: Nullable<number>;
  132942. /**
  132943. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  132944. * By default the indexOfrefraction is used to compute F0;
  132945. *
  132946. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  132947. *
  132948. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  132949. * F90 = metallicReflectanceColor;
  132950. */
  132951. protected _metallicF0Factor: number;
  132952. /**
  132953. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  132954. * By default the F90 is always 1;
  132955. *
  132956. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  132957. *
  132958. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  132959. * F90 = metallicReflectanceColor;
  132960. */
  132961. protected _metallicReflectanceColor: Color3;
  132962. /**
  132963. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  132964. * This is multiply against the scalar values defined in the material.
  132965. */
  132966. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  132967. /**
  132968. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  132969. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  132970. */
  132971. protected _microSurfaceTexture: Nullable<BaseTexture>;
  132972. /**
  132973. * Stores surface normal data used to displace a mesh in a texture.
  132974. */
  132975. protected _bumpTexture: Nullable<BaseTexture>;
  132976. /**
  132977. * Stores the pre-calculated light information of a mesh in a texture.
  132978. */
  132979. protected _lightmapTexture: Nullable<BaseTexture>;
  132980. /**
  132981. * The color of a material in ambient lighting.
  132982. */
  132983. protected _ambientColor: Color3;
  132984. /**
  132985. * AKA Diffuse Color in other nomenclature.
  132986. */
  132987. protected _albedoColor: Color3;
  132988. /**
  132989. * AKA Specular Color in other nomenclature.
  132990. */
  132991. protected _reflectivityColor: Color3;
  132992. /**
  132993. * The color applied when light is reflected from a material.
  132994. */
  132995. protected _reflectionColor: Color3;
  132996. /**
  132997. * The color applied when light is emitted from a material.
  132998. */
  132999. protected _emissiveColor: Color3;
  133000. /**
  133001. * AKA Glossiness in other nomenclature.
  133002. */
  133003. protected _microSurface: number;
  133004. /**
  133005. * Specifies that the material will use the light map as a show map.
  133006. */
  133007. protected _useLightmapAsShadowmap: boolean;
  133008. /**
  133009. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133010. * makes the reflect vector face the model (under horizon).
  133011. */
  133012. protected _useHorizonOcclusion: boolean;
  133013. /**
  133014. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133015. * too much the area relying on ambient texture to define their ambient occlusion.
  133016. */
  133017. protected _useRadianceOcclusion: boolean;
  133018. /**
  133019. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133020. */
  133021. protected _useAlphaFromAlbedoTexture: boolean;
  133022. /**
  133023. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133024. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133025. */
  133026. protected _useSpecularOverAlpha: boolean;
  133027. /**
  133028. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133029. */
  133030. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133031. /**
  133032. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133033. */
  133034. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133035. /**
  133036. * Specifies if the metallic texture contains the roughness information in its green channel.
  133037. */
  133038. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133039. /**
  133040. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133041. */
  133042. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133043. /**
  133044. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133045. */
  133046. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133047. /**
  133048. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133049. */
  133050. protected _useAmbientInGrayScale: boolean;
  133051. /**
  133052. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133053. * The material will try to infer what glossiness each pixel should be.
  133054. */
  133055. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133056. /**
  133057. * Defines the falloff type used in this material.
  133058. * It by default is Physical.
  133059. */
  133060. protected _lightFalloff: number;
  133061. /**
  133062. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133063. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133064. */
  133065. protected _useRadianceOverAlpha: boolean;
  133066. /**
  133067. * Allows using an object space normal map (instead of tangent space).
  133068. */
  133069. protected _useObjectSpaceNormalMap: boolean;
  133070. /**
  133071. * Allows using the bump map in parallax mode.
  133072. */
  133073. protected _useParallax: boolean;
  133074. /**
  133075. * Allows using the bump map in parallax occlusion mode.
  133076. */
  133077. protected _useParallaxOcclusion: boolean;
  133078. /**
  133079. * Controls the scale bias of the parallax mode.
  133080. */
  133081. protected _parallaxScaleBias: number;
  133082. /**
  133083. * If sets to true, disables all the lights affecting the material.
  133084. */
  133085. protected _disableLighting: boolean;
  133086. /**
  133087. * Number of Simultaneous lights allowed on the material.
  133088. */
  133089. protected _maxSimultaneousLights: number;
  133090. /**
  133091. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  133092. */
  133093. protected _invertNormalMapX: boolean;
  133094. /**
  133095. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  133096. */
  133097. protected _invertNormalMapY: boolean;
  133098. /**
  133099. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133100. */
  133101. protected _twoSidedLighting: boolean;
  133102. /**
  133103. * Defines the alpha limits in alpha test mode.
  133104. */
  133105. protected _alphaCutOff: number;
  133106. /**
  133107. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133108. */
  133109. protected _forceAlphaTest: boolean;
  133110. /**
  133111. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133112. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133113. */
  133114. protected _useAlphaFresnel: boolean;
  133115. /**
  133116. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133117. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133118. */
  133119. protected _useLinearAlphaFresnel: boolean;
  133120. /**
  133121. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  133122. * from cos thetav and roughness:
  133123. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  133124. */
  133125. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  133126. /**
  133127. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133128. */
  133129. protected _forceIrradianceInFragment: boolean;
  133130. private _realTimeFiltering;
  133131. /**
  133132. * Enables realtime filtering on the texture.
  133133. */
  133134. get realTimeFiltering(): boolean;
  133135. set realTimeFiltering(b: boolean);
  133136. private _realTimeFilteringQuality;
  133137. /**
  133138. * Quality switch for realtime filtering
  133139. */
  133140. get realTimeFilteringQuality(): number;
  133141. set realTimeFilteringQuality(n: number);
  133142. /**
  133143. * Force normal to face away from face.
  133144. */
  133145. protected _forceNormalForward: boolean;
  133146. /**
  133147. * Enables specular anti aliasing in the PBR shader.
  133148. * It will both interacts on the Geometry for analytical and IBL lighting.
  133149. * It also prefilter the roughness map based on the bump values.
  133150. */
  133151. protected _enableSpecularAntiAliasing: boolean;
  133152. /**
  133153. * Default configuration related to image processing available in the PBR Material.
  133154. */
  133155. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  133156. /**
  133157. * Keep track of the image processing observer to allow dispose and replace.
  133158. */
  133159. private _imageProcessingObserver;
  133160. /**
  133161. * Attaches a new image processing configuration to the PBR Material.
  133162. * @param configuration
  133163. */
  133164. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  133165. /**
  133166. * Stores the available render targets.
  133167. */
  133168. private _renderTargets;
  133169. /**
  133170. * Sets the global ambient color for the material used in lighting calculations.
  133171. */
  133172. private _globalAmbientColor;
  133173. /**
  133174. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  133175. */
  133176. private _useLogarithmicDepth;
  133177. /**
  133178. * If set to true, no lighting calculations will be applied.
  133179. */
  133180. private _unlit;
  133181. private _debugMode;
  133182. /**
  133183. * @hidden
  133184. * This is reserved for the inspector.
  133185. * Defines the material debug mode.
  133186. * It helps seeing only some components of the material while troubleshooting.
  133187. */
  133188. debugMode: number;
  133189. /**
  133190. * @hidden
  133191. * This is reserved for the inspector.
  133192. * Specify from where on screen the debug mode should start.
  133193. * The value goes from -1 (full screen) to 1 (not visible)
  133194. * It helps with side by side comparison against the final render
  133195. * This defaults to -1
  133196. */
  133197. private debugLimit;
  133198. /**
  133199. * @hidden
  133200. * This is reserved for the inspector.
  133201. * As the default viewing range might not be enough (if the ambient is really small for instance)
  133202. * You can use the factor to better multiply the final value.
  133203. */
  133204. private debugFactor;
  133205. /**
  133206. * Defines the clear coat layer parameters for the material.
  133207. */
  133208. readonly clearCoat: PBRClearCoatConfiguration;
  133209. /**
  133210. * Defines the anisotropic parameters for the material.
  133211. */
  133212. readonly anisotropy: PBRAnisotropicConfiguration;
  133213. /**
  133214. * Defines the BRDF parameters for the material.
  133215. */
  133216. readonly brdf: PBRBRDFConfiguration;
  133217. /**
  133218. * Defines the Sheen parameters for the material.
  133219. */
  133220. readonly sheen: PBRSheenConfiguration;
  133221. /**
  133222. * Defines the SubSurface parameters for the material.
  133223. */
  133224. readonly subSurface: PBRSubSurfaceConfiguration;
  133225. /**
  133226. * Defines the detail map parameters for the material.
  133227. */
  133228. readonly detailMap: DetailMapConfiguration;
  133229. protected _rebuildInParallel: boolean;
  133230. /**
  133231. * Instantiates a new PBRMaterial instance.
  133232. *
  133233. * @param name The material name
  133234. * @param scene The scene the material will be use in.
  133235. */
  133236. constructor(name: string, scene: Scene);
  133237. /**
  133238. * Gets a boolean indicating that current material needs to register RTT
  133239. */
  133240. get hasRenderTargetTextures(): boolean;
  133241. /**
  133242. * Gets the name of the material class.
  133243. */
  133244. getClassName(): string;
  133245. /**
  133246. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133247. */
  133248. get useLogarithmicDepth(): boolean;
  133249. /**
  133250. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  133251. */
  133252. set useLogarithmicDepth(value: boolean);
  133253. /**
  133254. * Returns true if alpha blending should be disabled.
  133255. */
  133256. protected get _disableAlphaBlending(): boolean;
  133257. /**
  133258. * Specifies whether or not this material should be rendered in alpha blend mode.
  133259. */
  133260. needAlphaBlending(): boolean;
  133261. /**
  133262. * Specifies whether or not this material should be rendered in alpha test mode.
  133263. */
  133264. needAlphaTesting(): boolean;
  133265. /**
  133266. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  133267. */
  133268. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  133269. /**
  133270. * Gets the texture used for the alpha test.
  133271. */
  133272. getAlphaTestTexture(): Nullable<BaseTexture>;
  133273. /**
  133274. * Specifies that the submesh is ready to be used.
  133275. * @param mesh - BJS mesh.
  133276. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  133277. * @param useInstances - Specifies that instances should be used.
  133278. * @returns - boolean indicating that the submesh is ready or not.
  133279. */
  133280. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  133281. /**
  133282. * Specifies if the material uses metallic roughness workflow.
  133283. * @returns boolean specifiying if the material uses metallic roughness workflow.
  133284. */
  133285. isMetallicWorkflow(): boolean;
  133286. private _prepareEffect;
  133287. private _prepareDefines;
  133288. /**
  133289. * Force shader compilation
  133290. */
  133291. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  133292. /**
  133293. * Initializes the uniform buffer layout for the shader.
  133294. */
  133295. buildUniformLayout(): void;
  133296. /**
  133297. * Unbinds the material from the mesh
  133298. */
  133299. unbind(): void;
  133300. /**
  133301. * Binds the submesh data.
  133302. * @param world - The world matrix.
  133303. * @param mesh - The BJS mesh.
  133304. * @param subMesh - A submesh of the BJS mesh.
  133305. */
  133306. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  133307. /**
  133308. * Returns the animatable textures.
  133309. * @returns - Array of animatable textures.
  133310. */
  133311. getAnimatables(): IAnimatable[];
  133312. /**
  133313. * Returns the texture used for reflections.
  133314. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  133315. */
  133316. private _getReflectionTexture;
  133317. /**
  133318. * Returns an array of the actively used textures.
  133319. * @returns - Array of BaseTextures
  133320. */
  133321. getActiveTextures(): BaseTexture[];
  133322. /**
  133323. * Checks to see if a texture is used in the material.
  133324. * @param texture - Base texture to use.
  133325. * @returns - Boolean specifying if a texture is used in the material.
  133326. */
  133327. hasTexture(texture: BaseTexture): boolean;
  133328. /**
  133329. * Disposes the resources of the material.
  133330. * @param forceDisposeEffect - Forces the disposal of effects.
  133331. * @param forceDisposeTextures - Forces the disposal of all textures.
  133332. */
  133333. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  133334. }
  133335. }
  133336. declare module BABYLON {
  133337. /**
  133338. * The Physically based material of BJS.
  133339. *
  133340. * This offers the main features of a standard PBR material.
  133341. * For more information, please refer to the documentation :
  133342. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133343. */
  133344. export class PBRMaterial extends PBRBaseMaterial {
  133345. /**
  133346. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133347. */
  133348. static readonly PBRMATERIAL_OPAQUE: number;
  133349. /**
  133350. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133351. */
  133352. static readonly PBRMATERIAL_ALPHATEST: number;
  133353. /**
  133354. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133355. */
  133356. static readonly PBRMATERIAL_ALPHABLEND: number;
  133357. /**
  133358. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133359. * They are also discarded below the alpha cutoff threshold to improve performances.
  133360. */
  133361. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133362. /**
  133363. * Defines the default value of how much AO map is occluding the analytical lights
  133364. * (point spot...).
  133365. */
  133366. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133367. /**
  133368. * Intensity of the direct lights e.g. the four lights available in your scene.
  133369. * This impacts both the direct diffuse and specular highlights.
  133370. */
  133371. directIntensity: number;
  133372. /**
  133373. * Intensity of the emissive part of the material.
  133374. * This helps controlling the emissive effect without modifying the emissive color.
  133375. */
  133376. emissiveIntensity: number;
  133377. /**
  133378. * Intensity of the environment e.g. how much the environment will light the object
  133379. * either through harmonics for rough material or through the refelction for shiny ones.
  133380. */
  133381. environmentIntensity: number;
  133382. /**
  133383. * This is a special control allowing the reduction of the specular highlights coming from the
  133384. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133385. */
  133386. specularIntensity: number;
  133387. /**
  133388. * Debug Control allowing disabling the bump map on this material.
  133389. */
  133390. disableBumpMap: boolean;
  133391. /**
  133392. * AKA Diffuse Texture in standard nomenclature.
  133393. */
  133394. albedoTexture: BaseTexture;
  133395. /**
  133396. * AKA Occlusion Texture in other nomenclature.
  133397. */
  133398. ambientTexture: BaseTexture;
  133399. /**
  133400. * AKA Occlusion Texture Intensity in other nomenclature.
  133401. */
  133402. ambientTextureStrength: number;
  133403. /**
  133404. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133405. * 1 means it completely occludes it
  133406. * 0 mean it has no impact
  133407. */
  133408. ambientTextureImpactOnAnalyticalLights: number;
  133409. /**
  133410. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  133411. */
  133412. opacityTexture: BaseTexture;
  133413. /**
  133414. * Stores the reflection values in a texture.
  133415. */
  133416. reflectionTexture: Nullable<BaseTexture>;
  133417. /**
  133418. * Stores the emissive values in a texture.
  133419. */
  133420. emissiveTexture: BaseTexture;
  133421. /**
  133422. * AKA Specular texture in other nomenclature.
  133423. */
  133424. reflectivityTexture: BaseTexture;
  133425. /**
  133426. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133427. */
  133428. metallicTexture: BaseTexture;
  133429. /**
  133430. * Specifies the metallic scalar of the metallic/roughness workflow.
  133431. * Can also be used to scale the metalness values of the metallic texture.
  133432. */
  133433. metallic: Nullable<number>;
  133434. /**
  133435. * Specifies the roughness scalar of the metallic/roughness workflow.
  133436. * Can also be used to scale the roughness values of the metallic texture.
  133437. */
  133438. roughness: Nullable<number>;
  133439. /**
  133440. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133441. * By default the indexOfrefraction is used to compute F0;
  133442. *
  133443. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133444. *
  133445. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133446. * F90 = metallicReflectanceColor;
  133447. */
  133448. metallicF0Factor: number;
  133449. /**
  133450. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133451. * By default the F90 is always 1;
  133452. *
  133453. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133454. *
  133455. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133456. * F90 = metallicReflectanceColor;
  133457. */
  133458. metallicReflectanceColor: Color3;
  133459. /**
  133460. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133461. * This is multiply against the scalar values defined in the material.
  133462. */
  133463. metallicReflectanceTexture: Nullable<BaseTexture>;
  133464. /**
  133465. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133466. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133467. */
  133468. microSurfaceTexture: BaseTexture;
  133469. /**
  133470. * Stores surface normal data used to displace a mesh in a texture.
  133471. */
  133472. bumpTexture: BaseTexture;
  133473. /**
  133474. * Stores the pre-calculated light information of a mesh in a texture.
  133475. */
  133476. lightmapTexture: BaseTexture;
  133477. /**
  133478. * Stores the refracted light information in a texture.
  133479. */
  133480. get refractionTexture(): Nullable<BaseTexture>;
  133481. set refractionTexture(value: Nullable<BaseTexture>);
  133482. /**
  133483. * The color of a material in ambient lighting.
  133484. */
  133485. ambientColor: Color3;
  133486. /**
  133487. * AKA Diffuse Color in other nomenclature.
  133488. */
  133489. albedoColor: Color3;
  133490. /**
  133491. * AKA Specular Color in other nomenclature.
  133492. */
  133493. reflectivityColor: Color3;
  133494. /**
  133495. * The color reflected from the material.
  133496. */
  133497. reflectionColor: Color3;
  133498. /**
  133499. * The color emitted from the material.
  133500. */
  133501. emissiveColor: Color3;
  133502. /**
  133503. * AKA Glossiness in other nomenclature.
  133504. */
  133505. microSurface: number;
  133506. /**
  133507. * Index of refraction of the material base layer.
  133508. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133509. *
  133510. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  133511. *
  133512. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  133513. */
  133514. get indexOfRefraction(): number;
  133515. set indexOfRefraction(value: number);
  133516. /**
  133517. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133518. */
  133519. get invertRefractionY(): boolean;
  133520. set invertRefractionY(value: boolean);
  133521. /**
  133522. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133523. * Materials half opaque for instance using refraction could benefit from this control.
  133524. */
  133525. get linkRefractionWithTransparency(): boolean;
  133526. set linkRefractionWithTransparency(value: boolean);
  133527. /**
  133528. * If true, the light map contains occlusion information instead of lighting info.
  133529. */
  133530. useLightmapAsShadowmap: boolean;
  133531. /**
  133532. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133533. */
  133534. useAlphaFromAlbedoTexture: boolean;
  133535. /**
  133536. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  133537. */
  133538. forceAlphaTest: boolean;
  133539. /**
  133540. * Defines the alpha limits in alpha test mode.
  133541. */
  133542. alphaCutOff: number;
  133543. /**
  133544. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  133545. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133546. */
  133547. useSpecularOverAlpha: boolean;
  133548. /**
  133549. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133550. */
  133551. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133552. /**
  133553. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133554. */
  133555. useRoughnessFromMetallicTextureAlpha: boolean;
  133556. /**
  133557. * Specifies if the metallic texture contains the roughness information in its green channel.
  133558. */
  133559. useRoughnessFromMetallicTextureGreen: boolean;
  133560. /**
  133561. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133562. */
  133563. useMetallnessFromMetallicTextureBlue: boolean;
  133564. /**
  133565. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133566. */
  133567. useAmbientOcclusionFromMetallicTextureRed: boolean;
  133568. /**
  133569. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133570. */
  133571. useAmbientInGrayScale: boolean;
  133572. /**
  133573. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133574. * The material will try to infer what glossiness each pixel should be.
  133575. */
  133576. useAutoMicroSurfaceFromReflectivityMap: boolean;
  133577. /**
  133578. * BJS is using an harcoded light falloff based on a manually sets up range.
  133579. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133580. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133581. */
  133582. get usePhysicalLightFalloff(): boolean;
  133583. /**
  133584. * BJS is using an harcoded light falloff based on a manually sets up range.
  133585. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  133586. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  133587. */
  133588. set usePhysicalLightFalloff(value: boolean);
  133589. /**
  133590. * In order to support the falloff compatibility with gltf, a special mode has been added
  133591. * to reproduce the gltf light falloff.
  133592. */
  133593. get useGLTFLightFalloff(): boolean;
  133594. /**
  133595. * In order to support the falloff compatibility with gltf, a special mode has been added
  133596. * to reproduce the gltf light falloff.
  133597. */
  133598. set useGLTFLightFalloff(value: boolean);
  133599. /**
  133600. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133601. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133602. */
  133603. useRadianceOverAlpha: boolean;
  133604. /**
  133605. * Allows using an object space normal map (instead of tangent space).
  133606. */
  133607. useObjectSpaceNormalMap: boolean;
  133608. /**
  133609. * Allows using the bump map in parallax mode.
  133610. */
  133611. useParallax: boolean;
  133612. /**
  133613. * Allows using the bump map in parallax occlusion mode.
  133614. */
  133615. useParallaxOcclusion: boolean;
  133616. /**
  133617. * Controls the scale bias of the parallax mode.
  133618. */
  133619. parallaxScaleBias: number;
  133620. /**
  133621. * If sets to true, disables all the lights affecting the material.
  133622. */
  133623. disableLighting: boolean;
  133624. /**
  133625. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  133626. */
  133627. forceIrradianceInFragment: boolean;
  133628. /**
  133629. * Number of Simultaneous lights allowed on the material.
  133630. */
  133631. maxSimultaneousLights: number;
  133632. /**
  133633. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  133634. */
  133635. invertNormalMapX: boolean;
  133636. /**
  133637. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  133638. */
  133639. invertNormalMapY: boolean;
  133640. /**
  133641. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  133642. */
  133643. twoSidedLighting: boolean;
  133644. /**
  133645. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133646. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  133647. */
  133648. useAlphaFresnel: boolean;
  133649. /**
  133650. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  133651. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  133652. */
  133653. useLinearAlphaFresnel: boolean;
  133654. /**
  133655. * Let user defines the brdf lookup texture used for IBL.
  133656. * A default 8bit version is embedded but you could point at :
  133657. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  133658. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  133659. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  133660. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  133661. */
  133662. environmentBRDFTexture: Nullable<BaseTexture>;
  133663. /**
  133664. * Force normal to face away from face.
  133665. */
  133666. forceNormalForward: boolean;
  133667. /**
  133668. * Enables specular anti aliasing in the PBR shader.
  133669. * It will both interacts on the Geometry for analytical and IBL lighting.
  133670. * It also prefilter the roughness map based on the bump values.
  133671. */
  133672. enableSpecularAntiAliasing: boolean;
  133673. /**
  133674. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133675. * makes the reflect vector face the model (under horizon).
  133676. */
  133677. useHorizonOcclusion: boolean;
  133678. /**
  133679. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133680. * too much the area relying on ambient texture to define their ambient occlusion.
  133681. */
  133682. useRadianceOcclusion: boolean;
  133683. /**
  133684. * If set to true, no lighting calculations will be applied.
  133685. */
  133686. unlit: boolean;
  133687. /**
  133688. * Gets the image processing configuration used either in this material.
  133689. */
  133690. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  133691. /**
  133692. * Sets the Default image processing configuration used either in the this material.
  133693. *
  133694. * If sets to null, the scene one is in use.
  133695. */
  133696. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  133697. /**
  133698. * Gets wether the color curves effect is enabled.
  133699. */
  133700. get cameraColorCurvesEnabled(): boolean;
  133701. /**
  133702. * Sets wether the color curves effect is enabled.
  133703. */
  133704. set cameraColorCurvesEnabled(value: boolean);
  133705. /**
  133706. * Gets wether the color grading effect is enabled.
  133707. */
  133708. get cameraColorGradingEnabled(): boolean;
  133709. /**
  133710. * Gets wether the color grading effect is enabled.
  133711. */
  133712. set cameraColorGradingEnabled(value: boolean);
  133713. /**
  133714. * Gets wether tonemapping is enabled or not.
  133715. */
  133716. get cameraToneMappingEnabled(): boolean;
  133717. /**
  133718. * Sets wether tonemapping is enabled or not
  133719. */
  133720. set cameraToneMappingEnabled(value: boolean);
  133721. /**
  133722. * The camera exposure used on this material.
  133723. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133724. * This corresponds to a photographic exposure.
  133725. */
  133726. get cameraExposure(): number;
  133727. /**
  133728. * The camera exposure used on this material.
  133729. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  133730. * This corresponds to a photographic exposure.
  133731. */
  133732. set cameraExposure(value: number);
  133733. /**
  133734. * Gets The camera contrast used on this material.
  133735. */
  133736. get cameraContrast(): number;
  133737. /**
  133738. * Sets The camera contrast used on this material.
  133739. */
  133740. set cameraContrast(value: number);
  133741. /**
  133742. * Gets the Color Grading 2D Lookup Texture.
  133743. */
  133744. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  133745. /**
  133746. * Sets the Color Grading 2D Lookup Texture.
  133747. */
  133748. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  133749. /**
  133750. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133751. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133752. * 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;
  133753. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133754. */
  133755. get cameraColorCurves(): Nullable<ColorCurves>;
  133756. /**
  133757. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  133758. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  133759. * 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;
  133760. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  133761. */
  133762. set cameraColorCurves(value: Nullable<ColorCurves>);
  133763. /**
  133764. * Instantiates a new PBRMaterial instance.
  133765. *
  133766. * @param name The material name
  133767. * @param scene The scene the material will be use in.
  133768. */
  133769. constructor(name: string, scene: Scene);
  133770. /**
  133771. * Returns the name of this material class.
  133772. */
  133773. getClassName(): string;
  133774. /**
  133775. * Makes a duplicate of the current material.
  133776. * @param name - name to use for the new material.
  133777. */
  133778. clone(name: string): PBRMaterial;
  133779. /**
  133780. * Serializes this PBR Material.
  133781. * @returns - An object with the serialized material.
  133782. */
  133783. serialize(): any;
  133784. /**
  133785. * Parses a PBR Material from a serialized object.
  133786. * @param source - Serialized object.
  133787. * @param scene - BJS scene instance.
  133788. * @param rootUrl - url for the scene object
  133789. * @returns - PBRMaterial
  133790. */
  133791. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  133792. }
  133793. }
  133794. declare module BABYLON {
  133795. /**
  133796. * Direct draw surface info
  133797. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  133798. */
  133799. export interface DDSInfo {
  133800. /**
  133801. * Width of the texture
  133802. */
  133803. width: number;
  133804. /**
  133805. * Width of the texture
  133806. */
  133807. height: number;
  133808. /**
  133809. * Number of Mipmaps for the texture
  133810. * @see https://en.wikipedia.org/wiki/Mipmap
  133811. */
  133812. mipmapCount: number;
  133813. /**
  133814. * If the textures format is a known fourCC format
  133815. * @see https://www.fourcc.org/
  133816. */
  133817. isFourCC: boolean;
  133818. /**
  133819. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  133820. */
  133821. isRGB: boolean;
  133822. /**
  133823. * If the texture is a lumincance format
  133824. */
  133825. isLuminance: boolean;
  133826. /**
  133827. * If this is a cube texture
  133828. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  133829. */
  133830. isCube: boolean;
  133831. /**
  133832. * If the texture is a compressed format eg. FOURCC_DXT1
  133833. */
  133834. isCompressed: boolean;
  133835. /**
  133836. * The dxgiFormat of the texture
  133837. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  133838. */
  133839. dxgiFormat: number;
  133840. /**
  133841. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  133842. */
  133843. textureType: number;
  133844. /**
  133845. * Sphericle polynomial created for the dds texture
  133846. */
  133847. sphericalPolynomial?: SphericalPolynomial;
  133848. }
  133849. /**
  133850. * Class used to provide DDS decompression tools
  133851. */
  133852. export class DDSTools {
  133853. /**
  133854. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  133855. */
  133856. static StoreLODInAlphaChannel: boolean;
  133857. /**
  133858. * Gets DDS information from an array buffer
  133859. * @param data defines the array buffer view to read data from
  133860. * @returns the DDS information
  133861. */
  133862. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  133863. private static _FloatView;
  133864. private static _Int32View;
  133865. private static _ToHalfFloat;
  133866. private static _FromHalfFloat;
  133867. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  133868. private static _GetHalfFloatRGBAArrayBuffer;
  133869. private static _GetFloatRGBAArrayBuffer;
  133870. private static _GetFloatAsUIntRGBAArrayBuffer;
  133871. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  133872. private static _GetRGBAArrayBuffer;
  133873. private static _ExtractLongWordOrder;
  133874. private static _GetRGBArrayBuffer;
  133875. private static _GetLuminanceArrayBuffer;
  133876. /**
  133877. * Uploads DDS Levels to a Babylon Texture
  133878. * @hidden
  133879. */
  133880. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  133881. }
  133882. interface ThinEngine {
  133883. /**
  133884. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  133885. * @param rootUrl defines the url where the file to load is located
  133886. * @param scene defines the current scene
  133887. * @param lodScale defines scale to apply to the mip map selection
  133888. * @param lodOffset defines offset to apply to the mip map selection
  133889. * @param onLoad defines an optional callback raised when the texture is loaded
  133890. * @param onError defines an optional callback raised if there is an issue to load the texture
  133891. * @param format defines the format of the data
  133892. * @param forcedExtension defines the extension to use to pick the right loader
  133893. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  133894. * @returns the cube texture as an InternalTexture
  133895. */
  133896. 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;
  133897. }
  133898. }
  133899. declare module BABYLON {
  133900. /**
  133901. * Implementation of the DDS Texture Loader.
  133902. * @hidden
  133903. */
  133904. export class _DDSTextureLoader implements IInternalTextureLoader {
  133905. /**
  133906. * Defines wether the loader supports cascade loading the different faces.
  133907. */
  133908. readonly supportCascades: boolean;
  133909. /**
  133910. * This returns if the loader support the current file information.
  133911. * @param extension defines the file extension of the file being loaded
  133912. * @returns true if the loader can load the specified file
  133913. */
  133914. canLoad(extension: string): boolean;
  133915. /**
  133916. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133917. * @param data contains the texture data
  133918. * @param texture defines the BabylonJS internal texture
  133919. * @param createPolynomials will be true if polynomials have been requested
  133920. * @param onLoad defines the callback to trigger once the texture is ready
  133921. * @param onError defines the callback to trigger in case of error
  133922. */
  133923. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133924. /**
  133925. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133926. * @param data contains the texture data
  133927. * @param texture defines the BabylonJS internal texture
  133928. * @param callback defines the method to call once ready to upload
  133929. */
  133930. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133931. }
  133932. }
  133933. declare module BABYLON {
  133934. /**
  133935. * Implementation of the ENV Texture Loader.
  133936. * @hidden
  133937. */
  133938. export class _ENVTextureLoader implements IInternalTextureLoader {
  133939. /**
  133940. * Defines wether the loader supports cascade loading the different faces.
  133941. */
  133942. readonly supportCascades: boolean;
  133943. /**
  133944. * This returns if the loader support the current file information.
  133945. * @param extension defines the file extension of the file being loaded
  133946. * @returns true if the loader can load the specified file
  133947. */
  133948. canLoad(extension: string): boolean;
  133949. /**
  133950. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  133951. * @param data contains the texture data
  133952. * @param texture defines the BabylonJS internal texture
  133953. * @param createPolynomials will be true if polynomials have been requested
  133954. * @param onLoad defines the callback to trigger once the texture is ready
  133955. * @param onError defines the callback to trigger in case of error
  133956. */
  133957. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  133958. /**
  133959. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  133960. * @param data contains the texture data
  133961. * @param texture defines the BabylonJS internal texture
  133962. * @param callback defines the method to call once ready to upload
  133963. */
  133964. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  133965. }
  133966. }
  133967. declare module BABYLON {
  133968. /**
  133969. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133970. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133971. */
  133972. export class KhronosTextureContainer {
  133973. /** contents of the KTX container file */
  133974. data: ArrayBufferView;
  133975. private static HEADER_LEN;
  133976. private static COMPRESSED_2D;
  133977. private static COMPRESSED_3D;
  133978. private static TEX_2D;
  133979. private static TEX_3D;
  133980. /**
  133981. * Gets the openGL type
  133982. */
  133983. glType: number;
  133984. /**
  133985. * Gets the openGL type size
  133986. */
  133987. glTypeSize: number;
  133988. /**
  133989. * Gets the openGL format
  133990. */
  133991. glFormat: number;
  133992. /**
  133993. * Gets the openGL internal format
  133994. */
  133995. glInternalFormat: number;
  133996. /**
  133997. * Gets the base internal format
  133998. */
  133999. glBaseInternalFormat: number;
  134000. /**
  134001. * Gets image width in pixel
  134002. */
  134003. pixelWidth: number;
  134004. /**
  134005. * Gets image height in pixel
  134006. */
  134007. pixelHeight: number;
  134008. /**
  134009. * Gets image depth in pixels
  134010. */
  134011. pixelDepth: number;
  134012. /**
  134013. * Gets the number of array elements
  134014. */
  134015. numberOfArrayElements: number;
  134016. /**
  134017. * Gets the number of faces
  134018. */
  134019. numberOfFaces: number;
  134020. /**
  134021. * Gets the number of mipmap levels
  134022. */
  134023. numberOfMipmapLevels: number;
  134024. /**
  134025. * Gets the bytes of key value data
  134026. */
  134027. bytesOfKeyValueData: number;
  134028. /**
  134029. * Gets the load type
  134030. */
  134031. loadType: number;
  134032. /**
  134033. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134034. */
  134035. isInvalid: boolean;
  134036. /**
  134037. * Creates a new KhronosTextureContainer
  134038. * @param data contents of the KTX container file
  134039. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134040. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134041. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134042. */
  134043. constructor(
  134044. /** contents of the KTX container file */
  134045. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134046. /**
  134047. * Uploads KTX content to a Babylon Texture.
  134048. * It is assumed that the texture has already been created & is currently bound
  134049. * @hidden
  134050. */
  134051. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134052. private _upload2DCompressedLevels;
  134053. /**
  134054. * Checks if the given data starts with a KTX file identifier.
  134055. * @param data the data to check
  134056. * @returns true if the data is a KTX file or false otherwise
  134057. */
  134058. static IsValid(data: ArrayBufferView): boolean;
  134059. }
  134060. }
  134061. declare module BABYLON {
  134062. /**
  134063. * Class for loading KTX2 files
  134064. * !!! Experimental Extension Subject to Changes !!!
  134065. * @hidden
  134066. */
  134067. export class KhronosTextureContainer2 {
  134068. private static _ModulePromise;
  134069. private static _TranscodeFormat;
  134070. constructor(engine: ThinEngine);
  134071. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134072. private _determineTranscodeFormat;
  134073. /**
  134074. * Checks if the given data starts with a KTX2 file identifier.
  134075. * @param data the data to check
  134076. * @returns true if the data is a KTX2 file or false otherwise
  134077. */
  134078. static IsValid(data: ArrayBufferView): boolean;
  134079. }
  134080. }
  134081. declare module BABYLON {
  134082. /**
  134083. * Implementation of the KTX Texture Loader.
  134084. * @hidden
  134085. */
  134086. export class _KTXTextureLoader implements IInternalTextureLoader {
  134087. /**
  134088. * Defines wether the loader supports cascade loading the different faces.
  134089. */
  134090. readonly supportCascades: boolean;
  134091. /**
  134092. * This returns if the loader support the current file information.
  134093. * @param extension defines the file extension of the file being loaded
  134094. * @returns true if the loader can load the specified file
  134095. */
  134096. canLoad(extension: string): boolean;
  134097. /**
  134098. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134099. * @param data contains the texture data
  134100. * @param texture defines the BabylonJS internal texture
  134101. * @param createPolynomials will be true if polynomials have been requested
  134102. * @param onLoad defines the callback to trigger once the texture is ready
  134103. * @param onError defines the callback to trigger in case of error
  134104. */
  134105. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134106. /**
  134107. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134108. * @param data contains the texture data
  134109. * @param texture defines the BabylonJS internal texture
  134110. * @param callback defines the method to call once ready to upload
  134111. */
  134112. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  134113. }
  134114. }
  134115. declare module BABYLON {
  134116. /** @hidden */
  134117. export var _forceSceneHelpersToBundle: boolean;
  134118. interface Scene {
  134119. /**
  134120. * Creates a default light for the scene.
  134121. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  134122. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  134123. */
  134124. createDefaultLight(replace?: boolean): void;
  134125. /**
  134126. * Creates a default camera for the scene.
  134127. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  134128. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134129. * @param replace has default false, when true replaces the active camera in the scene
  134130. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  134131. */
  134132. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134133. /**
  134134. * Creates a default camera and a default light.
  134135. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  134136. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  134137. * @param replace has the default false, when true replaces the active camera/light in the scene
  134138. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  134139. */
  134140. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  134141. /**
  134142. * Creates a new sky box
  134143. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  134144. * @param environmentTexture defines the texture to use as environment texture
  134145. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  134146. * @param scale defines the overall scale of the skybox
  134147. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  134148. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  134149. * @returns a new mesh holding the sky box
  134150. */
  134151. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  134152. /**
  134153. * Creates a new environment
  134154. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  134155. * @param options defines the options you can use to configure the environment
  134156. * @returns the new EnvironmentHelper
  134157. */
  134158. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  134159. /**
  134160. * Creates a new VREXperienceHelper
  134161. * @see http://doc.babylonjs.com/how_to/webvr_helper
  134162. * @param webVROptions defines the options used to create the new VREXperienceHelper
  134163. * @returns a new VREXperienceHelper
  134164. */
  134165. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  134166. /**
  134167. * Creates a new WebXRDefaultExperience
  134168. * @see http://doc.babylonjs.com/how_to/webxr
  134169. * @param options experience options
  134170. * @returns a promise for a new WebXRDefaultExperience
  134171. */
  134172. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134173. }
  134174. }
  134175. declare module BABYLON {
  134176. /**
  134177. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  134178. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  134179. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  134180. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  134181. */
  134182. export class VideoDome extends TransformNode {
  134183. /**
  134184. * Define the video source as a Monoscopic panoramic 360 video.
  134185. */
  134186. static readonly MODE_MONOSCOPIC: number;
  134187. /**
  134188. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134189. */
  134190. static readonly MODE_TOPBOTTOM: number;
  134191. /**
  134192. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134193. */
  134194. static readonly MODE_SIDEBYSIDE: number;
  134195. private _halfDome;
  134196. private _useDirectMapping;
  134197. /**
  134198. * The video texture being displayed on the sphere
  134199. */
  134200. protected _videoTexture: VideoTexture;
  134201. /**
  134202. * Gets the video texture being displayed on the sphere
  134203. */
  134204. get videoTexture(): VideoTexture;
  134205. /**
  134206. * The skybox material
  134207. */
  134208. protected _material: BackgroundMaterial;
  134209. /**
  134210. * The surface used for the skybox
  134211. */
  134212. protected _mesh: Mesh;
  134213. /**
  134214. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  134215. */
  134216. private _halfDomeMask;
  134217. /**
  134218. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134219. * Also see the options.resolution property.
  134220. */
  134221. get fovMultiplier(): number;
  134222. set fovMultiplier(value: number);
  134223. private _videoMode;
  134224. /**
  134225. * Gets or set the current video mode for the video. It can be:
  134226. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  134227. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  134228. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  134229. */
  134230. get videoMode(): number;
  134231. set videoMode(value: number);
  134232. /**
  134233. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  134234. *
  134235. */
  134236. get halfDome(): boolean;
  134237. /**
  134238. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  134239. */
  134240. set halfDome(enabled: boolean);
  134241. /**
  134242. * Oberserver used in Stereoscopic VR Mode.
  134243. */
  134244. private _onBeforeCameraRenderObserver;
  134245. /**
  134246. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  134247. * @param name Element's name, child elements will append suffixes for their own names.
  134248. * @param urlsOrVideo defines the url(s) or the video element to use
  134249. * @param options An object containing optional or exposed sub element properties
  134250. */
  134251. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  134252. resolution?: number;
  134253. clickToPlay?: boolean;
  134254. autoPlay?: boolean;
  134255. loop?: boolean;
  134256. size?: number;
  134257. poster?: string;
  134258. faceForward?: boolean;
  134259. useDirectMapping?: boolean;
  134260. halfDomeMode?: boolean;
  134261. }, scene: Scene);
  134262. private _changeVideoMode;
  134263. /**
  134264. * Releases resources associated with this node.
  134265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  134266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  134267. */
  134268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  134269. }
  134270. }
  134271. declare module BABYLON {
  134272. /**
  134273. * This class can be used to get instrumentation data from a Babylon engine
  134274. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134275. */
  134276. export class EngineInstrumentation implements IDisposable {
  134277. /**
  134278. * Define the instrumented engine.
  134279. */
  134280. engine: Engine;
  134281. private _captureGPUFrameTime;
  134282. private _gpuFrameTimeToken;
  134283. private _gpuFrameTime;
  134284. private _captureShaderCompilationTime;
  134285. private _shaderCompilationTime;
  134286. private _onBeginFrameObserver;
  134287. private _onEndFrameObserver;
  134288. private _onBeforeShaderCompilationObserver;
  134289. private _onAfterShaderCompilationObserver;
  134290. /**
  134291. * Gets the perf counter used for GPU frame time
  134292. */
  134293. get gpuFrameTimeCounter(): PerfCounter;
  134294. /**
  134295. * Gets the GPU frame time capture status
  134296. */
  134297. get captureGPUFrameTime(): boolean;
  134298. /**
  134299. * Enable or disable the GPU frame time capture
  134300. */
  134301. set captureGPUFrameTime(value: boolean);
  134302. /**
  134303. * Gets the perf counter used for shader compilation time
  134304. */
  134305. get shaderCompilationTimeCounter(): PerfCounter;
  134306. /**
  134307. * Gets the shader compilation time capture status
  134308. */
  134309. get captureShaderCompilationTime(): boolean;
  134310. /**
  134311. * Enable or disable the shader compilation time capture
  134312. */
  134313. set captureShaderCompilationTime(value: boolean);
  134314. /**
  134315. * Instantiates a new engine instrumentation.
  134316. * This class can be used to get instrumentation data from a Babylon engine
  134317. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  134318. * @param engine Defines the engine to instrument
  134319. */
  134320. constructor(
  134321. /**
  134322. * Define the instrumented engine.
  134323. */
  134324. engine: Engine);
  134325. /**
  134326. * Dispose and release associated resources.
  134327. */
  134328. dispose(): void;
  134329. }
  134330. }
  134331. declare module BABYLON {
  134332. /**
  134333. * This class can be used to get instrumentation data from a Babylon engine
  134334. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134335. */
  134336. export class SceneInstrumentation implements IDisposable {
  134337. /**
  134338. * Defines the scene to instrument
  134339. */
  134340. scene: Scene;
  134341. private _captureActiveMeshesEvaluationTime;
  134342. private _activeMeshesEvaluationTime;
  134343. private _captureRenderTargetsRenderTime;
  134344. private _renderTargetsRenderTime;
  134345. private _captureFrameTime;
  134346. private _frameTime;
  134347. private _captureRenderTime;
  134348. private _renderTime;
  134349. private _captureInterFrameTime;
  134350. private _interFrameTime;
  134351. private _captureParticlesRenderTime;
  134352. private _particlesRenderTime;
  134353. private _captureSpritesRenderTime;
  134354. private _spritesRenderTime;
  134355. private _capturePhysicsTime;
  134356. private _physicsTime;
  134357. private _captureAnimationsTime;
  134358. private _animationsTime;
  134359. private _captureCameraRenderTime;
  134360. private _cameraRenderTime;
  134361. private _onBeforeActiveMeshesEvaluationObserver;
  134362. private _onAfterActiveMeshesEvaluationObserver;
  134363. private _onBeforeRenderTargetsRenderObserver;
  134364. private _onAfterRenderTargetsRenderObserver;
  134365. private _onAfterRenderObserver;
  134366. private _onBeforeDrawPhaseObserver;
  134367. private _onAfterDrawPhaseObserver;
  134368. private _onBeforeAnimationsObserver;
  134369. private _onBeforeParticlesRenderingObserver;
  134370. private _onAfterParticlesRenderingObserver;
  134371. private _onBeforeSpritesRenderingObserver;
  134372. private _onAfterSpritesRenderingObserver;
  134373. private _onBeforePhysicsObserver;
  134374. private _onAfterPhysicsObserver;
  134375. private _onAfterAnimationsObserver;
  134376. private _onBeforeCameraRenderObserver;
  134377. private _onAfterCameraRenderObserver;
  134378. /**
  134379. * Gets the perf counter used for active meshes evaluation time
  134380. */
  134381. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  134382. /**
  134383. * Gets the active meshes evaluation time capture status
  134384. */
  134385. get captureActiveMeshesEvaluationTime(): boolean;
  134386. /**
  134387. * Enable or disable the active meshes evaluation time capture
  134388. */
  134389. set captureActiveMeshesEvaluationTime(value: boolean);
  134390. /**
  134391. * Gets the perf counter used for render targets render time
  134392. */
  134393. get renderTargetsRenderTimeCounter(): PerfCounter;
  134394. /**
  134395. * Gets the render targets render time capture status
  134396. */
  134397. get captureRenderTargetsRenderTime(): boolean;
  134398. /**
  134399. * Enable or disable the render targets render time capture
  134400. */
  134401. set captureRenderTargetsRenderTime(value: boolean);
  134402. /**
  134403. * Gets the perf counter used for particles render time
  134404. */
  134405. get particlesRenderTimeCounter(): PerfCounter;
  134406. /**
  134407. * Gets the particles render time capture status
  134408. */
  134409. get captureParticlesRenderTime(): boolean;
  134410. /**
  134411. * Enable or disable the particles render time capture
  134412. */
  134413. set captureParticlesRenderTime(value: boolean);
  134414. /**
  134415. * Gets the perf counter used for sprites render time
  134416. */
  134417. get spritesRenderTimeCounter(): PerfCounter;
  134418. /**
  134419. * Gets the sprites render time capture status
  134420. */
  134421. get captureSpritesRenderTime(): boolean;
  134422. /**
  134423. * Enable or disable the sprites render time capture
  134424. */
  134425. set captureSpritesRenderTime(value: boolean);
  134426. /**
  134427. * Gets the perf counter used for physics time
  134428. */
  134429. get physicsTimeCounter(): PerfCounter;
  134430. /**
  134431. * Gets the physics time capture status
  134432. */
  134433. get capturePhysicsTime(): boolean;
  134434. /**
  134435. * Enable or disable the physics time capture
  134436. */
  134437. set capturePhysicsTime(value: boolean);
  134438. /**
  134439. * Gets the perf counter used for animations time
  134440. */
  134441. get animationsTimeCounter(): PerfCounter;
  134442. /**
  134443. * Gets the animations time capture status
  134444. */
  134445. get captureAnimationsTime(): boolean;
  134446. /**
  134447. * Enable or disable the animations time capture
  134448. */
  134449. set captureAnimationsTime(value: boolean);
  134450. /**
  134451. * Gets the perf counter used for frame time capture
  134452. */
  134453. get frameTimeCounter(): PerfCounter;
  134454. /**
  134455. * Gets the frame time capture status
  134456. */
  134457. get captureFrameTime(): boolean;
  134458. /**
  134459. * Enable or disable the frame time capture
  134460. */
  134461. set captureFrameTime(value: boolean);
  134462. /**
  134463. * Gets the perf counter used for inter-frames time capture
  134464. */
  134465. get interFrameTimeCounter(): PerfCounter;
  134466. /**
  134467. * Gets the inter-frames time capture status
  134468. */
  134469. get captureInterFrameTime(): boolean;
  134470. /**
  134471. * Enable or disable the inter-frames time capture
  134472. */
  134473. set captureInterFrameTime(value: boolean);
  134474. /**
  134475. * Gets the perf counter used for render time capture
  134476. */
  134477. get renderTimeCounter(): PerfCounter;
  134478. /**
  134479. * Gets the render time capture status
  134480. */
  134481. get captureRenderTime(): boolean;
  134482. /**
  134483. * Enable or disable the render time capture
  134484. */
  134485. set captureRenderTime(value: boolean);
  134486. /**
  134487. * Gets the perf counter used for camera render time capture
  134488. */
  134489. get cameraRenderTimeCounter(): PerfCounter;
  134490. /**
  134491. * Gets the camera render time capture status
  134492. */
  134493. get captureCameraRenderTime(): boolean;
  134494. /**
  134495. * Enable or disable the camera render time capture
  134496. */
  134497. set captureCameraRenderTime(value: boolean);
  134498. /**
  134499. * Gets the perf counter used for draw calls
  134500. */
  134501. get drawCallsCounter(): PerfCounter;
  134502. /**
  134503. * Instantiates a new scene instrumentation.
  134504. * This class can be used to get instrumentation data from a Babylon engine
  134505. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  134506. * @param scene Defines the scene to instrument
  134507. */
  134508. constructor(
  134509. /**
  134510. * Defines the scene to instrument
  134511. */
  134512. scene: Scene);
  134513. /**
  134514. * Dispose and release associated resources.
  134515. */
  134516. dispose(): void;
  134517. }
  134518. }
  134519. declare module BABYLON {
  134520. /** @hidden */
  134521. export var glowMapGenerationPixelShader: {
  134522. name: string;
  134523. shader: string;
  134524. };
  134525. }
  134526. declare module BABYLON {
  134527. /** @hidden */
  134528. export var glowMapGenerationVertexShader: {
  134529. name: string;
  134530. shader: string;
  134531. };
  134532. }
  134533. declare module BABYLON {
  134534. /**
  134535. * Effect layer options. This helps customizing the behaviour
  134536. * of the effect layer.
  134537. */
  134538. export interface IEffectLayerOptions {
  134539. /**
  134540. * Multiplication factor apply to the canvas size to compute the render target size
  134541. * used to generated the objects (the smaller the faster).
  134542. */
  134543. mainTextureRatio: number;
  134544. /**
  134545. * Enforces a fixed size texture to ensure effect stability across devices.
  134546. */
  134547. mainTextureFixedSize?: number;
  134548. /**
  134549. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  134550. */
  134551. alphaBlendingMode: number;
  134552. /**
  134553. * The camera attached to the layer.
  134554. */
  134555. camera: Nullable<Camera>;
  134556. /**
  134557. * The rendering group to draw the layer in.
  134558. */
  134559. renderingGroupId: number;
  134560. }
  134561. /**
  134562. * The effect layer Helps adding post process effect blended with the main pass.
  134563. *
  134564. * This can be for instance use to generate glow or higlight effects on the scene.
  134565. *
  134566. * The effect layer class can not be used directly and is intented to inherited from to be
  134567. * customized per effects.
  134568. */
  134569. export abstract class EffectLayer {
  134570. private _vertexBuffers;
  134571. private _indexBuffer;
  134572. private _cachedDefines;
  134573. private _effectLayerMapGenerationEffect;
  134574. private _effectLayerOptions;
  134575. private _mergeEffect;
  134576. protected _scene: Scene;
  134577. protected _engine: Engine;
  134578. protected _maxSize: number;
  134579. protected _mainTextureDesiredSize: ISize;
  134580. protected _mainTexture: RenderTargetTexture;
  134581. protected _shouldRender: boolean;
  134582. protected _postProcesses: PostProcess[];
  134583. protected _textures: BaseTexture[];
  134584. protected _emissiveTextureAndColor: {
  134585. texture: Nullable<BaseTexture>;
  134586. color: Color4;
  134587. };
  134588. /**
  134589. * The name of the layer
  134590. */
  134591. name: string;
  134592. /**
  134593. * The clear color of the texture used to generate the glow map.
  134594. */
  134595. neutralColor: Color4;
  134596. /**
  134597. * Specifies whether the highlight layer is enabled or not.
  134598. */
  134599. isEnabled: boolean;
  134600. /**
  134601. * Gets the camera attached to the layer.
  134602. */
  134603. get camera(): Nullable<Camera>;
  134604. /**
  134605. * Gets the rendering group id the layer should render in.
  134606. */
  134607. get renderingGroupId(): number;
  134608. set renderingGroupId(renderingGroupId: number);
  134609. /**
  134610. * An event triggered when the effect layer has been disposed.
  134611. */
  134612. onDisposeObservable: Observable<EffectLayer>;
  134613. /**
  134614. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  134615. */
  134616. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  134617. /**
  134618. * An event triggered when the generated texture is being merged in the scene.
  134619. */
  134620. onBeforeComposeObservable: Observable<EffectLayer>;
  134621. /**
  134622. * An event triggered when the mesh is rendered into the effect render target.
  134623. */
  134624. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  134625. /**
  134626. * An event triggered after the mesh has been rendered into the effect render target.
  134627. */
  134628. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  134629. /**
  134630. * An event triggered when the generated texture has been merged in the scene.
  134631. */
  134632. onAfterComposeObservable: Observable<EffectLayer>;
  134633. /**
  134634. * An event triggered when the efffect layer changes its size.
  134635. */
  134636. onSizeChangedObservable: Observable<EffectLayer>;
  134637. /** @hidden */
  134638. static _SceneComponentInitialization: (scene: Scene) => void;
  134639. /**
  134640. * Instantiates a new effect Layer and references it in the scene.
  134641. * @param name The name of the layer
  134642. * @param scene The scene to use the layer in
  134643. */
  134644. constructor(
  134645. /** The Friendly of the effect in the scene */
  134646. name: string, scene: Scene);
  134647. /**
  134648. * Get the effect name of the layer.
  134649. * @return The effect name
  134650. */
  134651. abstract getEffectName(): string;
  134652. /**
  134653. * Checks for the readiness of the element composing the layer.
  134654. * @param subMesh the mesh to check for
  134655. * @param useInstances specify whether or not to use instances to render the mesh
  134656. * @return true if ready otherwise, false
  134657. */
  134658. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  134659. /**
  134660. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  134661. * @returns true if the effect requires stencil during the main canvas render pass.
  134662. */
  134663. abstract needStencil(): boolean;
  134664. /**
  134665. * Create the merge effect. This is the shader use to blit the information back
  134666. * to the main canvas at the end of the scene rendering.
  134667. * @returns The effect containing the shader used to merge the effect on the main canvas
  134668. */
  134669. protected abstract _createMergeEffect(): Effect;
  134670. /**
  134671. * Creates the render target textures and post processes used in the effect layer.
  134672. */
  134673. protected abstract _createTextureAndPostProcesses(): void;
  134674. /**
  134675. * Implementation specific of rendering the generating effect on the main canvas.
  134676. * @param effect The effect used to render through
  134677. */
  134678. protected abstract _internalRender(effect: Effect): void;
  134679. /**
  134680. * Sets the required values for both the emissive texture and and the main color.
  134681. */
  134682. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  134683. /**
  134684. * Free any resources and references associated to a mesh.
  134685. * Internal use
  134686. * @param mesh The mesh to free.
  134687. */
  134688. abstract _disposeMesh(mesh: Mesh): void;
  134689. /**
  134690. * Serializes this layer (Glow or Highlight for example)
  134691. * @returns a serialized layer object
  134692. */
  134693. abstract serialize?(): any;
  134694. /**
  134695. * Initializes the effect layer with the required options.
  134696. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  134697. */
  134698. protected _init(options: Partial<IEffectLayerOptions>): void;
  134699. /**
  134700. * Generates the index buffer of the full screen quad blending to the main canvas.
  134701. */
  134702. private _generateIndexBuffer;
  134703. /**
  134704. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  134705. */
  134706. private _generateVertexBuffer;
  134707. /**
  134708. * Sets the main texture desired size which is the closest power of two
  134709. * of the engine canvas size.
  134710. */
  134711. private _setMainTextureSize;
  134712. /**
  134713. * Creates the main texture for the effect layer.
  134714. */
  134715. protected _createMainTexture(): void;
  134716. /**
  134717. * Adds specific effects defines.
  134718. * @param defines The defines to add specifics to.
  134719. */
  134720. protected _addCustomEffectDefines(defines: string[]): void;
  134721. /**
  134722. * Checks for the readiness of the element composing the layer.
  134723. * @param subMesh the mesh to check for
  134724. * @param useInstances specify whether or not to use instances to render the mesh
  134725. * @param emissiveTexture the associated emissive texture used to generate the glow
  134726. * @return true if ready otherwise, false
  134727. */
  134728. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  134729. /**
  134730. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  134731. */
  134732. render(): void;
  134733. /**
  134734. * Determine if a given mesh will be used in the current effect.
  134735. * @param mesh mesh to test
  134736. * @returns true if the mesh will be used
  134737. */
  134738. hasMesh(mesh: AbstractMesh): boolean;
  134739. /**
  134740. * Returns true if the layer contains information to display, otherwise false.
  134741. * @returns true if the glow layer should be rendered
  134742. */
  134743. shouldRender(): boolean;
  134744. /**
  134745. * Returns true if the mesh should render, otherwise false.
  134746. * @param mesh The mesh to render
  134747. * @returns true if it should render otherwise false
  134748. */
  134749. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  134750. /**
  134751. * Returns true if the mesh can be rendered, otherwise false.
  134752. * @param mesh The mesh to render
  134753. * @param material The material used on the mesh
  134754. * @returns true if it can be rendered otherwise false
  134755. */
  134756. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  134757. /**
  134758. * Returns true if the mesh should render, otherwise false.
  134759. * @param mesh The mesh to render
  134760. * @returns true if it should render otherwise false
  134761. */
  134762. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  134763. /**
  134764. * Renders the submesh passed in parameter to the generation map.
  134765. */
  134766. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  134767. /**
  134768. * Defines whether the current material of the mesh should be use to render the effect.
  134769. * @param mesh defines the current mesh to render
  134770. */
  134771. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  134772. /**
  134773. * Rebuild the required buffers.
  134774. * @hidden Internal use only.
  134775. */
  134776. _rebuild(): void;
  134777. /**
  134778. * Dispose only the render target textures and post process.
  134779. */
  134780. private _disposeTextureAndPostProcesses;
  134781. /**
  134782. * Dispose the highlight layer and free resources.
  134783. */
  134784. dispose(): void;
  134785. /**
  134786. * Gets the class name of the effect layer
  134787. * @returns the string with the class name of the effect layer
  134788. */
  134789. getClassName(): string;
  134790. /**
  134791. * Creates an effect layer from parsed effect layer data
  134792. * @param parsedEffectLayer defines effect layer data
  134793. * @param scene defines the current scene
  134794. * @param rootUrl defines the root URL containing the effect layer information
  134795. * @returns a parsed effect Layer
  134796. */
  134797. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  134798. }
  134799. }
  134800. declare module BABYLON {
  134801. interface AbstractScene {
  134802. /**
  134803. * The list of effect layers (highlights/glow) added to the scene
  134804. * @see http://doc.babylonjs.com/how_to/highlight_layer
  134805. * @see http://doc.babylonjs.com/how_to/glow_layer
  134806. */
  134807. effectLayers: Array<EffectLayer>;
  134808. /**
  134809. * Removes the given effect layer from this scene.
  134810. * @param toRemove defines the effect layer to remove
  134811. * @returns the index of the removed effect layer
  134812. */
  134813. removeEffectLayer(toRemove: EffectLayer): number;
  134814. /**
  134815. * Adds the given effect layer to this scene
  134816. * @param newEffectLayer defines the effect layer to add
  134817. */
  134818. addEffectLayer(newEffectLayer: EffectLayer): void;
  134819. }
  134820. /**
  134821. * Defines the layer scene component responsible to manage any effect layers
  134822. * in a given scene.
  134823. */
  134824. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  134825. /**
  134826. * The component name helpfull to identify the component in the list of scene components.
  134827. */
  134828. readonly name: string;
  134829. /**
  134830. * The scene the component belongs to.
  134831. */
  134832. scene: Scene;
  134833. private _engine;
  134834. private _renderEffects;
  134835. private _needStencil;
  134836. private _previousStencilState;
  134837. /**
  134838. * Creates a new instance of the component for the given scene
  134839. * @param scene Defines the scene to register the component in
  134840. */
  134841. constructor(scene: Scene);
  134842. /**
  134843. * Registers the component in a given scene
  134844. */
  134845. register(): void;
  134846. /**
  134847. * Rebuilds the elements related to this component in case of
  134848. * context lost for instance.
  134849. */
  134850. rebuild(): void;
  134851. /**
  134852. * Serializes the component data to the specified json object
  134853. * @param serializationObject The object to serialize to
  134854. */
  134855. serialize(serializationObject: any): void;
  134856. /**
  134857. * Adds all the elements from the container to the scene
  134858. * @param container the container holding the elements
  134859. */
  134860. addFromContainer(container: AbstractScene): void;
  134861. /**
  134862. * Removes all the elements in the container from the scene
  134863. * @param container contains the elements to remove
  134864. * @param dispose if the removed element should be disposed (default: false)
  134865. */
  134866. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  134867. /**
  134868. * Disposes the component and the associated ressources.
  134869. */
  134870. dispose(): void;
  134871. private _isReadyForMesh;
  134872. private _renderMainTexture;
  134873. private _setStencil;
  134874. private _setStencilBack;
  134875. private _draw;
  134876. private _drawCamera;
  134877. private _drawRenderingGroup;
  134878. }
  134879. }
  134880. declare module BABYLON {
  134881. /** @hidden */
  134882. export var glowMapMergePixelShader: {
  134883. name: string;
  134884. shader: string;
  134885. };
  134886. }
  134887. declare module BABYLON {
  134888. /** @hidden */
  134889. export var glowMapMergeVertexShader: {
  134890. name: string;
  134891. shader: string;
  134892. };
  134893. }
  134894. declare module BABYLON {
  134895. interface AbstractScene {
  134896. /**
  134897. * Return a the first highlight layer of the scene with a given name.
  134898. * @param name The name of the highlight layer to look for.
  134899. * @return The highlight layer if found otherwise null.
  134900. */
  134901. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  134902. }
  134903. /**
  134904. * Glow layer options. This helps customizing the behaviour
  134905. * of the glow layer.
  134906. */
  134907. export interface IGlowLayerOptions {
  134908. /**
  134909. * Multiplication factor apply to the canvas size to compute the render target size
  134910. * used to generated the glowing objects (the smaller the faster).
  134911. */
  134912. mainTextureRatio: number;
  134913. /**
  134914. * Enforces a fixed size texture to ensure resize independant blur.
  134915. */
  134916. mainTextureFixedSize?: number;
  134917. /**
  134918. * How big is the kernel of the blur texture.
  134919. */
  134920. blurKernelSize: number;
  134921. /**
  134922. * The camera attached to the layer.
  134923. */
  134924. camera: Nullable<Camera>;
  134925. /**
  134926. * Enable MSAA by chosing the number of samples.
  134927. */
  134928. mainTextureSamples?: number;
  134929. /**
  134930. * The rendering group to draw the layer in.
  134931. */
  134932. renderingGroupId: number;
  134933. }
  134934. /**
  134935. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  134936. *
  134937. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  134938. *
  134939. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  134940. */
  134941. export class GlowLayer extends EffectLayer {
  134942. /**
  134943. * Effect Name of the layer.
  134944. */
  134945. static readonly EffectName: string;
  134946. /**
  134947. * The default blur kernel size used for the glow.
  134948. */
  134949. static DefaultBlurKernelSize: number;
  134950. /**
  134951. * The default texture size ratio used for the glow.
  134952. */
  134953. static DefaultTextureRatio: number;
  134954. /**
  134955. * Sets the kernel size of the blur.
  134956. */
  134957. set blurKernelSize(value: number);
  134958. /**
  134959. * Gets the kernel size of the blur.
  134960. */
  134961. get blurKernelSize(): number;
  134962. /**
  134963. * Sets the glow intensity.
  134964. */
  134965. set intensity(value: number);
  134966. /**
  134967. * Gets the glow intensity.
  134968. */
  134969. get intensity(): number;
  134970. private _options;
  134971. private _intensity;
  134972. private _horizontalBlurPostprocess1;
  134973. private _verticalBlurPostprocess1;
  134974. private _horizontalBlurPostprocess2;
  134975. private _verticalBlurPostprocess2;
  134976. private _blurTexture1;
  134977. private _blurTexture2;
  134978. private _postProcesses1;
  134979. private _postProcesses2;
  134980. private _includedOnlyMeshes;
  134981. private _excludedMeshes;
  134982. private _meshesUsingTheirOwnMaterials;
  134983. /**
  134984. * Callback used to let the user override the color selection on a per mesh basis
  134985. */
  134986. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  134987. /**
  134988. * Callback used to let the user override the texture selection on a per mesh basis
  134989. */
  134990. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  134991. /**
  134992. * Instantiates a new glow Layer and references it to the scene.
  134993. * @param name The name of the layer
  134994. * @param scene The scene to use the layer in
  134995. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  134996. */
  134997. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  134998. /**
  134999. * Get the effect name of the layer.
  135000. * @return The effect name
  135001. */
  135002. getEffectName(): string;
  135003. /**
  135004. * Create the merge effect. This is the shader use to blit the information back
  135005. * to the main canvas at the end of the scene rendering.
  135006. */
  135007. protected _createMergeEffect(): Effect;
  135008. /**
  135009. * Creates the render target textures and post processes used in the glow layer.
  135010. */
  135011. protected _createTextureAndPostProcesses(): void;
  135012. /**
  135013. * Checks for the readiness of the element composing the layer.
  135014. * @param subMesh the mesh to check for
  135015. * @param useInstances specify wether or not to use instances to render the mesh
  135016. * @param emissiveTexture the associated emissive texture used to generate the glow
  135017. * @return true if ready otherwise, false
  135018. */
  135019. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135020. /**
  135021. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135022. */
  135023. needStencil(): boolean;
  135024. /**
  135025. * Returns true if the mesh can be rendered, otherwise false.
  135026. * @param mesh The mesh to render
  135027. * @param material The material used on the mesh
  135028. * @returns true if it can be rendered otherwise false
  135029. */
  135030. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135031. /**
  135032. * Implementation specific of rendering the generating effect on the main canvas.
  135033. * @param effect The effect used to render through
  135034. */
  135035. protected _internalRender(effect: Effect): void;
  135036. /**
  135037. * Sets the required values for both the emissive texture and and the main color.
  135038. */
  135039. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135040. /**
  135041. * Returns true if the mesh should render, otherwise false.
  135042. * @param mesh The mesh to render
  135043. * @returns true if it should render otherwise false
  135044. */
  135045. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135046. /**
  135047. * Adds specific effects defines.
  135048. * @param defines The defines to add specifics to.
  135049. */
  135050. protected _addCustomEffectDefines(defines: string[]): void;
  135051. /**
  135052. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135053. * @param mesh The mesh to exclude from the glow layer
  135054. */
  135055. addExcludedMesh(mesh: Mesh): void;
  135056. /**
  135057. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135058. * @param mesh The mesh to remove
  135059. */
  135060. removeExcludedMesh(mesh: Mesh): void;
  135061. /**
  135062. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135063. * @param mesh The mesh to include in the glow layer
  135064. */
  135065. addIncludedOnlyMesh(mesh: Mesh): void;
  135066. /**
  135067. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135068. * @param mesh The mesh to remove
  135069. */
  135070. removeIncludedOnlyMesh(mesh: Mesh): void;
  135071. /**
  135072. * Determine if a given mesh will be used in the glow layer
  135073. * @param mesh The mesh to test
  135074. * @returns true if the mesh will be highlighted by the current glow layer
  135075. */
  135076. hasMesh(mesh: AbstractMesh): boolean;
  135077. /**
  135078. * Defines whether the current material of the mesh should be use to render the effect.
  135079. * @param mesh defines the current mesh to render
  135080. */
  135081. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135082. /**
  135083. * Add a mesh to be rendered through its own material and not with emissive only.
  135084. * @param mesh The mesh for which we need to use its material
  135085. */
  135086. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  135087. /**
  135088. * Remove a mesh from being rendered through its own material and not with emissive only.
  135089. * @param mesh The mesh for which we need to not use its material
  135090. */
  135091. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  135092. /**
  135093. * Free any resources and references associated to a mesh.
  135094. * Internal use
  135095. * @param mesh The mesh to free.
  135096. * @hidden
  135097. */
  135098. _disposeMesh(mesh: Mesh): void;
  135099. /**
  135100. * Gets the class name of the effect layer
  135101. * @returns the string with the class name of the effect layer
  135102. */
  135103. getClassName(): string;
  135104. /**
  135105. * Serializes this glow layer
  135106. * @returns a serialized glow layer object
  135107. */
  135108. serialize(): any;
  135109. /**
  135110. * Creates a Glow Layer from parsed glow layer data
  135111. * @param parsedGlowLayer defines glow layer data
  135112. * @param scene defines the current scene
  135113. * @param rootUrl defines the root URL containing the glow layer information
  135114. * @returns a parsed Glow Layer
  135115. */
  135116. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  135117. }
  135118. }
  135119. declare module BABYLON {
  135120. /** @hidden */
  135121. export var glowBlurPostProcessPixelShader: {
  135122. name: string;
  135123. shader: string;
  135124. };
  135125. }
  135126. declare module BABYLON {
  135127. interface AbstractScene {
  135128. /**
  135129. * Return a the first highlight layer of the scene with a given name.
  135130. * @param name The name of the highlight layer to look for.
  135131. * @return The highlight layer if found otherwise null.
  135132. */
  135133. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  135134. }
  135135. /**
  135136. * Highlight layer options. This helps customizing the behaviour
  135137. * of the highlight layer.
  135138. */
  135139. export interface IHighlightLayerOptions {
  135140. /**
  135141. * Multiplication factor apply to the canvas size to compute the render target size
  135142. * used to generated the glowing objects (the smaller the faster).
  135143. */
  135144. mainTextureRatio: number;
  135145. /**
  135146. * Enforces a fixed size texture to ensure resize independant blur.
  135147. */
  135148. mainTextureFixedSize?: number;
  135149. /**
  135150. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  135151. * of the picture to blur (the smaller the faster).
  135152. */
  135153. blurTextureSizeRatio: number;
  135154. /**
  135155. * How big in texel of the blur texture is the vertical blur.
  135156. */
  135157. blurVerticalSize: number;
  135158. /**
  135159. * How big in texel of the blur texture is the horizontal blur.
  135160. */
  135161. blurHorizontalSize: number;
  135162. /**
  135163. * Alpha blending mode used to apply the blur. Default is combine.
  135164. */
  135165. alphaBlendingMode: number;
  135166. /**
  135167. * The camera attached to the layer.
  135168. */
  135169. camera: Nullable<Camera>;
  135170. /**
  135171. * Should we display highlight as a solid stroke?
  135172. */
  135173. isStroke?: boolean;
  135174. /**
  135175. * The rendering group to draw the layer in.
  135176. */
  135177. renderingGroupId: number;
  135178. }
  135179. /**
  135180. * The highlight layer Helps adding a glow effect around a mesh.
  135181. *
  135182. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  135183. * glowy meshes to your scene.
  135184. *
  135185. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  135186. */
  135187. export class HighlightLayer extends EffectLayer {
  135188. name: string;
  135189. /**
  135190. * Effect Name of the highlight layer.
  135191. */
  135192. static readonly EffectName: string;
  135193. /**
  135194. * The neutral color used during the preparation of the glow effect.
  135195. * This is black by default as the blend operation is a blend operation.
  135196. */
  135197. static NeutralColor: Color4;
  135198. /**
  135199. * Stencil value used for glowing meshes.
  135200. */
  135201. static GlowingMeshStencilReference: number;
  135202. /**
  135203. * Stencil value used for the other meshes in the scene.
  135204. */
  135205. static NormalMeshStencilReference: number;
  135206. /**
  135207. * Specifies whether or not the inner glow is ACTIVE in the layer.
  135208. */
  135209. innerGlow: boolean;
  135210. /**
  135211. * Specifies whether or not the outer glow is ACTIVE in the layer.
  135212. */
  135213. outerGlow: boolean;
  135214. /**
  135215. * Specifies the horizontal size of the blur.
  135216. */
  135217. set blurHorizontalSize(value: number);
  135218. /**
  135219. * Specifies the vertical size of the blur.
  135220. */
  135221. set blurVerticalSize(value: number);
  135222. /**
  135223. * Gets the horizontal size of the blur.
  135224. */
  135225. get blurHorizontalSize(): number;
  135226. /**
  135227. * Gets the vertical size of the blur.
  135228. */
  135229. get blurVerticalSize(): number;
  135230. /**
  135231. * An event triggered when the highlight layer is being blurred.
  135232. */
  135233. onBeforeBlurObservable: Observable<HighlightLayer>;
  135234. /**
  135235. * An event triggered when the highlight layer has been blurred.
  135236. */
  135237. onAfterBlurObservable: Observable<HighlightLayer>;
  135238. private _instanceGlowingMeshStencilReference;
  135239. private _options;
  135240. private _downSamplePostprocess;
  135241. private _horizontalBlurPostprocess;
  135242. private _verticalBlurPostprocess;
  135243. private _blurTexture;
  135244. private _meshes;
  135245. private _excludedMeshes;
  135246. /**
  135247. * Instantiates a new highlight Layer and references it to the scene..
  135248. * @param name The name of the layer
  135249. * @param scene The scene to use the layer in
  135250. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  135251. */
  135252. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  135253. /**
  135254. * Get the effect name of the layer.
  135255. * @return The effect name
  135256. */
  135257. getEffectName(): string;
  135258. /**
  135259. * Create the merge effect. This is the shader use to blit the information back
  135260. * to the main canvas at the end of the scene rendering.
  135261. */
  135262. protected _createMergeEffect(): Effect;
  135263. /**
  135264. * Creates the render target textures and post processes used in the highlight layer.
  135265. */
  135266. protected _createTextureAndPostProcesses(): void;
  135267. /**
  135268. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  135269. */
  135270. needStencil(): boolean;
  135271. /**
  135272. * Checks for the readiness of the element composing the layer.
  135273. * @param subMesh the mesh to check for
  135274. * @param useInstances specify wether or not to use instances to render the mesh
  135275. * @param emissiveTexture the associated emissive texture used to generate the glow
  135276. * @return true if ready otherwise, false
  135277. */
  135278. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135279. /**
  135280. * Implementation specific of rendering the generating effect on the main canvas.
  135281. * @param effect The effect used to render through
  135282. */
  135283. protected _internalRender(effect: Effect): void;
  135284. /**
  135285. * Returns true if the layer contains information to display, otherwise false.
  135286. */
  135287. shouldRender(): boolean;
  135288. /**
  135289. * Returns true if the mesh should render, otherwise false.
  135290. * @param mesh The mesh to render
  135291. * @returns true if it should render otherwise false
  135292. */
  135293. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135294. /**
  135295. * Adds specific effects defines.
  135296. * @param defines The defines to add specifics to.
  135297. */
  135298. protected _addCustomEffectDefines(defines: string[]): void;
  135299. /**
  135300. * Sets the required values for both the emissive texture and and the main color.
  135301. */
  135302. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135303. /**
  135304. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  135305. * @param mesh The mesh to exclude from the highlight layer
  135306. */
  135307. addExcludedMesh(mesh: Mesh): void;
  135308. /**
  135309. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  135310. * @param mesh The mesh to highlight
  135311. */
  135312. removeExcludedMesh(mesh: Mesh): void;
  135313. /**
  135314. * Determine if a given mesh will be highlighted by the current HighlightLayer
  135315. * @param mesh mesh to test
  135316. * @returns true if the mesh will be highlighted by the current HighlightLayer
  135317. */
  135318. hasMesh(mesh: AbstractMesh): boolean;
  135319. /**
  135320. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  135321. * @param mesh The mesh to highlight
  135322. * @param color The color of the highlight
  135323. * @param glowEmissiveOnly Extract the glow from the emissive texture
  135324. */
  135325. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  135326. /**
  135327. * Remove a mesh from the highlight layer in order to make it stop glowing.
  135328. * @param mesh The mesh to highlight
  135329. */
  135330. removeMesh(mesh: Mesh): void;
  135331. /**
  135332. * Remove all the meshes currently referenced in the highlight layer
  135333. */
  135334. removeAllMeshes(): void;
  135335. /**
  135336. * Force the stencil to the normal expected value for none glowing parts
  135337. */
  135338. private _defaultStencilReference;
  135339. /**
  135340. * Free any resources and references associated to a mesh.
  135341. * Internal use
  135342. * @param mesh The mesh to free.
  135343. * @hidden
  135344. */
  135345. _disposeMesh(mesh: Mesh): void;
  135346. /**
  135347. * Dispose the highlight layer and free resources.
  135348. */
  135349. dispose(): void;
  135350. /**
  135351. * Gets the class name of the effect layer
  135352. * @returns the string with the class name of the effect layer
  135353. */
  135354. getClassName(): string;
  135355. /**
  135356. * Serializes this Highlight layer
  135357. * @returns a serialized Highlight layer object
  135358. */
  135359. serialize(): any;
  135360. /**
  135361. * Creates a Highlight layer from parsed Highlight layer data
  135362. * @param parsedHightlightLayer defines the Highlight layer data
  135363. * @param scene defines the current scene
  135364. * @param rootUrl defines the root URL containing the Highlight layer information
  135365. * @returns a parsed Highlight layer
  135366. */
  135367. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  135368. }
  135369. }
  135370. declare module BABYLON {
  135371. interface AbstractScene {
  135372. /**
  135373. * The list of layers (background and foreground) of the scene
  135374. */
  135375. layers: Array<Layer>;
  135376. }
  135377. /**
  135378. * Defines the layer scene component responsible to manage any layers
  135379. * in a given scene.
  135380. */
  135381. export class LayerSceneComponent implements ISceneComponent {
  135382. /**
  135383. * The component name helpfull to identify the component in the list of scene components.
  135384. */
  135385. readonly name: string;
  135386. /**
  135387. * The scene the component belongs to.
  135388. */
  135389. scene: Scene;
  135390. private _engine;
  135391. /**
  135392. * Creates a new instance of the component for the given scene
  135393. * @param scene Defines the scene to register the component in
  135394. */
  135395. constructor(scene: Scene);
  135396. /**
  135397. * Registers the component in a given scene
  135398. */
  135399. register(): void;
  135400. /**
  135401. * Rebuilds the elements related to this component in case of
  135402. * context lost for instance.
  135403. */
  135404. rebuild(): void;
  135405. /**
  135406. * Disposes the component and the associated ressources.
  135407. */
  135408. dispose(): void;
  135409. private _draw;
  135410. private _drawCameraPredicate;
  135411. private _drawCameraBackground;
  135412. private _drawCameraForeground;
  135413. private _drawRenderTargetPredicate;
  135414. private _drawRenderTargetBackground;
  135415. private _drawRenderTargetForeground;
  135416. /**
  135417. * Adds all the elements from the container to the scene
  135418. * @param container the container holding the elements
  135419. */
  135420. addFromContainer(container: AbstractScene): void;
  135421. /**
  135422. * Removes all the elements in the container from the scene
  135423. * @param container contains the elements to remove
  135424. * @param dispose if the removed element should be disposed (default: false)
  135425. */
  135426. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135427. }
  135428. }
  135429. declare module BABYLON {
  135430. /** @hidden */
  135431. export var layerPixelShader: {
  135432. name: string;
  135433. shader: string;
  135434. };
  135435. }
  135436. declare module BABYLON {
  135437. /** @hidden */
  135438. export var layerVertexShader: {
  135439. name: string;
  135440. shader: string;
  135441. };
  135442. }
  135443. declare module BABYLON {
  135444. /**
  135445. * This represents a full screen 2d layer.
  135446. * This can be useful to display a picture in the background of your scene for instance.
  135447. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135448. */
  135449. export class Layer {
  135450. /**
  135451. * Define the name of the layer.
  135452. */
  135453. name: string;
  135454. /**
  135455. * Define the texture the layer should display.
  135456. */
  135457. texture: Nullable<Texture>;
  135458. /**
  135459. * Is the layer in background or foreground.
  135460. */
  135461. isBackground: boolean;
  135462. /**
  135463. * Define the color of the layer (instead of texture).
  135464. */
  135465. color: Color4;
  135466. /**
  135467. * Define the scale of the layer in order to zoom in out of the texture.
  135468. */
  135469. scale: Vector2;
  135470. /**
  135471. * Define an offset for the layer in order to shift the texture.
  135472. */
  135473. offset: Vector2;
  135474. /**
  135475. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  135476. */
  135477. alphaBlendingMode: number;
  135478. /**
  135479. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  135480. * Alpha test will not mix with the background color in case of transparency.
  135481. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  135482. */
  135483. alphaTest: boolean;
  135484. /**
  135485. * Define a mask to restrict the layer to only some of the scene cameras.
  135486. */
  135487. layerMask: number;
  135488. /**
  135489. * Define the list of render target the layer is visible into.
  135490. */
  135491. renderTargetTextures: RenderTargetTexture[];
  135492. /**
  135493. * Define if the layer is only used in renderTarget or if it also
  135494. * renders in the main frame buffer of the canvas.
  135495. */
  135496. renderOnlyInRenderTargetTextures: boolean;
  135497. private _scene;
  135498. private _vertexBuffers;
  135499. private _indexBuffer;
  135500. private _effect;
  135501. private _previousDefines;
  135502. /**
  135503. * An event triggered when the layer is disposed.
  135504. */
  135505. onDisposeObservable: Observable<Layer>;
  135506. private _onDisposeObserver;
  135507. /**
  135508. * Back compatibility with callback before the onDisposeObservable existed.
  135509. * The set callback will be triggered when the layer has been disposed.
  135510. */
  135511. set onDispose(callback: () => void);
  135512. /**
  135513. * An event triggered before rendering the scene
  135514. */
  135515. onBeforeRenderObservable: Observable<Layer>;
  135516. private _onBeforeRenderObserver;
  135517. /**
  135518. * Back compatibility with callback before the onBeforeRenderObservable existed.
  135519. * The set callback will be triggered just before rendering the layer.
  135520. */
  135521. set onBeforeRender(callback: () => void);
  135522. /**
  135523. * An event triggered after rendering the scene
  135524. */
  135525. onAfterRenderObservable: Observable<Layer>;
  135526. private _onAfterRenderObserver;
  135527. /**
  135528. * Back compatibility with callback before the onAfterRenderObservable existed.
  135529. * The set callback will be triggered just after rendering the layer.
  135530. */
  135531. set onAfterRender(callback: () => void);
  135532. /**
  135533. * Instantiates a new layer.
  135534. * This represents a full screen 2d layer.
  135535. * This can be useful to display a picture in the background of your scene for instance.
  135536. * @see https://www.babylonjs-playground.com/#08A2BS#1
  135537. * @param name Define the name of the layer in the scene
  135538. * @param imgUrl Define the url of the texture to display in the layer
  135539. * @param scene Define the scene the layer belongs to
  135540. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  135541. * @param color Defines a color for the layer
  135542. */
  135543. constructor(
  135544. /**
  135545. * Define the name of the layer.
  135546. */
  135547. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  135548. private _createIndexBuffer;
  135549. /** @hidden */
  135550. _rebuild(): void;
  135551. /**
  135552. * Renders the layer in the scene.
  135553. */
  135554. render(): void;
  135555. /**
  135556. * Disposes and releases the associated ressources.
  135557. */
  135558. dispose(): void;
  135559. }
  135560. }
  135561. declare module BABYLON {
  135562. /** @hidden */
  135563. export var lensFlarePixelShader: {
  135564. name: string;
  135565. shader: string;
  135566. };
  135567. }
  135568. declare module BABYLON {
  135569. /** @hidden */
  135570. export var lensFlareVertexShader: {
  135571. name: string;
  135572. shader: string;
  135573. };
  135574. }
  135575. declare module BABYLON {
  135576. /**
  135577. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135578. * It is usually composed of several `lensFlare`.
  135579. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135580. */
  135581. export class LensFlareSystem {
  135582. /**
  135583. * Define the name of the lens flare system
  135584. */
  135585. name: string;
  135586. /**
  135587. * List of lens flares used in this system.
  135588. */
  135589. lensFlares: LensFlare[];
  135590. /**
  135591. * Define a limit from the border the lens flare can be visible.
  135592. */
  135593. borderLimit: number;
  135594. /**
  135595. * Define a viewport border we do not want to see the lens flare in.
  135596. */
  135597. viewportBorder: number;
  135598. /**
  135599. * Define a predicate which could limit the list of meshes able to occlude the effect.
  135600. */
  135601. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135602. /**
  135603. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  135604. */
  135605. layerMask: number;
  135606. /**
  135607. * Define the id of the lens flare system in the scene.
  135608. * (equal to name by default)
  135609. */
  135610. id: string;
  135611. private _scene;
  135612. private _emitter;
  135613. private _vertexBuffers;
  135614. private _indexBuffer;
  135615. private _effect;
  135616. private _positionX;
  135617. private _positionY;
  135618. private _isEnabled;
  135619. /** @hidden */
  135620. static _SceneComponentInitialization: (scene: Scene) => void;
  135621. /**
  135622. * Instantiates a lens flare system.
  135623. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  135624. * It is usually composed of several `lensFlare`.
  135625. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135626. * @param name Define the name of the lens flare system in the scene
  135627. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  135628. * @param scene Define the scene the lens flare system belongs to
  135629. */
  135630. constructor(
  135631. /**
  135632. * Define the name of the lens flare system
  135633. */
  135634. name: string, emitter: any, scene: Scene);
  135635. /**
  135636. * Define if the lens flare system is enabled.
  135637. */
  135638. get isEnabled(): boolean;
  135639. set isEnabled(value: boolean);
  135640. /**
  135641. * Get the scene the effects belongs to.
  135642. * @returns the scene holding the lens flare system
  135643. */
  135644. getScene(): Scene;
  135645. /**
  135646. * Get the emitter of the lens flare system.
  135647. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135648. * @returns the emitter of the lens flare system
  135649. */
  135650. getEmitter(): any;
  135651. /**
  135652. * Set the emitter of the lens flare system.
  135653. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  135654. * @param newEmitter Define the new emitter of the system
  135655. */
  135656. setEmitter(newEmitter: any): void;
  135657. /**
  135658. * Get the lens flare system emitter position.
  135659. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  135660. * @returns the position
  135661. */
  135662. getEmitterPosition(): Vector3;
  135663. /**
  135664. * @hidden
  135665. */
  135666. computeEffectivePosition(globalViewport: Viewport): boolean;
  135667. /** @hidden */
  135668. _isVisible(): boolean;
  135669. /**
  135670. * @hidden
  135671. */
  135672. render(): boolean;
  135673. /**
  135674. * Dispose and release the lens flare with its associated resources.
  135675. */
  135676. dispose(): void;
  135677. /**
  135678. * Parse a lens flare system from a JSON repressentation
  135679. * @param parsedLensFlareSystem Define the JSON to parse
  135680. * @param scene Define the scene the parsed system should be instantiated in
  135681. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  135682. * @returns the parsed system
  135683. */
  135684. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  135685. /**
  135686. * Serialize the current Lens Flare System into a JSON representation.
  135687. * @returns the serialized JSON
  135688. */
  135689. serialize(): any;
  135690. }
  135691. }
  135692. declare module BABYLON {
  135693. /**
  135694. * This represents one of the lens effect in a `lensFlareSystem`.
  135695. * It controls one of the indiviual texture used in the effect.
  135696. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135697. */
  135698. export class LensFlare {
  135699. /**
  135700. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135701. */
  135702. size: number;
  135703. /**
  135704. * 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.
  135705. */
  135706. position: number;
  135707. /**
  135708. * Define the lens color.
  135709. */
  135710. color: Color3;
  135711. /**
  135712. * Define the lens texture.
  135713. */
  135714. texture: Nullable<Texture>;
  135715. /**
  135716. * Define the alpha mode to render this particular lens.
  135717. */
  135718. alphaMode: number;
  135719. private _system;
  135720. /**
  135721. * Creates a new Lens Flare.
  135722. * This represents one of the lens effect in a `lensFlareSystem`.
  135723. * It controls one of the indiviual texture used in the effect.
  135724. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135725. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  135726. * @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.
  135727. * @param color Define the lens color
  135728. * @param imgUrl Define the lens texture url
  135729. * @param system Define the `lensFlareSystem` this flare is part of
  135730. * @returns The newly created Lens Flare
  135731. */
  135732. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  135733. /**
  135734. * Instantiates a new Lens Flare.
  135735. * This represents one of the lens effect in a `lensFlareSystem`.
  135736. * It controls one of the indiviual texture used in the effect.
  135737. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135738. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  135739. * @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.
  135740. * @param color Define the lens color
  135741. * @param imgUrl Define the lens texture url
  135742. * @param system Define the `lensFlareSystem` this flare is part of
  135743. */
  135744. constructor(
  135745. /**
  135746. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  135747. */
  135748. size: number,
  135749. /**
  135750. * 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.
  135751. */
  135752. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  135753. /**
  135754. * Dispose and release the lens flare with its associated resources.
  135755. */
  135756. dispose(): void;
  135757. }
  135758. }
  135759. declare module BABYLON {
  135760. interface AbstractScene {
  135761. /**
  135762. * The list of lens flare system added to the scene
  135763. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  135764. */
  135765. lensFlareSystems: Array<LensFlareSystem>;
  135766. /**
  135767. * Removes the given lens flare system from this scene.
  135768. * @param toRemove The lens flare system to remove
  135769. * @returns The index of the removed lens flare system
  135770. */
  135771. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  135772. /**
  135773. * Adds the given lens flare system to this scene
  135774. * @param newLensFlareSystem The lens flare system to add
  135775. */
  135776. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  135777. /**
  135778. * Gets a lens flare system using its name
  135779. * @param name defines the name to look for
  135780. * @returns the lens flare system or null if not found
  135781. */
  135782. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  135783. /**
  135784. * Gets a lens flare system using its id
  135785. * @param id defines the id to look for
  135786. * @returns the lens flare system or null if not found
  135787. */
  135788. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  135789. }
  135790. /**
  135791. * Defines the lens flare scene component responsible to manage any lens flares
  135792. * in a given scene.
  135793. */
  135794. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  135795. /**
  135796. * The component name helpfull to identify the component in the list of scene components.
  135797. */
  135798. readonly name: string;
  135799. /**
  135800. * The scene the component belongs to.
  135801. */
  135802. scene: Scene;
  135803. /**
  135804. * Creates a new instance of the component for the given scene
  135805. * @param scene Defines the scene to register the component in
  135806. */
  135807. constructor(scene: Scene);
  135808. /**
  135809. * Registers the component in a given scene
  135810. */
  135811. register(): void;
  135812. /**
  135813. * Rebuilds the elements related to this component in case of
  135814. * context lost for instance.
  135815. */
  135816. rebuild(): void;
  135817. /**
  135818. * Adds all the elements from the container to the scene
  135819. * @param container the container holding the elements
  135820. */
  135821. addFromContainer(container: AbstractScene): void;
  135822. /**
  135823. * Removes all the elements in the container from the scene
  135824. * @param container contains the elements to remove
  135825. * @param dispose if the removed element should be disposed (default: false)
  135826. */
  135827. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135828. /**
  135829. * Serializes the component data to the specified json object
  135830. * @param serializationObject The object to serialize to
  135831. */
  135832. serialize(serializationObject: any): void;
  135833. /**
  135834. * Disposes the component and the associated ressources.
  135835. */
  135836. dispose(): void;
  135837. private _draw;
  135838. }
  135839. }
  135840. declare module BABYLON {
  135841. /** @hidden */
  135842. export var depthPixelShader: {
  135843. name: string;
  135844. shader: string;
  135845. };
  135846. }
  135847. declare module BABYLON {
  135848. /** @hidden */
  135849. export var depthVertexShader: {
  135850. name: string;
  135851. shader: string;
  135852. };
  135853. }
  135854. declare module BABYLON {
  135855. /**
  135856. * This represents a depth renderer in Babylon.
  135857. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  135858. */
  135859. export class DepthRenderer {
  135860. private _scene;
  135861. private _depthMap;
  135862. private _effect;
  135863. private readonly _storeNonLinearDepth;
  135864. private readonly _clearColor;
  135865. /** Get if the depth renderer is using packed depth or not */
  135866. readonly isPacked: boolean;
  135867. private _cachedDefines;
  135868. private _camera;
  135869. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  135870. enabled: boolean;
  135871. /**
  135872. * Specifiess that the depth renderer will only be used within
  135873. * the camera it is created for.
  135874. * This can help forcing its rendering during the camera processing.
  135875. */
  135876. useOnlyInActiveCamera: boolean;
  135877. /** @hidden */
  135878. static _SceneComponentInitialization: (scene: Scene) => void;
  135879. /**
  135880. * Instantiates a depth renderer
  135881. * @param scene The scene the renderer belongs to
  135882. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  135883. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  135884. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  135885. */
  135886. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  135887. /**
  135888. * Creates the depth rendering effect and checks if the effect is ready.
  135889. * @param subMesh The submesh to be used to render the depth map of
  135890. * @param useInstances If multiple world instances should be used
  135891. * @returns if the depth renderer is ready to render the depth map
  135892. */
  135893. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135894. /**
  135895. * Gets the texture which the depth map will be written to.
  135896. * @returns The depth map texture
  135897. */
  135898. getDepthMap(): RenderTargetTexture;
  135899. /**
  135900. * Disposes of the depth renderer.
  135901. */
  135902. dispose(): void;
  135903. }
  135904. }
  135905. declare module BABYLON {
  135906. /** @hidden */
  135907. export var minmaxReduxPixelShader: {
  135908. name: string;
  135909. shader: string;
  135910. };
  135911. }
  135912. declare module BABYLON {
  135913. /**
  135914. * This class computes a min/max reduction from a texture: it means it computes the minimum
  135915. * and maximum values from all values of the texture.
  135916. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  135917. * The source values are read from the red channel of the texture.
  135918. */
  135919. export class MinMaxReducer {
  135920. /**
  135921. * Observable triggered when the computation has been performed
  135922. */
  135923. onAfterReductionPerformed: Observable<{
  135924. min: number;
  135925. max: number;
  135926. }>;
  135927. protected _camera: Camera;
  135928. protected _sourceTexture: Nullable<RenderTargetTexture>;
  135929. protected _reductionSteps: Nullable<Array<PostProcess>>;
  135930. protected _postProcessManager: PostProcessManager;
  135931. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  135932. protected _forceFullscreenViewport: boolean;
  135933. /**
  135934. * Creates a min/max reducer
  135935. * @param camera The camera to use for the post processes
  135936. */
  135937. constructor(camera: Camera);
  135938. /**
  135939. * Gets the texture used to read the values from.
  135940. */
  135941. get sourceTexture(): Nullable<RenderTargetTexture>;
  135942. /**
  135943. * Sets the source texture to read the values from.
  135944. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  135945. * because in such textures '1' value must not be taken into account to compute the maximum
  135946. * as this value is used to clear the texture.
  135947. * Note that the computation is not activated by calling this function, you must call activate() for that!
  135948. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  135949. * @param depthRedux Indicates if the texture is a depth texture or not
  135950. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  135951. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  135952. */
  135953. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  135954. /**
  135955. * Defines the refresh rate of the computation.
  135956. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  135957. */
  135958. get refreshRate(): number;
  135959. set refreshRate(value: number);
  135960. protected _activated: boolean;
  135961. /**
  135962. * Gets the activation status of the reducer
  135963. */
  135964. get activated(): boolean;
  135965. /**
  135966. * Activates the reduction computation.
  135967. * When activated, the observers registered in onAfterReductionPerformed are
  135968. * called after the compuation is performed
  135969. */
  135970. activate(): void;
  135971. /**
  135972. * Deactivates the reduction computation.
  135973. */
  135974. deactivate(): void;
  135975. /**
  135976. * Disposes the min/max reducer
  135977. * @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.
  135978. */
  135979. dispose(disposeAll?: boolean): void;
  135980. }
  135981. }
  135982. declare module BABYLON {
  135983. /**
  135984. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  135985. */
  135986. export class DepthReducer extends MinMaxReducer {
  135987. private _depthRenderer;
  135988. private _depthRendererId;
  135989. /**
  135990. * Gets the depth renderer used for the computation.
  135991. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  135992. */
  135993. get depthRenderer(): Nullable<DepthRenderer>;
  135994. /**
  135995. * Creates a depth reducer
  135996. * @param camera The camera used to render the depth texture
  135997. */
  135998. constructor(camera: Camera);
  135999. /**
  136000. * Sets the depth renderer to use to generate the depth map
  136001. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  136002. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  136003. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136004. */
  136005. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  136006. /** @hidden */
  136007. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136008. /**
  136009. * Activates the reduction computation.
  136010. * When activated, the observers registered in onAfterReductionPerformed are
  136011. * called after the compuation is performed
  136012. */
  136013. activate(): void;
  136014. /**
  136015. * Deactivates the reduction computation.
  136016. */
  136017. deactivate(): void;
  136018. /**
  136019. * Disposes the depth reducer
  136020. * @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.
  136021. */
  136022. dispose(disposeAll?: boolean): void;
  136023. }
  136024. }
  136025. declare module BABYLON {
  136026. /**
  136027. * A CSM implementation allowing casting shadows on large scenes.
  136028. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136029. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136030. */
  136031. export class CascadedShadowGenerator extends ShadowGenerator {
  136032. private static readonly frustumCornersNDCSpace;
  136033. /**
  136034. * Name of the CSM class
  136035. */
  136036. static CLASSNAME: string;
  136037. /**
  136038. * Defines the default number of cascades used by the CSM.
  136039. */
  136040. static readonly DEFAULT_CASCADES_COUNT: number;
  136041. /**
  136042. * Defines the minimum number of cascades used by the CSM.
  136043. */
  136044. static readonly MIN_CASCADES_COUNT: number;
  136045. /**
  136046. * Defines the maximum number of cascades used by the CSM.
  136047. */
  136048. static readonly MAX_CASCADES_COUNT: number;
  136049. protected _validateFilter(filter: number): number;
  136050. /**
  136051. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136052. */
  136053. penumbraDarkness: number;
  136054. private _numCascades;
  136055. /**
  136056. * Gets or set the number of cascades used by the CSM.
  136057. */
  136058. get numCascades(): number;
  136059. set numCascades(value: number);
  136060. /**
  136061. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136062. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136063. */
  136064. stabilizeCascades: boolean;
  136065. private _freezeShadowCastersBoundingInfo;
  136066. private _freezeShadowCastersBoundingInfoObservable;
  136067. /**
  136068. * Enables or disables the shadow casters bounding info computation.
  136069. * If your shadow casters don't move, you can disable this feature.
  136070. * If it is enabled, the bounding box computation is done every frame.
  136071. */
  136072. get freezeShadowCastersBoundingInfo(): boolean;
  136073. set freezeShadowCastersBoundingInfo(freeze: boolean);
  136074. private _scbiMin;
  136075. private _scbiMax;
  136076. protected _computeShadowCastersBoundingInfo(): void;
  136077. protected _shadowCastersBoundingInfo: BoundingInfo;
  136078. /**
  136079. * Gets or sets the shadow casters bounding info.
  136080. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  136081. * so that the system won't overwrite the bounds you provide
  136082. */
  136083. get shadowCastersBoundingInfo(): BoundingInfo;
  136084. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  136085. protected _breaksAreDirty: boolean;
  136086. protected _minDistance: number;
  136087. protected _maxDistance: number;
  136088. /**
  136089. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  136090. *
  136091. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  136092. * If you don't know these values, simply leave them to their defaults and don't call this function.
  136093. * @param min minimal distance for the breaks (default to 0.)
  136094. * @param max maximal distance for the breaks (default to 1.)
  136095. */
  136096. setMinMaxDistance(min: number, max: number): void;
  136097. /** Gets the minimal distance used in the cascade break computation */
  136098. get minDistance(): number;
  136099. /** Gets the maximal distance used in the cascade break computation */
  136100. get maxDistance(): number;
  136101. /**
  136102. * Gets the class name of that object
  136103. * @returns "CascadedShadowGenerator"
  136104. */
  136105. getClassName(): string;
  136106. private _cascadeMinExtents;
  136107. private _cascadeMaxExtents;
  136108. /**
  136109. * Gets a cascade minimum extents
  136110. * @param cascadeIndex index of the cascade
  136111. * @returns the minimum cascade extents
  136112. */
  136113. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  136114. /**
  136115. * Gets a cascade maximum extents
  136116. * @param cascadeIndex index of the cascade
  136117. * @returns the maximum cascade extents
  136118. */
  136119. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  136120. private _cascades;
  136121. private _currentLayer;
  136122. private _viewSpaceFrustumsZ;
  136123. private _viewMatrices;
  136124. private _projectionMatrices;
  136125. private _transformMatrices;
  136126. private _transformMatricesAsArray;
  136127. private _frustumLengths;
  136128. private _lightSizeUVCorrection;
  136129. private _depthCorrection;
  136130. private _frustumCornersWorldSpace;
  136131. private _frustumCenter;
  136132. private _shadowCameraPos;
  136133. private _shadowMaxZ;
  136134. /**
  136135. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  136136. * It defaults to camera.maxZ
  136137. */
  136138. get shadowMaxZ(): number;
  136139. /**
  136140. * Sets the shadow max z distance.
  136141. */
  136142. set shadowMaxZ(value: number);
  136143. protected _debug: boolean;
  136144. /**
  136145. * Gets or sets the debug flag.
  136146. * When enabled, the cascades are materialized by different colors on the screen.
  136147. */
  136148. get debug(): boolean;
  136149. set debug(dbg: boolean);
  136150. private _depthClamp;
  136151. /**
  136152. * Gets or sets the depth clamping value.
  136153. *
  136154. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  136155. * to account for the shadow casters far away.
  136156. *
  136157. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  136158. */
  136159. get depthClamp(): boolean;
  136160. set depthClamp(value: boolean);
  136161. private _cascadeBlendPercentage;
  136162. /**
  136163. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  136164. * It defaults to 0.1 (10% blending).
  136165. */
  136166. get cascadeBlendPercentage(): number;
  136167. set cascadeBlendPercentage(value: number);
  136168. private _lambda;
  136169. /**
  136170. * Gets or set the lambda parameter.
  136171. * This parameter is used to split the camera frustum and create the cascades.
  136172. * 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.
  136173. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  136174. */
  136175. get lambda(): number;
  136176. set lambda(value: number);
  136177. /**
  136178. * Gets the view matrix corresponding to a given cascade
  136179. * @param cascadeNum cascade to retrieve the view matrix from
  136180. * @returns the cascade view matrix
  136181. */
  136182. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  136183. /**
  136184. * Gets the projection matrix corresponding to a given cascade
  136185. * @param cascadeNum cascade to retrieve the projection matrix from
  136186. * @returns the cascade projection matrix
  136187. */
  136188. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  136189. /**
  136190. * Gets the transformation matrix corresponding to a given cascade
  136191. * @param cascadeNum cascade to retrieve the transformation matrix from
  136192. * @returns the cascade transformation matrix
  136193. */
  136194. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  136195. private _depthRenderer;
  136196. /**
  136197. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  136198. *
  136199. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  136200. *
  136201. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  136202. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  136203. * @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
  136204. */
  136205. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  136206. private _depthReducer;
  136207. private _autoCalcDepthBounds;
  136208. /**
  136209. * Gets or sets the autoCalcDepthBounds property.
  136210. *
  136211. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  136212. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  136213. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  136214. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  136215. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  136216. */
  136217. get autoCalcDepthBounds(): boolean;
  136218. set autoCalcDepthBounds(value: boolean);
  136219. /**
  136220. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  136221. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136222. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  136223. * for setting the refresh rate on the renderer yourself!
  136224. */
  136225. get autoCalcDepthBoundsRefreshRate(): number;
  136226. set autoCalcDepthBoundsRefreshRate(value: number);
  136227. /**
  136228. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  136229. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  136230. * you change the camera near/far planes!
  136231. */
  136232. splitFrustum(): void;
  136233. private _splitFrustum;
  136234. private _computeMatrices;
  136235. private _computeFrustumInWorldSpace;
  136236. private _computeCascadeFrustum;
  136237. /**
  136238. * Support test.
  136239. */
  136240. static get IsSupported(): boolean;
  136241. /** @hidden */
  136242. static _SceneComponentInitialization: (scene: Scene) => void;
  136243. /**
  136244. * Creates a Cascaded Shadow Generator object.
  136245. * A ShadowGenerator is the required tool to use the shadows.
  136246. * Each directional light casting shadows needs to use its own ShadowGenerator.
  136247. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136248. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  136249. * @param light The directional light object generating the shadows.
  136250. * @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.
  136251. */
  136252. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  136253. protected _initializeGenerator(): void;
  136254. protected _createTargetRenderTexture(): void;
  136255. protected _initializeShadowMap(): void;
  136256. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  136257. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  136258. /**
  136259. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  136260. * @param defines Defines of the material we want to update
  136261. * @param lightIndex Index of the light in the enabled light list of the material
  136262. */
  136263. prepareDefines(defines: any, lightIndex: number): void;
  136264. /**
  136265. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  136266. * defined in the generator but impacting the effect).
  136267. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  136268. * @param effect The effect we are binfing the information for
  136269. */
  136270. bindShadowLight(lightIndex: string, effect: Effect): void;
  136271. /**
  136272. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  136273. * (eq to view projection * shadow projection matrices)
  136274. * @returns The transform matrix used to create the shadow map
  136275. */
  136276. getTransformMatrix(): Matrix;
  136277. /**
  136278. * Disposes the ShadowGenerator.
  136279. * Returns nothing.
  136280. */
  136281. dispose(): void;
  136282. /**
  136283. * Serializes the shadow generator setup to a json object.
  136284. * @returns The serialized JSON object
  136285. */
  136286. serialize(): any;
  136287. /**
  136288. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  136289. * @param parsedShadowGenerator The JSON object to parse
  136290. * @param scene The scene to create the shadow map for
  136291. * @returns The parsed shadow generator
  136292. */
  136293. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  136294. }
  136295. }
  136296. declare module BABYLON {
  136297. /**
  136298. * Defines the shadow generator component responsible to manage any shadow generators
  136299. * in a given scene.
  136300. */
  136301. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  136302. /**
  136303. * The component name helpfull to identify the component in the list of scene components.
  136304. */
  136305. readonly name: string;
  136306. /**
  136307. * The scene the component belongs to.
  136308. */
  136309. scene: Scene;
  136310. /**
  136311. * Creates a new instance of the component for the given scene
  136312. * @param scene Defines the scene to register the component in
  136313. */
  136314. constructor(scene: Scene);
  136315. /**
  136316. * Registers the component in a given scene
  136317. */
  136318. register(): void;
  136319. /**
  136320. * Rebuilds the elements related to this component in case of
  136321. * context lost for instance.
  136322. */
  136323. rebuild(): void;
  136324. /**
  136325. * Serializes the component data to the specified json object
  136326. * @param serializationObject The object to serialize to
  136327. */
  136328. serialize(serializationObject: any): void;
  136329. /**
  136330. * Adds all the elements from the container to the scene
  136331. * @param container the container holding the elements
  136332. */
  136333. addFromContainer(container: AbstractScene): void;
  136334. /**
  136335. * Removes all the elements in the container from the scene
  136336. * @param container contains the elements to remove
  136337. * @param dispose if the removed element should be disposed (default: false)
  136338. */
  136339. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136340. /**
  136341. * Rebuilds the elements related to this component in case of
  136342. * context lost for instance.
  136343. */
  136344. dispose(): void;
  136345. private _gatherRenderTargets;
  136346. }
  136347. }
  136348. declare module BABYLON {
  136349. /**
  136350. * A point light is a light defined by an unique point in world space.
  136351. * The light is emitted in every direction from this point.
  136352. * A good example of a point light is a standard light bulb.
  136353. * Documentation: https://doc.babylonjs.com/babylon101/lights
  136354. */
  136355. export class PointLight extends ShadowLight {
  136356. private _shadowAngle;
  136357. /**
  136358. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136359. * This specifies what angle the shadow will use to be created.
  136360. *
  136361. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136362. */
  136363. get shadowAngle(): number;
  136364. /**
  136365. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136366. * This specifies what angle the shadow will use to be created.
  136367. *
  136368. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  136369. */
  136370. set shadowAngle(value: number);
  136371. /**
  136372. * Gets the direction if it has been set.
  136373. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136374. */
  136375. get direction(): Vector3;
  136376. /**
  136377. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  136378. */
  136379. set direction(value: Vector3);
  136380. /**
  136381. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  136382. * A PointLight emits the light in every direction.
  136383. * It can cast shadows.
  136384. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  136385. * ```javascript
  136386. * var pointLight = new PointLight("pl", camera.position, scene);
  136387. * ```
  136388. * Documentation : https://doc.babylonjs.com/babylon101/lights
  136389. * @param name The light friendly name
  136390. * @param position The position of the point light in the scene
  136391. * @param scene The scene the lights belongs to
  136392. */
  136393. constructor(name: string, position: Vector3, scene: Scene);
  136394. /**
  136395. * Returns the string "PointLight"
  136396. * @returns the class name
  136397. */
  136398. getClassName(): string;
  136399. /**
  136400. * Returns the integer 0.
  136401. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  136402. */
  136403. getTypeID(): number;
  136404. /**
  136405. * Specifies wether or not the shadowmap should be a cube texture.
  136406. * @returns true if the shadowmap needs to be a cube texture.
  136407. */
  136408. needCube(): boolean;
  136409. /**
  136410. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  136411. * @param faceIndex The index of the face we are computed the direction to generate shadow
  136412. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  136413. */
  136414. getShadowDirection(faceIndex?: number): Vector3;
  136415. /**
  136416. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  136417. * - fov = PI / 2
  136418. * - aspect ratio : 1.0
  136419. * - z-near and far equal to the active camera minZ and maxZ.
  136420. * Returns the PointLight.
  136421. */
  136422. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  136423. protected _buildUniformLayout(): void;
  136424. /**
  136425. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  136426. * @param effect The effect to update
  136427. * @param lightIndex The index of the light in the effect to update
  136428. * @returns The point light
  136429. */
  136430. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  136431. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  136432. /**
  136433. * Prepares the list of defines specific to the light type.
  136434. * @param defines the list of defines
  136435. * @param lightIndex defines the index of the light for the effect
  136436. */
  136437. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  136438. }
  136439. }
  136440. declare module BABYLON {
  136441. /**
  136442. * Header information of HDR texture files.
  136443. */
  136444. export interface HDRInfo {
  136445. /**
  136446. * The height of the texture in pixels.
  136447. */
  136448. height: number;
  136449. /**
  136450. * The width of the texture in pixels.
  136451. */
  136452. width: number;
  136453. /**
  136454. * The index of the beginning of the data in the binary file.
  136455. */
  136456. dataPosition: number;
  136457. }
  136458. /**
  136459. * This groups tools to convert HDR texture to native colors array.
  136460. */
  136461. export class HDRTools {
  136462. private static Ldexp;
  136463. private static Rgbe2float;
  136464. private static readStringLine;
  136465. /**
  136466. * Reads header information from an RGBE texture stored in a native array.
  136467. * More information on this format are available here:
  136468. * https://en.wikipedia.org/wiki/RGBE_image_format
  136469. *
  136470. * @param uint8array The binary file stored in native array.
  136471. * @return The header information.
  136472. */
  136473. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  136474. /**
  136475. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  136476. * This RGBE texture needs to store the information as a panorama.
  136477. *
  136478. * More information on this format are available here:
  136479. * https://en.wikipedia.org/wiki/RGBE_image_format
  136480. *
  136481. * @param buffer The binary file stored in an array buffer.
  136482. * @param size The expected size of the extracted cubemap.
  136483. * @return The Cube Map information.
  136484. */
  136485. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  136486. /**
  136487. * Returns the pixels data extracted from an RGBE texture.
  136488. * This pixels will be stored left to right up to down in the R G B order in one array.
  136489. *
  136490. * More information on this format are available here:
  136491. * https://en.wikipedia.org/wiki/RGBE_image_format
  136492. *
  136493. * @param uint8array The binary file stored in an array buffer.
  136494. * @param hdrInfo The header information of the file.
  136495. * @return The pixels data in RGB right to left up to down order.
  136496. */
  136497. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  136498. private static RGBE_ReadPixels_RLE;
  136499. }
  136500. }
  136501. declare module BABYLON {
  136502. /**
  136503. * Effect Render Options
  136504. */
  136505. export interface IEffectRendererOptions {
  136506. /**
  136507. * Defines the vertices positions.
  136508. */
  136509. positions?: number[];
  136510. /**
  136511. * Defines the indices.
  136512. */
  136513. indices?: number[];
  136514. }
  136515. /**
  136516. * Helper class to render one or more effects.
  136517. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  136518. */
  136519. export class EffectRenderer {
  136520. private engine;
  136521. private static _DefaultOptions;
  136522. private _vertexBuffers;
  136523. private _indexBuffer;
  136524. private _fullscreenViewport;
  136525. /**
  136526. * Creates an effect renderer
  136527. * @param engine the engine to use for rendering
  136528. * @param options defines the options of the effect renderer
  136529. */
  136530. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  136531. /**
  136532. * Sets the current viewport in normalized coordinates 0-1
  136533. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  136534. */
  136535. setViewport(viewport?: Viewport): void;
  136536. /**
  136537. * Binds the embedded attributes buffer to the effect.
  136538. * @param effect Defines the effect to bind the attributes for
  136539. */
  136540. bindBuffers(effect: Effect): void;
  136541. /**
  136542. * Sets the current effect wrapper to use during draw.
  136543. * The effect needs to be ready before calling this api.
  136544. * This also sets the default full screen position attribute.
  136545. * @param effectWrapper Defines the effect to draw with
  136546. */
  136547. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  136548. /**
  136549. * Restores engine states
  136550. */
  136551. restoreStates(): void;
  136552. /**
  136553. * Draws a full screen quad.
  136554. */
  136555. draw(): void;
  136556. private isRenderTargetTexture;
  136557. /**
  136558. * renders one or more effects to a specified texture
  136559. * @param effectWrapper the effect to renderer
  136560. * @param outputTexture texture to draw to, if null it will render to the screen.
  136561. */
  136562. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  136563. /**
  136564. * Disposes of the effect renderer
  136565. */
  136566. dispose(): void;
  136567. }
  136568. /**
  136569. * Options to create an EffectWrapper
  136570. */
  136571. interface EffectWrapperCreationOptions {
  136572. /**
  136573. * Engine to use to create the effect
  136574. */
  136575. engine: ThinEngine;
  136576. /**
  136577. * Fragment shader for the effect
  136578. */
  136579. fragmentShader: string;
  136580. /**
  136581. * Use the shader store instead of direct source code
  136582. */
  136583. useShaderStore?: boolean;
  136584. /**
  136585. * Vertex shader for the effect
  136586. */
  136587. vertexShader?: string;
  136588. /**
  136589. * Attributes to use in the shader
  136590. */
  136591. attributeNames?: Array<string>;
  136592. /**
  136593. * Uniforms to use in the shader
  136594. */
  136595. uniformNames?: Array<string>;
  136596. /**
  136597. * Texture sampler names to use in the shader
  136598. */
  136599. samplerNames?: Array<string>;
  136600. /**
  136601. * Defines to use in the shader
  136602. */
  136603. defines?: Array<string>;
  136604. /**
  136605. * Callback when effect is compiled
  136606. */
  136607. onCompiled?: Nullable<(effect: Effect) => void>;
  136608. /**
  136609. * The friendly name of the effect displayed in Spector.
  136610. */
  136611. name?: string;
  136612. }
  136613. /**
  136614. * Wraps an effect to be used for rendering
  136615. */
  136616. export class EffectWrapper {
  136617. /**
  136618. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  136619. */
  136620. onApplyObservable: Observable<{}>;
  136621. /**
  136622. * The underlying effect
  136623. */
  136624. effect: Effect;
  136625. /**
  136626. * Creates an effect to be renderer
  136627. * @param creationOptions options to create the effect
  136628. */
  136629. constructor(creationOptions: EffectWrapperCreationOptions);
  136630. /**
  136631. * Disposes of the effect wrapper
  136632. */
  136633. dispose(): void;
  136634. }
  136635. }
  136636. declare module BABYLON {
  136637. /** @hidden */
  136638. export var hdrFilteringVertexShader: {
  136639. name: string;
  136640. shader: string;
  136641. };
  136642. }
  136643. declare module BABYLON {
  136644. /** @hidden */
  136645. export var hdrFilteringPixelShader: {
  136646. name: string;
  136647. shader: string;
  136648. };
  136649. }
  136650. declare module BABYLON {
  136651. /**
  136652. * Options for texture filtering
  136653. */
  136654. interface IHDRFilteringOptions {
  136655. /**
  136656. * Scales pixel intensity for the input HDR map.
  136657. */
  136658. hdrScale?: number;
  136659. /**
  136660. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  136661. */
  136662. quality?: number;
  136663. }
  136664. /**
  136665. * Filters HDR maps to get correct renderings of PBR reflections
  136666. */
  136667. export class HDRFiltering {
  136668. private _engine;
  136669. private _effectRenderer;
  136670. private _effectWrapper;
  136671. private _lodGenerationOffset;
  136672. private _lodGenerationScale;
  136673. /**
  136674. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  136675. * you care about baking speed.
  136676. */
  136677. quality: number;
  136678. /**
  136679. * Scales pixel intensity for the input HDR map.
  136680. */
  136681. hdrScale: number;
  136682. /**
  136683. * Instantiates HDR filter for reflection maps
  136684. *
  136685. * @param engine Thin engine
  136686. * @param options Options
  136687. */
  136688. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  136689. private _createRenderTarget;
  136690. private _prefilterInternal;
  136691. private _createEffect;
  136692. /**
  136693. * Get a value indicating if the filter is ready to be used
  136694. * @param texture Texture to filter
  136695. * @returns true if the filter is ready
  136696. */
  136697. isReady(texture: BaseTexture): boolean;
  136698. /**
  136699. * Prefilters a cube texture to have mipmap levels representing roughness values.
  136700. * Prefiltering will be invoked at the end of next rendering pass.
  136701. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  136702. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  136703. * @param texture Texture to filter
  136704. * @param onFinished Callback when filtering is done
  136705. * @return Promise called when prefiltering is done
  136706. */
  136707. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  136708. }
  136709. }
  136710. declare module BABYLON {
  136711. /**
  136712. * This represents a texture coming from an HDR input.
  136713. *
  136714. * The only supported format is currently panorama picture stored in RGBE format.
  136715. * Example of such files can be found on HDRLib: http://hdrlib.com/
  136716. */
  136717. export class HDRCubeTexture extends BaseTexture {
  136718. private static _facesMapping;
  136719. private _generateHarmonics;
  136720. private _noMipmap;
  136721. private _prefilterOnLoad;
  136722. private _textureMatrix;
  136723. private _size;
  136724. private _onLoad;
  136725. private _onError;
  136726. /**
  136727. * The texture URL.
  136728. */
  136729. url: string;
  136730. /**
  136731. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  136732. */
  136733. coordinatesMode: number;
  136734. protected _isBlocking: boolean;
  136735. /**
  136736. * Sets wether or not the texture is blocking during loading.
  136737. */
  136738. set isBlocking(value: boolean);
  136739. /**
  136740. * Gets wether or not the texture is blocking during loading.
  136741. */
  136742. get isBlocking(): boolean;
  136743. protected _rotationY: number;
  136744. /**
  136745. * Sets texture matrix rotation angle around Y axis in radians.
  136746. */
  136747. set rotationY(value: number);
  136748. /**
  136749. * Gets texture matrix rotation angle around Y axis radians.
  136750. */
  136751. get rotationY(): number;
  136752. /**
  136753. * Gets or sets the center of the bounding box associated with the cube texture
  136754. * It must define where the camera used to render the texture was set
  136755. */
  136756. boundingBoxPosition: Vector3;
  136757. private _boundingBoxSize;
  136758. /**
  136759. * Gets or sets the size of the bounding box associated with the cube texture
  136760. * When defined, the cubemap will switch to local mode
  136761. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  136762. * @example https://www.babylonjs-playground.com/#RNASML
  136763. */
  136764. set boundingBoxSize(value: Vector3);
  136765. get boundingBoxSize(): Vector3;
  136766. /**
  136767. * Instantiates an HDRTexture from the following parameters.
  136768. *
  136769. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  136770. * @param sceneOrEngine The scene or engine the texture will be used in
  136771. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  136772. * @param noMipmap Forces to not generate the mipmap if true
  136773. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  136774. * @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)
  136775. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  136776. */
  136777. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, prefilterOnLoad?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  136778. /**
  136779. * Get the current class name of the texture useful for serialization or dynamic coding.
  136780. * @returns "HDRCubeTexture"
  136781. */
  136782. getClassName(): string;
  136783. /**
  136784. * Occurs when the file is raw .hdr file.
  136785. */
  136786. private loadTexture;
  136787. clone(): HDRCubeTexture;
  136788. delayLoad(): void;
  136789. /**
  136790. * Get the texture reflection matrix used to rotate/transform the reflection.
  136791. * @returns the reflection matrix
  136792. */
  136793. getReflectionTextureMatrix(): Matrix;
  136794. /**
  136795. * Set the texture reflection matrix used to rotate/transform the reflection.
  136796. * @param value Define the reflection matrix to set
  136797. */
  136798. setReflectionTextureMatrix(value: Matrix): void;
  136799. /**
  136800. * Parses a JSON representation of an HDR Texture in order to create the texture
  136801. * @param parsedTexture Define the JSON representation
  136802. * @param scene Define the scene the texture should be created in
  136803. * @param rootUrl Define the root url in case we need to load relative dependencies
  136804. * @returns the newly created texture after parsing
  136805. */
  136806. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  136807. serialize(): any;
  136808. }
  136809. }
  136810. declare module BABYLON {
  136811. /**
  136812. * Class used to control physics engine
  136813. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136814. */
  136815. export class PhysicsEngine implements IPhysicsEngine {
  136816. private _physicsPlugin;
  136817. /**
  136818. * Global value used to control the smallest number supported by the simulation
  136819. */
  136820. static Epsilon: number;
  136821. private _impostors;
  136822. private _joints;
  136823. private _subTimeStep;
  136824. /**
  136825. * Gets the gravity vector used by the simulation
  136826. */
  136827. gravity: Vector3;
  136828. /**
  136829. * Factory used to create the default physics plugin.
  136830. * @returns The default physics plugin
  136831. */
  136832. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  136833. /**
  136834. * Creates a new Physics Engine
  136835. * @param gravity defines the gravity vector used by the simulation
  136836. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  136837. */
  136838. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  136839. /**
  136840. * Sets the gravity vector used by the simulation
  136841. * @param gravity defines the gravity vector to use
  136842. */
  136843. setGravity(gravity: Vector3): void;
  136844. /**
  136845. * Set the time step of the physics engine.
  136846. * Default is 1/60.
  136847. * To slow it down, enter 1/600 for example.
  136848. * To speed it up, 1/30
  136849. * @param newTimeStep defines the new timestep to apply to this world.
  136850. */
  136851. setTimeStep(newTimeStep?: number): void;
  136852. /**
  136853. * Get the time step of the physics engine.
  136854. * @returns the current time step
  136855. */
  136856. getTimeStep(): number;
  136857. /**
  136858. * Set the sub time step of the physics engine.
  136859. * Default is 0 meaning there is no sub steps
  136860. * To increase physics resolution precision, set a small value (like 1 ms)
  136861. * @param subTimeStep defines the new sub timestep used for physics resolution.
  136862. */
  136863. setSubTimeStep(subTimeStep?: number): void;
  136864. /**
  136865. * Get the sub time step of the physics engine.
  136866. * @returns the current sub time step
  136867. */
  136868. getSubTimeStep(): number;
  136869. /**
  136870. * Release all resources
  136871. */
  136872. dispose(): void;
  136873. /**
  136874. * Gets the name of the current physics plugin
  136875. * @returns the name of the plugin
  136876. */
  136877. getPhysicsPluginName(): string;
  136878. /**
  136879. * Adding a new impostor for the impostor tracking.
  136880. * This will be done by the impostor itself.
  136881. * @param impostor the impostor to add
  136882. */
  136883. addImpostor(impostor: PhysicsImpostor): void;
  136884. /**
  136885. * Remove an impostor from the engine.
  136886. * This impostor and its mesh will not longer be updated by the physics engine.
  136887. * @param impostor the impostor to remove
  136888. */
  136889. removeImpostor(impostor: PhysicsImpostor): void;
  136890. /**
  136891. * Add a joint to the physics engine
  136892. * @param mainImpostor defines the main impostor to which the joint is added.
  136893. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  136894. * @param joint defines the joint that will connect both impostors.
  136895. */
  136896. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136897. /**
  136898. * Removes a joint from the simulation
  136899. * @param mainImpostor defines the impostor used with the joint
  136900. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  136901. * @param joint defines the joint to remove
  136902. */
  136903. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  136904. /**
  136905. * Called by the scene. No need to call it.
  136906. * @param delta defines the timespam between frames
  136907. */
  136908. _step(delta: number): void;
  136909. /**
  136910. * Gets the current plugin used to run the simulation
  136911. * @returns current plugin
  136912. */
  136913. getPhysicsPlugin(): IPhysicsEnginePlugin;
  136914. /**
  136915. * Gets the list of physic impostors
  136916. * @returns an array of PhysicsImpostor
  136917. */
  136918. getImpostors(): Array<PhysicsImpostor>;
  136919. /**
  136920. * Gets the impostor for a physics enabled object
  136921. * @param object defines the object impersonated by the impostor
  136922. * @returns the PhysicsImpostor or null if not found
  136923. */
  136924. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  136925. /**
  136926. * Gets the impostor for a physics body object
  136927. * @param body defines physics body used by the impostor
  136928. * @returns the PhysicsImpostor or null if not found
  136929. */
  136930. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  136931. /**
  136932. * Does a raycast in the physics world
  136933. * @param from when should the ray start?
  136934. * @param to when should the ray end?
  136935. * @returns PhysicsRaycastResult
  136936. */
  136937. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  136938. }
  136939. }
  136940. declare module BABYLON {
  136941. /** @hidden */
  136942. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  136943. private _useDeltaForWorldStep;
  136944. world: any;
  136945. name: string;
  136946. private _physicsMaterials;
  136947. private _fixedTimeStep;
  136948. private _cannonRaycastResult;
  136949. private _raycastResult;
  136950. private _physicsBodysToRemoveAfterStep;
  136951. private _firstFrame;
  136952. BJSCANNON: any;
  136953. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  136954. setGravity(gravity: Vector3): void;
  136955. setTimeStep(timeStep: number): void;
  136956. getTimeStep(): number;
  136957. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  136958. private _removeMarkedPhysicsBodiesFromWorld;
  136959. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136960. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  136961. generatePhysicsBody(impostor: PhysicsImpostor): void;
  136962. private _processChildMeshes;
  136963. removePhysicsBody(impostor: PhysicsImpostor): void;
  136964. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  136965. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  136966. private _addMaterial;
  136967. private _checkWithEpsilon;
  136968. private _createShape;
  136969. private _createHeightmap;
  136970. private _minus90X;
  136971. private _plus90X;
  136972. private _tmpPosition;
  136973. private _tmpDeltaPosition;
  136974. private _tmpUnityRotation;
  136975. private _updatePhysicsBodyTransformation;
  136976. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  136977. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  136978. isSupported(): boolean;
  136979. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136980. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  136981. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136982. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  136983. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  136984. getBodyMass(impostor: PhysicsImpostor): number;
  136985. getBodyFriction(impostor: PhysicsImpostor): number;
  136986. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  136987. getBodyRestitution(impostor: PhysicsImpostor): number;
  136988. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  136989. sleepBody(impostor: PhysicsImpostor): void;
  136990. wakeUpBody(impostor: PhysicsImpostor): void;
  136991. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  136992. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  136993. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  136994. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  136995. getRadius(impostor: PhysicsImpostor): number;
  136996. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  136997. dispose(): void;
  136998. private _extendNamespace;
  136999. /**
  137000. * Does a raycast in the physics world
  137001. * @param from when should the ray start?
  137002. * @param to when should the ray end?
  137003. * @returns PhysicsRaycastResult
  137004. */
  137005. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137006. }
  137007. }
  137008. declare module BABYLON {
  137009. /** @hidden */
  137010. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137011. private _useDeltaForWorldStep;
  137012. world: any;
  137013. name: string;
  137014. BJSOIMO: any;
  137015. private _raycastResult;
  137016. private _fixedTimeStep;
  137017. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137018. setGravity(gravity: Vector3): void;
  137019. setTimeStep(timeStep: number): void;
  137020. getTimeStep(): number;
  137021. private _tmpImpostorsArray;
  137022. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137023. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137024. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137025. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137026. private _tmpPositionVector;
  137027. removePhysicsBody(impostor: PhysicsImpostor): void;
  137028. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137029. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137030. isSupported(): boolean;
  137031. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137032. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137033. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137034. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137035. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137036. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137037. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137038. getBodyMass(impostor: PhysicsImpostor): number;
  137039. getBodyFriction(impostor: PhysicsImpostor): number;
  137040. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137041. getBodyRestitution(impostor: PhysicsImpostor): number;
  137042. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137043. sleepBody(impostor: PhysicsImpostor): void;
  137044. wakeUpBody(impostor: PhysicsImpostor): void;
  137045. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137046. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137047. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137048. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137049. getRadius(impostor: PhysicsImpostor): number;
  137050. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137051. dispose(): void;
  137052. /**
  137053. * Does a raycast in the physics world
  137054. * @param from when should the ray start?
  137055. * @param to when should the ray end?
  137056. * @returns PhysicsRaycastResult
  137057. */
  137058. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137059. }
  137060. }
  137061. declare module BABYLON {
  137062. /**
  137063. * Class containing static functions to help procedurally build meshes
  137064. */
  137065. export class RibbonBuilder {
  137066. /**
  137067. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137068. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137069. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137070. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137071. * * 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
  137072. * * 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
  137073. * * 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
  137074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137077. * * 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
  137078. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137079. * * 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
  137080. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137082. * @param name defines the name of the mesh
  137083. * @param options defines the options used to create the mesh
  137084. * @param scene defines the hosting scene
  137085. * @returns the ribbon mesh
  137086. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137087. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137088. */
  137089. static CreateRibbon(name: string, options: {
  137090. pathArray: Vector3[][];
  137091. closeArray?: boolean;
  137092. closePath?: boolean;
  137093. offset?: number;
  137094. updatable?: boolean;
  137095. sideOrientation?: number;
  137096. frontUVs?: Vector4;
  137097. backUVs?: Vector4;
  137098. instance?: Mesh;
  137099. invertUV?: boolean;
  137100. uvs?: Vector2[];
  137101. colors?: Color4[];
  137102. }, scene?: Nullable<Scene>): Mesh;
  137103. }
  137104. }
  137105. declare module BABYLON {
  137106. /**
  137107. * Class containing static functions to help procedurally build meshes
  137108. */
  137109. export class ShapeBuilder {
  137110. /**
  137111. * 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.
  137112. * * 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.
  137113. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137114. * * 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.
  137115. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137116. * * 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
  137117. * * 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
  137118. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137121. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137123. * @param name defines the name of the mesh
  137124. * @param options defines the options used to create the mesh
  137125. * @param scene defines the hosting scene
  137126. * @returns the extruded shape mesh
  137127. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137129. */
  137130. static ExtrudeShape(name: string, options: {
  137131. shape: Vector3[];
  137132. path: Vector3[];
  137133. scale?: number;
  137134. rotation?: number;
  137135. cap?: number;
  137136. updatable?: boolean;
  137137. sideOrientation?: number;
  137138. frontUVs?: Vector4;
  137139. backUVs?: Vector4;
  137140. instance?: Mesh;
  137141. invertUV?: boolean;
  137142. }, scene?: Nullable<Scene>): Mesh;
  137143. /**
  137144. * Creates an custom extruded shape mesh.
  137145. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137146. * * 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.
  137147. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137148. * * 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
  137149. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137150. * * 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
  137151. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137152. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137153. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137154. * * 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
  137155. * * 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
  137156. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137159. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137161. * @param name defines the name of the mesh
  137162. * @param options defines the options used to create the mesh
  137163. * @param scene defines the hosting scene
  137164. * @returns the custom extruded shape mesh
  137165. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137166. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137168. */
  137169. static ExtrudeShapeCustom(name: string, options: {
  137170. shape: Vector3[];
  137171. path: Vector3[];
  137172. scaleFunction?: any;
  137173. rotationFunction?: any;
  137174. ribbonCloseArray?: boolean;
  137175. ribbonClosePath?: boolean;
  137176. cap?: number;
  137177. updatable?: boolean;
  137178. sideOrientation?: number;
  137179. frontUVs?: Vector4;
  137180. backUVs?: Vector4;
  137181. instance?: Mesh;
  137182. invertUV?: boolean;
  137183. }, scene?: Nullable<Scene>): Mesh;
  137184. private static _ExtrudeShapeGeneric;
  137185. }
  137186. }
  137187. declare module BABYLON {
  137188. /**
  137189. * AmmoJS Physics plugin
  137190. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137191. * @see https://github.com/kripken/ammo.js/
  137192. */
  137193. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  137194. private _useDeltaForWorldStep;
  137195. /**
  137196. * Reference to the Ammo library
  137197. */
  137198. bjsAMMO: any;
  137199. /**
  137200. * Created ammoJS world which physics bodies are added to
  137201. */
  137202. world: any;
  137203. /**
  137204. * Name of the plugin
  137205. */
  137206. name: string;
  137207. private _timeStep;
  137208. private _fixedTimeStep;
  137209. private _maxSteps;
  137210. private _tmpQuaternion;
  137211. private _tmpAmmoTransform;
  137212. private _tmpAmmoQuaternion;
  137213. private _tmpAmmoConcreteContactResultCallback;
  137214. private _collisionConfiguration;
  137215. private _dispatcher;
  137216. private _overlappingPairCache;
  137217. private _solver;
  137218. private _softBodySolver;
  137219. private _tmpAmmoVectorA;
  137220. private _tmpAmmoVectorB;
  137221. private _tmpAmmoVectorC;
  137222. private _tmpAmmoVectorD;
  137223. private _tmpContactCallbackResult;
  137224. private _tmpAmmoVectorRCA;
  137225. private _tmpAmmoVectorRCB;
  137226. private _raycastResult;
  137227. private static readonly DISABLE_COLLISION_FLAG;
  137228. private static readonly KINEMATIC_FLAG;
  137229. private static readonly DISABLE_DEACTIVATION_FLAG;
  137230. /**
  137231. * Initializes the ammoJS plugin
  137232. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  137233. * @param ammoInjection can be used to inject your own ammo reference
  137234. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  137235. */
  137236. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  137237. /**
  137238. * Sets the gravity of the physics world (m/(s^2))
  137239. * @param gravity Gravity to set
  137240. */
  137241. setGravity(gravity: Vector3): void;
  137242. /**
  137243. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  137244. * @param timeStep timestep to use in seconds
  137245. */
  137246. setTimeStep(timeStep: number): void;
  137247. /**
  137248. * 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)
  137249. * @param fixedTimeStep fixedTimeStep to use in seconds
  137250. */
  137251. setFixedTimeStep(fixedTimeStep: number): void;
  137252. /**
  137253. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  137254. * @param maxSteps the maximum number of steps by the physics engine per frame
  137255. */
  137256. setMaxSteps(maxSteps: number): void;
  137257. /**
  137258. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  137259. * @returns the current timestep in seconds
  137260. */
  137261. getTimeStep(): number;
  137262. /**
  137263. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  137264. */
  137265. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  137266. private _isImpostorInContact;
  137267. private _isImpostorPairInContact;
  137268. private _stepSimulation;
  137269. /**
  137270. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  137271. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  137272. * After the step the babylon meshes are set to the position of the physics imposters
  137273. * @param delta amount of time to step forward
  137274. * @param impostors array of imposters to update before/after the step
  137275. */
  137276. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137277. /**
  137278. * Update babylon mesh to match physics world object
  137279. * @param impostor imposter to match
  137280. */
  137281. private _afterSoftStep;
  137282. /**
  137283. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137284. * @param impostor imposter to match
  137285. */
  137286. private _ropeStep;
  137287. /**
  137288. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  137289. * @param impostor imposter to match
  137290. */
  137291. private _softbodyOrClothStep;
  137292. private _tmpMatrix;
  137293. /**
  137294. * Applies an impulse on the imposter
  137295. * @param impostor imposter to apply impulse to
  137296. * @param force amount of force to be applied to the imposter
  137297. * @param contactPoint the location to apply the impulse on the imposter
  137298. */
  137299. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137300. /**
  137301. * Applies a force on the imposter
  137302. * @param impostor imposter to apply force
  137303. * @param force amount of force to be applied to the imposter
  137304. * @param contactPoint the location to apply the force on the imposter
  137305. */
  137306. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137307. /**
  137308. * Creates a physics body using the plugin
  137309. * @param impostor the imposter to create the physics body on
  137310. */
  137311. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137312. /**
  137313. * Removes the physics body from the imposter and disposes of the body's memory
  137314. * @param impostor imposter to remove the physics body from
  137315. */
  137316. removePhysicsBody(impostor: PhysicsImpostor): void;
  137317. /**
  137318. * Generates a joint
  137319. * @param impostorJoint the imposter joint to create the joint with
  137320. */
  137321. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137322. /**
  137323. * Removes a joint
  137324. * @param impostorJoint the imposter joint to remove the joint from
  137325. */
  137326. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137327. private _addMeshVerts;
  137328. /**
  137329. * Initialise the soft body vertices to match its object's (mesh) vertices
  137330. * Softbody vertices (nodes) are in world space and to match this
  137331. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  137332. * @param impostor to create the softbody for
  137333. */
  137334. private _softVertexData;
  137335. /**
  137336. * Create an impostor's soft body
  137337. * @param impostor to create the softbody for
  137338. */
  137339. private _createSoftbody;
  137340. /**
  137341. * Create cloth for an impostor
  137342. * @param impostor to create the softbody for
  137343. */
  137344. private _createCloth;
  137345. /**
  137346. * Create rope for an impostor
  137347. * @param impostor to create the softbody for
  137348. */
  137349. private _createRope;
  137350. /**
  137351. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  137352. * @param impostor to create the custom physics shape for
  137353. */
  137354. private _createCustom;
  137355. private _addHullVerts;
  137356. private _createShape;
  137357. /**
  137358. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  137359. * @param impostor imposter containing the physics body and babylon object
  137360. */
  137361. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137362. /**
  137363. * Sets the babylon object's position/rotation from the physics body's position/rotation
  137364. * @param impostor imposter containing the physics body and babylon object
  137365. * @param newPosition new position
  137366. * @param newRotation new rotation
  137367. */
  137368. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137369. /**
  137370. * If this plugin is supported
  137371. * @returns true if its supported
  137372. */
  137373. isSupported(): boolean;
  137374. /**
  137375. * Sets the linear velocity of the physics body
  137376. * @param impostor imposter to set the velocity on
  137377. * @param velocity velocity to set
  137378. */
  137379. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137380. /**
  137381. * Sets the angular velocity of the physics body
  137382. * @param impostor imposter to set the velocity on
  137383. * @param velocity velocity to set
  137384. */
  137385. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137386. /**
  137387. * gets the linear velocity
  137388. * @param impostor imposter to get linear velocity from
  137389. * @returns linear velocity
  137390. */
  137391. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137392. /**
  137393. * gets the angular velocity
  137394. * @param impostor imposter to get angular velocity from
  137395. * @returns angular velocity
  137396. */
  137397. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137398. /**
  137399. * Sets the mass of physics body
  137400. * @param impostor imposter to set the mass on
  137401. * @param mass mass to set
  137402. */
  137403. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137404. /**
  137405. * Gets the mass of the physics body
  137406. * @param impostor imposter to get the mass from
  137407. * @returns mass
  137408. */
  137409. getBodyMass(impostor: PhysicsImpostor): number;
  137410. /**
  137411. * Gets friction of the impostor
  137412. * @param impostor impostor to get friction from
  137413. * @returns friction value
  137414. */
  137415. getBodyFriction(impostor: PhysicsImpostor): number;
  137416. /**
  137417. * Sets friction of the impostor
  137418. * @param impostor impostor to set friction on
  137419. * @param friction friction value
  137420. */
  137421. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137422. /**
  137423. * Gets restitution of the impostor
  137424. * @param impostor impostor to get restitution from
  137425. * @returns restitution value
  137426. */
  137427. getBodyRestitution(impostor: PhysicsImpostor): number;
  137428. /**
  137429. * Sets resitution of the impostor
  137430. * @param impostor impostor to set resitution on
  137431. * @param restitution resitution value
  137432. */
  137433. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137434. /**
  137435. * Gets pressure inside the impostor
  137436. * @param impostor impostor to get pressure from
  137437. * @returns pressure value
  137438. */
  137439. getBodyPressure(impostor: PhysicsImpostor): number;
  137440. /**
  137441. * Sets pressure inside a soft body impostor
  137442. * Cloth and rope must remain 0 pressure
  137443. * @param impostor impostor to set pressure on
  137444. * @param pressure pressure value
  137445. */
  137446. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  137447. /**
  137448. * Gets stiffness of the impostor
  137449. * @param impostor impostor to get stiffness from
  137450. * @returns pressure value
  137451. */
  137452. getBodyStiffness(impostor: PhysicsImpostor): number;
  137453. /**
  137454. * Sets stiffness of the impostor
  137455. * @param impostor impostor to set stiffness on
  137456. * @param stiffness stiffness value from 0 to 1
  137457. */
  137458. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  137459. /**
  137460. * Gets velocityIterations of the impostor
  137461. * @param impostor impostor to get velocity iterations from
  137462. * @returns velocityIterations value
  137463. */
  137464. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  137465. /**
  137466. * Sets velocityIterations of the impostor
  137467. * @param impostor impostor to set velocity iterations on
  137468. * @param velocityIterations velocityIterations value
  137469. */
  137470. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  137471. /**
  137472. * Gets positionIterations of the impostor
  137473. * @param impostor impostor to get position iterations from
  137474. * @returns positionIterations value
  137475. */
  137476. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  137477. /**
  137478. * Sets positionIterations of the impostor
  137479. * @param impostor impostor to set position on
  137480. * @param positionIterations positionIterations value
  137481. */
  137482. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  137483. /**
  137484. * Append an anchor to a cloth object
  137485. * @param impostor is the cloth impostor to add anchor to
  137486. * @param otherImpostor is the rigid impostor to anchor to
  137487. * @param width ratio across width from 0 to 1
  137488. * @param height ratio up height from 0 to 1
  137489. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  137490. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137491. */
  137492. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137493. /**
  137494. * Append an hook to a rope object
  137495. * @param impostor is the rope impostor to add hook to
  137496. * @param otherImpostor is the rigid impostor to hook to
  137497. * @param length ratio along the rope from 0 to 1
  137498. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  137499. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  137500. */
  137501. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  137502. /**
  137503. * Sleeps the physics body and stops it from being active
  137504. * @param impostor impostor to sleep
  137505. */
  137506. sleepBody(impostor: PhysicsImpostor): void;
  137507. /**
  137508. * Activates the physics body
  137509. * @param impostor impostor to activate
  137510. */
  137511. wakeUpBody(impostor: PhysicsImpostor): void;
  137512. /**
  137513. * Updates the distance parameters of the joint
  137514. * @param joint joint to update
  137515. * @param maxDistance maximum distance of the joint
  137516. * @param minDistance minimum distance of the joint
  137517. */
  137518. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137519. /**
  137520. * Sets a motor on the joint
  137521. * @param joint joint to set motor on
  137522. * @param speed speed of the motor
  137523. * @param maxForce maximum force of the motor
  137524. * @param motorIndex index of the motor
  137525. */
  137526. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137527. /**
  137528. * Sets the motors limit
  137529. * @param joint joint to set limit on
  137530. * @param upperLimit upper limit
  137531. * @param lowerLimit lower limit
  137532. */
  137533. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137534. /**
  137535. * Syncs the position and rotation of a mesh with the impostor
  137536. * @param mesh mesh to sync
  137537. * @param impostor impostor to update the mesh with
  137538. */
  137539. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137540. /**
  137541. * Gets the radius of the impostor
  137542. * @param impostor impostor to get radius from
  137543. * @returns the radius
  137544. */
  137545. getRadius(impostor: PhysicsImpostor): number;
  137546. /**
  137547. * Gets the box size of the impostor
  137548. * @param impostor impostor to get box size from
  137549. * @param result the resulting box size
  137550. */
  137551. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137552. /**
  137553. * Disposes of the impostor
  137554. */
  137555. dispose(): void;
  137556. /**
  137557. * Does a raycast in the physics world
  137558. * @param from when should the ray start?
  137559. * @param to when should the ray end?
  137560. * @returns PhysicsRaycastResult
  137561. */
  137562. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137563. }
  137564. }
  137565. declare module BABYLON {
  137566. interface AbstractScene {
  137567. /**
  137568. * The list of reflection probes added to the scene
  137569. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137570. */
  137571. reflectionProbes: Array<ReflectionProbe>;
  137572. /**
  137573. * Removes the given reflection probe from this scene.
  137574. * @param toRemove The reflection probe to remove
  137575. * @returns The index of the removed reflection probe
  137576. */
  137577. removeReflectionProbe(toRemove: ReflectionProbe): number;
  137578. /**
  137579. * Adds the given reflection probe to this scene.
  137580. * @param newReflectionProbe The reflection probe to add
  137581. */
  137582. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  137583. }
  137584. /**
  137585. * Class used to generate realtime reflection / refraction cube textures
  137586. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  137587. */
  137588. export class ReflectionProbe {
  137589. /** defines the name of the probe */
  137590. name: string;
  137591. private _scene;
  137592. private _renderTargetTexture;
  137593. private _projectionMatrix;
  137594. private _viewMatrix;
  137595. private _target;
  137596. private _add;
  137597. private _attachedMesh;
  137598. private _invertYAxis;
  137599. /** Gets or sets probe position (center of the cube map) */
  137600. position: Vector3;
  137601. /**
  137602. * Creates a new reflection probe
  137603. * @param name defines the name of the probe
  137604. * @param size defines the texture resolution (for each face)
  137605. * @param scene defines the hosting scene
  137606. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  137607. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  137608. */
  137609. constructor(
  137610. /** defines the name of the probe */
  137611. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  137612. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  137613. get samples(): number;
  137614. set samples(value: number);
  137615. /** Gets or sets the refresh rate to use (on every frame by default) */
  137616. get refreshRate(): number;
  137617. set refreshRate(value: number);
  137618. /**
  137619. * Gets the hosting scene
  137620. * @returns a Scene
  137621. */
  137622. getScene(): Scene;
  137623. /** Gets the internal CubeTexture used to render to */
  137624. get cubeTexture(): RenderTargetTexture;
  137625. /** Gets the list of meshes to render */
  137626. get renderList(): Nullable<AbstractMesh[]>;
  137627. /**
  137628. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  137629. * @param mesh defines the mesh to attach to
  137630. */
  137631. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  137632. /**
  137633. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  137634. * @param renderingGroupId The rendering group id corresponding to its index
  137635. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  137636. */
  137637. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  137638. /**
  137639. * Clean all associated resources
  137640. */
  137641. dispose(): void;
  137642. /**
  137643. * Converts the reflection probe information to a readable string for debug purpose.
  137644. * @param fullDetails Supports for multiple levels of logging within scene loading
  137645. * @returns the human readable reflection probe info
  137646. */
  137647. toString(fullDetails?: boolean): string;
  137648. /**
  137649. * Get the class name of the relfection probe.
  137650. * @returns "ReflectionProbe"
  137651. */
  137652. getClassName(): string;
  137653. /**
  137654. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  137655. * @returns The JSON representation of the texture
  137656. */
  137657. serialize(): any;
  137658. /**
  137659. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  137660. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  137661. * @param scene Define the scene the parsed reflection probe should be instantiated in
  137662. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  137663. * @returns The parsed reflection probe if successful
  137664. */
  137665. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  137666. }
  137667. }
  137668. declare module BABYLON {
  137669. /** @hidden */
  137670. export var _BabylonLoaderRegistered: boolean;
  137671. /**
  137672. * Helps setting up some configuration for the babylon file loader.
  137673. */
  137674. export class BabylonFileLoaderConfiguration {
  137675. /**
  137676. * The loader does not allow injecting custom physix engine into the plugins.
  137677. * Unfortunately in ES6, we need to manually inject them into the plugin.
  137678. * So you could set this variable to your engine import to make it work.
  137679. */
  137680. static LoaderInjectedPhysicsEngine: any;
  137681. }
  137682. }
  137683. declare module BABYLON {
  137684. /**
  137685. * The Physically based simple base material of BJS.
  137686. *
  137687. * This enables better naming and convention enforcements on top of the pbrMaterial.
  137688. * It is used as the base class for both the specGloss and metalRough conventions.
  137689. */
  137690. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  137691. /**
  137692. * Number of Simultaneous lights allowed on the material.
  137693. */
  137694. maxSimultaneousLights: number;
  137695. /**
  137696. * If sets to true, disables all the lights affecting the material.
  137697. */
  137698. disableLighting: boolean;
  137699. /**
  137700. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  137701. */
  137702. environmentTexture: BaseTexture;
  137703. /**
  137704. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137705. */
  137706. invertNormalMapX: boolean;
  137707. /**
  137708. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137709. */
  137710. invertNormalMapY: boolean;
  137711. /**
  137712. * Normal map used in the model.
  137713. */
  137714. normalTexture: BaseTexture;
  137715. /**
  137716. * Emissivie color used to self-illuminate the model.
  137717. */
  137718. emissiveColor: Color3;
  137719. /**
  137720. * Emissivie texture used to self-illuminate the model.
  137721. */
  137722. emissiveTexture: BaseTexture;
  137723. /**
  137724. * Occlusion Channel Strenght.
  137725. */
  137726. occlusionStrength: number;
  137727. /**
  137728. * Occlusion Texture of the material (adding extra occlusion effects).
  137729. */
  137730. occlusionTexture: BaseTexture;
  137731. /**
  137732. * Defines the alpha limits in alpha test mode.
  137733. */
  137734. alphaCutOff: number;
  137735. /**
  137736. * Gets the current double sided mode.
  137737. */
  137738. get doubleSided(): boolean;
  137739. /**
  137740. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137741. */
  137742. set doubleSided(value: boolean);
  137743. /**
  137744. * Stores the pre-calculated light information of a mesh in a texture.
  137745. */
  137746. lightmapTexture: BaseTexture;
  137747. /**
  137748. * If true, the light map contains occlusion information instead of lighting info.
  137749. */
  137750. useLightmapAsShadowmap: boolean;
  137751. /**
  137752. * Instantiates a new PBRMaterial instance.
  137753. *
  137754. * @param name The material name
  137755. * @param scene The scene the material will be use in.
  137756. */
  137757. constructor(name: string, scene: Scene);
  137758. getClassName(): string;
  137759. }
  137760. }
  137761. declare module BABYLON {
  137762. /**
  137763. * The PBR material of BJS following the metal roughness convention.
  137764. *
  137765. * This fits to the PBR convention in the GLTF definition:
  137766. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  137767. */
  137768. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  137769. /**
  137770. * The base color has two different interpretations depending on the value of metalness.
  137771. * When the material is a metal, the base color is the specific measured reflectance value
  137772. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  137773. * of the material.
  137774. */
  137775. baseColor: Color3;
  137776. /**
  137777. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  137778. * well as opacity information in the alpha channel.
  137779. */
  137780. baseTexture: BaseTexture;
  137781. /**
  137782. * Specifies the metallic scalar value of the material.
  137783. * Can also be used to scale the metalness values of the metallic texture.
  137784. */
  137785. metallic: number;
  137786. /**
  137787. * Specifies the roughness scalar value of the material.
  137788. * Can also be used to scale the roughness values of the metallic texture.
  137789. */
  137790. roughness: number;
  137791. /**
  137792. * Texture containing both the metallic value in the B channel and the
  137793. * roughness value in the G channel to keep better precision.
  137794. */
  137795. metallicRoughnessTexture: BaseTexture;
  137796. /**
  137797. * Instantiates a new PBRMetalRoughnessMaterial instance.
  137798. *
  137799. * @param name The material name
  137800. * @param scene The scene the material will be use in.
  137801. */
  137802. constructor(name: string, scene: Scene);
  137803. /**
  137804. * Return the currrent class name of the material.
  137805. */
  137806. getClassName(): string;
  137807. /**
  137808. * Makes a duplicate of the current material.
  137809. * @param name - name to use for the new material.
  137810. */
  137811. clone(name: string): PBRMetallicRoughnessMaterial;
  137812. /**
  137813. * Serialize the material to a parsable JSON object.
  137814. */
  137815. serialize(): any;
  137816. /**
  137817. * Parses a JSON object correponding to the serialize function.
  137818. */
  137819. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  137820. }
  137821. }
  137822. declare module BABYLON {
  137823. /**
  137824. * The PBR material of BJS following the specular glossiness convention.
  137825. *
  137826. * This fits to the PBR convention in the GLTF definition:
  137827. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  137828. */
  137829. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  137830. /**
  137831. * Specifies the diffuse color of the material.
  137832. */
  137833. diffuseColor: Color3;
  137834. /**
  137835. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  137836. * channel.
  137837. */
  137838. diffuseTexture: BaseTexture;
  137839. /**
  137840. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  137841. */
  137842. specularColor: Color3;
  137843. /**
  137844. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  137845. */
  137846. glossiness: number;
  137847. /**
  137848. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  137849. */
  137850. specularGlossinessTexture: BaseTexture;
  137851. /**
  137852. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  137853. *
  137854. * @param name The material name
  137855. * @param scene The scene the material will be use in.
  137856. */
  137857. constructor(name: string, scene: Scene);
  137858. /**
  137859. * Return the currrent class name of the material.
  137860. */
  137861. getClassName(): string;
  137862. /**
  137863. * Makes a duplicate of the current material.
  137864. * @param name - name to use for the new material.
  137865. */
  137866. clone(name: string): PBRSpecularGlossinessMaterial;
  137867. /**
  137868. * Serialize the material to a parsable JSON object.
  137869. */
  137870. serialize(): any;
  137871. /**
  137872. * Parses a JSON object correponding to the serialize function.
  137873. */
  137874. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  137875. }
  137876. }
  137877. declare module BABYLON {
  137878. /**
  137879. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  137880. * It can help converting any input color in a desired output one. This can then be used to create effects
  137881. * from sepia, black and white to sixties or futuristic rendering...
  137882. *
  137883. * The only supported format is currently 3dl.
  137884. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  137885. */
  137886. export class ColorGradingTexture extends BaseTexture {
  137887. /**
  137888. * The texture URL.
  137889. */
  137890. url: string;
  137891. /**
  137892. * Empty line regex stored for GC.
  137893. */
  137894. private static _noneEmptyLineRegex;
  137895. private _textureMatrix;
  137896. private _onLoad;
  137897. /**
  137898. * Instantiates a ColorGradingTexture from the following parameters.
  137899. *
  137900. * @param url The location of the color gradind data (currently only supporting 3dl)
  137901. * @param sceneOrEngine The scene or engine the texture will be used in
  137902. * @param onLoad defines a callback triggered when the texture has been loaded
  137903. */
  137904. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  137905. /**
  137906. * Fires the onload event from the constructor if requested.
  137907. */
  137908. private _triggerOnLoad;
  137909. /**
  137910. * Returns the texture matrix used in most of the material.
  137911. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  137912. */
  137913. getTextureMatrix(): Matrix;
  137914. /**
  137915. * Occurs when the file being loaded is a .3dl LUT file.
  137916. */
  137917. private load3dlTexture;
  137918. /**
  137919. * Starts the loading process of the texture.
  137920. */
  137921. private loadTexture;
  137922. /**
  137923. * Clones the color gradind texture.
  137924. */
  137925. clone(): ColorGradingTexture;
  137926. /**
  137927. * Called during delayed load for textures.
  137928. */
  137929. delayLoad(): void;
  137930. /**
  137931. * Parses a color grading texture serialized by Babylon.
  137932. * @param parsedTexture The texture information being parsedTexture
  137933. * @param scene The scene to load the texture in
  137934. * @param rootUrl The root url of the data assets to load
  137935. * @return A color gradind texture
  137936. */
  137937. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  137938. /**
  137939. * Serializes the LUT texture to json format.
  137940. */
  137941. serialize(): any;
  137942. }
  137943. }
  137944. declare module BABYLON {
  137945. /**
  137946. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  137947. */
  137948. export class EquiRectangularCubeTexture extends BaseTexture {
  137949. /** The six faces of the cube. */
  137950. private static _FacesMapping;
  137951. private _noMipmap;
  137952. private _onLoad;
  137953. private _onError;
  137954. /** The size of the cubemap. */
  137955. private _size;
  137956. /** The buffer of the image. */
  137957. private _buffer;
  137958. /** The width of the input image. */
  137959. private _width;
  137960. /** The height of the input image. */
  137961. private _height;
  137962. /** The URL to the image. */
  137963. url: string;
  137964. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  137965. coordinatesMode: number;
  137966. /**
  137967. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  137968. * @param url The location of the image
  137969. * @param scene The scene the texture will be used in
  137970. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137971. * @param noMipmap Forces to not generate the mipmap if true
  137972. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  137973. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  137974. * @param onLoad — defines a callback called when texture is loaded
  137975. * @param onError — defines a callback called if there is an error
  137976. */
  137977. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  137978. /**
  137979. * Load the image data, by putting the image on a canvas and extracting its buffer.
  137980. */
  137981. private loadImage;
  137982. /**
  137983. * Convert the image buffer into a cubemap and create a CubeTexture.
  137984. */
  137985. private loadTexture;
  137986. /**
  137987. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  137988. * @param buffer The ArrayBuffer that should be converted.
  137989. * @returns The buffer as Float32Array.
  137990. */
  137991. private getFloat32ArrayFromArrayBuffer;
  137992. /**
  137993. * Get the current class name of the texture useful for serialization or dynamic coding.
  137994. * @returns "EquiRectangularCubeTexture"
  137995. */
  137996. getClassName(): string;
  137997. /**
  137998. * Create a clone of the current EquiRectangularCubeTexture and return it.
  137999. * @returns A clone of the current EquiRectangularCubeTexture.
  138000. */
  138001. clone(): EquiRectangularCubeTexture;
  138002. }
  138003. }
  138004. declare module BABYLON {
  138005. /**
  138006. * Defines the options related to the creation of an HtmlElementTexture
  138007. */
  138008. export interface IHtmlElementTextureOptions {
  138009. /**
  138010. * Defines wether mip maps should be created or not.
  138011. */
  138012. generateMipMaps?: boolean;
  138013. /**
  138014. * Defines the sampling mode of the texture.
  138015. */
  138016. samplingMode?: number;
  138017. /**
  138018. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138019. */
  138020. engine: Nullable<ThinEngine>;
  138021. /**
  138022. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138023. */
  138024. scene: Nullable<Scene>;
  138025. }
  138026. /**
  138027. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138028. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138029. * is automatically managed.
  138030. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138031. * in your application.
  138032. *
  138033. * As the update is not automatic, you need to call them manually.
  138034. */
  138035. export class HtmlElementTexture extends BaseTexture {
  138036. /**
  138037. * The texture URL.
  138038. */
  138039. element: HTMLVideoElement | HTMLCanvasElement;
  138040. private static readonly DefaultOptions;
  138041. private _textureMatrix;
  138042. private _isVideo;
  138043. private _generateMipMaps;
  138044. private _samplingMode;
  138045. /**
  138046. * Instantiates a HtmlElementTexture from the following parameters.
  138047. *
  138048. * @param name Defines the name of the texture
  138049. * @param element Defines the video or canvas the texture is filled with
  138050. * @param options Defines the other none mandatory texture creation options
  138051. */
  138052. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138053. private _createInternalTexture;
  138054. /**
  138055. * Returns the texture matrix used in most of the material.
  138056. */
  138057. getTextureMatrix(): Matrix;
  138058. /**
  138059. * Updates the content of the texture.
  138060. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138061. */
  138062. update(invertY?: Nullable<boolean>): void;
  138063. }
  138064. }
  138065. declare module BABYLON {
  138066. /**
  138067. * Based on jsTGALoader - Javascript loader for TGA file
  138068. * By Vincent Thibault
  138069. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138070. */
  138071. export class TGATools {
  138072. private static _TYPE_INDEXED;
  138073. private static _TYPE_RGB;
  138074. private static _TYPE_GREY;
  138075. private static _TYPE_RLE_INDEXED;
  138076. private static _TYPE_RLE_RGB;
  138077. private static _TYPE_RLE_GREY;
  138078. private static _ORIGIN_MASK;
  138079. private static _ORIGIN_SHIFT;
  138080. private static _ORIGIN_BL;
  138081. private static _ORIGIN_BR;
  138082. private static _ORIGIN_UL;
  138083. private static _ORIGIN_UR;
  138084. /**
  138085. * Gets the header of a TGA file
  138086. * @param data defines the TGA data
  138087. * @returns the header
  138088. */
  138089. static GetTGAHeader(data: Uint8Array): any;
  138090. /**
  138091. * Uploads TGA content to a Babylon Texture
  138092. * @hidden
  138093. */
  138094. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  138095. /** @hidden */
  138096. 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;
  138097. /** @hidden */
  138098. 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;
  138099. /** @hidden */
  138100. 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;
  138101. /** @hidden */
  138102. 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;
  138103. /** @hidden */
  138104. 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;
  138105. /** @hidden */
  138106. 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;
  138107. }
  138108. }
  138109. declare module BABYLON {
  138110. /**
  138111. * Implementation of the TGA Texture Loader.
  138112. * @hidden
  138113. */
  138114. export class _TGATextureLoader implements IInternalTextureLoader {
  138115. /**
  138116. * Defines wether the loader supports cascade loading the different faces.
  138117. */
  138118. readonly supportCascades: boolean;
  138119. /**
  138120. * This returns if the loader support the current file information.
  138121. * @param extension defines the file extension of the file being loaded
  138122. * @returns true if the loader can load the specified file
  138123. */
  138124. canLoad(extension: string): boolean;
  138125. /**
  138126. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138127. * @param data contains the texture data
  138128. * @param texture defines the BabylonJS internal texture
  138129. * @param createPolynomials will be true if polynomials have been requested
  138130. * @param onLoad defines the callback to trigger once the texture is ready
  138131. * @param onError defines the callback to trigger in case of error
  138132. */
  138133. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138134. /**
  138135. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138136. * @param data contains the texture data
  138137. * @param texture defines the BabylonJS internal texture
  138138. * @param callback defines the method to call once ready to upload
  138139. */
  138140. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138141. }
  138142. }
  138143. declare module BABYLON {
  138144. /**
  138145. * Info about the .basis files
  138146. */
  138147. class BasisFileInfo {
  138148. /**
  138149. * If the file has alpha
  138150. */
  138151. hasAlpha: boolean;
  138152. /**
  138153. * Info about each image of the basis file
  138154. */
  138155. images: Array<{
  138156. levels: Array<{
  138157. width: number;
  138158. height: number;
  138159. transcodedPixels: ArrayBufferView;
  138160. }>;
  138161. }>;
  138162. }
  138163. /**
  138164. * Result of transcoding a basis file
  138165. */
  138166. class TranscodeResult {
  138167. /**
  138168. * Info about the .basis file
  138169. */
  138170. fileInfo: BasisFileInfo;
  138171. /**
  138172. * Format to use when loading the file
  138173. */
  138174. format: number;
  138175. }
  138176. /**
  138177. * Configuration options for the Basis transcoder
  138178. */
  138179. export class BasisTranscodeConfiguration {
  138180. /**
  138181. * Supported compression formats used to determine the supported output format of the transcoder
  138182. */
  138183. supportedCompressionFormats?: {
  138184. /**
  138185. * etc1 compression format
  138186. */
  138187. etc1?: boolean;
  138188. /**
  138189. * s3tc compression format
  138190. */
  138191. s3tc?: boolean;
  138192. /**
  138193. * pvrtc compression format
  138194. */
  138195. pvrtc?: boolean;
  138196. /**
  138197. * etc2 compression format
  138198. */
  138199. etc2?: boolean;
  138200. };
  138201. /**
  138202. * If mipmap levels should be loaded for transcoded images (Default: true)
  138203. */
  138204. loadMipmapLevels?: boolean;
  138205. /**
  138206. * Index of a single image to load (Default: all images)
  138207. */
  138208. loadSingleImage?: number;
  138209. }
  138210. /**
  138211. * Used to load .Basis files
  138212. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  138213. */
  138214. export class BasisTools {
  138215. private static _IgnoreSupportedFormats;
  138216. /**
  138217. * URL to use when loading the basis transcoder
  138218. */
  138219. static JSModuleURL: string;
  138220. /**
  138221. * URL to use when loading the wasm module for the transcoder
  138222. */
  138223. static WasmModuleURL: string;
  138224. /**
  138225. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  138226. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  138227. * @returns internal format corresponding to the Basis format
  138228. */
  138229. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  138230. private static _WorkerPromise;
  138231. private static _Worker;
  138232. private static _actionId;
  138233. private static _CreateWorkerAsync;
  138234. /**
  138235. * Transcodes a loaded image file to compressed pixel data
  138236. * @param data image data to transcode
  138237. * @param config configuration options for the transcoding
  138238. * @returns a promise resulting in the transcoded image
  138239. */
  138240. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  138241. /**
  138242. * Loads a texture from the transcode result
  138243. * @param texture texture load to
  138244. * @param transcodeResult the result of transcoding the basis file to load from
  138245. */
  138246. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  138247. }
  138248. }
  138249. declare module BABYLON {
  138250. /**
  138251. * Loader for .basis file format
  138252. */
  138253. export class _BasisTextureLoader implements IInternalTextureLoader {
  138254. /**
  138255. * Defines whether the loader supports cascade loading the different faces.
  138256. */
  138257. readonly supportCascades: boolean;
  138258. /**
  138259. * This returns if the loader support the current file information.
  138260. * @param extension defines the file extension of the file being loaded
  138261. * @returns true if the loader can load the specified file
  138262. */
  138263. canLoad(extension: string): boolean;
  138264. /**
  138265. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138266. * @param data contains the texture data
  138267. * @param texture defines the BabylonJS internal texture
  138268. * @param createPolynomials will be true if polynomials have been requested
  138269. * @param onLoad defines the callback to trigger once the texture is ready
  138270. * @param onError defines the callback to trigger in case of error
  138271. */
  138272. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138273. /**
  138274. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138275. * @param data contains the texture data
  138276. * @param texture defines the BabylonJS internal texture
  138277. * @param callback defines the method to call once ready to upload
  138278. */
  138279. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138280. }
  138281. }
  138282. declare module BABYLON {
  138283. /**
  138284. * Defines the basic options interface of a TexturePacker Frame
  138285. */
  138286. export interface ITexturePackerFrame {
  138287. /**
  138288. * The frame ID
  138289. */
  138290. id: number;
  138291. /**
  138292. * The frames Scale
  138293. */
  138294. scale: Vector2;
  138295. /**
  138296. * The Frames offset
  138297. */
  138298. offset: Vector2;
  138299. }
  138300. /**
  138301. * This is a support class for frame Data on texture packer sets.
  138302. */
  138303. export class TexturePackerFrame implements ITexturePackerFrame {
  138304. /**
  138305. * The frame ID
  138306. */
  138307. id: number;
  138308. /**
  138309. * The frames Scale
  138310. */
  138311. scale: Vector2;
  138312. /**
  138313. * The Frames offset
  138314. */
  138315. offset: Vector2;
  138316. /**
  138317. * Initializes a texture package frame.
  138318. * @param id The numerical frame identifier
  138319. * @param scale Scalar Vector2 for UV frame
  138320. * @param offset Vector2 for the frame position in UV units.
  138321. * @returns TexturePackerFrame
  138322. */
  138323. constructor(id: number, scale: Vector2, offset: Vector2);
  138324. }
  138325. }
  138326. declare module BABYLON {
  138327. /**
  138328. * Defines the basic options interface of a TexturePacker
  138329. */
  138330. export interface ITexturePackerOptions {
  138331. /**
  138332. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  138333. */
  138334. map?: string[];
  138335. /**
  138336. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  138337. */
  138338. uvsIn?: string;
  138339. /**
  138340. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  138341. */
  138342. uvsOut?: string;
  138343. /**
  138344. * number representing the layout style. Defaults to LAYOUT_STRIP
  138345. */
  138346. layout?: number;
  138347. /**
  138348. * number of columns if using custom column count layout(2). This defaults to 4.
  138349. */
  138350. colnum?: number;
  138351. /**
  138352. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  138353. */
  138354. updateInputMeshes?: boolean;
  138355. /**
  138356. * boolean flag to dispose all the source textures. Defaults to true.
  138357. */
  138358. disposeSources?: boolean;
  138359. /**
  138360. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  138361. */
  138362. fillBlanks?: boolean;
  138363. /**
  138364. * string value representing the context fill style color. Defaults to 'black'.
  138365. */
  138366. customFillColor?: string;
  138367. /**
  138368. * Width and Height Value of each Frame in the TexturePacker Sets
  138369. */
  138370. frameSize?: number;
  138371. /**
  138372. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  138373. */
  138374. paddingRatio?: number;
  138375. /**
  138376. * Number that declares the fill method for the padding gutter.
  138377. */
  138378. paddingMode?: number;
  138379. /**
  138380. * If in SUBUV_COLOR padding mode what color to use.
  138381. */
  138382. paddingColor?: Color3 | Color4;
  138383. }
  138384. /**
  138385. * Defines the basic interface of a TexturePacker JSON File
  138386. */
  138387. export interface ITexturePackerJSON {
  138388. /**
  138389. * The frame ID
  138390. */
  138391. name: string;
  138392. /**
  138393. * The base64 channel data
  138394. */
  138395. sets: any;
  138396. /**
  138397. * The options of the Packer
  138398. */
  138399. options: ITexturePackerOptions;
  138400. /**
  138401. * The frame data of the Packer
  138402. */
  138403. frames: Array<number>;
  138404. }
  138405. /**
  138406. * This is a support class that generates a series of packed texture sets.
  138407. * @see https://doc.babylonjs.com/babylon101/materials
  138408. */
  138409. export class TexturePacker {
  138410. /** Packer Layout Constant 0 */
  138411. static readonly LAYOUT_STRIP: number;
  138412. /** Packer Layout Constant 1 */
  138413. static readonly LAYOUT_POWER2: number;
  138414. /** Packer Layout Constant 2 */
  138415. static readonly LAYOUT_COLNUM: number;
  138416. /** Packer Layout Constant 0 */
  138417. static readonly SUBUV_WRAP: number;
  138418. /** Packer Layout Constant 1 */
  138419. static readonly SUBUV_EXTEND: number;
  138420. /** Packer Layout Constant 2 */
  138421. static readonly SUBUV_COLOR: number;
  138422. /** The Name of the Texture Package */
  138423. name: string;
  138424. /** The scene scope of the TexturePacker */
  138425. scene: Scene;
  138426. /** The Meshes to target */
  138427. meshes: AbstractMesh[];
  138428. /** Arguments passed with the Constructor */
  138429. options: ITexturePackerOptions;
  138430. /** The promise that is started upon initialization */
  138431. promise: Nullable<Promise<TexturePacker | string>>;
  138432. /** The Container object for the channel sets that are generated */
  138433. sets: object;
  138434. /** The Container array for the frames that are generated */
  138435. frames: TexturePackerFrame[];
  138436. /** The expected number of textures the system is parsing. */
  138437. private _expecting;
  138438. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  138439. private _paddingValue;
  138440. /**
  138441. * Initializes a texture package series from an array of meshes or a single mesh.
  138442. * @param name The name of the package
  138443. * @param meshes The target meshes to compose the package from
  138444. * @param options The arguments that texture packer should follow while building.
  138445. * @param scene The scene which the textures are scoped to.
  138446. * @returns TexturePacker
  138447. */
  138448. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  138449. /**
  138450. * Starts the package process
  138451. * @param resolve The promises resolution function
  138452. * @returns TexturePacker
  138453. */
  138454. private _createFrames;
  138455. /**
  138456. * Calculates the Size of the Channel Sets
  138457. * @returns Vector2
  138458. */
  138459. private _calculateSize;
  138460. /**
  138461. * Calculates the UV data for the frames.
  138462. * @param baseSize the base frameSize
  138463. * @param padding the base frame padding
  138464. * @param dtSize size of the Dynamic Texture for that channel
  138465. * @param dtUnits is 1/dtSize
  138466. * @param update flag to update the input meshes
  138467. */
  138468. private _calculateMeshUVFrames;
  138469. /**
  138470. * Calculates the frames Offset.
  138471. * @param index of the frame
  138472. * @returns Vector2
  138473. */
  138474. private _getFrameOffset;
  138475. /**
  138476. * Updates a Mesh to the frame data
  138477. * @param mesh that is the target
  138478. * @param frameID or the frame index
  138479. */
  138480. private _updateMeshUV;
  138481. /**
  138482. * Updates a Meshes materials to use the texture packer channels
  138483. * @param m is the mesh to target
  138484. * @param force all channels on the packer to be set.
  138485. */
  138486. private _updateTextureReferences;
  138487. /**
  138488. * Public method to set a Mesh to a frame
  138489. * @param m that is the target
  138490. * @param frameID or the frame index
  138491. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  138492. */
  138493. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  138494. /**
  138495. * Starts the async promise to compile the texture packer.
  138496. * @returns Promise<void>
  138497. */
  138498. processAsync(): Promise<void>;
  138499. /**
  138500. * Disposes all textures associated with this packer
  138501. */
  138502. dispose(): void;
  138503. /**
  138504. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  138505. * @param imageType is the image type to use.
  138506. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  138507. */
  138508. download(imageType?: string, quality?: number): void;
  138509. /**
  138510. * Public method to load a texturePacker JSON file.
  138511. * @param data of the JSON file in string format.
  138512. */
  138513. updateFromJSON(data: string): void;
  138514. }
  138515. }
  138516. declare module BABYLON {
  138517. /**
  138518. * 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.
  138519. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138520. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138521. */
  138522. export class CustomProceduralTexture extends ProceduralTexture {
  138523. private _animate;
  138524. private _time;
  138525. private _config;
  138526. private _texturePath;
  138527. /**
  138528. * Instantiates a new Custom Procedural Texture.
  138529. * 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.
  138530. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  138531. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  138532. * @param name Define the name of the texture
  138533. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  138534. * @param size Define the size of the texture to create
  138535. * @param scene Define the scene the texture belongs to
  138536. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  138537. * @param generateMipMaps Define if the texture should creates mip maps or not
  138538. */
  138539. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138540. private _loadJson;
  138541. /**
  138542. * Is the texture ready to be used ? (rendered at least once)
  138543. * @returns true if ready, otherwise, false.
  138544. */
  138545. isReady(): boolean;
  138546. /**
  138547. * Render the texture to its associated render target.
  138548. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  138549. */
  138550. render(useCameraPostProcess?: boolean): void;
  138551. /**
  138552. * Update the list of dependant textures samplers in the shader.
  138553. */
  138554. updateTextures(): void;
  138555. /**
  138556. * Update the uniform values of the procedural texture in the shader.
  138557. */
  138558. updateShaderUniforms(): void;
  138559. /**
  138560. * Define if the texture animates or not.
  138561. */
  138562. get animate(): boolean;
  138563. set animate(value: boolean);
  138564. }
  138565. }
  138566. declare module BABYLON {
  138567. /** @hidden */
  138568. export var noisePixelShader: {
  138569. name: string;
  138570. shader: string;
  138571. };
  138572. }
  138573. declare module BABYLON {
  138574. /**
  138575. * Class used to generate noise procedural textures
  138576. */
  138577. export class NoiseProceduralTexture extends ProceduralTexture {
  138578. private _time;
  138579. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  138580. brightness: number;
  138581. /** Defines the number of octaves to process */
  138582. octaves: number;
  138583. /** Defines the level of persistence (0.8 by default) */
  138584. persistence: number;
  138585. /** Gets or sets animation speed factor (default is 1) */
  138586. animationSpeedFactor: number;
  138587. /**
  138588. * Creates a new NoiseProceduralTexture
  138589. * @param name defines the name fo the texture
  138590. * @param size defines the size of the texture (default is 256)
  138591. * @param scene defines the hosting scene
  138592. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  138593. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  138594. */
  138595. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  138596. private _updateShaderUniforms;
  138597. protected _getDefines(): string;
  138598. /** Generate the current state of the procedural texture */
  138599. render(useCameraPostProcess?: boolean): void;
  138600. /**
  138601. * Serializes this noise procedural texture
  138602. * @returns a serialized noise procedural texture object
  138603. */
  138604. serialize(): any;
  138605. /**
  138606. * Clone the texture.
  138607. * @returns the cloned texture
  138608. */
  138609. clone(): NoiseProceduralTexture;
  138610. /**
  138611. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  138612. * @param parsedTexture defines parsed texture data
  138613. * @param scene defines the current scene
  138614. * @param rootUrl defines the root URL containing noise procedural texture information
  138615. * @returns a parsed NoiseProceduralTexture
  138616. */
  138617. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  138618. }
  138619. }
  138620. declare module BABYLON {
  138621. /**
  138622. * Raw cube texture where the raw buffers are passed in
  138623. */
  138624. export class RawCubeTexture extends CubeTexture {
  138625. /**
  138626. * Creates a cube texture where the raw buffers are passed in.
  138627. * @param scene defines the scene the texture is attached to
  138628. * @param data defines the array of data to use to create each face
  138629. * @param size defines the size of the textures
  138630. * @param format defines the format of the data
  138631. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  138632. * @param generateMipMaps defines if the engine should generate the mip levels
  138633. * @param invertY defines if data must be stored with Y axis inverted
  138634. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  138635. * @param compression defines the compression used (null by default)
  138636. */
  138637. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  138638. /**
  138639. * Updates the raw cube texture.
  138640. * @param data defines the data to store
  138641. * @param format defines the data format
  138642. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  138643. * @param invertY defines if data must be stored with Y axis inverted
  138644. * @param compression defines the compression used (null by default)
  138645. * @param level defines which level of the texture to update
  138646. */
  138647. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  138648. /**
  138649. * Updates a raw cube texture with RGBD encoded data.
  138650. * @param data defines the array of data [mipmap][face] to use to create each face
  138651. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  138652. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138653. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138654. * @returns a promsie that resolves when the operation is complete
  138655. */
  138656. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  138657. /**
  138658. * Clones the raw cube texture.
  138659. * @return a new cube texture
  138660. */
  138661. clone(): CubeTexture;
  138662. /** @hidden */
  138663. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138664. }
  138665. }
  138666. declare module BABYLON {
  138667. /**
  138668. * Class used to store 2D array textures containing user data
  138669. */
  138670. export class RawTexture2DArray extends Texture {
  138671. /** Gets or sets the texture format to use */
  138672. format: number;
  138673. /**
  138674. * Create a new RawTexture2DArray
  138675. * @param data defines the data of the texture
  138676. * @param width defines the width of the texture
  138677. * @param height defines the height of the texture
  138678. * @param depth defines the number of layers of the texture
  138679. * @param format defines the texture format to use
  138680. * @param scene defines the hosting scene
  138681. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138682. * @param invertY defines if texture must be stored with Y axis inverted
  138683. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138684. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138685. */
  138686. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138687. /** Gets or sets the texture format to use */
  138688. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138689. /**
  138690. * Update the texture with new data
  138691. * @param data defines the data to store in the texture
  138692. */
  138693. update(data: ArrayBufferView): void;
  138694. }
  138695. }
  138696. declare module BABYLON {
  138697. /**
  138698. * Class used to store 3D textures containing user data
  138699. */
  138700. export class RawTexture3D extends Texture {
  138701. /** Gets or sets the texture format to use */
  138702. format: number;
  138703. /**
  138704. * Create a new RawTexture3D
  138705. * @param data defines the data of the texture
  138706. * @param width defines the width of the texture
  138707. * @param height defines the height of the texture
  138708. * @param depth defines the depth of the texture
  138709. * @param format defines the texture format to use
  138710. * @param scene defines the hosting scene
  138711. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  138712. * @param invertY defines if texture must be stored with Y axis inverted
  138713. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138714. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  138715. */
  138716. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  138717. /** Gets or sets the texture format to use */
  138718. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  138719. /**
  138720. * Update the texture with new data
  138721. * @param data defines the data to store in the texture
  138722. */
  138723. update(data: ArrayBufferView): void;
  138724. }
  138725. }
  138726. declare module BABYLON {
  138727. /**
  138728. * Creates a refraction texture used by refraction channel of the standard material.
  138729. * It is like a mirror but to see through a material.
  138730. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138731. */
  138732. export class RefractionTexture extends RenderTargetTexture {
  138733. /**
  138734. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  138735. * 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.
  138736. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138737. */
  138738. refractionPlane: Plane;
  138739. /**
  138740. * Define how deep under the surface we should see.
  138741. */
  138742. depth: number;
  138743. /**
  138744. * Creates a refraction texture used by refraction channel of the standard material.
  138745. * It is like a mirror but to see through a material.
  138746. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  138747. * @param name Define the texture name
  138748. * @param size Define the size of the underlying texture
  138749. * @param scene Define the scene the refraction belongs to
  138750. * @param generateMipMaps Define if we need to generate mips level for the refraction
  138751. */
  138752. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  138753. /**
  138754. * Clone the refraction texture.
  138755. * @returns the cloned texture
  138756. */
  138757. clone(): RefractionTexture;
  138758. /**
  138759. * Serialize the texture to a JSON representation you could use in Parse later on
  138760. * @returns the serialized JSON representation
  138761. */
  138762. serialize(): any;
  138763. }
  138764. }
  138765. declare module BABYLON {
  138766. /**
  138767. * Block used to add support for vertex skinning (bones)
  138768. */
  138769. export class BonesBlock extends NodeMaterialBlock {
  138770. /**
  138771. * Creates a new BonesBlock
  138772. * @param name defines the block name
  138773. */
  138774. constructor(name: string);
  138775. /**
  138776. * Initialize the block and prepare the context for build
  138777. * @param state defines the state that will be used for the build
  138778. */
  138779. initialize(state: NodeMaterialBuildState): void;
  138780. /**
  138781. * Gets the current class name
  138782. * @returns the class name
  138783. */
  138784. getClassName(): string;
  138785. /**
  138786. * Gets the matrix indices input component
  138787. */
  138788. get matricesIndices(): NodeMaterialConnectionPoint;
  138789. /**
  138790. * Gets the matrix weights input component
  138791. */
  138792. get matricesWeights(): NodeMaterialConnectionPoint;
  138793. /**
  138794. * Gets the extra matrix indices input component
  138795. */
  138796. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  138797. /**
  138798. * Gets the extra matrix weights input component
  138799. */
  138800. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  138801. /**
  138802. * Gets the world input component
  138803. */
  138804. get world(): NodeMaterialConnectionPoint;
  138805. /**
  138806. * Gets the output component
  138807. */
  138808. get output(): NodeMaterialConnectionPoint;
  138809. autoConfigure(material: NodeMaterial): void;
  138810. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  138811. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138812. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138813. protected _buildBlock(state: NodeMaterialBuildState): this;
  138814. }
  138815. }
  138816. declare module BABYLON {
  138817. /**
  138818. * Block used to add support for instances
  138819. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  138820. */
  138821. export class InstancesBlock extends NodeMaterialBlock {
  138822. /**
  138823. * Creates a new InstancesBlock
  138824. * @param name defines the block name
  138825. */
  138826. constructor(name: string);
  138827. /**
  138828. * Gets the current class name
  138829. * @returns the class name
  138830. */
  138831. getClassName(): string;
  138832. /**
  138833. * Gets the first world row input component
  138834. */
  138835. get world0(): NodeMaterialConnectionPoint;
  138836. /**
  138837. * Gets the second world row input component
  138838. */
  138839. get world1(): NodeMaterialConnectionPoint;
  138840. /**
  138841. * Gets the third world row input component
  138842. */
  138843. get world2(): NodeMaterialConnectionPoint;
  138844. /**
  138845. * Gets the forth world row input component
  138846. */
  138847. get world3(): NodeMaterialConnectionPoint;
  138848. /**
  138849. * Gets the world input component
  138850. */
  138851. get world(): NodeMaterialConnectionPoint;
  138852. /**
  138853. * Gets the output component
  138854. */
  138855. get output(): NodeMaterialConnectionPoint;
  138856. /**
  138857. * Gets the isntanceID component
  138858. */
  138859. get instanceID(): NodeMaterialConnectionPoint;
  138860. autoConfigure(material: NodeMaterial): void;
  138861. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  138862. protected _buildBlock(state: NodeMaterialBuildState): this;
  138863. }
  138864. }
  138865. declare module BABYLON {
  138866. /**
  138867. * Block used to add morph targets support to vertex shader
  138868. */
  138869. export class MorphTargetsBlock extends NodeMaterialBlock {
  138870. private _repeatableContentAnchor;
  138871. /**
  138872. * Create a new MorphTargetsBlock
  138873. * @param name defines the block name
  138874. */
  138875. constructor(name: string);
  138876. /**
  138877. * Gets the current class name
  138878. * @returns the class name
  138879. */
  138880. getClassName(): string;
  138881. /**
  138882. * Gets the position input component
  138883. */
  138884. get position(): NodeMaterialConnectionPoint;
  138885. /**
  138886. * Gets the normal input component
  138887. */
  138888. get normal(): NodeMaterialConnectionPoint;
  138889. /**
  138890. * Gets the tangent input component
  138891. */
  138892. get tangent(): NodeMaterialConnectionPoint;
  138893. /**
  138894. * Gets the tangent input component
  138895. */
  138896. get uv(): NodeMaterialConnectionPoint;
  138897. /**
  138898. * Gets the position output component
  138899. */
  138900. get positionOutput(): NodeMaterialConnectionPoint;
  138901. /**
  138902. * Gets the normal output component
  138903. */
  138904. get normalOutput(): NodeMaterialConnectionPoint;
  138905. /**
  138906. * Gets the tangent output component
  138907. */
  138908. get tangentOutput(): NodeMaterialConnectionPoint;
  138909. /**
  138910. * Gets the tangent output component
  138911. */
  138912. get uvOutput(): NodeMaterialConnectionPoint;
  138913. initialize(state: NodeMaterialBuildState): void;
  138914. autoConfigure(material: NodeMaterial): void;
  138915. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138917. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  138918. protected _buildBlock(state: NodeMaterialBuildState): this;
  138919. }
  138920. }
  138921. declare module BABYLON {
  138922. /**
  138923. * Block used to get data information from a light
  138924. */
  138925. export class LightInformationBlock extends NodeMaterialBlock {
  138926. private _lightDataUniformName;
  138927. private _lightColorUniformName;
  138928. private _lightTypeDefineName;
  138929. /**
  138930. * Gets or sets the light associated with this block
  138931. */
  138932. light: Nullable<Light>;
  138933. /**
  138934. * Creates a new LightInformationBlock
  138935. * @param name defines the block name
  138936. */
  138937. constructor(name: string);
  138938. /**
  138939. * Gets the current class name
  138940. * @returns the class name
  138941. */
  138942. getClassName(): string;
  138943. /**
  138944. * Gets the world position input component
  138945. */
  138946. get worldPosition(): NodeMaterialConnectionPoint;
  138947. /**
  138948. * Gets the direction output component
  138949. */
  138950. get direction(): NodeMaterialConnectionPoint;
  138951. /**
  138952. * Gets the direction output component
  138953. */
  138954. get color(): NodeMaterialConnectionPoint;
  138955. /**
  138956. * Gets the direction output component
  138957. */
  138958. get intensity(): NodeMaterialConnectionPoint;
  138959. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138961. protected _buildBlock(state: NodeMaterialBuildState): this;
  138962. serialize(): any;
  138963. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  138964. }
  138965. }
  138966. declare module BABYLON {
  138967. /**
  138968. * Block used to add image processing support to fragment shader
  138969. */
  138970. export class ImageProcessingBlock extends NodeMaterialBlock {
  138971. /**
  138972. * Create a new ImageProcessingBlock
  138973. * @param name defines the block name
  138974. */
  138975. constructor(name: string);
  138976. /**
  138977. * Gets the current class name
  138978. * @returns the class name
  138979. */
  138980. getClassName(): string;
  138981. /**
  138982. * Gets the color input component
  138983. */
  138984. get color(): NodeMaterialConnectionPoint;
  138985. /**
  138986. * Gets the output component
  138987. */
  138988. get output(): NodeMaterialConnectionPoint;
  138989. /**
  138990. * Initialize the block and prepare the context for build
  138991. * @param state defines the state that will be used for the build
  138992. */
  138993. initialize(state: NodeMaterialBuildState): void;
  138994. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  138995. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  138996. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  138997. protected _buildBlock(state: NodeMaterialBuildState): this;
  138998. }
  138999. }
  139000. declare module BABYLON {
  139001. /**
  139002. * Block used to pertub normals based on a normal map
  139003. */
  139004. export class PerturbNormalBlock extends NodeMaterialBlock {
  139005. private _tangentSpaceParameterName;
  139006. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139007. invertX: boolean;
  139008. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139009. invertY: boolean;
  139010. /**
  139011. * Create a new PerturbNormalBlock
  139012. * @param name defines the block name
  139013. */
  139014. constructor(name: string);
  139015. /**
  139016. * Gets the current class name
  139017. * @returns the class name
  139018. */
  139019. getClassName(): string;
  139020. /**
  139021. * Gets the world position input component
  139022. */
  139023. get worldPosition(): NodeMaterialConnectionPoint;
  139024. /**
  139025. * Gets the world normal input component
  139026. */
  139027. get worldNormal(): NodeMaterialConnectionPoint;
  139028. /**
  139029. * Gets the world tangent input component
  139030. */
  139031. get worldTangent(): NodeMaterialConnectionPoint;
  139032. /**
  139033. * Gets the uv input component
  139034. */
  139035. get uv(): NodeMaterialConnectionPoint;
  139036. /**
  139037. * Gets the normal map color input component
  139038. */
  139039. get normalMapColor(): NodeMaterialConnectionPoint;
  139040. /**
  139041. * Gets the strength input component
  139042. */
  139043. get strength(): NodeMaterialConnectionPoint;
  139044. /**
  139045. * Gets the output component
  139046. */
  139047. get output(): NodeMaterialConnectionPoint;
  139048. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139049. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139050. autoConfigure(material: NodeMaterial): void;
  139051. protected _buildBlock(state: NodeMaterialBuildState): this;
  139052. protected _dumpPropertiesCode(): string;
  139053. serialize(): any;
  139054. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139055. }
  139056. }
  139057. declare module BABYLON {
  139058. /**
  139059. * Block used to discard a pixel if a value is smaller than a cutoff
  139060. */
  139061. export class DiscardBlock extends NodeMaterialBlock {
  139062. /**
  139063. * Create a new DiscardBlock
  139064. * @param name defines the block name
  139065. */
  139066. constructor(name: string);
  139067. /**
  139068. * Gets the current class name
  139069. * @returns the class name
  139070. */
  139071. getClassName(): string;
  139072. /**
  139073. * Gets the color input component
  139074. */
  139075. get value(): NodeMaterialConnectionPoint;
  139076. /**
  139077. * Gets the cutoff input component
  139078. */
  139079. get cutoff(): NodeMaterialConnectionPoint;
  139080. protected _buildBlock(state: NodeMaterialBuildState): this;
  139081. }
  139082. }
  139083. declare module BABYLON {
  139084. /**
  139085. * Block used to test if the fragment shader is front facing
  139086. */
  139087. export class FrontFacingBlock extends NodeMaterialBlock {
  139088. /**
  139089. * Creates a new FrontFacingBlock
  139090. * @param name defines the block name
  139091. */
  139092. constructor(name: string);
  139093. /**
  139094. * Gets the current class name
  139095. * @returns the class name
  139096. */
  139097. getClassName(): string;
  139098. /**
  139099. * Gets the output component
  139100. */
  139101. get output(): NodeMaterialConnectionPoint;
  139102. protected _buildBlock(state: NodeMaterialBuildState): this;
  139103. }
  139104. }
  139105. declare module BABYLON {
  139106. /**
  139107. * Block used to get the derivative value on x and y of a given input
  139108. */
  139109. export class DerivativeBlock extends NodeMaterialBlock {
  139110. /**
  139111. * Create a new DerivativeBlock
  139112. * @param name defines the block name
  139113. */
  139114. constructor(name: string);
  139115. /**
  139116. * Gets the current class name
  139117. * @returns the class name
  139118. */
  139119. getClassName(): string;
  139120. /**
  139121. * Gets the input component
  139122. */
  139123. get input(): NodeMaterialConnectionPoint;
  139124. /**
  139125. * Gets the derivative output on x
  139126. */
  139127. get dx(): NodeMaterialConnectionPoint;
  139128. /**
  139129. * Gets the derivative output on y
  139130. */
  139131. get dy(): NodeMaterialConnectionPoint;
  139132. protected _buildBlock(state: NodeMaterialBuildState): this;
  139133. }
  139134. }
  139135. declare module BABYLON {
  139136. /**
  139137. * Block used to make gl_FragCoord available
  139138. */
  139139. export class FragCoordBlock extends NodeMaterialBlock {
  139140. /**
  139141. * Creates a new FragCoordBlock
  139142. * @param name defines the block name
  139143. */
  139144. constructor(name: string);
  139145. /**
  139146. * Gets the current class name
  139147. * @returns the class name
  139148. */
  139149. getClassName(): string;
  139150. /**
  139151. * Gets the xy component
  139152. */
  139153. get xy(): NodeMaterialConnectionPoint;
  139154. /**
  139155. * Gets the xyz component
  139156. */
  139157. get xyz(): NodeMaterialConnectionPoint;
  139158. /**
  139159. * Gets the xyzw component
  139160. */
  139161. get xyzw(): NodeMaterialConnectionPoint;
  139162. /**
  139163. * Gets the x component
  139164. */
  139165. get x(): NodeMaterialConnectionPoint;
  139166. /**
  139167. * Gets the y component
  139168. */
  139169. get y(): NodeMaterialConnectionPoint;
  139170. /**
  139171. * Gets the z component
  139172. */
  139173. get z(): NodeMaterialConnectionPoint;
  139174. /**
  139175. * Gets the w component
  139176. */
  139177. get output(): NodeMaterialConnectionPoint;
  139178. protected writeOutputs(state: NodeMaterialBuildState): string;
  139179. protected _buildBlock(state: NodeMaterialBuildState): this;
  139180. }
  139181. }
  139182. declare module BABYLON {
  139183. /**
  139184. * Block used to get the screen sizes
  139185. */
  139186. export class ScreenSizeBlock extends NodeMaterialBlock {
  139187. private _varName;
  139188. private _scene;
  139189. /**
  139190. * Creates a new ScreenSizeBlock
  139191. * @param name defines the block name
  139192. */
  139193. constructor(name: string);
  139194. /**
  139195. * Gets the current class name
  139196. * @returns the class name
  139197. */
  139198. getClassName(): string;
  139199. /**
  139200. * Gets the xy component
  139201. */
  139202. get xy(): NodeMaterialConnectionPoint;
  139203. /**
  139204. * Gets the x component
  139205. */
  139206. get x(): NodeMaterialConnectionPoint;
  139207. /**
  139208. * Gets the y component
  139209. */
  139210. get y(): NodeMaterialConnectionPoint;
  139211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139212. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  139213. protected _buildBlock(state: NodeMaterialBuildState): this;
  139214. }
  139215. }
  139216. declare module BABYLON {
  139217. /**
  139218. * Block used to add support for scene fog
  139219. */
  139220. export class FogBlock extends NodeMaterialBlock {
  139221. private _fogDistanceName;
  139222. private _fogParameters;
  139223. /**
  139224. * Create a new FogBlock
  139225. * @param name defines the block name
  139226. */
  139227. constructor(name: string);
  139228. /**
  139229. * Gets the current class name
  139230. * @returns the class name
  139231. */
  139232. getClassName(): string;
  139233. /**
  139234. * Gets the world position input component
  139235. */
  139236. get worldPosition(): NodeMaterialConnectionPoint;
  139237. /**
  139238. * Gets the view input component
  139239. */
  139240. get view(): NodeMaterialConnectionPoint;
  139241. /**
  139242. * Gets the color input component
  139243. */
  139244. get input(): NodeMaterialConnectionPoint;
  139245. /**
  139246. * Gets the fog color input component
  139247. */
  139248. get fogColor(): NodeMaterialConnectionPoint;
  139249. /**
  139250. * Gets the output component
  139251. */
  139252. get output(): NodeMaterialConnectionPoint;
  139253. autoConfigure(material: NodeMaterial): void;
  139254. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139255. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139256. protected _buildBlock(state: NodeMaterialBuildState): this;
  139257. }
  139258. }
  139259. declare module BABYLON {
  139260. /**
  139261. * Block used to add light in the fragment shader
  139262. */
  139263. export class LightBlock extends NodeMaterialBlock {
  139264. private _lightId;
  139265. /**
  139266. * Gets or sets the light associated with this block
  139267. */
  139268. light: Nullable<Light>;
  139269. /**
  139270. * Create a new LightBlock
  139271. * @param name defines the block name
  139272. */
  139273. constructor(name: string);
  139274. /**
  139275. * Gets the current class name
  139276. * @returns the class name
  139277. */
  139278. getClassName(): string;
  139279. /**
  139280. * Gets the world position input component
  139281. */
  139282. get worldPosition(): NodeMaterialConnectionPoint;
  139283. /**
  139284. * Gets the world normal input component
  139285. */
  139286. get worldNormal(): NodeMaterialConnectionPoint;
  139287. /**
  139288. * Gets the camera (or eye) position component
  139289. */
  139290. get cameraPosition(): NodeMaterialConnectionPoint;
  139291. /**
  139292. * Gets the glossiness component
  139293. */
  139294. get glossiness(): NodeMaterialConnectionPoint;
  139295. /**
  139296. * Gets the glossinness power component
  139297. */
  139298. get glossPower(): NodeMaterialConnectionPoint;
  139299. /**
  139300. * Gets the diffuse color component
  139301. */
  139302. get diffuseColor(): NodeMaterialConnectionPoint;
  139303. /**
  139304. * Gets the specular color component
  139305. */
  139306. get specularColor(): NodeMaterialConnectionPoint;
  139307. /**
  139308. * Gets the diffuse output component
  139309. */
  139310. get diffuseOutput(): NodeMaterialConnectionPoint;
  139311. /**
  139312. * Gets the specular output component
  139313. */
  139314. get specularOutput(): NodeMaterialConnectionPoint;
  139315. /**
  139316. * Gets the shadow output component
  139317. */
  139318. get shadow(): NodeMaterialConnectionPoint;
  139319. autoConfigure(material: NodeMaterial): void;
  139320. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139321. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  139322. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139323. private _injectVertexCode;
  139324. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  139325. serialize(): any;
  139326. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139327. }
  139328. }
  139329. declare module BABYLON {
  139330. /**
  139331. * Block used to read a reflection texture from a sampler
  139332. */
  139333. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  139334. /**
  139335. * Create a new ReflectionTextureBlock
  139336. * @param name defines the block name
  139337. */
  139338. constructor(name: string);
  139339. /**
  139340. * Gets the current class name
  139341. * @returns the class name
  139342. */
  139343. getClassName(): string;
  139344. /**
  139345. * Gets the world position input component
  139346. */
  139347. get position(): NodeMaterialConnectionPoint;
  139348. /**
  139349. * Gets the world position input component
  139350. */
  139351. get worldPosition(): NodeMaterialConnectionPoint;
  139352. /**
  139353. * Gets the world normal input component
  139354. */
  139355. get worldNormal(): NodeMaterialConnectionPoint;
  139356. /**
  139357. * Gets the world input component
  139358. */
  139359. get world(): NodeMaterialConnectionPoint;
  139360. /**
  139361. * Gets the camera (or eye) position component
  139362. */
  139363. get cameraPosition(): NodeMaterialConnectionPoint;
  139364. /**
  139365. * Gets the view input component
  139366. */
  139367. get view(): NodeMaterialConnectionPoint;
  139368. /**
  139369. * Gets the rgb output component
  139370. */
  139371. get rgb(): NodeMaterialConnectionPoint;
  139372. /**
  139373. * Gets the r output component
  139374. */
  139375. get r(): NodeMaterialConnectionPoint;
  139376. /**
  139377. * Gets the g output component
  139378. */
  139379. get g(): NodeMaterialConnectionPoint;
  139380. /**
  139381. * Gets the b output component
  139382. */
  139383. get b(): NodeMaterialConnectionPoint;
  139384. autoConfigure(material: NodeMaterial): void;
  139385. protected _buildBlock(state: NodeMaterialBuildState): this;
  139386. }
  139387. }
  139388. declare module BABYLON {
  139389. /**
  139390. * Block used to add 2 vectors
  139391. */
  139392. export class AddBlock extends NodeMaterialBlock {
  139393. /**
  139394. * Creates a new AddBlock
  139395. * @param name defines the block name
  139396. */
  139397. constructor(name: string);
  139398. /**
  139399. * Gets the current class name
  139400. * @returns the class name
  139401. */
  139402. getClassName(): string;
  139403. /**
  139404. * Gets the left operand input component
  139405. */
  139406. get left(): NodeMaterialConnectionPoint;
  139407. /**
  139408. * Gets the right operand input component
  139409. */
  139410. get right(): NodeMaterialConnectionPoint;
  139411. /**
  139412. * Gets the output component
  139413. */
  139414. get output(): NodeMaterialConnectionPoint;
  139415. protected _buildBlock(state: NodeMaterialBuildState): this;
  139416. }
  139417. }
  139418. declare module BABYLON {
  139419. /**
  139420. * Block used to scale a vector by a float
  139421. */
  139422. export class ScaleBlock extends NodeMaterialBlock {
  139423. /**
  139424. * Creates a new ScaleBlock
  139425. * @param name defines the block name
  139426. */
  139427. constructor(name: string);
  139428. /**
  139429. * Gets the current class name
  139430. * @returns the class name
  139431. */
  139432. getClassName(): string;
  139433. /**
  139434. * Gets the input component
  139435. */
  139436. get input(): NodeMaterialConnectionPoint;
  139437. /**
  139438. * Gets the factor input component
  139439. */
  139440. get factor(): NodeMaterialConnectionPoint;
  139441. /**
  139442. * Gets the output component
  139443. */
  139444. get output(): NodeMaterialConnectionPoint;
  139445. protected _buildBlock(state: NodeMaterialBuildState): this;
  139446. }
  139447. }
  139448. declare module BABYLON {
  139449. /**
  139450. * Block used to clamp a float
  139451. */
  139452. export class ClampBlock extends NodeMaterialBlock {
  139453. /** Gets or sets the minimum range */
  139454. minimum: number;
  139455. /** Gets or sets the maximum range */
  139456. maximum: number;
  139457. /**
  139458. * Creates a new ClampBlock
  139459. * @param name defines the block name
  139460. */
  139461. constructor(name: string);
  139462. /**
  139463. * Gets the current class name
  139464. * @returns the class name
  139465. */
  139466. getClassName(): string;
  139467. /**
  139468. * Gets the value input component
  139469. */
  139470. get value(): NodeMaterialConnectionPoint;
  139471. /**
  139472. * Gets the output component
  139473. */
  139474. get output(): NodeMaterialConnectionPoint;
  139475. protected _buildBlock(state: NodeMaterialBuildState): this;
  139476. protected _dumpPropertiesCode(): string;
  139477. serialize(): any;
  139478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139479. }
  139480. }
  139481. declare module BABYLON {
  139482. /**
  139483. * Block used to apply a cross product between 2 vectors
  139484. */
  139485. export class CrossBlock extends NodeMaterialBlock {
  139486. /**
  139487. * Creates a new CrossBlock
  139488. * @param name defines the block name
  139489. */
  139490. constructor(name: string);
  139491. /**
  139492. * Gets the current class name
  139493. * @returns the class name
  139494. */
  139495. getClassName(): string;
  139496. /**
  139497. * Gets the left operand input component
  139498. */
  139499. get left(): NodeMaterialConnectionPoint;
  139500. /**
  139501. * Gets the right operand input component
  139502. */
  139503. get right(): NodeMaterialConnectionPoint;
  139504. /**
  139505. * Gets the output component
  139506. */
  139507. get output(): NodeMaterialConnectionPoint;
  139508. protected _buildBlock(state: NodeMaterialBuildState): this;
  139509. }
  139510. }
  139511. declare module BABYLON {
  139512. /**
  139513. * Block used to apply a dot product between 2 vectors
  139514. */
  139515. export class DotBlock extends NodeMaterialBlock {
  139516. /**
  139517. * Creates a new DotBlock
  139518. * @param name defines the block name
  139519. */
  139520. constructor(name: string);
  139521. /**
  139522. * Gets the current class name
  139523. * @returns the class name
  139524. */
  139525. getClassName(): string;
  139526. /**
  139527. * Gets the left operand input component
  139528. */
  139529. get left(): NodeMaterialConnectionPoint;
  139530. /**
  139531. * Gets the right operand input component
  139532. */
  139533. get right(): NodeMaterialConnectionPoint;
  139534. /**
  139535. * Gets the output component
  139536. */
  139537. get output(): NodeMaterialConnectionPoint;
  139538. protected _buildBlock(state: NodeMaterialBuildState): this;
  139539. }
  139540. }
  139541. declare module BABYLON {
  139542. /**
  139543. * Block used to normalize a vector
  139544. */
  139545. export class NormalizeBlock extends NodeMaterialBlock {
  139546. /**
  139547. * Creates a new NormalizeBlock
  139548. * @param name defines the block name
  139549. */
  139550. constructor(name: string);
  139551. /**
  139552. * Gets the current class name
  139553. * @returns the class name
  139554. */
  139555. getClassName(): string;
  139556. /**
  139557. * Gets the input component
  139558. */
  139559. get input(): NodeMaterialConnectionPoint;
  139560. /**
  139561. * Gets the output component
  139562. */
  139563. get output(): NodeMaterialConnectionPoint;
  139564. protected _buildBlock(state: NodeMaterialBuildState): this;
  139565. }
  139566. }
  139567. declare module BABYLON {
  139568. /**
  139569. * Operations supported by the Trigonometry block
  139570. */
  139571. export enum TrigonometryBlockOperations {
  139572. /** Cos */
  139573. Cos = 0,
  139574. /** Sin */
  139575. Sin = 1,
  139576. /** Abs */
  139577. Abs = 2,
  139578. /** Exp */
  139579. Exp = 3,
  139580. /** Exp2 */
  139581. Exp2 = 4,
  139582. /** Round */
  139583. Round = 5,
  139584. /** Floor */
  139585. Floor = 6,
  139586. /** Ceiling */
  139587. Ceiling = 7,
  139588. /** Square root */
  139589. Sqrt = 8,
  139590. /** Log */
  139591. Log = 9,
  139592. /** Tangent */
  139593. Tan = 10,
  139594. /** Arc tangent */
  139595. ArcTan = 11,
  139596. /** Arc cosinus */
  139597. ArcCos = 12,
  139598. /** Arc sinus */
  139599. ArcSin = 13,
  139600. /** Fraction */
  139601. Fract = 14,
  139602. /** Sign */
  139603. Sign = 15,
  139604. /** To radians (from degrees) */
  139605. Radians = 16,
  139606. /** To degrees (from radians) */
  139607. Degrees = 17
  139608. }
  139609. /**
  139610. * Block used to apply trigonometry operation to floats
  139611. */
  139612. export class TrigonometryBlock extends NodeMaterialBlock {
  139613. /**
  139614. * Gets or sets the operation applied by the block
  139615. */
  139616. operation: TrigonometryBlockOperations;
  139617. /**
  139618. * Creates a new TrigonometryBlock
  139619. * @param name defines the block name
  139620. */
  139621. constructor(name: string);
  139622. /**
  139623. * Gets the current class name
  139624. * @returns the class name
  139625. */
  139626. getClassName(): string;
  139627. /**
  139628. * Gets the input component
  139629. */
  139630. get input(): NodeMaterialConnectionPoint;
  139631. /**
  139632. * Gets the output component
  139633. */
  139634. get output(): NodeMaterialConnectionPoint;
  139635. protected _buildBlock(state: NodeMaterialBuildState): this;
  139636. serialize(): any;
  139637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139638. protected _dumpPropertiesCode(): string;
  139639. }
  139640. }
  139641. declare module BABYLON {
  139642. /**
  139643. * Block used to create a Color3/4 out of individual inputs (one for each component)
  139644. */
  139645. export class ColorMergerBlock extends NodeMaterialBlock {
  139646. /**
  139647. * Create a new ColorMergerBlock
  139648. * @param name defines the block name
  139649. */
  139650. constructor(name: string);
  139651. /**
  139652. * Gets the current class name
  139653. * @returns the class name
  139654. */
  139655. getClassName(): string;
  139656. /**
  139657. * Gets the rgb component (input)
  139658. */
  139659. get rgbIn(): NodeMaterialConnectionPoint;
  139660. /**
  139661. * Gets the r component (input)
  139662. */
  139663. get r(): NodeMaterialConnectionPoint;
  139664. /**
  139665. * Gets the g component (input)
  139666. */
  139667. get g(): NodeMaterialConnectionPoint;
  139668. /**
  139669. * Gets the b component (input)
  139670. */
  139671. get b(): NodeMaterialConnectionPoint;
  139672. /**
  139673. * Gets the a component (input)
  139674. */
  139675. get a(): NodeMaterialConnectionPoint;
  139676. /**
  139677. * Gets the rgba component (output)
  139678. */
  139679. get rgba(): NodeMaterialConnectionPoint;
  139680. /**
  139681. * Gets the rgb component (output)
  139682. */
  139683. get rgbOut(): NodeMaterialConnectionPoint;
  139684. /**
  139685. * Gets the rgb component (output)
  139686. * @deprecated Please use rgbOut instead.
  139687. */
  139688. get rgb(): NodeMaterialConnectionPoint;
  139689. protected _buildBlock(state: NodeMaterialBuildState): this;
  139690. }
  139691. }
  139692. declare module BABYLON {
  139693. /**
  139694. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  139695. */
  139696. export class VectorSplitterBlock extends NodeMaterialBlock {
  139697. /**
  139698. * Create a new VectorSplitterBlock
  139699. * @param name defines the block name
  139700. */
  139701. constructor(name: string);
  139702. /**
  139703. * Gets the current class name
  139704. * @returns the class name
  139705. */
  139706. getClassName(): string;
  139707. /**
  139708. * Gets the xyzw component (input)
  139709. */
  139710. get xyzw(): NodeMaterialConnectionPoint;
  139711. /**
  139712. * Gets the xyz component (input)
  139713. */
  139714. get xyzIn(): NodeMaterialConnectionPoint;
  139715. /**
  139716. * Gets the xy component (input)
  139717. */
  139718. get xyIn(): NodeMaterialConnectionPoint;
  139719. /**
  139720. * Gets the xyz component (output)
  139721. */
  139722. get xyzOut(): NodeMaterialConnectionPoint;
  139723. /**
  139724. * Gets the xy component (output)
  139725. */
  139726. get xyOut(): NodeMaterialConnectionPoint;
  139727. /**
  139728. * Gets the x component (output)
  139729. */
  139730. get x(): NodeMaterialConnectionPoint;
  139731. /**
  139732. * Gets the y component (output)
  139733. */
  139734. get y(): NodeMaterialConnectionPoint;
  139735. /**
  139736. * Gets the z component (output)
  139737. */
  139738. get z(): NodeMaterialConnectionPoint;
  139739. /**
  139740. * Gets the w component (output)
  139741. */
  139742. get w(): NodeMaterialConnectionPoint;
  139743. protected _inputRename(name: string): string;
  139744. protected _outputRename(name: string): string;
  139745. protected _buildBlock(state: NodeMaterialBuildState): this;
  139746. }
  139747. }
  139748. declare module BABYLON {
  139749. /**
  139750. * Block used to lerp between 2 values
  139751. */
  139752. export class LerpBlock extends NodeMaterialBlock {
  139753. /**
  139754. * Creates a new LerpBlock
  139755. * @param name defines the block name
  139756. */
  139757. constructor(name: string);
  139758. /**
  139759. * Gets the current class name
  139760. * @returns the class name
  139761. */
  139762. getClassName(): string;
  139763. /**
  139764. * Gets the left operand input component
  139765. */
  139766. get left(): NodeMaterialConnectionPoint;
  139767. /**
  139768. * Gets the right operand input component
  139769. */
  139770. get right(): NodeMaterialConnectionPoint;
  139771. /**
  139772. * Gets the gradient operand input component
  139773. */
  139774. get gradient(): NodeMaterialConnectionPoint;
  139775. /**
  139776. * Gets the output component
  139777. */
  139778. get output(): NodeMaterialConnectionPoint;
  139779. protected _buildBlock(state: NodeMaterialBuildState): this;
  139780. }
  139781. }
  139782. declare module BABYLON {
  139783. /**
  139784. * Block used to divide 2 vectors
  139785. */
  139786. export class DivideBlock extends NodeMaterialBlock {
  139787. /**
  139788. * Creates a new DivideBlock
  139789. * @param name defines the block name
  139790. */
  139791. constructor(name: string);
  139792. /**
  139793. * Gets the current class name
  139794. * @returns the class name
  139795. */
  139796. getClassName(): string;
  139797. /**
  139798. * Gets the left operand input component
  139799. */
  139800. get left(): NodeMaterialConnectionPoint;
  139801. /**
  139802. * Gets the right operand input component
  139803. */
  139804. get right(): NodeMaterialConnectionPoint;
  139805. /**
  139806. * Gets the output component
  139807. */
  139808. get output(): NodeMaterialConnectionPoint;
  139809. protected _buildBlock(state: NodeMaterialBuildState): this;
  139810. }
  139811. }
  139812. declare module BABYLON {
  139813. /**
  139814. * Block used to subtract 2 vectors
  139815. */
  139816. export class SubtractBlock extends NodeMaterialBlock {
  139817. /**
  139818. * Creates a new SubtractBlock
  139819. * @param name defines the block name
  139820. */
  139821. constructor(name: string);
  139822. /**
  139823. * Gets the current class name
  139824. * @returns the class name
  139825. */
  139826. getClassName(): string;
  139827. /**
  139828. * Gets the left operand input component
  139829. */
  139830. get left(): NodeMaterialConnectionPoint;
  139831. /**
  139832. * Gets the right operand input component
  139833. */
  139834. get right(): NodeMaterialConnectionPoint;
  139835. /**
  139836. * Gets the output component
  139837. */
  139838. get output(): NodeMaterialConnectionPoint;
  139839. protected _buildBlock(state: NodeMaterialBuildState): this;
  139840. }
  139841. }
  139842. declare module BABYLON {
  139843. /**
  139844. * Block used to step a value
  139845. */
  139846. export class StepBlock extends NodeMaterialBlock {
  139847. /**
  139848. * Creates a new StepBlock
  139849. * @param name defines the block name
  139850. */
  139851. constructor(name: string);
  139852. /**
  139853. * Gets the current class name
  139854. * @returns the class name
  139855. */
  139856. getClassName(): string;
  139857. /**
  139858. * Gets the value operand input component
  139859. */
  139860. get value(): NodeMaterialConnectionPoint;
  139861. /**
  139862. * Gets the edge operand input component
  139863. */
  139864. get edge(): NodeMaterialConnectionPoint;
  139865. /**
  139866. * Gets the output component
  139867. */
  139868. get output(): NodeMaterialConnectionPoint;
  139869. protected _buildBlock(state: NodeMaterialBuildState): this;
  139870. }
  139871. }
  139872. declare module BABYLON {
  139873. /**
  139874. * Block used to get the opposite (1 - x) of a value
  139875. */
  139876. export class OneMinusBlock extends NodeMaterialBlock {
  139877. /**
  139878. * Creates a new OneMinusBlock
  139879. * @param name defines the block name
  139880. */
  139881. constructor(name: string);
  139882. /**
  139883. * Gets the current class name
  139884. * @returns the class name
  139885. */
  139886. getClassName(): string;
  139887. /**
  139888. * Gets the input component
  139889. */
  139890. get input(): NodeMaterialConnectionPoint;
  139891. /**
  139892. * Gets the output component
  139893. */
  139894. get output(): NodeMaterialConnectionPoint;
  139895. protected _buildBlock(state: NodeMaterialBuildState): this;
  139896. }
  139897. }
  139898. declare module BABYLON {
  139899. /**
  139900. * Block used to get the view direction
  139901. */
  139902. export class ViewDirectionBlock extends NodeMaterialBlock {
  139903. /**
  139904. * Creates a new ViewDirectionBlock
  139905. * @param name defines the block name
  139906. */
  139907. constructor(name: string);
  139908. /**
  139909. * Gets the current class name
  139910. * @returns the class name
  139911. */
  139912. getClassName(): string;
  139913. /**
  139914. * Gets the world position component
  139915. */
  139916. get worldPosition(): NodeMaterialConnectionPoint;
  139917. /**
  139918. * Gets the camera position component
  139919. */
  139920. get cameraPosition(): NodeMaterialConnectionPoint;
  139921. /**
  139922. * Gets the output component
  139923. */
  139924. get output(): NodeMaterialConnectionPoint;
  139925. autoConfigure(material: NodeMaterial): void;
  139926. protected _buildBlock(state: NodeMaterialBuildState): this;
  139927. }
  139928. }
  139929. declare module BABYLON {
  139930. /**
  139931. * Block used to compute fresnel value
  139932. */
  139933. export class FresnelBlock extends NodeMaterialBlock {
  139934. /**
  139935. * Create a new FresnelBlock
  139936. * @param name defines the block name
  139937. */
  139938. constructor(name: string);
  139939. /**
  139940. * Gets the current class name
  139941. * @returns the class name
  139942. */
  139943. getClassName(): string;
  139944. /**
  139945. * Gets the world normal input component
  139946. */
  139947. get worldNormal(): NodeMaterialConnectionPoint;
  139948. /**
  139949. * Gets the view direction input component
  139950. */
  139951. get viewDirection(): NodeMaterialConnectionPoint;
  139952. /**
  139953. * Gets the bias input component
  139954. */
  139955. get bias(): NodeMaterialConnectionPoint;
  139956. /**
  139957. * Gets the camera (or eye) position component
  139958. */
  139959. get power(): NodeMaterialConnectionPoint;
  139960. /**
  139961. * Gets the fresnel output component
  139962. */
  139963. get fresnel(): NodeMaterialConnectionPoint;
  139964. autoConfigure(material: NodeMaterial): void;
  139965. protected _buildBlock(state: NodeMaterialBuildState): this;
  139966. }
  139967. }
  139968. declare module BABYLON {
  139969. /**
  139970. * Block used to get the max of 2 values
  139971. */
  139972. export class MaxBlock extends NodeMaterialBlock {
  139973. /**
  139974. * Creates a new MaxBlock
  139975. * @param name defines the block name
  139976. */
  139977. constructor(name: string);
  139978. /**
  139979. * Gets the current class name
  139980. * @returns the class name
  139981. */
  139982. getClassName(): string;
  139983. /**
  139984. * Gets the left operand input component
  139985. */
  139986. get left(): NodeMaterialConnectionPoint;
  139987. /**
  139988. * Gets the right operand input component
  139989. */
  139990. get right(): NodeMaterialConnectionPoint;
  139991. /**
  139992. * Gets the output component
  139993. */
  139994. get output(): NodeMaterialConnectionPoint;
  139995. protected _buildBlock(state: NodeMaterialBuildState): this;
  139996. }
  139997. }
  139998. declare module BABYLON {
  139999. /**
  140000. * Block used to get the min of 2 values
  140001. */
  140002. export class MinBlock extends NodeMaterialBlock {
  140003. /**
  140004. * Creates a new MinBlock
  140005. * @param name defines the block name
  140006. */
  140007. constructor(name: string);
  140008. /**
  140009. * Gets the current class name
  140010. * @returns the class name
  140011. */
  140012. getClassName(): string;
  140013. /**
  140014. * Gets the left operand input component
  140015. */
  140016. get left(): NodeMaterialConnectionPoint;
  140017. /**
  140018. * Gets the right operand input component
  140019. */
  140020. get right(): NodeMaterialConnectionPoint;
  140021. /**
  140022. * Gets the output component
  140023. */
  140024. get output(): NodeMaterialConnectionPoint;
  140025. protected _buildBlock(state: NodeMaterialBuildState): this;
  140026. }
  140027. }
  140028. declare module BABYLON {
  140029. /**
  140030. * Block used to get the distance between 2 values
  140031. */
  140032. export class DistanceBlock extends NodeMaterialBlock {
  140033. /**
  140034. * Creates a new DistanceBlock
  140035. * @param name defines the block name
  140036. */
  140037. constructor(name: string);
  140038. /**
  140039. * Gets the current class name
  140040. * @returns the class name
  140041. */
  140042. getClassName(): string;
  140043. /**
  140044. * Gets the left operand input component
  140045. */
  140046. get left(): NodeMaterialConnectionPoint;
  140047. /**
  140048. * Gets the right operand input component
  140049. */
  140050. get right(): NodeMaterialConnectionPoint;
  140051. /**
  140052. * Gets the output component
  140053. */
  140054. get output(): NodeMaterialConnectionPoint;
  140055. protected _buildBlock(state: NodeMaterialBuildState): this;
  140056. }
  140057. }
  140058. declare module BABYLON {
  140059. /**
  140060. * Block used to get the length of a vector
  140061. */
  140062. export class LengthBlock extends NodeMaterialBlock {
  140063. /**
  140064. * Creates a new LengthBlock
  140065. * @param name defines the block name
  140066. */
  140067. constructor(name: string);
  140068. /**
  140069. * Gets the current class name
  140070. * @returns the class name
  140071. */
  140072. getClassName(): string;
  140073. /**
  140074. * Gets the value input component
  140075. */
  140076. get value(): NodeMaterialConnectionPoint;
  140077. /**
  140078. * Gets the output component
  140079. */
  140080. get output(): NodeMaterialConnectionPoint;
  140081. protected _buildBlock(state: NodeMaterialBuildState): this;
  140082. }
  140083. }
  140084. declare module BABYLON {
  140085. /**
  140086. * Block used to get negative version of a value (i.e. x * -1)
  140087. */
  140088. export class NegateBlock extends NodeMaterialBlock {
  140089. /**
  140090. * Creates a new NegateBlock
  140091. * @param name defines the block name
  140092. */
  140093. constructor(name: string);
  140094. /**
  140095. * Gets the current class name
  140096. * @returns the class name
  140097. */
  140098. getClassName(): string;
  140099. /**
  140100. * Gets the value input component
  140101. */
  140102. get value(): NodeMaterialConnectionPoint;
  140103. /**
  140104. * Gets the output component
  140105. */
  140106. get output(): NodeMaterialConnectionPoint;
  140107. protected _buildBlock(state: NodeMaterialBuildState): this;
  140108. }
  140109. }
  140110. declare module BABYLON {
  140111. /**
  140112. * Block used to get the value of the first parameter raised to the power of the second
  140113. */
  140114. export class PowBlock extends NodeMaterialBlock {
  140115. /**
  140116. * Creates a new PowBlock
  140117. * @param name defines the block name
  140118. */
  140119. constructor(name: string);
  140120. /**
  140121. * Gets the current class name
  140122. * @returns the class name
  140123. */
  140124. getClassName(): string;
  140125. /**
  140126. * Gets the value operand input component
  140127. */
  140128. get value(): NodeMaterialConnectionPoint;
  140129. /**
  140130. * Gets the power operand input component
  140131. */
  140132. get power(): NodeMaterialConnectionPoint;
  140133. /**
  140134. * Gets the output component
  140135. */
  140136. get output(): NodeMaterialConnectionPoint;
  140137. protected _buildBlock(state: NodeMaterialBuildState): this;
  140138. }
  140139. }
  140140. declare module BABYLON {
  140141. /**
  140142. * Block used to get a random number
  140143. */
  140144. export class RandomNumberBlock extends NodeMaterialBlock {
  140145. /**
  140146. * Creates a new RandomNumberBlock
  140147. * @param name defines the block name
  140148. */
  140149. constructor(name: string);
  140150. /**
  140151. * Gets the current class name
  140152. * @returns the class name
  140153. */
  140154. getClassName(): string;
  140155. /**
  140156. * Gets the seed input component
  140157. */
  140158. get seed(): NodeMaterialConnectionPoint;
  140159. /**
  140160. * Gets the output component
  140161. */
  140162. get output(): NodeMaterialConnectionPoint;
  140163. protected _buildBlock(state: NodeMaterialBuildState): this;
  140164. }
  140165. }
  140166. declare module BABYLON {
  140167. /**
  140168. * Block used to compute arc tangent of 2 values
  140169. */
  140170. export class ArcTan2Block extends NodeMaterialBlock {
  140171. /**
  140172. * Creates a new ArcTan2Block
  140173. * @param name defines the block name
  140174. */
  140175. constructor(name: string);
  140176. /**
  140177. * Gets the current class name
  140178. * @returns the class name
  140179. */
  140180. getClassName(): string;
  140181. /**
  140182. * Gets the x operand input component
  140183. */
  140184. get x(): NodeMaterialConnectionPoint;
  140185. /**
  140186. * Gets the y operand input component
  140187. */
  140188. get y(): NodeMaterialConnectionPoint;
  140189. /**
  140190. * Gets the output component
  140191. */
  140192. get output(): NodeMaterialConnectionPoint;
  140193. protected _buildBlock(state: NodeMaterialBuildState): this;
  140194. }
  140195. }
  140196. declare module BABYLON {
  140197. /**
  140198. * Block used to smooth step a value
  140199. */
  140200. export class SmoothStepBlock extends NodeMaterialBlock {
  140201. /**
  140202. * Creates a new SmoothStepBlock
  140203. * @param name defines the block name
  140204. */
  140205. constructor(name: string);
  140206. /**
  140207. * Gets the current class name
  140208. * @returns the class name
  140209. */
  140210. getClassName(): string;
  140211. /**
  140212. * Gets the value operand input component
  140213. */
  140214. get value(): NodeMaterialConnectionPoint;
  140215. /**
  140216. * Gets the first edge operand input component
  140217. */
  140218. get edge0(): NodeMaterialConnectionPoint;
  140219. /**
  140220. * Gets the second edge operand input component
  140221. */
  140222. get edge1(): NodeMaterialConnectionPoint;
  140223. /**
  140224. * Gets the output component
  140225. */
  140226. get output(): NodeMaterialConnectionPoint;
  140227. protected _buildBlock(state: NodeMaterialBuildState): this;
  140228. }
  140229. }
  140230. declare module BABYLON {
  140231. /**
  140232. * Block used to get the reciprocal (1 / x) of a value
  140233. */
  140234. export class ReciprocalBlock extends NodeMaterialBlock {
  140235. /**
  140236. * Creates a new ReciprocalBlock
  140237. * @param name defines the block name
  140238. */
  140239. constructor(name: string);
  140240. /**
  140241. * Gets the current class name
  140242. * @returns the class name
  140243. */
  140244. getClassName(): string;
  140245. /**
  140246. * Gets the input component
  140247. */
  140248. get input(): NodeMaterialConnectionPoint;
  140249. /**
  140250. * Gets the output component
  140251. */
  140252. get output(): NodeMaterialConnectionPoint;
  140253. protected _buildBlock(state: NodeMaterialBuildState): this;
  140254. }
  140255. }
  140256. declare module BABYLON {
  140257. /**
  140258. * Block used to replace a color by another one
  140259. */
  140260. export class ReplaceColorBlock extends NodeMaterialBlock {
  140261. /**
  140262. * Creates a new ReplaceColorBlock
  140263. * @param name defines the block name
  140264. */
  140265. constructor(name: string);
  140266. /**
  140267. * Gets the current class name
  140268. * @returns the class name
  140269. */
  140270. getClassName(): string;
  140271. /**
  140272. * Gets the value input component
  140273. */
  140274. get value(): NodeMaterialConnectionPoint;
  140275. /**
  140276. * Gets the reference input component
  140277. */
  140278. get reference(): NodeMaterialConnectionPoint;
  140279. /**
  140280. * Gets the distance input component
  140281. */
  140282. get distance(): NodeMaterialConnectionPoint;
  140283. /**
  140284. * Gets the replacement input component
  140285. */
  140286. get replacement(): NodeMaterialConnectionPoint;
  140287. /**
  140288. * Gets the output component
  140289. */
  140290. get output(): NodeMaterialConnectionPoint;
  140291. protected _buildBlock(state: NodeMaterialBuildState): this;
  140292. }
  140293. }
  140294. declare module BABYLON {
  140295. /**
  140296. * Block used to posterize a value
  140297. * @see https://en.wikipedia.org/wiki/Posterization
  140298. */
  140299. export class PosterizeBlock extends NodeMaterialBlock {
  140300. /**
  140301. * Creates a new PosterizeBlock
  140302. * @param name defines the block name
  140303. */
  140304. constructor(name: string);
  140305. /**
  140306. * Gets the current class name
  140307. * @returns the class name
  140308. */
  140309. getClassName(): string;
  140310. /**
  140311. * Gets the value input component
  140312. */
  140313. get value(): NodeMaterialConnectionPoint;
  140314. /**
  140315. * Gets the steps input component
  140316. */
  140317. get steps(): NodeMaterialConnectionPoint;
  140318. /**
  140319. * Gets the output component
  140320. */
  140321. get output(): NodeMaterialConnectionPoint;
  140322. protected _buildBlock(state: NodeMaterialBuildState): this;
  140323. }
  140324. }
  140325. declare module BABYLON {
  140326. /**
  140327. * Operations supported by the Wave block
  140328. */
  140329. export enum WaveBlockKind {
  140330. /** SawTooth */
  140331. SawTooth = 0,
  140332. /** Square */
  140333. Square = 1,
  140334. /** Triangle */
  140335. Triangle = 2
  140336. }
  140337. /**
  140338. * Block used to apply wave operation to floats
  140339. */
  140340. export class WaveBlock extends NodeMaterialBlock {
  140341. /**
  140342. * Gets or sets the kibnd of wave to be applied by the block
  140343. */
  140344. kind: WaveBlockKind;
  140345. /**
  140346. * Creates a new WaveBlock
  140347. * @param name defines the block name
  140348. */
  140349. constructor(name: string);
  140350. /**
  140351. * Gets the current class name
  140352. * @returns the class name
  140353. */
  140354. getClassName(): string;
  140355. /**
  140356. * Gets the input component
  140357. */
  140358. get input(): NodeMaterialConnectionPoint;
  140359. /**
  140360. * Gets the output component
  140361. */
  140362. get output(): NodeMaterialConnectionPoint;
  140363. protected _buildBlock(state: NodeMaterialBuildState): this;
  140364. serialize(): any;
  140365. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140366. }
  140367. }
  140368. declare module BABYLON {
  140369. /**
  140370. * Class used to store a color step for the GradientBlock
  140371. */
  140372. export class GradientBlockColorStep {
  140373. /**
  140374. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140375. */
  140376. step: number;
  140377. /**
  140378. * Gets or sets the color associated with this step
  140379. */
  140380. color: Color3;
  140381. /**
  140382. * Creates a new GradientBlockColorStep
  140383. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  140384. * @param color defines the color associated with this step
  140385. */
  140386. constructor(
  140387. /**
  140388. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  140389. */
  140390. step: number,
  140391. /**
  140392. * Gets or sets the color associated with this step
  140393. */
  140394. color: Color3);
  140395. }
  140396. /**
  140397. * Block used to return a color from a gradient based on an input value between 0 and 1
  140398. */
  140399. export class GradientBlock extends NodeMaterialBlock {
  140400. /**
  140401. * Gets or sets the list of color steps
  140402. */
  140403. colorSteps: GradientBlockColorStep[];
  140404. /**
  140405. * Creates a new GradientBlock
  140406. * @param name defines the block name
  140407. */
  140408. constructor(name: string);
  140409. /**
  140410. * Gets the current class name
  140411. * @returns the class name
  140412. */
  140413. getClassName(): string;
  140414. /**
  140415. * Gets the gradient input component
  140416. */
  140417. get gradient(): NodeMaterialConnectionPoint;
  140418. /**
  140419. * Gets the output component
  140420. */
  140421. get output(): NodeMaterialConnectionPoint;
  140422. private _writeColorConstant;
  140423. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140424. serialize(): any;
  140425. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140426. protected _dumpPropertiesCode(): string;
  140427. }
  140428. }
  140429. declare module BABYLON {
  140430. /**
  140431. * Block used to normalize lerp between 2 values
  140432. */
  140433. export class NLerpBlock extends NodeMaterialBlock {
  140434. /**
  140435. * Creates a new NLerpBlock
  140436. * @param name defines the block name
  140437. */
  140438. constructor(name: string);
  140439. /**
  140440. * Gets the current class name
  140441. * @returns the class name
  140442. */
  140443. getClassName(): string;
  140444. /**
  140445. * Gets the left operand input component
  140446. */
  140447. get left(): NodeMaterialConnectionPoint;
  140448. /**
  140449. * Gets the right operand input component
  140450. */
  140451. get right(): NodeMaterialConnectionPoint;
  140452. /**
  140453. * Gets the gradient operand input component
  140454. */
  140455. get gradient(): NodeMaterialConnectionPoint;
  140456. /**
  140457. * Gets the output component
  140458. */
  140459. get output(): NodeMaterialConnectionPoint;
  140460. protected _buildBlock(state: NodeMaterialBuildState): this;
  140461. }
  140462. }
  140463. declare module BABYLON {
  140464. /**
  140465. * block used to Generate a Worley Noise 3D Noise Pattern
  140466. */
  140467. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  140468. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  140469. manhattanDistance: boolean;
  140470. /**
  140471. * Creates a new WorleyNoise3DBlock
  140472. * @param name defines the block name
  140473. */
  140474. constructor(name: string);
  140475. /**
  140476. * Gets the current class name
  140477. * @returns the class name
  140478. */
  140479. getClassName(): string;
  140480. /**
  140481. * Gets the seed input component
  140482. */
  140483. get seed(): NodeMaterialConnectionPoint;
  140484. /**
  140485. * Gets the jitter input component
  140486. */
  140487. get jitter(): NodeMaterialConnectionPoint;
  140488. /**
  140489. * Gets the output component
  140490. */
  140491. get output(): NodeMaterialConnectionPoint;
  140492. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140493. /**
  140494. * Exposes the properties to the UI?
  140495. */
  140496. protected _dumpPropertiesCode(): string;
  140497. /**
  140498. * Exposes the properties to the Seralize?
  140499. */
  140500. serialize(): any;
  140501. /**
  140502. * Exposes the properties to the deseralize?
  140503. */
  140504. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140505. }
  140506. }
  140507. declare module BABYLON {
  140508. /**
  140509. * block used to Generate a Simplex Perlin 3d Noise Pattern
  140510. */
  140511. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  140512. /**
  140513. * Creates a new SimplexPerlin3DBlock
  140514. * @param name defines the block name
  140515. */
  140516. constructor(name: string);
  140517. /**
  140518. * Gets the current class name
  140519. * @returns the class name
  140520. */
  140521. getClassName(): string;
  140522. /**
  140523. * Gets the seed operand input component
  140524. */
  140525. get seed(): NodeMaterialConnectionPoint;
  140526. /**
  140527. * Gets the output component
  140528. */
  140529. get output(): NodeMaterialConnectionPoint;
  140530. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140531. }
  140532. }
  140533. declare module BABYLON {
  140534. /**
  140535. * Block used to blend normals
  140536. */
  140537. export class NormalBlendBlock extends NodeMaterialBlock {
  140538. /**
  140539. * Creates a new NormalBlendBlock
  140540. * @param name defines the block name
  140541. */
  140542. constructor(name: string);
  140543. /**
  140544. * Gets the current class name
  140545. * @returns the class name
  140546. */
  140547. getClassName(): string;
  140548. /**
  140549. * Gets the first input component
  140550. */
  140551. get normalMap0(): NodeMaterialConnectionPoint;
  140552. /**
  140553. * Gets the second input component
  140554. */
  140555. get normalMap1(): NodeMaterialConnectionPoint;
  140556. /**
  140557. * Gets the output component
  140558. */
  140559. get output(): NodeMaterialConnectionPoint;
  140560. protected _buildBlock(state: NodeMaterialBuildState): this;
  140561. }
  140562. }
  140563. declare module BABYLON {
  140564. /**
  140565. * Block used to rotate a 2d vector by a given angle
  140566. */
  140567. export class Rotate2dBlock extends NodeMaterialBlock {
  140568. /**
  140569. * Creates a new Rotate2dBlock
  140570. * @param name defines the block name
  140571. */
  140572. constructor(name: string);
  140573. /**
  140574. * Gets the current class name
  140575. * @returns the class name
  140576. */
  140577. getClassName(): string;
  140578. /**
  140579. * Gets the input vector
  140580. */
  140581. get input(): NodeMaterialConnectionPoint;
  140582. /**
  140583. * Gets the input angle
  140584. */
  140585. get angle(): NodeMaterialConnectionPoint;
  140586. /**
  140587. * Gets the output component
  140588. */
  140589. get output(): NodeMaterialConnectionPoint;
  140590. autoConfigure(material: NodeMaterial): void;
  140591. protected _buildBlock(state: NodeMaterialBuildState): this;
  140592. }
  140593. }
  140594. declare module BABYLON {
  140595. /**
  140596. * Block used to get the reflected vector from a direction and a normal
  140597. */
  140598. export class ReflectBlock extends NodeMaterialBlock {
  140599. /**
  140600. * Creates a new ReflectBlock
  140601. * @param name defines the block name
  140602. */
  140603. constructor(name: string);
  140604. /**
  140605. * Gets the current class name
  140606. * @returns the class name
  140607. */
  140608. getClassName(): string;
  140609. /**
  140610. * Gets the incident component
  140611. */
  140612. get incident(): NodeMaterialConnectionPoint;
  140613. /**
  140614. * Gets the normal component
  140615. */
  140616. get normal(): NodeMaterialConnectionPoint;
  140617. /**
  140618. * Gets the output component
  140619. */
  140620. get output(): NodeMaterialConnectionPoint;
  140621. protected _buildBlock(state: NodeMaterialBuildState): this;
  140622. }
  140623. }
  140624. declare module BABYLON {
  140625. /**
  140626. * Block used to get the refracted vector from a direction and a normal
  140627. */
  140628. export class RefractBlock extends NodeMaterialBlock {
  140629. /**
  140630. * Creates a new RefractBlock
  140631. * @param name defines the block name
  140632. */
  140633. constructor(name: string);
  140634. /**
  140635. * Gets the current class name
  140636. * @returns the class name
  140637. */
  140638. getClassName(): string;
  140639. /**
  140640. * Gets the incident component
  140641. */
  140642. get incident(): NodeMaterialConnectionPoint;
  140643. /**
  140644. * Gets the normal component
  140645. */
  140646. get normal(): NodeMaterialConnectionPoint;
  140647. /**
  140648. * Gets the index of refraction component
  140649. */
  140650. get ior(): NodeMaterialConnectionPoint;
  140651. /**
  140652. * Gets the output component
  140653. */
  140654. get output(): NodeMaterialConnectionPoint;
  140655. protected _buildBlock(state: NodeMaterialBuildState): this;
  140656. }
  140657. }
  140658. declare module BABYLON {
  140659. /**
  140660. * Block used to desaturate a color
  140661. */
  140662. export class DesaturateBlock extends NodeMaterialBlock {
  140663. /**
  140664. * Creates a new DesaturateBlock
  140665. * @param name defines the block name
  140666. */
  140667. constructor(name: string);
  140668. /**
  140669. * Gets the current class name
  140670. * @returns the class name
  140671. */
  140672. getClassName(): string;
  140673. /**
  140674. * Gets the color operand input component
  140675. */
  140676. get color(): NodeMaterialConnectionPoint;
  140677. /**
  140678. * Gets the level operand input component
  140679. */
  140680. get level(): NodeMaterialConnectionPoint;
  140681. /**
  140682. * Gets the output component
  140683. */
  140684. get output(): NodeMaterialConnectionPoint;
  140685. protected _buildBlock(state: NodeMaterialBuildState): this;
  140686. }
  140687. }
  140688. declare module BABYLON {
  140689. /**
  140690. * Block used to implement the ambient occlusion module of the PBR material
  140691. */
  140692. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  140693. /**
  140694. * Create a new AmbientOcclusionBlock
  140695. * @param name defines the block name
  140696. */
  140697. constructor(name: string);
  140698. /**
  140699. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  140700. */
  140701. useAmbientInGrayScale: boolean;
  140702. /**
  140703. * Initialize the block and prepare the context for build
  140704. * @param state defines the state that will be used for the build
  140705. */
  140706. initialize(state: NodeMaterialBuildState): void;
  140707. /**
  140708. * Gets the current class name
  140709. * @returns the class name
  140710. */
  140711. getClassName(): string;
  140712. /**
  140713. * Gets the texture input component
  140714. */
  140715. get texture(): NodeMaterialConnectionPoint;
  140716. /**
  140717. * Gets the texture intensity component
  140718. */
  140719. get intensity(): NodeMaterialConnectionPoint;
  140720. /**
  140721. * Gets the direct light intensity input component
  140722. */
  140723. get directLightIntensity(): NodeMaterialConnectionPoint;
  140724. /**
  140725. * Gets the ambient occlusion object output component
  140726. */
  140727. get ambientOcclusion(): NodeMaterialConnectionPoint;
  140728. /**
  140729. * Gets the main code of the block (fragment side)
  140730. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  140731. * @returns the shader code
  140732. */
  140733. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  140734. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140735. protected _buildBlock(state: NodeMaterialBuildState): this;
  140736. protected _dumpPropertiesCode(): string;
  140737. serialize(): any;
  140738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140739. }
  140740. }
  140741. declare module BABYLON {
  140742. /**
  140743. * Block used to implement the reflection module of the PBR material
  140744. */
  140745. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  140746. /** @hidden */
  140747. _defineLODReflectionAlpha: string;
  140748. /** @hidden */
  140749. _defineLinearSpecularReflection: string;
  140750. private _vEnvironmentIrradianceName;
  140751. /** @hidden */
  140752. _vReflectionMicrosurfaceInfosName: string;
  140753. /** @hidden */
  140754. _vReflectionInfosName: string;
  140755. /** @hidden */
  140756. _vReflectionFilteringInfoName: string;
  140757. private _scene;
  140758. /**
  140759. * The three properties below are set by the main PBR block prior to calling methods of this class.
  140760. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  140761. * It's less burden on the user side in the editor part.
  140762. */
  140763. /** @hidden */
  140764. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  140765. /** @hidden */
  140766. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  140767. /** @hidden */
  140768. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  140769. /**
  140770. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  140771. * diffuse part of the IBL.
  140772. */
  140773. useSphericalHarmonics: boolean;
  140774. /**
  140775. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  140776. */
  140777. forceIrradianceInFragment: boolean;
  140778. /**
  140779. * Create a new ReflectionBlock
  140780. * @param name defines the block name
  140781. */
  140782. constructor(name: string);
  140783. /**
  140784. * Gets the current class name
  140785. * @returns the class name
  140786. */
  140787. getClassName(): string;
  140788. /**
  140789. * Gets the position input component
  140790. */
  140791. get position(): NodeMaterialConnectionPoint;
  140792. /**
  140793. * Gets the world position input component
  140794. */
  140795. get worldPosition(): NodeMaterialConnectionPoint;
  140796. /**
  140797. * Gets the world normal input component
  140798. */
  140799. get worldNormal(): NodeMaterialConnectionPoint;
  140800. /**
  140801. * Gets the world input component
  140802. */
  140803. get world(): NodeMaterialConnectionPoint;
  140804. /**
  140805. * Gets the camera (or eye) position component
  140806. */
  140807. get cameraPosition(): NodeMaterialConnectionPoint;
  140808. /**
  140809. * Gets the view input component
  140810. */
  140811. get view(): NodeMaterialConnectionPoint;
  140812. /**
  140813. * Gets the color input component
  140814. */
  140815. get color(): NodeMaterialConnectionPoint;
  140816. /**
  140817. * Gets the reflection object output component
  140818. */
  140819. get reflection(): NodeMaterialConnectionPoint;
  140820. /**
  140821. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  140822. */
  140823. get hasTexture(): boolean;
  140824. /**
  140825. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  140826. */
  140827. get reflectionColor(): string;
  140828. protected _getTexture(): Nullable<BaseTexture>;
  140829. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140830. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140831. /**
  140832. * Gets the code to inject in the vertex shader
  140833. * @param state current state of the node material building
  140834. * @returns the shader code
  140835. */
  140836. handleVertexSide(state: NodeMaterialBuildState): string;
  140837. /**
  140838. * Gets the main code of the block (fragment side)
  140839. * @param state current state of the node material building
  140840. * @param normalVarName name of the existing variable corresponding to the normal
  140841. * @returns the shader code
  140842. */
  140843. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  140844. protected _buildBlock(state: NodeMaterialBuildState): this;
  140845. protected _dumpPropertiesCode(): string;
  140846. serialize(): any;
  140847. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140848. }
  140849. }
  140850. declare module BABYLON {
  140851. /**
  140852. * Block used to implement the sheen module of the PBR material
  140853. */
  140854. export class SheenBlock extends NodeMaterialBlock {
  140855. /**
  140856. * Create a new SheenBlock
  140857. * @param name defines the block name
  140858. */
  140859. constructor(name: string);
  140860. /**
  140861. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  140862. * It allows the strength of the sheen effect to not depend on the base color of the material,
  140863. * making it easier to setup and tweak the effect
  140864. */
  140865. albedoScaling: boolean;
  140866. /**
  140867. * Defines if the sheen is linked to the sheen color.
  140868. */
  140869. linkSheenWithAlbedo: boolean;
  140870. /**
  140871. * Initialize the block and prepare the context for build
  140872. * @param state defines the state that will be used for the build
  140873. */
  140874. initialize(state: NodeMaterialBuildState): void;
  140875. /**
  140876. * Gets the current class name
  140877. * @returns the class name
  140878. */
  140879. getClassName(): string;
  140880. /**
  140881. * Gets the intensity input component
  140882. */
  140883. get intensity(): NodeMaterialConnectionPoint;
  140884. /**
  140885. * Gets the color input component
  140886. */
  140887. get color(): NodeMaterialConnectionPoint;
  140888. /**
  140889. * Gets the roughness input component
  140890. */
  140891. get roughness(): NodeMaterialConnectionPoint;
  140892. /**
  140893. * Gets the sheen object output component
  140894. */
  140895. get sheen(): NodeMaterialConnectionPoint;
  140896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140897. /**
  140898. * Gets the main code of the block (fragment side)
  140899. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  140900. * @returns the shader code
  140901. */
  140902. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  140903. protected _buildBlock(state: NodeMaterialBuildState): this;
  140904. protected _dumpPropertiesCode(): string;
  140905. serialize(): any;
  140906. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140907. }
  140908. }
  140909. declare module BABYLON {
  140910. /**
  140911. * Block used to implement the reflectivity module of the PBR material
  140912. */
  140913. export class ReflectivityBlock extends NodeMaterialBlock {
  140914. private _metallicReflectanceColor;
  140915. private _metallicF0Factor;
  140916. /** @hidden */
  140917. _vMetallicReflectanceFactorsName: string;
  140918. /**
  140919. * The property below is set by the main PBR block prior to calling methods of this class.
  140920. */
  140921. /** @hidden */
  140922. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  140923. /**
  140924. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  140925. */
  140926. useAmbientOcclusionFromMetallicTextureRed: boolean;
  140927. /**
  140928. * Specifies if the metallic texture contains the metallness information in its blue channel.
  140929. */
  140930. useMetallnessFromMetallicTextureBlue: boolean;
  140931. /**
  140932. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  140933. */
  140934. useRoughnessFromMetallicTextureAlpha: boolean;
  140935. /**
  140936. * Specifies if the metallic texture contains the roughness information in its green channel.
  140937. */
  140938. useRoughnessFromMetallicTextureGreen: boolean;
  140939. /**
  140940. * Create a new ReflectivityBlock
  140941. * @param name defines the block name
  140942. */
  140943. constructor(name: string);
  140944. /**
  140945. * Initialize the block and prepare the context for build
  140946. * @param state defines the state that will be used for the build
  140947. */
  140948. initialize(state: NodeMaterialBuildState): void;
  140949. /**
  140950. * Gets the current class name
  140951. * @returns the class name
  140952. */
  140953. getClassName(): string;
  140954. /**
  140955. * Gets the metallic input component
  140956. */
  140957. get metallic(): NodeMaterialConnectionPoint;
  140958. /**
  140959. * Gets the roughness input component
  140960. */
  140961. get roughness(): NodeMaterialConnectionPoint;
  140962. /**
  140963. * Gets the texture input component
  140964. */
  140965. get texture(): NodeMaterialConnectionPoint;
  140966. /**
  140967. * Gets the reflectivity object output component
  140968. */
  140969. get reflectivity(): NodeMaterialConnectionPoint;
  140970. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  140971. /**
  140972. * Gets the main code of the block (fragment side)
  140973. * @param state current state of the node material building
  140974. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  140975. * @returns the shader code
  140976. */
  140977. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  140978. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140979. protected _buildBlock(state: NodeMaterialBuildState): this;
  140980. protected _dumpPropertiesCode(): string;
  140981. serialize(): any;
  140982. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140983. }
  140984. }
  140985. declare module BABYLON {
  140986. /**
  140987. * Block used to implement the anisotropy module of the PBR material
  140988. */
  140989. export class AnisotropyBlock extends NodeMaterialBlock {
  140990. /**
  140991. * The two properties below are set by the main PBR block prior to calling methods of this class.
  140992. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  140993. * It's less burden on the user side in the editor part.
  140994. */
  140995. /** @hidden */
  140996. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  140997. /** @hidden */
  140998. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  140999. /**
  141000. * Create a new AnisotropyBlock
  141001. * @param name defines the block name
  141002. */
  141003. constructor(name: string);
  141004. /**
  141005. * Initialize the block and prepare the context for build
  141006. * @param state defines the state that will be used for the build
  141007. */
  141008. initialize(state: NodeMaterialBuildState): void;
  141009. /**
  141010. * Gets the current class name
  141011. * @returns the class name
  141012. */
  141013. getClassName(): string;
  141014. /**
  141015. * Gets the intensity input component
  141016. */
  141017. get intensity(): NodeMaterialConnectionPoint;
  141018. /**
  141019. * Gets the direction input component
  141020. */
  141021. get direction(): NodeMaterialConnectionPoint;
  141022. /**
  141023. * Gets the texture input component
  141024. */
  141025. get texture(): NodeMaterialConnectionPoint;
  141026. /**
  141027. * Gets the uv input component
  141028. */
  141029. get uv(): NodeMaterialConnectionPoint;
  141030. /**
  141031. * Gets the worldTangent input component
  141032. */
  141033. get worldTangent(): NodeMaterialConnectionPoint;
  141034. /**
  141035. * Gets the anisotropy object output component
  141036. */
  141037. get anisotropy(): NodeMaterialConnectionPoint;
  141038. private _generateTBNSpace;
  141039. /**
  141040. * Gets the main code of the block (fragment side)
  141041. * @param state current state of the node material building
  141042. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141043. * @returns the shader code
  141044. */
  141045. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141047. protected _buildBlock(state: NodeMaterialBuildState): this;
  141048. }
  141049. }
  141050. declare module BABYLON {
  141051. /**
  141052. * Block used to implement the clear coat module of the PBR material
  141053. */
  141054. export class ClearCoatBlock extends NodeMaterialBlock {
  141055. private _scene;
  141056. /**
  141057. * Create a new ClearCoatBlock
  141058. * @param name defines the block name
  141059. */
  141060. constructor(name: string);
  141061. /**
  141062. * Initialize the block and prepare the context for build
  141063. * @param state defines the state that will be used for the build
  141064. */
  141065. initialize(state: NodeMaterialBuildState): void;
  141066. /**
  141067. * Gets the current class name
  141068. * @returns the class name
  141069. */
  141070. getClassName(): string;
  141071. /**
  141072. * Gets the intensity input component
  141073. */
  141074. get intensity(): NodeMaterialConnectionPoint;
  141075. /**
  141076. * Gets the roughness input component
  141077. */
  141078. get roughness(): NodeMaterialConnectionPoint;
  141079. /**
  141080. * Gets the ior input component
  141081. */
  141082. get ior(): NodeMaterialConnectionPoint;
  141083. /**
  141084. * Gets the texture input component
  141085. */
  141086. get texture(): NodeMaterialConnectionPoint;
  141087. /**
  141088. * Gets the bump texture input component
  141089. */
  141090. get bumpTexture(): NodeMaterialConnectionPoint;
  141091. /**
  141092. * Gets the uv input component
  141093. */
  141094. get uv(): NodeMaterialConnectionPoint;
  141095. /**
  141096. * Gets the tint color input component
  141097. */
  141098. get tintColor(): NodeMaterialConnectionPoint;
  141099. /**
  141100. * Gets the tint "at distance" input component
  141101. */
  141102. get tintAtDistance(): NodeMaterialConnectionPoint;
  141103. /**
  141104. * Gets the tint thickness input component
  141105. */
  141106. get tintThickness(): NodeMaterialConnectionPoint;
  141107. /**
  141108. * Gets the world tangent input component
  141109. */
  141110. get worldTangent(): NodeMaterialConnectionPoint;
  141111. /**
  141112. * Gets the clear coat object output component
  141113. */
  141114. get clearcoat(): NodeMaterialConnectionPoint;
  141115. autoConfigure(material: NodeMaterial): void;
  141116. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141117. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141118. private _generateTBNSpace;
  141119. /**
  141120. * Gets the main code of the block (fragment side)
  141121. * @param state current state of the node material building
  141122. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  141123. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141124. * @param worldPosVarName name of the variable holding the world position
  141125. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141126. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  141127. * @param worldNormalVarName name of the variable holding the world normal
  141128. * @returns the shader code
  141129. */
  141130. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  141131. protected _buildBlock(state: NodeMaterialBuildState): this;
  141132. }
  141133. }
  141134. declare module BABYLON {
  141135. /**
  141136. * Block used to implement the sub surface module of the PBR material
  141137. */
  141138. export class SubSurfaceBlock extends NodeMaterialBlock {
  141139. /**
  141140. * Create a new SubSurfaceBlock
  141141. * @param name defines the block name
  141142. */
  141143. constructor(name: string);
  141144. /**
  141145. * Stores the intensity of the different subsurface effects in the thickness texture.
  141146. * * the green channel is the translucency intensity.
  141147. * * the blue channel is the scattering intensity.
  141148. * * the alpha channel is the refraction intensity.
  141149. */
  141150. useMaskFromThicknessTexture: boolean;
  141151. /**
  141152. * Initialize the block and prepare the context for build
  141153. * @param state defines the state that will be used for the build
  141154. */
  141155. initialize(state: NodeMaterialBuildState): void;
  141156. /**
  141157. * Gets the current class name
  141158. * @returns the class name
  141159. */
  141160. getClassName(): string;
  141161. /**
  141162. * Gets the min thickness input component
  141163. */
  141164. get minThickness(): NodeMaterialConnectionPoint;
  141165. /**
  141166. * Gets the max thickness input component
  141167. */
  141168. get maxThickness(): NodeMaterialConnectionPoint;
  141169. /**
  141170. * Gets the thickness texture component
  141171. */
  141172. get thicknessTexture(): NodeMaterialConnectionPoint;
  141173. /**
  141174. * Gets the tint color input component
  141175. */
  141176. get tintColor(): NodeMaterialConnectionPoint;
  141177. /**
  141178. * Gets the translucency intensity input component
  141179. */
  141180. get translucencyIntensity(): NodeMaterialConnectionPoint;
  141181. /**
  141182. * Gets the translucency diffusion distance input component
  141183. */
  141184. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  141185. /**
  141186. * Gets the refraction object parameters
  141187. */
  141188. get refraction(): NodeMaterialConnectionPoint;
  141189. /**
  141190. * Gets the sub surface object output component
  141191. */
  141192. get subsurface(): NodeMaterialConnectionPoint;
  141193. autoConfigure(material: NodeMaterial): void;
  141194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141195. /**
  141196. * Gets the main code of the block (fragment side)
  141197. * @param state current state of the node material building
  141198. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  141199. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141200. * @param worldPosVarName name of the variable holding the world position
  141201. * @returns the shader code
  141202. */
  141203. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  141204. protected _buildBlock(state: NodeMaterialBuildState): this;
  141205. }
  141206. }
  141207. declare module BABYLON {
  141208. /**
  141209. * Block used to implement the PBR metallic/roughness model
  141210. */
  141211. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  141212. /**
  141213. * Gets or sets the light associated with this block
  141214. */
  141215. light: Nullable<Light>;
  141216. private _lightId;
  141217. private _scene;
  141218. private _environmentBRDFTexture;
  141219. private _environmentBrdfSamplerName;
  141220. private _vNormalWName;
  141221. private _invertNormalName;
  141222. /**
  141223. * Create a new ReflectionBlock
  141224. * @param name defines the block name
  141225. */
  141226. constructor(name: string);
  141227. /**
  141228. * Intensity of the direct lights e.g. the four lights available in your scene.
  141229. * This impacts both the direct diffuse and specular highlights.
  141230. */
  141231. directIntensity: number;
  141232. /**
  141233. * Intensity of the environment e.g. how much the environment will light the object
  141234. * either through harmonics for rough material or through the refelction for shiny ones.
  141235. */
  141236. environmentIntensity: number;
  141237. /**
  141238. * This is a special control allowing the reduction of the specular highlights coming from the
  141239. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  141240. */
  141241. specularIntensity: number;
  141242. /**
  141243. * Defines the falloff type used in this material.
  141244. * It by default is Physical.
  141245. */
  141246. lightFalloff: number;
  141247. /**
  141248. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  141249. */
  141250. useAlphaFromAlbedoTexture: boolean;
  141251. /**
  141252. * Specifies that alpha test should be used
  141253. */
  141254. useAlphaTest: boolean;
  141255. /**
  141256. * Defines the alpha limits in alpha test mode.
  141257. */
  141258. alphaTestCutoff: number;
  141259. /**
  141260. * Specifies that alpha blending should be used
  141261. */
  141262. useAlphaBlending: boolean;
  141263. /**
  141264. * Defines if the alpha value should be determined via the rgb values.
  141265. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  141266. */
  141267. opacityRGB: boolean;
  141268. /**
  141269. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  141270. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  141271. */
  141272. useRadianceOverAlpha: boolean;
  141273. /**
  141274. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  141275. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  141276. */
  141277. useSpecularOverAlpha: boolean;
  141278. /**
  141279. * Enables specular anti aliasing in the PBR shader.
  141280. * It will both interacts on the Geometry for analytical and IBL lighting.
  141281. * It also prefilter the roughness map based on the bump values.
  141282. */
  141283. enableSpecularAntiAliasing: boolean;
  141284. /**
  141285. * Enables realtime filtering on the texture.
  141286. */
  141287. realTimeFiltering: boolean;
  141288. /**
  141289. * Quality switch for realtime filtering
  141290. */
  141291. realTimeFilteringQuality: number;
  141292. /**
  141293. * Defines if the material uses energy conservation.
  141294. */
  141295. useEnergyConservation: boolean;
  141296. /**
  141297. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  141298. * too much the area relying on ambient texture to define their ambient occlusion.
  141299. */
  141300. useRadianceOcclusion: boolean;
  141301. /**
  141302. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  141303. * makes the reflect vector face the model (under horizon).
  141304. */
  141305. useHorizonOcclusion: boolean;
  141306. /**
  141307. * If set to true, no lighting calculations will be applied.
  141308. */
  141309. unlit: boolean;
  141310. /**
  141311. * Force normal to face away from face.
  141312. */
  141313. forceNormalForward: boolean;
  141314. /**
  141315. * Defines the material debug mode.
  141316. * It helps seeing only some components of the material while troubleshooting.
  141317. */
  141318. debugMode: number;
  141319. /**
  141320. * Specify from where on screen the debug mode should start.
  141321. * The value goes from -1 (full screen) to 1 (not visible)
  141322. * It helps with side by side comparison against the final render
  141323. * This defaults to 0
  141324. */
  141325. debugLimit: number;
  141326. /**
  141327. * As the default viewing range might not be enough (if the ambient is really small for instance)
  141328. * You can use the factor to better multiply the final value.
  141329. */
  141330. debugFactor: number;
  141331. /**
  141332. * Initialize the block and prepare the context for build
  141333. * @param state defines the state that will be used for the build
  141334. */
  141335. initialize(state: NodeMaterialBuildState): void;
  141336. /**
  141337. * Gets the current class name
  141338. * @returns the class name
  141339. */
  141340. getClassName(): string;
  141341. /**
  141342. * Gets the world position input component
  141343. */
  141344. get worldPosition(): NodeMaterialConnectionPoint;
  141345. /**
  141346. * Gets the world normal input component
  141347. */
  141348. get worldNormal(): NodeMaterialConnectionPoint;
  141349. /**
  141350. * Gets the perturbed normal input component
  141351. */
  141352. get perturbedNormal(): NodeMaterialConnectionPoint;
  141353. /**
  141354. * Gets the camera position input component
  141355. */
  141356. get cameraPosition(): NodeMaterialConnectionPoint;
  141357. /**
  141358. * Gets the base color input component
  141359. */
  141360. get baseColor(): NodeMaterialConnectionPoint;
  141361. /**
  141362. * Gets the opacity texture input component
  141363. */
  141364. get opacityTexture(): NodeMaterialConnectionPoint;
  141365. /**
  141366. * Gets the ambient color input component
  141367. */
  141368. get ambientColor(): NodeMaterialConnectionPoint;
  141369. /**
  141370. * Gets the reflectivity object parameters
  141371. */
  141372. get reflectivity(): NodeMaterialConnectionPoint;
  141373. /**
  141374. * Gets the ambient occlusion object parameters
  141375. */
  141376. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141377. /**
  141378. * Gets the reflection object parameters
  141379. */
  141380. get reflection(): NodeMaterialConnectionPoint;
  141381. /**
  141382. * Gets the sheen object parameters
  141383. */
  141384. get sheen(): NodeMaterialConnectionPoint;
  141385. /**
  141386. * Gets the clear coat object parameters
  141387. */
  141388. get clearcoat(): NodeMaterialConnectionPoint;
  141389. /**
  141390. * Gets the sub surface object parameters
  141391. */
  141392. get subsurface(): NodeMaterialConnectionPoint;
  141393. /**
  141394. * Gets the anisotropy object parameters
  141395. */
  141396. get anisotropy(): NodeMaterialConnectionPoint;
  141397. /**
  141398. * Gets the ambient output component
  141399. */
  141400. get ambient(): NodeMaterialConnectionPoint;
  141401. /**
  141402. * Gets the diffuse output component
  141403. */
  141404. get diffuse(): NodeMaterialConnectionPoint;
  141405. /**
  141406. * Gets the specular output component
  141407. */
  141408. get specular(): NodeMaterialConnectionPoint;
  141409. /**
  141410. * Gets the sheen output component
  141411. */
  141412. get sheenDir(): NodeMaterialConnectionPoint;
  141413. /**
  141414. * Gets the clear coat output component
  141415. */
  141416. get clearcoatDir(): NodeMaterialConnectionPoint;
  141417. /**
  141418. * Gets the indirect diffuse output component
  141419. */
  141420. get diffuseIndirect(): NodeMaterialConnectionPoint;
  141421. /**
  141422. * Gets the indirect specular output component
  141423. */
  141424. get specularIndirect(): NodeMaterialConnectionPoint;
  141425. /**
  141426. * Gets the indirect sheen output component
  141427. */
  141428. get sheenIndirect(): NodeMaterialConnectionPoint;
  141429. /**
  141430. * Gets the indirect clear coat output component
  141431. */
  141432. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  141433. /**
  141434. * Gets the refraction output component
  141435. */
  141436. get refraction(): NodeMaterialConnectionPoint;
  141437. /**
  141438. * Gets the global lighting output component
  141439. */
  141440. get lighting(): NodeMaterialConnectionPoint;
  141441. /**
  141442. * Gets the shadow output component
  141443. */
  141444. get shadow(): NodeMaterialConnectionPoint;
  141445. /**
  141446. * Gets the alpha output component
  141447. */
  141448. get alpha(): NodeMaterialConnectionPoint;
  141449. autoConfigure(material: NodeMaterial): void;
  141450. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141451. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  141452. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  141453. private _injectVertexCode;
  141454. /**
  141455. * Gets the code corresponding to the albedo/opacity module
  141456. * @returns the shader code
  141457. */
  141458. getAlbedoOpacityCode(): string;
  141459. protected _buildBlock(state: NodeMaterialBuildState): this;
  141460. protected _dumpPropertiesCode(): string;
  141461. serialize(): any;
  141462. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141463. }
  141464. }
  141465. declare module BABYLON {
  141466. /**
  141467. * Block used to compute value of one parameter modulo another
  141468. */
  141469. export class ModBlock extends NodeMaterialBlock {
  141470. /**
  141471. * Creates a new ModBlock
  141472. * @param name defines the block name
  141473. */
  141474. constructor(name: string);
  141475. /**
  141476. * Gets the current class name
  141477. * @returns the class name
  141478. */
  141479. getClassName(): string;
  141480. /**
  141481. * Gets the left operand input component
  141482. */
  141483. get left(): NodeMaterialConnectionPoint;
  141484. /**
  141485. * Gets the right operand input component
  141486. */
  141487. get right(): NodeMaterialConnectionPoint;
  141488. /**
  141489. * Gets the output component
  141490. */
  141491. get output(): NodeMaterialConnectionPoint;
  141492. protected _buildBlock(state: NodeMaterialBuildState): this;
  141493. }
  141494. }
  141495. declare module BABYLON {
  141496. /**
  141497. * Helper class to push actions to a pool of workers.
  141498. */
  141499. export class WorkerPool implements IDisposable {
  141500. private _workerInfos;
  141501. private _pendingActions;
  141502. /**
  141503. * Constructor
  141504. * @param workers Array of workers to use for actions
  141505. */
  141506. constructor(workers: Array<Worker>);
  141507. /**
  141508. * Terminates all workers and clears any pending actions.
  141509. */
  141510. dispose(): void;
  141511. /**
  141512. * Pushes an action to the worker pool. If all the workers are active, the action will be
  141513. * pended until a worker has completed its action.
  141514. * @param action The action to perform. Call onComplete when the action is complete.
  141515. */
  141516. push(action: (worker: Worker, onComplete: () => void) => void): void;
  141517. private _execute;
  141518. }
  141519. }
  141520. declare module BABYLON {
  141521. /**
  141522. * Configuration for Draco compression
  141523. */
  141524. export interface IDracoCompressionConfiguration {
  141525. /**
  141526. * Configuration for the decoder.
  141527. */
  141528. decoder: {
  141529. /**
  141530. * The url to the WebAssembly module.
  141531. */
  141532. wasmUrl?: string;
  141533. /**
  141534. * The url to the WebAssembly binary.
  141535. */
  141536. wasmBinaryUrl?: string;
  141537. /**
  141538. * The url to the fallback JavaScript module.
  141539. */
  141540. fallbackUrl?: string;
  141541. };
  141542. }
  141543. /**
  141544. * Draco compression (https://google.github.io/draco/)
  141545. *
  141546. * This class wraps the Draco module.
  141547. *
  141548. * **Encoder**
  141549. *
  141550. * The encoder is not currently implemented.
  141551. *
  141552. * **Decoder**
  141553. *
  141554. * 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.
  141555. *
  141556. * To update the configuration, use the following code:
  141557. * ```javascript
  141558. * DracoCompression.Configuration = {
  141559. * decoder: {
  141560. * wasmUrl: "<url to the WebAssembly library>",
  141561. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  141562. * fallbackUrl: "<url to the fallback JavaScript library>",
  141563. * }
  141564. * };
  141565. * ```
  141566. *
  141567. * 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.
  141568. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  141569. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  141570. *
  141571. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  141572. * ```javascript
  141573. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  141574. * ```
  141575. *
  141576. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  141577. */
  141578. export class DracoCompression implements IDisposable {
  141579. private _workerPoolPromise?;
  141580. private _decoderModulePromise?;
  141581. /**
  141582. * The configuration. Defaults to the following urls:
  141583. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  141584. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  141585. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  141586. */
  141587. static Configuration: IDracoCompressionConfiguration;
  141588. /**
  141589. * Returns true if the decoder configuration is available.
  141590. */
  141591. static get DecoderAvailable(): boolean;
  141592. /**
  141593. * Default number of workers to create when creating the draco compression object.
  141594. */
  141595. static DefaultNumWorkers: number;
  141596. private static GetDefaultNumWorkers;
  141597. private static _Default;
  141598. /**
  141599. * Default instance for the draco compression object.
  141600. */
  141601. static get Default(): DracoCompression;
  141602. /**
  141603. * Constructor
  141604. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  141605. */
  141606. constructor(numWorkers?: number);
  141607. /**
  141608. * Stop all async operations and release resources.
  141609. */
  141610. dispose(): void;
  141611. /**
  141612. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  141613. * @returns a promise that resolves when ready
  141614. */
  141615. whenReadyAsync(): Promise<void>;
  141616. /**
  141617. * Decode Draco compressed mesh data to vertex data.
  141618. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  141619. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  141620. * @returns A promise that resolves with the decoded vertex data
  141621. */
  141622. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  141623. [kind: string]: number;
  141624. }): Promise<VertexData>;
  141625. }
  141626. }
  141627. declare module BABYLON {
  141628. /**
  141629. * Class for building Constructive Solid Geometry
  141630. */
  141631. export class CSG {
  141632. private polygons;
  141633. /**
  141634. * The world matrix
  141635. */
  141636. matrix: Matrix;
  141637. /**
  141638. * Stores the position
  141639. */
  141640. position: Vector3;
  141641. /**
  141642. * Stores the rotation
  141643. */
  141644. rotation: Vector3;
  141645. /**
  141646. * Stores the rotation quaternion
  141647. */
  141648. rotationQuaternion: Nullable<Quaternion>;
  141649. /**
  141650. * Stores the scaling vector
  141651. */
  141652. scaling: Vector3;
  141653. /**
  141654. * Convert the Mesh to CSG
  141655. * @param mesh The Mesh to convert to CSG
  141656. * @returns A new CSG from the Mesh
  141657. */
  141658. static FromMesh(mesh: Mesh): CSG;
  141659. /**
  141660. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  141661. * @param polygons Polygons used to construct a CSG solid
  141662. */
  141663. private static FromPolygons;
  141664. /**
  141665. * Clones, or makes a deep copy, of the CSG
  141666. * @returns A new CSG
  141667. */
  141668. clone(): CSG;
  141669. /**
  141670. * Unions this CSG with another CSG
  141671. * @param csg The CSG to union against this CSG
  141672. * @returns The unioned CSG
  141673. */
  141674. union(csg: CSG): CSG;
  141675. /**
  141676. * Unions this CSG with another CSG in place
  141677. * @param csg The CSG to union against this CSG
  141678. */
  141679. unionInPlace(csg: CSG): void;
  141680. /**
  141681. * Subtracts this CSG with another CSG
  141682. * @param csg The CSG to subtract against this CSG
  141683. * @returns A new CSG
  141684. */
  141685. subtract(csg: CSG): CSG;
  141686. /**
  141687. * Subtracts this CSG with another CSG in place
  141688. * @param csg The CSG to subtact against this CSG
  141689. */
  141690. subtractInPlace(csg: CSG): void;
  141691. /**
  141692. * Intersect this CSG with another CSG
  141693. * @param csg The CSG to intersect against this CSG
  141694. * @returns A new CSG
  141695. */
  141696. intersect(csg: CSG): CSG;
  141697. /**
  141698. * Intersects this CSG with another CSG in place
  141699. * @param csg The CSG to intersect against this CSG
  141700. */
  141701. intersectInPlace(csg: CSG): void;
  141702. /**
  141703. * Return a new CSG solid with solid and empty space switched. This solid is
  141704. * not modified.
  141705. * @returns A new CSG solid with solid and empty space switched
  141706. */
  141707. inverse(): CSG;
  141708. /**
  141709. * Inverses the CSG in place
  141710. */
  141711. inverseInPlace(): void;
  141712. /**
  141713. * This is used to keep meshes transformations so they can be restored
  141714. * when we build back a Babylon Mesh
  141715. * NB : All CSG operations are performed in world coordinates
  141716. * @param csg The CSG to copy the transform attributes from
  141717. * @returns This CSG
  141718. */
  141719. copyTransformAttributes(csg: CSG): CSG;
  141720. /**
  141721. * Build Raw mesh from CSG
  141722. * Coordinates here are in world space
  141723. * @param name The name of the mesh geometry
  141724. * @param scene The Scene
  141725. * @param keepSubMeshes Specifies if the submeshes should be kept
  141726. * @returns A new Mesh
  141727. */
  141728. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  141729. /**
  141730. * Build Mesh from CSG taking material and transforms into account
  141731. * @param name The name of the Mesh
  141732. * @param material The material of the Mesh
  141733. * @param scene The Scene
  141734. * @param keepSubMeshes Specifies if submeshes should be kept
  141735. * @returns The new Mesh
  141736. */
  141737. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  141738. }
  141739. }
  141740. declare module BABYLON {
  141741. /**
  141742. * Class used to create a trail following a mesh
  141743. */
  141744. export class TrailMesh extends Mesh {
  141745. private _generator;
  141746. private _autoStart;
  141747. private _running;
  141748. private _diameter;
  141749. private _length;
  141750. private _sectionPolygonPointsCount;
  141751. private _sectionVectors;
  141752. private _sectionNormalVectors;
  141753. private _beforeRenderObserver;
  141754. /**
  141755. * @constructor
  141756. * @param name The value used by scene.getMeshByName() to do a lookup.
  141757. * @param generator The mesh or transform node to generate a trail.
  141758. * @param scene The scene to add this mesh to.
  141759. * @param diameter Diameter of trailing mesh. Default is 1.
  141760. * @param length Length of trailing mesh. Default is 60.
  141761. * @param autoStart Automatically start trailing mesh. Default true.
  141762. */
  141763. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  141764. /**
  141765. * "TrailMesh"
  141766. * @returns "TrailMesh"
  141767. */
  141768. getClassName(): string;
  141769. private _createMesh;
  141770. /**
  141771. * Start trailing mesh.
  141772. */
  141773. start(): void;
  141774. /**
  141775. * Stop trailing mesh.
  141776. */
  141777. stop(): void;
  141778. /**
  141779. * Update trailing mesh geometry.
  141780. */
  141781. update(): void;
  141782. /**
  141783. * Returns a new TrailMesh object.
  141784. * @param name is a string, the name given to the new mesh
  141785. * @param newGenerator use new generator object for cloned trail mesh
  141786. * @returns a new mesh
  141787. */
  141788. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  141789. /**
  141790. * Serializes this trail mesh
  141791. * @param serializationObject object to write serialization to
  141792. */
  141793. serialize(serializationObject: any): void;
  141794. /**
  141795. * Parses a serialized trail mesh
  141796. * @param parsedMesh the serialized mesh
  141797. * @param scene the scene to create the trail mesh in
  141798. * @returns the created trail mesh
  141799. */
  141800. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  141801. }
  141802. }
  141803. declare module BABYLON {
  141804. /**
  141805. * Class containing static functions to help procedurally build meshes
  141806. */
  141807. export class TiledBoxBuilder {
  141808. /**
  141809. * Creates a box mesh
  141810. * 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)
  141811. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  141812. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141813. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141815. * @param name defines the name of the mesh
  141816. * @param options defines the options used to create the mesh
  141817. * @param scene defines the hosting scene
  141818. * @returns the box mesh
  141819. */
  141820. static CreateTiledBox(name: string, options: {
  141821. pattern?: number;
  141822. width?: number;
  141823. height?: number;
  141824. depth?: number;
  141825. tileSize?: number;
  141826. tileWidth?: number;
  141827. tileHeight?: number;
  141828. alignHorizontal?: number;
  141829. alignVertical?: number;
  141830. faceUV?: Vector4[];
  141831. faceColors?: Color4[];
  141832. sideOrientation?: number;
  141833. updatable?: boolean;
  141834. }, scene?: Nullable<Scene>): Mesh;
  141835. }
  141836. }
  141837. declare module BABYLON {
  141838. /**
  141839. * Class containing static functions to help procedurally build meshes
  141840. */
  141841. export class TorusKnotBuilder {
  141842. /**
  141843. * Creates a torus knot mesh
  141844. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  141845. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  141846. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  141847. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  141848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  141849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  141850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  141851. * @param name defines the name of the mesh
  141852. * @param options defines the options used to create the mesh
  141853. * @param scene defines the hosting scene
  141854. * @returns the torus knot mesh
  141855. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  141856. */
  141857. static CreateTorusKnot(name: string, options: {
  141858. radius?: number;
  141859. tube?: number;
  141860. radialSegments?: number;
  141861. tubularSegments?: number;
  141862. p?: number;
  141863. q?: number;
  141864. updatable?: boolean;
  141865. sideOrientation?: number;
  141866. frontUVs?: Vector4;
  141867. backUVs?: Vector4;
  141868. }, scene: any): Mesh;
  141869. }
  141870. }
  141871. declare module BABYLON {
  141872. /**
  141873. * Polygon
  141874. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  141875. */
  141876. export class Polygon {
  141877. /**
  141878. * Creates a rectangle
  141879. * @param xmin bottom X coord
  141880. * @param ymin bottom Y coord
  141881. * @param xmax top X coord
  141882. * @param ymax top Y coord
  141883. * @returns points that make the resulting rectation
  141884. */
  141885. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  141886. /**
  141887. * Creates a circle
  141888. * @param radius radius of circle
  141889. * @param cx scale in x
  141890. * @param cy scale in y
  141891. * @param numberOfSides number of sides that make up the circle
  141892. * @returns points that make the resulting circle
  141893. */
  141894. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  141895. /**
  141896. * Creates a polygon from input string
  141897. * @param input Input polygon data
  141898. * @returns the parsed points
  141899. */
  141900. static Parse(input: string): Vector2[];
  141901. /**
  141902. * Starts building a polygon from x and y coordinates
  141903. * @param x x coordinate
  141904. * @param y y coordinate
  141905. * @returns the started path2
  141906. */
  141907. static StartingAt(x: number, y: number): Path2;
  141908. }
  141909. /**
  141910. * Builds a polygon
  141911. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  141912. */
  141913. export class PolygonMeshBuilder {
  141914. private _points;
  141915. private _outlinepoints;
  141916. private _holes;
  141917. private _name;
  141918. private _scene;
  141919. private _epoints;
  141920. private _eholes;
  141921. private _addToepoint;
  141922. /**
  141923. * Babylon reference to the earcut plugin.
  141924. */
  141925. bjsEarcut: any;
  141926. /**
  141927. * Creates a PolygonMeshBuilder
  141928. * @param name name of the builder
  141929. * @param contours Path of the polygon
  141930. * @param scene scene to add to when creating the mesh
  141931. * @param earcutInjection can be used to inject your own earcut reference
  141932. */
  141933. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  141934. /**
  141935. * Adds a whole within the polygon
  141936. * @param hole Array of points defining the hole
  141937. * @returns this
  141938. */
  141939. addHole(hole: Vector2[]): PolygonMeshBuilder;
  141940. /**
  141941. * Creates the polygon
  141942. * @param updatable If the mesh should be updatable
  141943. * @param depth The depth of the mesh created
  141944. * @returns the created mesh
  141945. */
  141946. build(updatable?: boolean, depth?: number): Mesh;
  141947. /**
  141948. * Creates the polygon
  141949. * @param depth The depth of the mesh created
  141950. * @returns the created VertexData
  141951. */
  141952. buildVertexData(depth?: number): VertexData;
  141953. /**
  141954. * Adds a side to the polygon
  141955. * @param positions points that make the polygon
  141956. * @param normals normals of the polygon
  141957. * @param uvs uvs of the polygon
  141958. * @param indices indices of the polygon
  141959. * @param bounds bounds of the polygon
  141960. * @param points points of the polygon
  141961. * @param depth depth of the polygon
  141962. * @param flip flip of the polygon
  141963. */
  141964. private addSide;
  141965. }
  141966. }
  141967. declare module BABYLON {
  141968. /**
  141969. * Class containing static functions to help procedurally build meshes
  141970. */
  141971. export class PolygonBuilder {
  141972. /**
  141973. * Creates a polygon mesh
  141974. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  141975. * * 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
  141976. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  141977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  141978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  141979. * * Remember you can only change the shape positions, not their number when updating a polygon
  141980. * @param name defines the name of the mesh
  141981. * @param options defines the options used to create the mesh
  141982. * @param scene defines the hosting scene
  141983. * @param earcutInjection can be used to inject your own earcut reference
  141984. * @returns the polygon mesh
  141985. */
  141986. static CreatePolygon(name: string, options: {
  141987. shape: Vector3[];
  141988. holes?: Vector3[][];
  141989. depth?: number;
  141990. faceUV?: Vector4[];
  141991. faceColors?: Color4[];
  141992. updatable?: boolean;
  141993. sideOrientation?: number;
  141994. frontUVs?: Vector4;
  141995. backUVs?: Vector4;
  141996. wrap?: boolean;
  141997. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  141998. /**
  141999. * Creates an extruded polygon mesh, with depth in the Y direction.
  142000. * * 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)
  142001. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142002. * @param name defines the name of the mesh
  142003. * @param options defines the options used to create the mesh
  142004. * @param scene defines the hosting scene
  142005. * @param earcutInjection can be used to inject your own earcut reference
  142006. * @returns the polygon mesh
  142007. */
  142008. static ExtrudePolygon(name: string, options: {
  142009. shape: Vector3[];
  142010. holes?: Vector3[][];
  142011. depth?: number;
  142012. faceUV?: Vector4[];
  142013. faceColors?: Color4[];
  142014. updatable?: boolean;
  142015. sideOrientation?: number;
  142016. frontUVs?: Vector4;
  142017. backUVs?: Vector4;
  142018. wrap?: boolean;
  142019. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142020. }
  142021. }
  142022. declare module BABYLON {
  142023. /**
  142024. * Class containing static functions to help procedurally build meshes
  142025. */
  142026. export class LatheBuilder {
  142027. /**
  142028. * Creates lathe mesh.
  142029. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142030. * * 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
  142031. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142032. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142033. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142034. * * 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
  142035. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142036. * * 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
  142037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142039. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142041. * @param name defines the name of the mesh
  142042. * @param options defines the options used to create the mesh
  142043. * @param scene defines the hosting scene
  142044. * @returns the lathe mesh
  142045. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142046. */
  142047. static CreateLathe(name: string, options: {
  142048. shape: Vector3[];
  142049. radius?: number;
  142050. tessellation?: number;
  142051. clip?: number;
  142052. arc?: number;
  142053. closed?: boolean;
  142054. updatable?: boolean;
  142055. sideOrientation?: number;
  142056. frontUVs?: Vector4;
  142057. backUVs?: Vector4;
  142058. cap?: number;
  142059. invertUV?: boolean;
  142060. }, scene?: Nullable<Scene>): Mesh;
  142061. }
  142062. }
  142063. declare module BABYLON {
  142064. /**
  142065. * Class containing static functions to help procedurally build meshes
  142066. */
  142067. export class TiledPlaneBuilder {
  142068. /**
  142069. * Creates a tiled plane mesh
  142070. * * The parameter `pattern` will, depending on value, do nothing or
  142071. * * * flip (reflect about central vertical) alternate tiles across and up
  142072. * * * flip every tile on alternate rows
  142073. * * * rotate (180 degs) alternate tiles across and up
  142074. * * * rotate every tile on alternate rows
  142075. * * * flip and rotate alternate tiles across and up
  142076. * * * flip and rotate every tile on alternate rows
  142077. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  142078. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  142079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142080. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142081. * * 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)
  142082. * * 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)
  142083. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142084. * @param name defines the name of the mesh
  142085. * @param options defines the options used to create the mesh
  142086. * @param scene defines the hosting scene
  142087. * @returns the box mesh
  142088. */
  142089. static CreateTiledPlane(name: string, options: {
  142090. pattern?: number;
  142091. tileSize?: number;
  142092. tileWidth?: number;
  142093. tileHeight?: number;
  142094. size?: number;
  142095. width?: number;
  142096. height?: number;
  142097. alignHorizontal?: number;
  142098. alignVertical?: number;
  142099. sideOrientation?: number;
  142100. frontUVs?: Vector4;
  142101. backUVs?: Vector4;
  142102. updatable?: boolean;
  142103. }, scene?: Nullable<Scene>): Mesh;
  142104. }
  142105. }
  142106. declare module BABYLON {
  142107. /**
  142108. * Class containing static functions to help procedurally build meshes
  142109. */
  142110. export class TubeBuilder {
  142111. /**
  142112. * Creates a tube mesh.
  142113. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142114. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142115. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142116. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142117. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142118. * * 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)
  142119. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142120. * * 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
  142121. * * 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
  142122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142124. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142126. * @param name defines the name of the mesh
  142127. * @param options defines the options used to create the mesh
  142128. * @param scene defines the hosting scene
  142129. * @returns the tube mesh
  142130. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142131. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142132. */
  142133. static CreateTube(name: string, options: {
  142134. path: Vector3[];
  142135. radius?: number;
  142136. tessellation?: number;
  142137. radiusFunction?: {
  142138. (i: number, distance: number): number;
  142139. };
  142140. cap?: number;
  142141. arc?: number;
  142142. updatable?: boolean;
  142143. sideOrientation?: number;
  142144. frontUVs?: Vector4;
  142145. backUVs?: Vector4;
  142146. instance?: Mesh;
  142147. invertUV?: boolean;
  142148. }, scene?: Nullable<Scene>): Mesh;
  142149. }
  142150. }
  142151. declare module BABYLON {
  142152. /**
  142153. * Class containing static functions to help procedurally build meshes
  142154. */
  142155. export class IcoSphereBuilder {
  142156. /**
  142157. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142158. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142159. * * 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`)
  142160. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142161. * * 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
  142162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142163. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142165. * @param name defines the name of the mesh
  142166. * @param options defines the options used to create the mesh
  142167. * @param scene defines the hosting scene
  142168. * @returns the icosahedron mesh
  142169. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142170. */
  142171. static CreateIcoSphere(name: string, options: {
  142172. radius?: number;
  142173. radiusX?: number;
  142174. radiusY?: number;
  142175. radiusZ?: number;
  142176. flat?: boolean;
  142177. subdivisions?: number;
  142178. sideOrientation?: number;
  142179. frontUVs?: Vector4;
  142180. backUVs?: Vector4;
  142181. updatable?: boolean;
  142182. }, scene?: Nullable<Scene>): Mesh;
  142183. }
  142184. }
  142185. declare module BABYLON {
  142186. /**
  142187. * Class containing static functions to help procedurally build meshes
  142188. */
  142189. export class DecalBuilder {
  142190. /**
  142191. * Creates a decal mesh.
  142192. * 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
  142193. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142194. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142195. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142196. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142197. * @param name defines the name of the mesh
  142198. * @param sourceMesh defines the mesh where the decal must be applied
  142199. * @param options defines the options used to create the mesh
  142200. * @param scene defines the hosting scene
  142201. * @returns the decal mesh
  142202. * @see https://doc.babylonjs.com/how_to/decals
  142203. */
  142204. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142205. position?: Vector3;
  142206. normal?: Vector3;
  142207. size?: Vector3;
  142208. angle?: number;
  142209. }): Mesh;
  142210. }
  142211. }
  142212. declare module BABYLON {
  142213. /**
  142214. * Class containing static functions to help procedurally build meshes
  142215. */
  142216. export class MeshBuilder {
  142217. /**
  142218. * Creates a box mesh
  142219. * * The parameter `size` sets the size (float) of each box side (default 1)
  142220. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  142221. * * 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)
  142222. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142226. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  142227. * @param name defines the name of the mesh
  142228. * @param options defines the options used to create the mesh
  142229. * @param scene defines the hosting scene
  142230. * @returns the box mesh
  142231. */
  142232. static CreateBox(name: string, options: {
  142233. size?: number;
  142234. width?: number;
  142235. height?: number;
  142236. depth?: number;
  142237. faceUV?: Vector4[];
  142238. faceColors?: Color4[];
  142239. sideOrientation?: number;
  142240. frontUVs?: Vector4;
  142241. backUVs?: Vector4;
  142242. wrap?: boolean;
  142243. topBaseAt?: number;
  142244. bottomBaseAt?: number;
  142245. updatable?: boolean;
  142246. }, scene?: Nullable<Scene>): Mesh;
  142247. /**
  142248. * Creates a tiled box mesh
  142249. * * faceTiles sets the pattern, tile size and number of tiles for a face
  142250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142251. * @param name defines the name of the mesh
  142252. * @param options defines the options used to create the mesh
  142253. * @param scene defines the hosting scene
  142254. * @returns the tiled box mesh
  142255. */
  142256. static CreateTiledBox(name: string, options: {
  142257. pattern?: number;
  142258. size?: number;
  142259. width?: number;
  142260. height?: number;
  142261. depth: number;
  142262. tileSize?: number;
  142263. tileWidth?: number;
  142264. tileHeight?: number;
  142265. faceUV?: Vector4[];
  142266. faceColors?: Color4[];
  142267. alignHorizontal?: number;
  142268. alignVertical?: number;
  142269. sideOrientation?: number;
  142270. updatable?: boolean;
  142271. }, scene?: Nullable<Scene>): Mesh;
  142272. /**
  142273. * Creates a sphere mesh
  142274. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  142275. * * 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`)
  142276. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  142277. * * 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
  142278. * * 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)
  142279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142280. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142282. * @param name defines the name of the mesh
  142283. * @param options defines the options used to create the mesh
  142284. * @param scene defines the hosting scene
  142285. * @returns the sphere mesh
  142286. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  142287. */
  142288. static CreateSphere(name: string, options: {
  142289. segments?: number;
  142290. diameter?: number;
  142291. diameterX?: number;
  142292. diameterY?: number;
  142293. diameterZ?: number;
  142294. arc?: number;
  142295. slice?: number;
  142296. sideOrientation?: number;
  142297. frontUVs?: Vector4;
  142298. backUVs?: Vector4;
  142299. updatable?: boolean;
  142300. }, scene?: Nullable<Scene>): Mesh;
  142301. /**
  142302. * Creates a plane polygonal mesh. By default, this is a disc
  142303. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  142304. * * 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
  142305. * * 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
  142306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142307. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142309. * @param name defines the name of the mesh
  142310. * @param options defines the options used to create the mesh
  142311. * @param scene defines the hosting scene
  142312. * @returns the plane polygonal mesh
  142313. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  142314. */
  142315. static CreateDisc(name: string, options: {
  142316. radius?: number;
  142317. tessellation?: number;
  142318. arc?: number;
  142319. updatable?: boolean;
  142320. sideOrientation?: number;
  142321. frontUVs?: Vector4;
  142322. backUVs?: Vector4;
  142323. }, scene?: Nullable<Scene>): Mesh;
  142324. /**
  142325. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  142326. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  142327. * * 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`)
  142328. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  142329. * * 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
  142330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142331. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142333. * @param name defines the name of the mesh
  142334. * @param options defines the options used to create the mesh
  142335. * @param scene defines the hosting scene
  142336. * @returns the icosahedron mesh
  142337. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  142338. */
  142339. static CreateIcoSphere(name: string, options: {
  142340. radius?: number;
  142341. radiusX?: number;
  142342. radiusY?: number;
  142343. radiusZ?: number;
  142344. flat?: boolean;
  142345. subdivisions?: number;
  142346. sideOrientation?: number;
  142347. frontUVs?: Vector4;
  142348. backUVs?: Vector4;
  142349. updatable?: boolean;
  142350. }, scene?: Nullable<Scene>): Mesh;
  142351. /**
  142352. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142353. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  142354. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  142355. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  142356. * * 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
  142357. * * 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
  142358. * * 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
  142359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142362. * * 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
  142363. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  142364. * * 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
  142365. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  142366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142367. * @param name defines the name of the mesh
  142368. * @param options defines the options used to create the mesh
  142369. * @param scene defines the hosting scene
  142370. * @returns the ribbon mesh
  142371. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  142372. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142373. */
  142374. static CreateRibbon(name: string, options: {
  142375. pathArray: Vector3[][];
  142376. closeArray?: boolean;
  142377. closePath?: boolean;
  142378. offset?: number;
  142379. updatable?: boolean;
  142380. sideOrientation?: number;
  142381. frontUVs?: Vector4;
  142382. backUVs?: Vector4;
  142383. instance?: Mesh;
  142384. invertUV?: boolean;
  142385. uvs?: Vector2[];
  142386. colors?: Color4[];
  142387. }, scene?: Nullable<Scene>): Mesh;
  142388. /**
  142389. * Creates a cylinder or a cone mesh
  142390. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  142391. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  142392. * * 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.
  142393. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  142394. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  142395. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  142396. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  142397. * * 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).
  142398. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  142399. * * 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).
  142400. * * 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
  142401. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  142402. * * 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
  142403. * * 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.
  142404. * * If `enclose` is false, a ring surface is one element.
  142405. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  142406. * * 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
  142407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142408. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142410. * @param name defines the name of the mesh
  142411. * @param options defines the options used to create the mesh
  142412. * @param scene defines the hosting scene
  142413. * @returns the cylinder mesh
  142414. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  142415. */
  142416. static CreateCylinder(name: string, options: {
  142417. height?: number;
  142418. diameterTop?: number;
  142419. diameterBottom?: number;
  142420. diameter?: number;
  142421. tessellation?: number;
  142422. subdivisions?: number;
  142423. arc?: number;
  142424. faceColors?: Color4[];
  142425. faceUV?: Vector4[];
  142426. updatable?: boolean;
  142427. hasRings?: boolean;
  142428. enclose?: boolean;
  142429. cap?: number;
  142430. sideOrientation?: number;
  142431. frontUVs?: Vector4;
  142432. backUVs?: Vector4;
  142433. }, scene?: Nullable<Scene>): Mesh;
  142434. /**
  142435. * Creates a torus mesh
  142436. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  142437. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  142438. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  142439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142442. * @param name defines the name of the mesh
  142443. * @param options defines the options used to create the mesh
  142444. * @param scene defines the hosting scene
  142445. * @returns the torus mesh
  142446. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  142447. */
  142448. static CreateTorus(name: string, options: {
  142449. diameter?: number;
  142450. thickness?: number;
  142451. tessellation?: number;
  142452. updatable?: boolean;
  142453. sideOrientation?: number;
  142454. frontUVs?: Vector4;
  142455. backUVs?: Vector4;
  142456. }, scene?: Nullable<Scene>): Mesh;
  142457. /**
  142458. * Creates a torus knot mesh
  142459. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142460. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142461. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142462. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142466. * @param name defines the name of the mesh
  142467. * @param options defines the options used to create the mesh
  142468. * @param scene defines the hosting scene
  142469. * @returns the torus knot mesh
  142470. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142471. */
  142472. static CreateTorusKnot(name: string, options: {
  142473. radius?: number;
  142474. tube?: number;
  142475. radialSegments?: number;
  142476. tubularSegments?: number;
  142477. p?: number;
  142478. q?: number;
  142479. updatable?: boolean;
  142480. sideOrientation?: number;
  142481. frontUVs?: Vector4;
  142482. backUVs?: Vector4;
  142483. }, scene?: Nullable<Scene>): Mesh;
  142484. /**
  142485. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  142486. * * 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
  142487. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  142488. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  142489. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  142490. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  142491. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  142492. * * 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
  142493. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  142494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  142496. * @param name defines the name of the new line system
  142497. * @param options defines the options used to create the line system
  142498. * @param scene defines the hosting scene
  142499. * @returns a new line system mesh
  142500. */
  142501. static CreateLineSystem(name: string, options: {
  142502. lines: Vector3[][];
  142503. updatable?: boolean;
  142504. instance?: Nullable<LinesMesh>;
  142505. colors?: Nullable<Color4[][]>;
  142506. useVertexAlpha?: boolean;
  142507. }, scene: Nullable<Scene>): LinesMesh;
  142508. /**
  142509. * Creates a line mesh
  142510. * 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
  142511. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142512. * * The parameter `points` is an array successive Vector3
  142513. * * 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
  142514. * * The optional parameter `colors` is an array of successive Color4, one per line point
  142515. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  142516. * * When updating an instance, remember that only point positions can change, not the number of points
  142517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  142519. * @param name defines the name of the new line system
  142520. * @param options defines the options used to create the line system
  142521. * @param scene defines the hosting scene
  142522. * @returns a new line mesh
  142523. */
  142524. static CreateLines(name: string, options: {
  142525. points: Vector3[];
  142526. updatable?: boolean;
  142527. instance?: Nullable<LinesMesh>;
  142528. colors?: Color4[];
  142529. useVertexAlpha?: boolean;
  142530. }, scene?: Nullable<Scene>): LinesMesh;
  142531. /**
  142532. * Creates a dashed line mesh
  142533. * * 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
  142534. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  142535. * * The parameter `points` is an array successive Vector3
  142536. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  142537. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  142538. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  142539. * * 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
  142540. * * When updating an instance, remember that only point positions can change, not the number of points
  142541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142542. * @param name defines the name of the mesh
  142543. * @param options defines the options used to create the mesh
  142544. * @param scene defines the hosting scene
  142545. * @returns the dashed line mesh
  142546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  142547. */
  142548. static CreateDashedLines(name: string, options: {
  142549. points: Vector3[];
  142550. dashSize?: number;
  142551. gapSize?: number;
  142552. dashNb?: number;
  142553. updatable?: boolean;
  142554. instance?: LinesMesh;
  142555. }, scene?: Nullable<Scene>): LinesMesh;
  142556. /**
  142557. * 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.
  142558. * * 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.
  142559. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142560. * * 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.
  142561. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  142562. * * 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
  142563. * * 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
  142564. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  142565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142567. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  142568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142569. * @param name defines the name of the mesh
  142570. * @param options defines the options used to create the mesh
  142571. * @param scene defines the hosting scene
  142572. * @returns the extruded shape mesh
  142573. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142575. */
  142576. static ExtrudeShape(name: string, options: {
  142577. shape: Vector3[];
  142578. path: Vector3[];
  142579. scale?: number;
  142580. rotation?: number;
  142581. cap?: number;
  142582. updatable?: boolean;
  142583. sideOrientation?: number;
  142584. frontUVs?: Vector4;
  142585. backUVs?: Vector4;
  142586. instance?: Mesh;
  142587. invertUV?: boolean;
  142588. }, scene?: Nullable<Scene>): Mesh;
  142589. /**
  142590. * Creates an custom extruded shape mesh.
  142591. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  142592. * * 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.
  142593. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  142594. * * 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
  142595. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  142596. * * 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
  142597. * * It must returns a float value that will be the scale value applied to the shape on each path point
  142598. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  142599. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  142600. * * 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
  142601. * * 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
  142602. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  142603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142604. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142605. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142607. * @param name defines the name of the mesh
  142608. * @param options defines the options used to create the mesh
  142609. * @param scene defines the hosting scene
  142610. * @returns the custom extruded shape mesh
  142611. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  142612. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  142614. */
  142615. static ExtrudeShapeCustom(name: string, options: {
  142616. shape: Vector3[];
  142617. path: Vector3[];
  142618. scaleFunction?: any;
  142619. rotationFunction?: any;
  142620. ribbonCloseArray?: boolean;
  142621. ribbonClosePath?: boolean;
  142622. cap?: number;
  142623. updatable?: boolean;
  142624. sideOrientation?: number;
  142625. frontUVs?: Vector4;
  142626. backUVs?: Vector4;
  142627. instance?: Mesh;
  142628. invertUV?: boolean;
  142629. }, scene?: Nullable<Scene>): Mesh;
  142630. /**
  142631. * Creates lathe mesh.
  142632. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142633. * * 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
  142634. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142635. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142636. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142637. * * 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
  142638. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142639. * * 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
  142640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142641. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142642. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142644. * @param name defines the name of the mesh
  142645. * @param options defines the options used to create the mesh
  142646. * @param scene defines the hosting scene
  142647. * @returns the lathe mesh
  142648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142649. */
  142650. static CreateLathe(name: string, options: {
  142651. shape: Vector3[];
  142652. radius?: number;
  142653. tessellation?: number;
  142654. clip?: number;
  142655. arc?: number;
  142656. closed?: boolean;
  142657. updatable?: boolean;
  142658. sideOrientation?: number;
  142659. frontUVs?: Vector4;
  142660. backUVs?: Vector4;
  142661. cap?: number;
  142662. invertUV?: boolean;
  142663. }, scene?: Nullable<Scene>): Mesh;
  142664. /**
  142665. * Creates a tiled plane mesh
  142666. * * You can set a limited pattern arrangement with the tiles
  142667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142670. * @param name defines the name of the mesh
  142671. * @param options defines the options used to create the mesh
  142672. * @param scene defines the hosting scene
  142673. * @returns the plane mesh
  142674. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142675. */
  142676. static CreateTiledPlane(name: string, options: {
  142677. pattern?: number;
  142678. tileSize?: number;
  142679. tileWidth?: number;
  142680. tileHeight?: number;
  142681. size?: number;
  142682. width?: number;
  142683. height?: number;
  142684. alignHorizontal?: number;
  142685. alignVertical?: number;
  142686. sideOrientation?: number;
  142687. frontUVs?: Vector4;
  142688. backUVs?: Vector4;
  142689. updatable?: boolean;
  142690. }, scene?: Nullable<Scene>): Mesh;
  142691. /**
  142692. * Creates a plane mesh
  142693. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  142694. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  142695. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  142696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142699. * @param name defines the name of the mesh
  142700. * @param options defines the options used to create the mesh
  142701. * @param scene defines the hosting scene
  142702. * @returns the plane mesh
  142703. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  142704. */
  142705. static CreatePlane(name: string, options: {
  142706. size?: number;
  142707. width?: number;
  142708. height?: number;
  142709. sideOrientation?: number;
  142710. frontUVs?: Vector4;
  142711. backUVs?: Vector4;
  142712. updatable?: boolean;
  142713. sourcePlane?: Plane;
  142714. }, scene?: Nullable<Scene>): Mesh;
  142715. /**
  142716. * Creates a ground mesh
  142717. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  142718. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  142719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142720. * @param name defines the name of the mesh
  142721. * @param options defines the options used to create the mesh
  142722. * @param scene defines the hosting scene
  142723. * @returns the ground mesh
  142724. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  142725. */
  142726. static CreateGround(name: string, options: {
  142727. width?: number;
  142728. height?: number;
  142729. subdivisions?: number;
  142730. subdivisionsX?: number;
  142731. subdivisionsY?: number;
  142732. updatable?: boolean;
  142733. }, scene?: Nullable<Scene>): Mesh;
  142734. /**
  142735. * Creates a tiled ground mesh
  142736. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  142737. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  142738. * * 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
  142739. * * 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
  142740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142741. * @param name defines the name of the mesh
  142742. * @param options defines the options used to create the mesh
  142743. * @param scene defines the hosting scene
  142744. * @returns the tiled ground mesh
  142745. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  142746. */
  142747. static CreateTiledGround(name: string, options: {
  142748. xmin: number;
  142749. zmin: number;
  142750. xmax: number;
  142751. zmax: number;
  142752. subdivisions?: {
  142753. w: number;
  142754. h: number;
  142755. };
  142756. precision?: {
  142757. w: number;
  142758. h: number;
  142759. };
  142760. updatable?: boolean;
  142761. }, scene?: Nullable<Scene>): Mesh;
  142762. /**
  142763. * Creates a ground mesh from a height map
  142764. * * The parameter `url` sets the URL of the height map image resource.
  142765. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  142766. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  142767. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  142768. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  142769. * * 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.
  142770. * * 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).
  142771. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  142772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142773. * @param name defines the name of the mesh
  142774. * @param url defines the url to the height map
  142775. * @param options defines the options used to create the mesh
  142776. * @param scene defines the hosting scene
  142777. * @returns the ground mesh
  142778. * @see https://doc.babylonjs.com/babylon101/height_map
  142779. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  142780. */
  142781. static CreateGroundFromHeightMap(name: string, url: string, options: {
  142782. width?: number;
  142783. height?: number;
  142784. subdivisions?: number;
  142785. minHeight?: number;
  142786. maxHeight?: number;
  142787. colorFilter?: Color3;
  142788. alphaFilter?: number;
  142789. updatable?: boolean;
  142790. onReady?: (mesh: GroundMesh) => void;
  142791. }, scene?: Nullable<Scene>): GroundMesh;
  142792. /**
  142793. * Creates a polygon mesh
  142794. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142795. * * 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
  142796. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  142799. * * Remember you can only change the shape positions, not their number when updating a polygon
  142800. * @param name defines the name of the mesh
  142801. * @param options defines the options used to create the mesh
  142802. * @param scene defines the hosting scene
  142803. * @param earcutInjection can be used to inject your own earcut reference
  142804. * @returns the polygon mesh
  142805. */
  142806. static CreatePolygon(name: string, options: {
  142807. shape: Vector3[];
  142808. holes?: Vector3[][];
  142809. depth?: number;
  142810. faceUV?: Vector4[];
  142811. faceColors?: Color4[];
  142812. updatable?: boolean;
  142813. sideOrientation?: number;
  142814. frontUVs?: Vector4;
  142815. backUVs?: Vector4;
  142816. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142817. /**
  142818. * Creates an extruded polygon mesh, with depth in the Y direction.
  142819. * * 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)
  142820. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142821. * @param name defines the name of the mesh
  142822. * @param options defines the options used to create the mesh
  142823. * @param scene defines the hosting scene
  142824. * @param earcutInjection can be used to inject your own earcut reference
  142825. * @returns the polygon mesh
  142826. */
  142827. static ExtrudePolygon(name: string, options: {
  142828. shape: Vector3[];
  142829. holes?: Vector3[][];
  142830. depth?: number;
  142831. faceUV?: Vector4[];
  142832. faceColors?: Color4[];
  142833. updatable?: boolean;
  142834. sideOrientation?: number;
  142835. frontUVs?: Vector4;
  142836. backUVs?: Vector4;
  142837. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142838. /**
  142839. * Creates a tube mesh.
  142840. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  142841. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  142842. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  142843. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  142844. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  142845. * * 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)
  142846. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  142847. * * 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
  142848. * * 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
  142849. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142851. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142853. * @param name defines the name of the mesh
  142854. * @param options defines the options used to create the mesh
  142855. * @param scene defines the hosting scene
  142856. * @returns the tube mesh
  142857. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  142858. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  142859. */
  142860. static CreateTube(name: string, options: {
  142861. path: Vector3[];
  142862. radius?: number;
  142863. tessellation?: number;
  142864. radiusFunction?: {
  142865. (i: number, distance: number): number;
  142866. };
  142867. cap?: number;
  142868. arc?: number;
  142869. updatable?: boolean;
  142870. sideOrientation?: number;
  142871. frontUVs?: Vector4;
  142872. backUVs?: Vector4;
  142873. instance?: Mesh;
  142874. invertUV?: boolean;
  142875. }, scene?: Nullable<Scene>): Mesh;
  142876. /**
  142877. * Creates a polyhedron mesh
  142878. * * 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
  142879. * * The parameter `size` (positive float, default 1) sets the polygon size
  142880. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  142881. * * 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`
  142882. * * 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
  142883. * * 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)`)
  142884. * * 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
  142885. * * 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
  142886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142889. * @param name defines the name of the mesh
  142890. * @param options defines the options used to create the mesh
  142891. * @param scene defines the hosting scene
  142892. * @returns the polyhedron mesh
  142893. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  142894. */
  142895. static CreatePolyhedron(name: string, options: {
  142896. type?: number;
  142897. size?: number;
  142898. sizeX?: number;
  142899. sizeY?: number;
  142900. sizeZ?: number;
  142901. custom?: any;
  142902. faceUV?: Vector4[];
  142903. faceColors?: Color4[];
  142904. flat?: boolean;
  142905. updatable?: boolean;
  142906. sideOrientation?: number;
  142907. frontUVs?: Vector4;
  142908. backUVs?: Vector4;
  142909. }, scene?: Nullable<Scene>): Mesh;
  142910. /**
  142911. * Creates a decal mesh.
  142912. * 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
  142913. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  142914. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  142915. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  142916. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  142917. * @param name defines the name of the mesh
  142918. * @param sourceMesh defines the mesh where the decal must be applied
  142919. * @param options defines the options used to create the mesh
  142920. * @param scene defines the hosting scene
  142921. * @returns the decal mesh
  142922. * @see https://doc.babylonjs.com/how_to/decals
  142923. */
  142924. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  142925. position?: Vector3;
  142926. normal?: Vector3;
  142927. size?: Vector3;
  142928. angle?: number;
  142929. }): Mesh;
  142930. }
  142931. }
  142932. declare module BABYLON {
  142933. /**
  142934. * A simplifier interface for future simplification implementations
  142935. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142936. */
  142937. export interface ISimplifier {
  142938. /**
  142939. * Simplification of a given mesh according to the given settings.
  142940. * Since this requires computation, it is assumed that the function runs async.
  142941. * @param settings The settings of the simplification, including quality and distance
  142942. * @param successCallback A callback that will be called after the mesh was simplified.
  142943. * @param errorCallback in case of an error, this callback will be called. optional.
  142944. */
  142945. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  142946. }
  142947. /**
  142948. * Expected simplification settings.
  142949. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  142950. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142951. */
  142952. export interface ISimplificationSettings {
  142953. /**
  142954. * Gets or sets the expected quality
  142955. */
  142956. quality: number;
  142957. /**
  142958. * Gets or sets the distance when this optimized version should be used
  142959. */
  142960. distance: number;
  142961. /**
  142962. * Gets an already optimized mesh
  142963. */
  142964. optimizeMesh?: boolean;
  142965. }
  142966. /**
  142967. * Class used to specify simplification options
  142968. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  142969. */
  142970. export class SimplificationSettings implements ISimplificationSettings {
  142971. /** expected quality */
  142972. quality: number;
  142973. /** distance when this optimized version should be used */
  142974. distance: number;
  142975. /** already optimized mesh */
  142976. optimizeMesh?: boolean | undefined;
  142977. /**
  142978. * Creates a SimplificationSettings
  142979. * @param quality expected quality
  142980. * @param distance distance when this optimized version should be used
  142981. * @param optimizeMesh already optimized mesh
  142982. */
  142983. constructor(
  142984. /** expected quality */
  142985. quality: number,
  142986. /** distance when this optimized version should be used */
  142987. distance: number,
  142988. /** already optimized mesh */
  142989. optimizeMesh?: boolean | undefined);
  142990. }
  142991. /**
  142992. * Interface used to define a simplification task
  142993. */
  142994. export interface ISimplificationTask {
  142995. /**
  142996. * Array of settings
  142997. */
  142998. settings: Array<ISimplificationSettings>;
  142999. /**
  143000. * Simplification type
  143001. */
  143002. simplificationType: SimplificationType;
  143003. /**
  143004. * Mesh to simplify
  143005. */
  143006. mesh: Mesh;
  143007. /**
  143008. * Callback called on success
  143009. */
  143010. successCallback?: () => void;
  143011. /**
  143012. * Defines if parallel processing can be used
  143013. */
  143014. parallelProcessing: boolean;
  143015. }
  143016. /**
  143017. * Queue used to order the simplification tasks
  143018. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143019. */
  143020. export class SimplificationQueue {
  143021. private _simplificationArray;
  143022. /**
  143023. * Gets a boolean indicating that the process is still running
  143024. */
  143025. running: boolean;
  143026. /**
  143027. * Creates a new queue
  143028. */
  143029. constructor();
  143030. /**
  143031. * Adds a new simplification task
  143032. * @param task defines a task to add
  143033. */
  143034. addTask(task: ISimplificationTask): void;
  143035. /**
  143036. * Execute next task
  143037. */
  143038. executeNext(): void;
  143039. /**
  143040. * Execute a simplification task
  143041. * @param task defines the task to run
  143042. */
  143043. runSimplification(task: ISimplificationTask): void;
  143044. private getSimplifier;
  143045. }
  143046. /**
  143047. * The implemented types of simplification
  143048. * At the moment only Quadratic Error Decimation is implemented
  143049. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143050. */
  143051. export enum SimplificationType {
  143052. /** Quadratic error decimation */
  143053. QUADRATIC = 0
  143054. }
  143055. /**
  143056. * An implementation of the Quadratic Error simplification algorithm.
  143057. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143058. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143059. * @author RaananW
  143060. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143061. */
  143062. export class QuadraticErrorSimplification implements ISimplifier {
  143063. private _mesh;
  143064. private triangles;
  143065. private vertices;
  143066. private references;
  143067. private _reconstructedMesh;
  143068. /** Gets or sets the number pf sync interations */
  143069. syncIterations: number;
  143070. /** Gets or sets the aggressiveness of the simplifier */
  143071. aggressiveness: number;
  143072. /** Gets or sets the number of allowed iterations for decimation */
  143073. decimationIterations: number;
  143074. /** Gets or sets the espilon to use for bounding box computation */
  143075. boundingBoxEpsilon: number;
  143076. /**
  143077. * Creates a new QuadraticErrorSimplification
  143078. * @param _mesh defines the target mesh
  143079. */
  143080. constructor(_mesh: Mesh);
  143081. /**
  143082. * Simplification of a given mesh according to the given settings.
  143083. * Since this requires computation, it is assumed that the function runs async.
  143084. * @param settings The settings of the simplification, including quality and distance
  143085. * @param successCallback A callback that will be called after the mesh was simplified.
  143086. */
  143087. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  143088. private runDecimation;
  143089. private initWithMesh;
  143090. private init;
  143091. private reconstructMesh;
  143092. private initDecimatedMesh;
  143093. private isFlipped;
  143094. private updateTriangles;
  143095. private identifyBorder;
  143096. private updateMesh;
  143097. private vertexError;
  143098. private calculateError;
  143099. }
  143100. }
  143101. declare module BABYLON {
  143102. interface Scene {
  143103. /** @hidden (Backing field) */
  143104. _simplificationQueue: SimplificationQueue;
  143105. /**
  143106. * Gets or sets the simplification queue attached to the scene
  143107. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143108. */
  143109. simplificationQueue: SimplificationQueue;
  143110. }
  143111. interface Mesh {
  143112. /**
  143113. * Simplify the mesh according to the given array of settings.
  143114. * Function will return immediately and will simplify async
  143115. * @param settings a collection of simplification settings
  143116. * @param parallelProcessing should all levels calculate parallel or one after the other
  143117. * @param simplificationType the type of simplification to run
  143118. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  143119. * @returns the current mesh
  143120. */
  143121. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  143122. }
  143123. /**
  143124. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  143125. * created in a scene
  143126. */
  143127. export class SimplicationQueueSceneComponent implements ISceneComponent {
  143128. /**
  143129. * The component name helpfull to identify the component in the list of scene components.
  143130. */
  143131. readonly name: string;
  143132. /**
  143133. * The scene the component belongs to.
  143134. */
  143135. scene: Scene;
  143136. /**
  143137. * Creates a new instance of the component for the given scene
  143138. * @param scene Defines the scene to register the component in
  143139. */
  143140. constructor(scene: Scene);
  143141. /**
  143142. * Registers the component in a given scene
  143143. */
  143144. register(): void;
  143145. /**
  143146. * Rebuilds the elements related to this component in case of
  143147. * context lost for instance.
  143148. */
  143149. rebuild(): void;
  143150. /**
  143151. * Disposes the component and the associated ressources
  143152. */
  143153. dispose(): void;
  143154. private _beforeCameraUpdate;
  143155. }
  143156. }
  143157. declare module BABYLON {
  143158. interface Mesh {
  143159. /**
  143160. * Creates a new thin instance
  143161. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  143162. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  143163. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  143164. */
  143165. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  143166. /**
  143167. * Adds the transformation (matrix) of the current mesh as a thin instance
  143168. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  143169. * @returns the thin instance index number
  143170. */
  143171. thinInstanceAddSelf(refresh: boolean): number;
  143172. /**
  143173. * Registers a custom attribute to be used with thin instances
  143174. * @param kind name of the attribute
  143175. * @param stride size in floats of the attribute
  143176. */
  143177. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  143178. /**
  143179. * Sets the matrix of a thin instance
  143180. * @param index index of the thin instance
  143181. * @param matrix matrix to set
  143182. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  143183. */
  143184. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  143185. /**
  143186. * Sets the value of a custom attribute for a thin instance
  143187. * @param kind name of the attribute
  143188. * @param index index of the thin instance
  143189. * @param value value to set
  143190. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  143191. */
  143192. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  143193. /**
  143194. * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
  143195. */
  143196. thinInstanceCount: number;
  143197. /**
  143198. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  143199. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  143200. * @param buffer buffer to set
  143201. * @param stride size in floats of each value of the buffer
  143202. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  143203. */
  143204. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  143205. /**
  143206. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  143207. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  143208. */
  143209. thinInstanceBufferUpdated(kind: string): void;
  143210. /**
  143211. * Refreshes the bounding info, taking into account all the thin instances defined
  143212. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  143213. */
  143214. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  143215. /** @hidden */
  143216. _thinInstanceInitializeUserStorage(): void;
  143217. /** @hidden */
  143218. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  143219. /** @hidden */
  143220. _userThinInstanceBuffersStorage: {
  143221. data: {
  143222. [key: string]: Float32Array;
  143223. };
  143224. sizes: {
  143225. [key: string]: number;
  143226. };
  143227. vertexBuffers: {
  143228. [key: string]: Nullable<VertexBuffer>;
  143229. };
  143230. strides: {
  143231. [key: string]: number;
  143232. };
  143233. };
  143234. }
  143235. }
  143236. declare module BABYLON {
  143237. /**
  143238. * Navigation plugin interface to add navigation constrained by a navigation mesh
  143239. */
  143240. export interface INavigationEnginePlugin {
  143241. /**
  143242. * plugin name
  143243. */
  143244. name: string;
  143245. /**
  143246. * Creates a navigation mesh
  143247. * @param meshes array of all the geometry used to compute the navigatio mesh
  143248. * @param parameters bunch of parameters used to filter geometry
  143249. */
  143250. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143251. /**
  143252. * Create a navigation mesh debug mesh
  143253. * @param scene is where the mesh will be added
  143254. * @returns debug display mesh
  143255. */
  143256. createDebugNavMesh(scene: Scene): Mesh;
  143257. /**
  143258. * Get a navigation mesh constrained position, closest to the parameter position
  143259. * @param position world position
  143260. * @returns the closest point to position constrained by the navigation mesh
  143261. */
  143262. getClosestPoint(position: Vector3): Vector3;
  143263. /**
  143264. * Get a navigation mesh constrained position, closest to the parameter position
  143265. * @param position world position
  143266. * @param result output the closest point to position constrained by the navigation mesh
  143267. */
  143268. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143269. /**
  143270. * Get a navigation mesh constrained position, within a particular radius
  143271. * @param position world position
  143272. * @param maxRadius the maximum distance to the constrained world position
  143273. * @returns the closest point to position constrained by the navigation mesh
  143274. */
  143275. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143276. /**
  143277. * Get a navigation mesh constrained position, within a particular radius
  143278. * @param position world position
  143279. * @param maxRadius the maximum distance to the constrained world position
  143280. * @param result output the closest point to position constrained by the navigation mesh
  143281. */
  143282. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143283. /**
  143284. * Compute the final position from a segment made of destination-position
  143285. * @param position world position
  143286. * @param destination world position
  143287. * @returns the resulting point along the navmesh
  143288. */
  143289. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143290. /**
  143291. * Compute the final position from a segment made of destination-position
  143292. * @param position world position
  143293. * @param destination world position
  143294. * @param result output the resulting point along the navmesh
  143295. */
  143296. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143297. /**
  143298. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143299. * @param start world position
  143300. * @param end world position
  143301. * @returns array containing world position composing the path
  143302. */
  143303. computePath(start: Vector3, end: Vector3): Vector3[];
  143304. /**
  143305. * If this plugin is supported
  143306. * @returns true if plugin is supported
  143307. */
  143308. isSupported(): boolean;
  143309. /**
  143310. * Create a new Crowd so you can add agents
  143311. * @param maxAgents the maximum agent count in the crowd
  143312. * @param maxAgentRadius the maximum radius an agent can have
  143313. * @param scene to attach the crowd to
  143314. * @returns the crowd you can add agents to
  143315. */
  143316. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143317. /**
  143318. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143319. * The queries will try to find a solution within those bounds
  143320. * default is (1,1,1)
  143321. * @param extent x,y,z value that define the extent around the queries point of reference
  143322. */
  143323. setDefaultQueryExtent(extent: Vector3): void;
  143324. /**
  143325. * Get the Bounding box extent specified by setDefaultQueryExtent
  143326. * @returns the box extent values
  143327. */
  143328. getDefaultQueryExtent(): Vector3;
  143329. /**
  143330. * build the navmesh from a previously saved state using getNavmeshData
  143331. * @param data the Uint8Array returned by getNavmeshData
  143332. */
  143333. buildFromNavmeshData(data: Uint8Array): void;
  143334. /**
  143335. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143336. * @returns data the Uint8Array that can be saved and reused
  143337. */
  143338. getNavmeshData(): Uint8Array;
  143339. /**
  143340. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143341. * @param result output the box extent values
  143342. */
  143343. getDefaultQueryExtentToRef(result: Vector3): void;
  143344. /**
  143345. * Release all resources
  143346. */
  143347. dispose(): void;
  143348. }
  143349. /**
  143350. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  143351. */
  143352. export interface ICrowd {
  143353. /**
  143354. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143355. * You can attach anything to that node. The node position is updated in the scene update tick.
  143356. * @param pos world position that will be constrained by the navigation mesh
  143357. * @param parameters agent parameters
  143358. * @param transform hooked to the agent that will be update by the scene
  143359. * @returns agent index
  143360. */
  143361. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143362. /**
  143363. * Returns the agent position in world space
  143364. * @param index agent index returned by addAgent
  143365. * @returns world space position
  143366. */
  143367. getAgentPosition(index: number): Vector3;
  143368. /**
  143369. * Gets the agent position result in world space
  143370. * @param index agent index returned by addAgent
  143371. * @param result output world space position
  143372. */
  143373. getAgentPositionToRef(index: number, result: Vector3): void;
  143374. /**
  143375. * Gets the agent velocity in world space
  143376. * @param index agent index returned by addAgent
  143377. * @returns world space velocity
  143378. */
  143379. getAgentVelocity(index: number): Vector3;
  143380. /**
  143381. * Gets the agent velocity result in world space
  143382. * @param index agent index returned by addAgent
  143383. * @param result output world space velocity
  143384. */
  143385. getAgentVelocityToRef(index: number, result: Vector3): void;
  143386. /**
  143387. * remove a particular agent previously created
  143388. * @param index agent index returned by addAgent
  143389. */
  143390. removeAgent(index: number): void;
  143391. /**
  143392. * get the list of all agents attached to this crowd
  143393. * @returns list of agent indices
  143394. */
  143395. getAgents(): number[];
  143396. /**
  143397. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143398. * @param deltaTime in seconds
  143399. */
  143400. update(deltaTime: number): void;
  143401. /**
  143402. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143403. * @param index agent index returned by addAgent
  143404. * @param destination targeted world position
  143405. */
  143406. agentGoto(index: number, destination: Vector3): void;
  143407. /**
  143408. * Teleport the agent to a new position
  143409. * @param index agent index returned by addAgent
  143410. * @param destination targeted world position
  143411. */
  143412. agentTeleport(index: number, destination: Vector3): void;
  143413. /**
  143414. * Update agent parameters
  143415. * @param index agent index returned by addAgent
  143416. * @param parameters agent parameters
  143417. */
  143418. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143419. /**
  143420. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143421. * The queries will try to find a solution within those bounds
  143422. * default is (1,1,1)
  143423. * @param extent x,y,z value that define the extent around the queries point of reference
  143424. */
  143425. setDefaultQueryExtent(extent: Vector3): void;
  143426. /**
  143427. * Get the Bounding box extent specified by setDefaultQueryExtent
  143428. * @returns the box extent values
  143429. */
  143430. getDefaultQueryExtent(): Vector3;
  143431. /**
  143432. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143433. * @param result output the box extent values
  143434. */
  143435. getDefaultQueryExtentToRef(result: Vector3): void;
  143436. /**
  143437. * Release all resources
  143438. */
  143439. dispose(): void;
  143440. }
  143441. /**
  143442. * Configures an agent
  143443. */
  143444. export interface IAgentParameters {
  143445. /**
  143446. * Agent radius. [Limit: >= 0]
  143447. */
  143448. radius: number;
  143449. /**
  143450. * Agent height. [Limit: > 0]
  143451. */
  143452. height: number;
  143453. /**
  143454. * Maximum allowed acceleration. [Limit: >= 0]
  143455. */
  143456. maxAcceleration: number;
  143457. /**
  143458. * Maximum allowed speed. [Limit: >= 0]
  143459. */
  143460. maxSpeed: number;
  143461. /**
  143462. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  143463. */
  143464. collisionQueryRange: number;
  143465. /**
  143466. * The path visibility optimization range. [Limit: > 0]
  143467. */
  143468. pathOptimizationRange: number;
  143469. /**
  143470. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  143471. */
  143472. separationWeight: number;
  143473. }
  143474. /**
  143475. * Configures the navigation mesh creation
  143476. */
  143477. export interface INavMeshParameters {
  143478. /**
  143479. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  143480. */
  143481. cs: number;
  143482. /**
  143483. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  143484. */
  143485. ch: number;
  143486. /**
  143487. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  143488. */
  143489. walkableSlopeAngle: number;
  143490. /**
  143491. * Minimum floor to 'ceiling' height that will still allow the floor area to
  143492. * be considered walkable. [Limit: >= 3] [Units: vx]
  143493. */
  143494. walkableHeight: number;
  143495. /**
  143496. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  143497. */
  143498. walkableClimb: number;
  143499. /**
  143500. * The distance to erode/shrink the walkable area of the heightfield away from
  143501. * obstructions. [Limit: >=0] [Units: vx]
  143502. */
  143503. walkableRadius: number;
  143504. /**
  143505. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  143506. */
  143507. maxEdgeLen: number;
  143508. /**
  143509. * The maximum distance a simplfied contour's border edges should deviate
  143510. * the original raw contour. [Limit: >=0] [Units: vx]
  143511. */
  143512. maxSimplificationError: number;
  143513. /**
  143514. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  143515. */
  143516. minRegionArea: number;
  143517. /**
  143518. * Any regions with a span count smaller than this value will, if possible,
  143519. * be merged with larger regions. [Limit: >=0] [Units: vx]
  143520. */
  143521. mergeRegionArea: number;
  143522. /**
  143523. * The maximum number of vertices allowed for polygons generated during the
  143524. * contour to polygon conversion process. [Limit: >= 3]
  143525. */
  143526. maxVertsPerPoly: number;
  143527. /**
  143528. * Sets the sampling distance to use when generating the detail mesh.
  143529. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  143530. */
  143531. detailSampleDist: number;
  143532. /**
  143533. * The maximum distance the detail mesh surface should deviate from heightfield
  143534. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  143535. */
  143536. detailSampleMaxError: number;
  143537. }
  143538. }
  143539. declare module BABYLON {
  143540. /**
  143541. * RecastJS navigation plugin
  143542. */
  143543. export class RecastJSPlugin implements INavigationEnginePlugin {
  143544. /**
  143545. * Reference to the Recast library
  143546. */
  143547. bjsRECAST: any;
  143548. /**
  143549. * plugin name
  143550. */
  143551. name: string;
  143552. /**
  143553. * the first navmesh created. We might extend this to support multiple navmeshes
  143554. */
  143555. navMesh: any;
  143556. /**
  143557. * Initializes the recastJS plugin
  143558. * @param recastInjection can be used to inject your own recast reference
  143559. */
  143560. constructor(recastInjection?: any);
  143561. /**
  143562. * Creates a navigation mesh
  143563. * @param meshes array of all the geometry used to compute the navigatio mesh
  143564. * @param parameters bunch of parameters used to filter geometry
  143565. */
  143566. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  143567. /**
  143568. * Create a navigation mesh debug mesh
  143569. * @param scene is where the mesh will be added
  143570. * @returns debug display mesh
  143571. */
  143572. createDebugNavMesh(scene: Scene): Mesh;
  143573. /**
  143574. * Get a navigation mesh constrained position, closest to the parameter position
  143575. * @param position world position
  143576. * @returns the closest point to position constrained by the navigation mesh
  143577. */
  143578. getClosestPoint(position: Vector3): Vector3;
  143579. /**
  143580. * Get a navigation mesh constrained position, closest to the parameter position
  143581. * @param position world position
  143582. * @param result output the closest point to position constrained by the navigation mesh
  143583. */
  143584. getClosestPointToRef(position: Vector3, result: Vector3): void;
  143585. /**
  143586. * Get a navigation mesh constrained position, within a particular radius
  143587. * @param position world position
  143588. * @param maxRadius the maximum distance to the constrained world position
  143589. * @returns the closest point to position constrained by the navigation mesh
  143590. */
  143591. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  143592. /**
  143593. * Get a navigation mesh constrained position, within a particular radius
  143594. * @param position world position
  143595. * @param maxRadius the maximum distance to the constrained world position
  143596. * @param result output the closest point to position constrained by the navigation mesh
  143597. */
  143598. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  143599. /**
  143600. * Compute the final position from a segment made of destination-position
  143601. * @param position world position
  143602. * @param destination world position
  143603. * @returns the resulting point along the navmesh
  143604. */
  143605. moveAlong(position: Vector3, destination: Vector3): Vector3;
  143606. /**
  143607. * Compute the final position from a segment made of destination-position
  143608. * @param position world position
  143609. * @param destination world position
  143610. * @param result output the resulting point along the navmesh
  143611. */
  143612. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  143613. /**
  143614. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  143615. * @param start world position
  143616. * @param end world position
  143617. * @returns array containing world position composing the path
  143618. */
  143619. computePath(start: Vector3, end: Vector3): Vector3[];
  143620. /**
  143621. * Create a new Crowd so you can add agents
  143622. * @param maxAgents the maximum agent count in the crowd
  143623. * @param maxAgentRadius the maximum radius an agent can have
  143624. * @param scene to attach the crowd to
  143625. * @returns the crowd you can add agents to
  143626. */
  143627. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  143628. /**
  143629. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143630. * The queries will try to find a solution within those bounds
  143631. * default is (1,1,1)
  143632. * @param extent x,y,z value that define the extent around the queries point of reference
  143633. */
  143634. setDefaultQueryExtent(extent: Vector3): void;
  143635. /**
  143636. * Get the Bounding box extent specified by setDefaultQueryExtent
  143637. * @returns the box extent values
  143638. */
  143639. getDefaultQueryExtent(): Vector3;
  143640. /**
  143641. * build the navmesh from a previously saved state using getNavmeshData
  143642. * @param data the Uint8Array returned by getNavmeshData
  143643. */
  143644. buildFromNavmeshData(data: Uint8Array): void;
  143645. /**
  143646. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  143647. * @returns data the Uint8Array that can be saved and reused
  143648. */
  143649. getNavmeshData(): Uint8Array;
  143650. /**
  143651. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143652. * @param result output the box extent values
  143653. */
  143654. getDefaultQueryExtentToRef(result: Vector3): void;
  143655. /**
  143656. * Disposes
  143657. */
  143658. dispose(): void;
  143659. /**
  143660. * If this plugin is supported
  143661. * @returns true if plugin is supported
  143662. */
  143663. isSupported(): boolean;
  143664. }
  143665. /**
  143666. * Recast detour crowd implementation
  143667. */
  143668. export class RecastJSCrowd implements ICrowd {
  143669. /**
  143670. * Recast/detour plugin
  143671. */
  143672. bjsRECASTPlugin: RecastJSPlugin;
  143673. /**
  143674. * Link to the detour crowd
  143675. */
  143676. recastCrowd: any;
  143677. /**
  143678. * One transform per agent
  143679. */
  143680. transforms: TransformNode[];
  143681. /**
  143682. * All agents created
  143683. */
  143684. agents: number[];
  143685. /**
  143686. * Link to the scene is kept to unregister the crowd from the scene
  143687. */
  143688. private _scene;
  143689. /**
  143690. * Observer for crowd updates
  143691. */
  143692. private _onBeforeAnimationsObserver;
  143693. /**
  143694. * Constructor
  143695. * @param plugin recastJS plugin
  143696. * @param maxAgents the maximum agent count in the crowd
  143697. * @param maxAgentRadius the maximum radius an agent can have
  143698. * @param scene to attach the crowd to
  143699. * @returns the crowd you can add agents to
  143700. */
  143701. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  143702. /**
  143703. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  143704. * You can attach anything to that node. The node position is updated in the scene update tick.
  143705. * @param pos world position that will be constrained by the navigation mesh
  143706. * @param parameters agent parameters
  143707. * @param transform hooked to the agent that will be update by the scene
  143708. * @returns agent index
  143709. */
  143710. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  143711. /**
  143712. * Returns the agent position in world space
  143713. * @param index agent index returned by addAgent
  143714. * @returns world space position
  143715. */
  143716. getAgentPosition(index: number): Vector3;
  143717. /**
  143718. * Returns the agent position result in world space
  143719. * @param index agent index returned by addAgent
  143720. * @param result output world space position
  143721. */
  143722. getAgentPositionToRef(index: number, result: Vector3): void;
  143723. /**
  143724. * Returns the agent velocity in world space
  143725. * @param index agent index returned by addAgent
  143726. * @returns world space velocity
  143727. */
  143728. getAgentVelocity(index: number): Vector3;
  143729. /**
  143730. * Returns the agent velocity result in world space
  143731. * @param index agent index returned by addAgent
  143732. * @param result output world space velocity
  143733. */
  143734. getAgentVelocityToRef(index: number, result: Vector3): void;
  143735. /**
  143736. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  143737. * @param index agent index returned by addAgent
  143738. * @param destination targeted world position
  143739. */
  143740. agentGoto(index: number, destination: Vector3): void;
  143741. /**
  143742. * Teleport the agent to a new position
  143743. * @param index agent index returned by addAgent
  143744. * @param destination targeted world position
  143745. */
  143746. agentTeleport(index: number, destination: Vector3): void;
  143747. /**
  143748. * Update agent parameters
  143749. * @param index agent index returned by addAgent
  143750. * @param parameters agent parameters
  143751. */
  143752. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  143753. /**
  143754. * remove a particular agent previously created
  143755. * @param index agent index returned by addAgent
  143756. */
  143757. removeAgent(index: number): void;
  143758. /**
  143759. * get the list of all agents attached to this crowd
  143760. * @returns list of agent indices
  143761. */
  143762. getAgents(): number[];
  143763. /**
  143764. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  143765. * @param deltaTime in seconds
  143766. */
  143767. update(deltaTime: number): void;
  143768. /**
  143769. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  143770. * The queries will try to find a solution within those bounds
  143771. * default is (1,1,1)
  143772. * @param extent x,y,z value that define the extent around the queries point of reference
  143773. */
  143774. setDefaultQueryExtent(extent: Vector3): void;
  143775. /**
  143776. * Get the Bounding box extent specified by setDefaultQueryExtent
  143777. * @returns the box extent values
  143778. */
  143779. getDefaultQueryExtent(): Vector3;
  143780. /**
  143781. * Get the Bounding box extent result specified by setDefaultQueryExtent
  143782. * @param result output the box extent values
  143783. */
  143784. getDefaultQueryExtentToRef(result: Vector3): void;
  143785. /**
  143786. * Release all resources
  143787. */
  143788. dispose(): void;
  143789. }
  143790. }
  143791. declare module BABYLON {
  143792. /**
  143793. * Class used to enable access to IndexedDB
  143794. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  143795. */
  143796. export class Database implements IOfflineProvider {
  143797. private _callbackManifestChecked;
  143798. private _currentSceneUrl;
  143799. private _db;
  143800. private _enableSceneOffline;
  143801. private _enableTexturesOffline;
  143802. private _manifestVersionFound;
  143803. private _mustUpdateRessources;
  143804. private _hasReachedQuota;
  143805. private _isSupported;
  143806. private _idbFactory;
  143807. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  143808. private static IsUASupportingBlobStorage;
  143809. /**
  143810. * Gets a boolean indicating if Database storate is enabled (off by default)
  143811. */
  143812. static IDBStorageEnabled: boolean;
  143813. /**
  143814. * Gets a boolean indicating if scene must be saved in the database
  143815. */
  143816. get enableSceneOffline(): boolean;
  143817. /**
  143818. * Gets a boolean indicating if textures must be saved in the database
  143819. */
  143820. get enableTexturesOffline(): boolean;
  143821. /**
  143822. * Creates a new Database
  143823. * @param urlToScene defines the url to load the scene
  143824. * @param callbackManifestChecked defines the callback to use when manifest is checked
  143825. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  143826. */
  143827. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  143828. private static _ParseURL;
  143829. private static _ReturnFullUrlLocation;
  143830. private _checkManifestFile;
  143831. /**
  143832. * Open the database and make it available
  143833. * @param successCallback defines the callback to call on success
  143834. * @param errorCallback defines the callback to call on error
  143835. */
  143836. open(successCallback: () => void, errorCallback: () => void): void;
  143837. /**
  143838. * Loads an image from the database
  143839. * @param url defines the url to load from
  143840. * @param image defines the target DOM image
  143841. */
  143842. loadImage(url: string, image: HTMLImageElement): void;
  143843. private _loadImageFromDBAsync;
  143844. private _saveImageIntoDBAsync;
  143845. private _checkVersionFromDB;
  143846. private _loadVersionFromDBAsync;
  143847. private _saveVersionIntoDBAsync;
  143848. /**
  143849. * Loads a file from database
  143850. * @param url defines the URL to load from
  143851. * @param sceneLoaded defines a callback to call on success
  143852. * @param progressCallBack defines a callback to call when progress changed
  143853. * @param errorCallback defines a callback to call on error
  143854. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  143855. */
  143856. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  143857. private _loadFileAsync;
  143858. private _saveFileAsync;
  143859. /**
  143860. * Validates if xhr data is correct
  143861. * @param xhr defines the request to validate
  143862. * @param dataType defines the expected data type
  143863. * @returns true if data is correct
  143864. */
  143865. private static _ValidateXHRData;
  143866. }
  143867. }
  143868. declare module BABYLON {
  143869. /** @hidden */
  143870. export var gpuUpdateParticlesPixelShader: {
  143871. name: string;
  143872. shader: string;
  143873. };
  143874. }
  143875. declare module BABYLON {
  143876. /** @hidden */
  143877. export var gpuUpdateParticlesVertexShader: {
  143878. name: string;
  143879. shader: string;
  143880. };
  143881. }
  143882. declare module BABYLON {
  143883. /** @hidden */
  143884. export var clipPlaneFragmentDeclaration2: {
  143885. name: string;
  143886. shader: string;
  143887. };
  143888. }
  143889. declare module BABYLON {
  143890. /** @hidden */
  143891. export var gpuRenderParticlesPixelShader: {
  143892. name: string;
  143893. shader: string;
  143894. };
  143895. }
  143896. declare module BABYLON {
  143897. /** @hidden */
  143898. export var clipPlaneVertexDeclaration2: {
  143899. name: string;
  143900. shader: string;
  143901. };
  143902. }
  143903. declare module BABYLON {
  143904. /** @hidden */
  143905. export var gpuRenderParticlesVertexShader: {
  143906. name: string;
  143907. shader: string;
  143908. };
  143909. }
  143910. declare module BABYLON {
  143911. /**
  143912. * This represents a GPU particle system in Babylon
  143913. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  143914. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  143915. */
  143916. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  143917. /**
  143918. * The layer mask we are rendering the particles through.
  143919. */
  143920. layerMask: number;
  143921. private _capacity;
  143922. private _activeCount;
  143923. private _currentActiveCount;
  143924. private _accumulatedCount;
  143925. private _renderEffect;
  143926. private _updateEffect;
  143927. private _buffer0;
  143928. private _buffer1;
  143929. private _spriteBuffer;
  143930. private _updateVAO;
  143931. private _renderVAO;
  143932. private _targetIndex;
  143933. private _sourceBuffer;
  143934. private _targetBuffer;
  143935. private _engine;
  143936. private _currentRenderId;
  143937. private _started;
  143938. private _stopped;
  143939. private _timeDelta;
  143940. private _randomTexture;
  143941. private _randomTexture2;
  143942. private _attributesStrideSize;
  143943. private _updateEffectOptions;
  143944. private _randomTextureSize;
  143945. private _actualFrame;
  143946. private _customEffect;
  143947. private readonly _rawTextureWidth;
  143948. /**
  143949. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  143950. */
  143951. static get IsSupported(): boolean;
  143952. /**
  143953. * An event triggered when the system is disposed.
  143954. */
  143955. onDisposeObservable: Observable<IParticleSystem>;
  143956. /**
  143957. * Gets the maximum number of particles active at the same time.
  143958. * @returns The max number of active particles.
  143959. */
  143960. getCapacity(): number;
  143961. /**
  143962. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  143963. * to override the particles.
  143964. */
  143965. forceDepthWrite: boolean;
  143966. /**
  143967. * Gets or set the number of active particles
  143968. */
  143969. get activeParticleCount(): number;
  143970. set activeParticleCount(value: number);
  143971. private _preWarmDone;
  143972. /**
  143973. * Specifies if the particles are updated in emitter local space or world space.
  143974. */
  143975. isLocal: boolean;
  143976. /**
  143977. * Is this system ready to be used/rendered
  143978. * @return true if the system is ready
  143979. */
  143980. isReady(): boolean;
  143981. /**
  143982. * Gets if the system has been started. (Note: this will still be true after stop is called)
  143983. * @returns True if it has been started, otherwise false.
  143984. */
  143985. isStarted(): boolean;
  143986. /**
  143987. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  143988. * @returns True if it has been stopped, otherwise false.
  143989. */
  143990. isStopped(): boolean;
  143991. /**
  143992. * Gets a boolean indicating that the system is stopping
  143993. * @returns true if the system is currently stopping
  143994. */
  143995. isStopping(): boolean;
  143996. /**
  143997. * Gets the number of particles active at the same time.
  143998. * @returns The number of active particles.
  143999. */
  144000. getActiveCount(): number;
  144001. /**
  144002. * Starts the particle system and begins to emit
  144003. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  144004. */
  144005. start(delay?: number): void;
  144006. /**
  144007. * Stops the particle system.
  144008. */
  144009. stop(): void;
  144010. /**
  144011. * Remove all active particles
  144012. */
  144013. reset(): void;
  144014. /**
  144015. * Returns the string "GPUParticleSystem"
  144016. * @returns a string containing the class name
  144017. */
  144018. getClassName(): string;
  144019. /**
  144020. * Gets the custom effect used to render the particles
  144021. * @param blendMode Blend mode for which the effect should be retrieved
  144022. * @returns The effect
  144023. */
  144024. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144025. /**
  144026. * Sets the custom effect used to render the particles
  144027. * @param effect The effect to set
  144028. * @param blendMode Blend mode for which the effect should be set
  144029. */
  144030. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144031. /** @hidden */
  144032. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144033. /**
  144034. * Observable that will be called just before the particles are drawn
  144035. */
  144036. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144037. /**
  144038. * Gets the name of the particle vertex shader
  144039. */
  144040. get vertexShaderName(): string;
  144041. private _colorGradientsTexture;
  144042. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144043. /**
  144044. * Adds a new color gradient
  144045. * @param gradient defines the gradient to use (between 0 and 1)
  144046. * @param color1 defines the color to affect to the specified gradient
  144047. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144048. * @returns the current particle system
  144049. */
  144050. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144051. private _refreshColorGradient;
  144052. /** Force the system to rebuild all gradients that need to be resync */
  144053. forceRefreshGradients(): void;
  144054. /**
  144055. * Remove a specific color gradient
  144056. * @param gradient defines the gradient to remove
  144057. * @returns the current particle system
  144058. */
  144059. removeColorGradient(gradient: number): GPUParticleSystem;
  144060. private _angularSpeedGradientsTexture;
  144061. private _sizeGradientsTexture;
  144062. private _velocityGradientsTexture;
  144063. private _limitVelocityGradientsTexture;
  144064. private _dragGradientsTexture;
  144065. private _addFactorGradient;
  144066. /**
  144067. * Adds a new size gradient
  144068. * @param gradient defines the gradient to use (between 0 and 1)
  144069. * @param factor defines the size factor to affect to the specified gradient
  144070. * @returns the current particle system
  144071. */
  144072. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  144073. /**
  144074. * Remove a specific size gradient
  144075. * @param gradient defines the gradient to remove
  144076. * @returns the current particle system
  144077. */
  144078. removeSizeGradient(gradient: number): GPUParticleSystem;
  144079. private _refreshFactorGradient;
  144080. /**
  144081. * Adds a new angular speed gradient
  144082. * @param gradient defines the gradient to use (between 0 and 1)
  144083. * @param factor defines the angular speed to affect to the specified gradient
  144084. * @returns the current particle system
  144085. */
  144086. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  144087. /**
  144088. * Remove a specific angular speed gradient
  144089. * @param gradient defines the gradient to remove
  144090. * @returns the current particle system
  144091. */
  144092. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  144093. /**
  144094. * Adds a new velocity gradient
  144095. * @param gradient defines the gradient to use (between 0 and 1)
  144096. * @param factor defines the velocity to affect to the specified gradient
  144097. * @returns the current particle system
  144098. */
  144099. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144100. /**
  144101. * Remove a specific velocity gradient
  144102. * @param gradient defines the gradient to remove
  144103. * @returns the current particle system
  144104. */
  144105. removeVelocityGradient(gradient: number): GPUParticleSystem;
  144106. /**
  144107. * Adds a new limit velocity gradient
  144108. * @param gradient defines the gradient to use (between 0 and 1)
  144109. * @param factor defines the limit velocity value to affect to the specified gradient
  144110. * @returns the current particle system
  144111. */
  144112. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  144113. /**
  144114. * Remove a specific limit velocity gradient
  144115. * @param gradient defines the gradient to remove
  144116. * @returns the current particle system
  144117. */
  144118. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  144119. /**
  144120. * Adds a new drag gradient
  144121. * @param gradient defines the gradient to use (between 0 and 1)
  144122. * @param factor defines the drag value to affect to the specified gradient
  144123. * @returns the current particle system
  144124. */
  144125. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  144126. /**
  144127. * Remove a specific drag gradient
  144128. * @param gradient defines the gradient to remove
  144129. * @returns the current particle system
  144130. */
  144131. removeDragGradient(gradient: number): GPUParticleSystem;
  144132. /**
  144133. * Not supported by GPUParticleSystem
  144134. * @param gradient defines the gradient to use (between 0 and 1)
  144135. * @param factor defines the emit rate value to affect to the specified gradient
  144136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144137. * @returns the current particle system
  144138. */
  144139. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144140. /**
  144141. * Not supported by GPUParticleSystem
  144142. * @param gradient defines the gradient to remove
  144143. * @returns the current particle system
  144144. */
  144145. removeEmitRateGradient(gradient: number): IParticleSystem;
  144146. /**
  144147. * Not supported by GPUParticleSystem
  144148. * @param gradient defines the gradient to use (between 0 and 1)
  144149. * @param factor defines the start size value to affect to the specified gradient
  144150. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144151. * @returns the current particle system
  144152. */
  144153. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144154. /**
  144155. * Not supported by GPUParticleSystem
  144156. * @param gradient defines the gradient to remove
  144157. * @returns the current particle system
  144158. */
  144159. removeStartSizeGradient(gradient: number): IParticleSystem;
  144160. /**
  144161. * Not supported by GPUParticleSystem
  144162. * @param gradient defines the gradient to use (between 0 and 1)
  144163. * @param min defines the color remap minimal range
  144164. * @param max defines the color remap maximal range
  144165. * @returns the current particle system
  144166. */
  144167. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144168. /**
  144169. * Not supported by GPUParticleSystem
  144170. * @param gradient defines the gradient to remove
  144171. * @returns the current particle system
  144172. */
  144173. removeColorRemapGradient(): IParticleSystem;
  144174. /**
  144175. * Not supported by GPUParticleSystem
  144176. * @param gradient defines the gradient to use (between 0 and 1)
  144177. * @param min defines the alpha remap minimal range
  144178. * @param max defines the alpha remap maximal range
  144179. * @returns the current particle system
  144180. */
  144181. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  144182. /**
  144183. * Not supported by GPUParticleSystem
  144184. * @param gradient defines the gradient to remove
  144185. * @returns the current particle system
  144186. */
  144187. removeAlphaRemapGradient(): IParticleSystem;
  144188. /**
  144189. * Not supported by GPUParticleSystem
  144190. * @param gradient defines the gradient to use (between 0 and 1)
  144191. * @param color defines the color to affect to the specified gradient
  144192. * @returns the current particle system
  144193. */
  144194. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  144195. /**
  144196. * Not supported by GPUParticleSystem
  144197. * @param gradient defines the gradient to remove
  144198. * @returns the current particle system
  144199. */
  144200. removeRampGradient(): IParticleSystem;
  144201. /**
  144202. * Not supported by GPUParticleSystem
  144203. * @returns the list of ramp gradients
  144204. */
  144205. getRampGradients(): Nullable<Array<Color3Gradient>>;
  144206. /**
  144207. * Not supported by GPUParticleSystem
  144208. * Gets or sets a boolean indicating that ramp gradients must be used
  144209. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  144210. */
  144211. get useRampGradients(): boolean;
  144212. set useRampGradients(value: boolean);
  144213. /**
  144214. * Not supported by GPUParticleSystem
  144215. * @param gradient defines the gradient to use (between 0 and 1)
  144216. * @param factor defines the life time factor to affect to the specified gradient
  144217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  144218. * @returns the current particle system
  144219. */
  144220. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  144221. /**
  144222. * Not supported by GPUParticleSystem
  144223. * @param gradient defines the gradient to remove
  144224. * @returns the current particle system
  144225. */
  144226. removeLifeTimeGradient(gradient: number): IParticleSystem;
  144227. /**
  144228. * Instantiates a GPU particle system.
  144229. * 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.
  144230. * @param name The name of the particle system
  144231. * @param options The options used to create the system
  144232. * @param scene The scene the particle system belongs to
  144233. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  144234. * @param customEffect a custom effect used to change the way particles are rendered by default
  144235. */
  144236. constructor(name: string, options: Partial<{
  144237. capacity: number;
  144238. randomTextureSize: number;
  144239. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  144240. protected _reset(): void;
  144241. private _createUpdateVAO;
  144242. private _createRenderVAO;
  144243. private _initialize;
  144244. /** @hidden */
  144245. _recreateUpdateEffect(): void;
  144246. private _getEffect;
  144247. /**
  144248. * Fill the defines array according to the current settings of the particle system
  144249. * @param defines Array to be updated
  144250. * @param blendMode blend mode to take into account when updating the array
  144251. */
  144252. fillDefines(defines: Array<string>, blendMode?: number): void;
  144253. /**
  144254. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  144255. * @param uniforms Uniforms array to fill
  144256. * @param attributes Attributes array to fill
  144257. * @param samplers Samplers array to fill
  144258. */
  144259. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  144260. /** @hidden */
  144261. _recreateRenderEffect(): Effect;
  144262. /**
  144263. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  144264. * @param preWarm defines if we are in the pre-warmimg phase
  144265. */
  144266. animate(preWarm?: boolean): void;
  144267. private _createFactorGradientTexture;
  144268. private _createSizeGradientTexture;
  144269. private _createAngularSpeedGradientTexture;
  144270. private _createVelocityGradientTexture;
  144271. private _createLimitVelocityGradientTexture;
  144272. private _createDragGradientTexture;
  144273. private _createColorGradientTexture;
  144274. /**
  144275. * Renders the particle system in its current state
  144276. * @param preWarm defines if the system should only update the particles but not render them
  144277. * @returns the current number of particles
  144278. */
  144279. render(preWarm?: boolean): number;
  144280. /**
  144281. * Rebuilds the particle system
  144282. */
  144283. rebuild(): void;
  144284. private _releaseBuffers;
  144285. private _releaseVAOs;
  144286. /**
  144287. * Disposes the particle system and free the associated resources
  144288. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  144289. */
  144290. dispose(disposeTexture?: boolean): void;
  144291. /**
  144292. * Clones the particle system.
  144293. * @param name The name of the cloned object
  144294. * @param newEmitter The new emitter to use
  144295. * @returns the cloned particle system
  144296. */
  144297. clone(name: string, newEmitter: any): GPUParticleSystem;
  144298. /**
  144299. * Serializes the particle system to a JSON object
  144300. * @param serializeTexture defines if the texture must be serialized as well
  144301. * @returns the JSON object
  144302. */
  144303. serialize(serializeTexture?: boolean): any;
  144304. /**
  144305. * Parses a JSON object to create a GPU particle system.
  144306. * @param parsedParticleSystem The JSON object to parse
  144307. * @param scene The scene to create the particle system in
  144308. * @param rootUrl The root url to use to load external dependencies like texture
  144309. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  144310. * @returns the parsed GPU particle system
  144311. */
  144312. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  144313. }
  144314. }
  144315. declare module BABYLON {
  144316. /**
  144317. * Represents a set of particle systems working together to create a specific effect
  144318. */
  144319. export class ParticleSystemSet implements IDisposable {
  144320. /**
  144321. * Gets or sets base Assets URL
  144322. */
  144323. static BaseAssetsUrl: string;
  144324. private _emitterCreationOptions;
  144325. private _emitterNode;
  144326. /**
  144327. * Gets the particle system list
  144328. */
  144329. systems: IParticleSystem[];
  144330. /**
  144331. * Gets the emitter node used with this set
  144332. */
  144333. get emitterNode(): Nullable<TransformNode>;
  144334. /**
  144335. * Creates a new emitter mesh as a sphere
  144336. * @param options defines the options used to create the sphere
  144337. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  144338. * @param scene defines the hosting scene
  144339. */
  144340. setEmitterAsSphere(options: {
  144341. diameter: number;
  144342. segments: number;
  144343. color: Color3;
  144344. }, renderingGroupId: number, scene: Scene): void;
  144345. /**
  144346. * Starts all particle systems of the set
  144347. * @param emitter defines an optional mesh to use as emitter for the particle systems
  144348. */
  144349. start(emitter?: AbstractMesh): void;
  144350. /**
  144351. * Release all associated resources
  144352. */
  144353. dispose(): void;
  144354. /**
  144355. * Serialize the set into a JSON compatible object
  144356. * @param serializeTexture defines if the texture must be serialized as well
  144357. * @returns a JSON compatible representation of the set
  144358. */
  144359. serialize(serializeTexture?: boolean): any;
  144360. /**
  144361. * Parse a new ParticleSystemSet from a serialized source
  144362. * @param data defines a JSON compatible representation of the set
  144363. * @param scene defines the hosting scene
  144364. * @param gpu defines if we want GPU particles or CPU particles
  144365. * @returns a new ParticleSystemSet
  144366. */
  144367. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  144368. }
  144369. }
  144370. declare module BABYLON {
  144371. /**
  144372. * This class is made for on one-liner static method to help creating particle system set.
  144373. */
  144374. export class ParticleHelper {
  144375. /**
  144376. * Gets or sets base Assets URL
  144377. */
  144378. static BaseAssetsUrl: string;
  144379. /** Define the Url to load snippets */
  144380. static SnippetUrl: string;
  144381. /**
  144382. * Create a default particle system that you can tweak
  144383. * @param emitter defines the emitter to use
  144384. * @param capacity defines the system capacity (default is 500 particles)
  144385. * @param scene defines the hosting scene
  144386. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  144387. * @returns the new Particle system
  144388. */
  144389. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  144390. /**
  144391. * This is the main static method (one-liner) of this helper to create different particle systems
  144392. * @param type This string represents the type to the particle system to create
  144393. * @param scene The scene where the particle system should live
  144394. * @param gpu If the system will use gpu
  144395. * @returns the ParticleSystemSet created
  144396. */
  144397. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  144398. /**
  144399. * Static function used to export a particle system to a ParticleSystemSet variable.
  144400. * Please note that the emitter shape is not exported
  144401. * @param systems defines the particle systems to export
  144402. * @returns the created particle system set
  144403. */
  144404. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  144405. /**
  144406. * Creates a particle system from a snippet saved in a remote file
  144407. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  144408. * @param url defines the url to load from
  144409. * @param scene defines the hosting scene
  144410. * @param gpu If the system will use gpu
  144411. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144412. * @returns a promise that will resolve to the new particle system
  144413. */
  144414. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144415. /**
  144416. * Creates a particle system from a snippet saved by the particle system editor
  144417. * @param snippetId defines the snippet to load
  144418. * @param scene defines the hosting scene
  144419. * @param gpu If the system will use gpu
  144420. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  144421. * @returns a promise that will resolve to the new particle system
  144422. */
  144423. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  144424. }
  144425. }
  144426. declare module BABYLON {
  144427. interface Engine {
  144428. /**
  144429. * Create an effect to use with particle systems.
  144430. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  144431. * the particle system for which you want to create a custom effect in the last parameter
  144432. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  144433. * @param uniformsNames defines a list of attribute names
  144434. * @param samplers defines an array of string used to represent textures
  144435. * @param defines defines the string containing the defines to use to compile the shaders
  144436. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  144437. * @param onCompiled defines a function to call when the effect creation is successful
  144438. * @param onError defines a function to call when the effect creation has failed
  144439. * @param particleSystem the particle system you want to create the effect for
  144440. * @returns the new Effect
  144441. */
  144442. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  144443. }
  144444. interface Mesh {
  144445. /**
  144446. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  144447. * @returns an array of IParticleSystem
  144448. */
  144449. getEmittedParticleSystems(): IParticleSystem[];
  144450. /**
  144451. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  144452. * @returns an array of IParticleSystem
  144453. */
  144454. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  144455. }
  144456. }
  144457. declare module BABYLON {
  144458. /** Defines the 4 color options */
  144459. export enum PointColor {
  144460. /** color value */
  144461. Color = 2,
  144462. /** uv value */
  144463. UV = 1,
  144464. /** random value */
  144465. Random = 0,
  144466. /** stated value */
  144467. Stated = 3
  144468. }
  144469. /**
  144470. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  144471. * 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.
  144472. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  144473. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  144474. *
  144475. * Full documentation here : TO BE ENTERED
  144476. */
  144477. export class PointsCloudSystem implements IDisposable {
  144478. /**
  144479. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  144480. * Example : var p = SPS.particles[i];
  144481. */
  144482. particles: CloudPoint[];
  144483. /**
  144484. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  144485. */
  144486. nbParticles: number;
  144487. /**
  144488. * This a counter for your own usage. It's not set by any SPS functions.
  144489. */
  144490. counter: number;
  144491. /**
  144492. * The PCS name. This name is also given to the underlying mesh.
  144493. */
  144494. name: string;
  144495. /**
  144496. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  144497. */
  144498. mesh: Mesh;
  144499. /**
  144500. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  144501. * Please read :
  144502. */
  144503. vars: any;
  144504. /**
  144505. * @hidden
  144506. */
  144507. _size: number;
  144508. private _scene;
  144509. private _promises;
  144510. private _positions;
  144511. private _indices;
  144512. private _normals;
  144513. private _colors;
  144514. private _uvs;
  144515. private _indices32;
  144516. private _positions32;
  144517. private _colors32;
  144518. private _uvs32;
  144519. private _updatable;
  144520. private _isVisibilityBoxLocked;
  144521. private _alwaysVisible;
  144522. private _groups;
  144523. private _groupCounter;
  144524. private _computeParticleColor;
  144525. private _computeParticleTexture;
  144526. private _computeParticleRotation;
  144527. private _computeBoundingBox;
  144528. private _isReady;
  144529. /**
  144530. * Creates a PCS (Points Cloud System) object
  144531. * @param name (String) is the PCS name, this will be the underlying mesh name
  144532. * @param pointSize (number) is the size for each point
  144533. * @param scene (Scene) is the scene in which the PCS is added
  144534. * @param options defines the options of the PCS e.g.
  144535. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  144536. */
  144537. constructor(name: string, pointSize: number, scene: Scene, options?: {
  144538. updatable?: boolean;
  144539. });
  144540. /**
  144541. * Builds the PCS underlying mesh. Returns a standard Mesh.
  144542. * If no points were added to the PCS, the returned mesh is just a single point.
  144543. * @returns a promise for the created mesh
  144544. */
  144545. buildMeshAsync(): Promise<Mesh>;
  144546. /**
  144547. * @hidden
  144548. */
  144549. private _buildMesh;
  144550. private _addParticle;
  144551. private _randomUnitVector;
  144552. private _getColorIndicesForCoord;
  144553. private _setPointsColorOrUV;
  144554. private _colorFromTexture;
  144555. private _calculateDensity;
  144556. /**
  144557. * Adds points to the PCS in random positions within a unit sphere
  144558. * @param nb (positive integer) the number of particles to be created from this model
  144559. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  144560. * @returns the number of groups in the system
  144561. */
  144562. addPoints(nb: number, pointFunction?: any): number;
  144563. /**
  144564. * Adds points to the PCS from the surface of the model shape
  144565. * @param mesh is any Mesh object that will be used as a surface model for the points
  144566. * @param nb (positive integer) the number of particles to be created from this model
  144567. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144568. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144569. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144570. * @returns the number of groups in the system
  144571. */
  144572. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144573. /**
  144574. * Adds points to the PCS inside the model shape
  144575. * @param mesh is any Mesh object that will be used as a surface model for the points
  144576. * @param nb (positive integer) the number of particles to be created from this model
  144577. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  144578. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  144579. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  144580. * @returns the number of groups in the system
  144581. */
  144582. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  144583. /**
  144584. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  144585. * This method calls `updateParticle()` for each particle of the SPS.
  144586. * For an animated SPS, it is usually called within the render loop.
  144587. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  144588. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  144589. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  144590. * @returns the PCS.
  144591. */
  144592. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  144593. /**
  144594. * Disposes the PCS.
  144595. */
  144596. dispose(): void;
  144597. /**
  144598. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  144599. * doc :
  144600. * @returns the PCS.
  144601. */
  144602. refreshVisibleSize(): PointsCloudSystem;
  144603. /**
  144604. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  144605. * @param size the size (float) of the visibility box
  144606. * note : this doesn't lock the PCS mesh bounding box.
  144607. * doc :
  144608. */
  144609. setVisibilityBox(size: number): void;
  144610. /**
  144611. * Gets whether the PCS is always visible or not
  144612. * doc :
  144613. */
  144614. get isAlwaysVisible(): boolean;
  144615. /**
  144616. * Sets the PCS as always visible or not
  144617. * doc :
  144618. */
  144619. set isAlwaysVisible(val: boolean);
  144620. /**
  144621. * Tells to `setParticles()` to compute the particle rotations or not
  144622. * Default value : false. The PCS is faster when it's set to false
  144623. * Note : particle rotations are only applied to parent particles
  144624. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  144625. */
  144626. set computeParticleRotation(val: boolean);
  144627. /**
  144628. * Tells to `setParticles()` to compute the particle colors or not.
  144629. * Default value : true. The PCS is faster when it's set to false.
  144630. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144631. */
  144632. set computeParticleColor(val: boolean);
  144633. set computeParticleTexture(val: boolean);
  144634. /**
  144635. * Gets if `setParticles()` computes the particle colors or not.
  144636. * Default value : false. The PCS is faster when it's set to false.
  144637. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  144638. */
  144639. get computeParticleColor(): boolean;
  144640. /**
  144641. * Gets if `setParticles()` computes the particle textures or not.
  144642. * Default value : false. The PCS is faster when it's set to false.
  144643. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  144644. */
  144645. get computeParticleTexture(): boolean;
  144646. /**
  144647. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  144648. */
  144649. set computeBoundingBox(val: boolean);
  144650. /**
  144651. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  144652. */
  144653. get computeBoundingBox(): boolean;
  144654. /**
  144655. * This function does nothing. It may be overwritten to set all the particle first values.
  144656. * The PCS doesn't call this function, you may have to call it by your own.
  144657. * doc :
  144658. */
  144659. initParticles(): void;
  144660. /**
  144661. * This function does nothing. It may be overwritten to recycle a particle
  144662. * The PCS doesn't call this function, you can to call it
  144663. * doc :
  144664. * @param particle The particle to recycle
  144665. * @returns the recycled particle
  144666. */
  144667. recycleParticle(particle: CloudPoint): CloudPoint;
  144668. /**
  144669. * Updates a particle : this function should be overwritten by the user.
  144670. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  144671. * doc :
  144672. * @example : just set a particle position or velocity and recycle conditions
  144673. * @param particle The particle to update
  144674. * @returns the updated particle
  144675. */
  144676. updateParticle(particle: CloudPoint): CloudPoint;
  144677. /**
  144678. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  144679. * This does nothing and may be overwritten by the user.
  144680. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144681. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144682. * @param update the boolean update value actually passed to setParticles()
  144683. */
  144684. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144685. /**
  144686. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  144687. * This will be passed three parameters.
  144688. * This does nothing and may be overwritten by the user.
  144689. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  144690. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  144691. * @param update the boolean update value actually passed to setParticles()
  144692. */
  144693. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  144694. }
  144695. }
  144696. declare module BABYLON {
  144697. /**
  144698. * Represents one particle of a points cloud system.
  144699. */
  144700. export class CloudPoint {
  144701. /**
  144702. * particle global index
  144703. */
  144704. idx: number;
  144705. /**
  144706. * The color of the particle
  144707. */
  144708. color: Nullable<Color4>;
  144709. /**
  144710. * The world space position of the particle.
  144711. */
  144712. position: Vector3;
  144713. /**
  144714. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  144715. */
  144716. rotation: Vector3;
  144717. /**
  144718. * The world space rotation quaternion of the particle.
  144719. */
  144720. rotationQuaternion: Nullable<Quaternion>;
  144721. /**
  144722. * The uv of the particle.
  144723. */
  144724. uv: Nullable<Vector2>;
  144725. /**
  144726. * The current speed of the particle.
  144727. */
  144728. velocity: Vector3;
  144729. /**
  144730. * The pivot point in the particle local space.
  144731. */
  144732. pivot: Vector3;
  144733. /**
  144734. * Must the particle be translated from its pivot point in its local space ?
  144735. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  144736. * Default : false
  144737. */
  144738. translateFromPivot: boolean;
  144739. /**
  144740. * Index of this particle in the global "positions" array (Internal use)
  144741. * @hidden
  144742. */
  144743. _pos: number;
  144744. /**
  144745. * @hidden Index of this particle in the global "indices" array (Internal use)
  144746. */
  144747. _ind: number;
  144748. /**
  144749. * Group this particle belongs to
  144750. */
  144751. _group: PointsGroup;
  144752. /**
  144753. * Group id of this particle
  144754. */
  144755. groupId: number;
  144756. /**
  144757. * Index of the particle in its group id (Internal use)
  144758. */
  144759. idxInGroup: number;
  144760. /**
  144761. * @hidden Particle BoundingInfo object (Internal use)
  144762. */
  144763. _boundingInfo: BoundingInfo;
  144764. /**
  144765. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  144766. */
  144767. _pcs: PointsCloudSystem;
  144768. /**
  144769. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  144770. */
  144771. _stillInvisible: boolean;
  144772. /**
  144773. * @hidden Last computed particle rotation matrix
  144774. */
  144775. _rotationMatrix: number[];
  144776. /**
  144777. * Parent particle Id, if any.
  144778. * Default null.
  144779. */
  144780. parentId: Nullable<number>;
  144781. /**
  144782. * @hidden Internal global position in the PCS.
  144783. */
  144784. _globalPosition: Vector3;
  144785. /**
  144786. * Creates a Point Cloud object.
  144787. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  144788. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  144789. * @param group (PointsGroup) is the group the particle belongs to
  144790. * @param groupId (integer) is the group identifier in the PCS.
  144791. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  144792. * @param pcs defines the PCS it is associated to
  144793. */
  144794. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  144795. /**
  144796. * get point size
  144797. */
  144798. get size(): Vector3;
  144799. /**
  144800. * Set point size
  144801. */
  144802. set size(scale: Vector3);
  144803. /**
  144804. * Legacy support, changed quaternion to rotationQuaternion
  144805. */
  144806. get quaternion(): Nullable<Quaternion>;
  144807. /**
  144808. * Legacy support, changed quaternion to rotationQuaternion
  144809. */
  144810. set quaternion(q: Nullable<Quaternion>);
  144811. /**
  144812. * Returns a boolean. True if the particle intersects a mesh, else false
  144813. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  144814. * @param target is the object (point or mesh) what the intersection is computed against
  144815. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  144816. * @returns true if it intersects
  144817. */
  144818. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  144819. /**
  144820. * get the rotation matrix of the particle
  144821. * @hidden
  144822. */
  144823. getRotationMatrix(m: Matrix): void;
  144824. }
  144825. /**
  144826. * Represents a group of points in a points cloud system
  144827. * * PCS internal tool, don't use it manually.
  144828. */
  144829. export class PointsGroup {
  144830. /**
  144831. * The group id
  144832. * @hidden
  144833. */
  144834. groupID: number;
  144835. /**
  144836. * image data for group (internal use)
  144837. * @hidden
  144838. */
  144839. _groupImageData: Nullable<ArrayBufferView>;
  144840. /**
  144841. * Image Width (internal use)
  144842. * @hidden
  144843. */
  144844. _groupImgWidth: number;
  144845. /**
  144846. * Image Height (internal use)
  144847. * @hidden
  144848. */
  144849. _groupImgHeight: number;
  144850. /**
  144851. * Custom position function (internal use)
  144852. * @hidden
  144853. */
  144854. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  144855. /**
  144856. * density per facet for surface points
  144857. * @hidden
  144858. */
  144859. _groupDensity: number[];
  144860. /**
  144861. * Only when points are colored by texture carries pointer to texture list array
  144862. * @hidden
  144863. */
  144864. _textureNb: number;
  144865. /**
  144866. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  144867. * PCS internal tool, don't use it manually.
  144868. * @hidden
  144869. */
  144870. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  144871. }
  144872. }
  144873. declare module BABYLON {
  144874. interface Scene {
  144875. /** @hidden (Backing field) */
  144876. _physicsEngine: Nullable<IPhysicsEngine>;
  144877. /** @hidden */
  144878. _physicsTimeAccumulator: number;
  144879. /**
  144880. * Gets the current physics engine
  144881. * @returns a IPhysicsEngine or null if none attached
  144882. */
  144883. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  144884. /**
  144885. * Enables physics to the current scene
  144886. * @param gravity defines the scene's gravity for the physics engine
  144887. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  144888. * @return a boolean indicating if the physics engine was initialized
  144889. */
  144890. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  144891. /**
  144892. * Disables and disposes the physics engine associated with the scene
  144893. */
  144894. disablePhysicsEngine(): void;
  144895. /**
  144896. * Gets a boolean indicating if there is an active physics engine
  144897. * @returns a boolean indicating if there is an active physics engine
  144898. */
  144899. isPhysicsEnabled(): boolean;
  144900. /**
  144901. * Deletes a physics compound impostor
  144902. * @param compound defines the compound to delete
  144903. */
  144904. deleteCompoundImpostor(compound: any): void;
  144905. /**
  144906. * An event triggered when physic simulation is about to be run
  144907. */
  144908. onBeforePhysicsObservable: Observable<Scene>;
  144909. /**
  144910. * An event triggered when physic simulation has been done
  144911. */
  144912. onAfterPhysicsObservable: Observable<Scene>;
  144913. }
  144914. interface AbstractMesh {
  144915. /** @hidden */
  144916. _physicsImpostor: Nullable<PhysicsImpostor>;
  144917. /**
  144918. * Gets or sets impostor used for physic simulation
  144919. * @see http://doc.babylonjs.com/features/physics_engine
  144920. */
  144921. physicsImpostor: Nullable<PhysicsImpostor>;
  144922. /**
  144923. * Gets the current physics impostor
  144924. * @see http://doc.babylonjs.com/features/physics_engine
  144925. * @returns a physics impostor or null
  144926. */
  144927. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  144928. /** Apply a physic impulse to the mesh
  144929. * @param force defines the force to apply
  144930. * @param contactPoint defines where to apply the force
  144931. * @returns the current mesh
  144932. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  144933. */
  144934. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  144935. /**
  144936. * Creates a physic joint between two meshes
  144937. * @param otherMesh defines the other mesh to use
  144938. * @param pivot1 defines the pivot to use on this mesh
  144939. * @param pivot2 defines the pivot to use on the other mesh
  144940. * @param options defines additional options (can be plugin dependent)
  144941. * @returns the current mesh
  144942. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  144943. */
  144944. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  144945. /** @hidden */
  144946. _disposePhysicsObserver: Nullable<Observer<Node>>;
  144947. }
  144948. /**
  144949. * Defines the physics engine scene component responsible to manage a physics engine
  144950. */
  144951. export class PhysicsEngineSceneComponent implements ISceneComponent {
  144952. /**
  144953. * The component name helpful to identify the component in the list of scene components.
  144954. */
  144955. readonly name: string;
  144956. /**
  144957. * The scene the component belongs to.
  144958. */
  144959. scene: Scene;
  144960. /**
  144961. * Creates a new instance of the component for the given scene
  144962. * @param scene Defines the scene to register the component in
  144963. */
  144964. constructor(scene: Scene);
  144965. /**
  144966. * Registers the component in a given scene
  144967. */
  144968. register(): void;
  144969. /**
  144970. * Rebuilds the elements related to this component in case of
  144971. * context lost for instance.
  144972. */
  144973. rebuild(): void;
  144974. /**
  144975. * Disposes the component and the associated ressources
  144976. */
  144977. dispose(): void;
  144978. }
  144979. }
  144980. declare module BABYLON {
  144981. /**
  144982. * A helper for physics simulations
  144983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  144984. */
  144985. export class PhysicsHelper {
  144986. private _scene;
  144987. private _physicsEngine;
  144988. /**
  144989. * Initializes the Physics helper
  144990. * @param scene Babylon.js scene
  144991. */
  144992. constructor(scene: Scene);
  144993. /**
  144994. * Applies a radial explosion impulse
  144995. * @param origin the origin of the explosion
  144996. * @param radiusOrEventOptions the radius or the options of radial explosion
  144997. * @param strength the explosion strength
  144998. * @param falloff possible options: Constant & Linear. Defaults to Constant
  144999. * @returns A physics radial explosion event, or null
  145000. */
  145001. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145002. /**
  145003. * Applies a radial explosion force
  145004. * @param origin the origin of the explosion
  145005. * @param radiusOrEventOptions the radius or the options of radial explosion
  145006. * @param strength the explosion strength
  145007. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145008. * @returns A physics radial explosion event, or null
  145009. */
  145010. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145011. /**
  145012. * Creates a gravitational field
  145013. * @param origin the origin of the explosion
  145014. * @param radiusOrEventOptions the radius or the options of radial explosion
  145015. * @param strength the explosion strength
  145016. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145017. * @returns A physics gravitational field event, or null
  145018. */
  145019. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145020. /**
  145021. * Creates a physics updraft event
  145022. * @param origin the origin of the updraft
  145023. * @param radiusOrEventOptions the radius or the options of the updraft
  145024. * @param strength the strength of the updraft
  145025. * @param height the height of the updraft
  145026. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145027. * @returns A physics updraft event, or null
  145028. */
  145029. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145030. /**
  145031. * Creates a physics vortex event
  145032. * @param origin the of the vortex
  145033. * @param radiusOrEventOptions the radius or the options of the vortex
  145034. * @param strength the strength of the vortex
  145035. * @param height the height of the vortex
  145036. * @returns a Physics vortex event, or null
  145037. * A physics vortex event or null
  145038. */
  145039. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145040. }
  145041. /**
  145042. * Represents a physics radial explosion event
  145043. */
  145044. class PhysicsRadialExplosionEvent {
  145045. private _scene;
  145046. private _options;
  145047. private _sphere;
  145048. private _dataFetched;
  145049. /**
  145050. * Initializes a radial explosioin event
  145051. * @param _scene BabylonJS scene
  145052. * @param _options The options for the vortex event
  145053. */
  145054. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145055. /**
  145056. * Returns the data related to the radial explosion event (sphere).
  145057. * @returns The radial explosion event data
  145058. */
  145059. getData(): PhysicsRadialExplosionEventData;
  145060. /**
  145061. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145062. * @param impostor A physics imposter
  145063. * @param origin the origin of the explosion
  145064. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  145065. */
  145066. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  145067. /**
  145068. * Triggers affecterd impostors callbacks
  145069. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  145070. */
  145071. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  145072. /**
  145073. * Disposes the sphere.
  145074. * @param force Specifies if the sphere should be disposed by force
  145075. */
  145076. dispose(force?: boolean): void;
  145077. /*** Helpers ***/
  145078. private _prepareSphere;
  145079. private _intersectsWithSphere;
  145080. }
  145081. /**
  145082. * Represents a gravitational field event
  145083. */
  145084. class PhysicsGravitationalFieldEvent {
  145085. private _physicsHelper;
  145086. private _scene;
  145087. private _origin;
  145088. private _options;
  145089. private _tickCallback;
  145090. private _sphere;
  145091. private _dataFetched;
  145092. /**
  145093. * Initializes the physics gravitational field event
  145094. * @param _physicsHelper A physics helper
  145095. * @param _scene BabylonJS scene
  145096. * @param _origin The origin position of the gravitational field event
  145097. * @param _options The options for the vortex event
  145098. */
  145099. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  145100. /**
  145101. * Returns the data related to the gravitational field event (sphere).
  145102. * @returns A gravitational field event
  145103. */
  145104. getData(): PhysicsGravitationalFieldEventData;
  145105. /**
  145106. * Enables the gravitational field.
  145107. */
  145108. enable(): void;
  145109. /**
  145110. * Disables the gravitational field.
  145111. */
  145112. disable(): void;
  145113. /**
  145114. * Disposes the sphere.
  145115. * @param force The force to dispose from the gravitational field event
  145116. */
  145117. dispose(force?: boolean): void;
  145118. private _tick;
  145119. }
  145120. /**
  145121. * Represents a physics updraft event
  145122. */
  145123. class PhysicsUpdraftEvent {
  145124. private _scene;
  145125. private _origin;
  145126. private _options;
  145127. private _physicsEngine;
  145128. private _originTop;
  145129. private _originDirection;
  145130. private _tickCallback;
  145131. private _cylinder;
  145132. private _cylinderPosition;
  145133. private _dataFetched;
  145134. /**
  145135. * Initializes the physics updraft event
  145136. * @param _scene BabylonJS scene
  145137. * @param _origin The origin position of the updraft
  145138. * @param _options The options for the updraft event
  145139. */
  145140. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  145141. /**
  145142. * Returns the data related to the updraft event (cylinder).
  145143. * @returns A physics updraft event
  145144. */
  145145. getData(): PhysicsUpdraftEventData;
  145146. /**
  145147. * Enables the updraft.
  145148. */
  145149. enable(): void;
  145150. /**
  145151. * Disables the updraft.
  145152. */
  145153. disable(): void;
  145154. /**
  145155. * Disposes the cylinder.
  145156. * @param force Specifies if the updraft should be disposed by force
  145157. */
  145158. dispose(force?: boolean): void;
  145159. private getImpostorHitData;
  145160. private _tick;
  145161. /*** Helpers ***/
  145162. private _prepareCylinder;
  145163. private _intersectsWithCylinder;
  145164. }
  145165. /**
  145166. * Represents a physics vortex event
  145167. */
  145168. class PhysicsVortexEvent {
  145169. private _scene;
  145170. private _origin;
  145171. private _options;
  145172. private _physicsEngine;
  145173. private _originTop;
  145174. private _tickCallback;
  145175. private _cylinder;
  145176. private _cylinderPosition;
  145177. private _dataFetched;
  145178. /**
  145179. * Initializes the physics vortex event
  145180. * @param _scene The BabylonJS scene
  145181. * @param _origin The origin position of the vortex
  145182. * @param _options The options for the vortex event
  145183. */
  145184. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  145185. /**
  145186. * Returns the data related to the vortex event (cylinder).
  145187. * @returns The physics vortex event data
  145188. */
  145189. getData(): PhysicsVortexEventData;
  145190. /**
  145191. * Enables the vortex.
  145192. */
  145193. enable(): void;
  145194. /**
  145195. * Disables the cortex.
  145196. */
  145197. disable(): void;
  145198. /**
  145199. * Disposes the sphere.
  145200. * @param force
  145201. */
  145202. dispose(force?: boolean): void;
  145203. private getImpostorHitData;
  145204. private _tick;
  145205. /*** Helpers ***/
  145206. private _prepareCylinder;
  145207. private _intersectsWithCylinder;
  145208. }
  145209. /**
  145210. * Options fot the radial explosion event
  145211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145212. */
  145213. export class PhysicsRadialExplosionEventOptions {
  145214. /**
  145215. * The radius of the sphere for the radial explosion.
  145216. */
  145217. radius: number;
  145218. /**
  145219. * The strenth of the explosion.
  145220. */
  145221. strength: number;
  145222. /**
  145223. * The strenght of the force in correspondence to the distance of the affected object
  145224. */
  145225. falloff: PhysicsRadialImpulseFalloff;
  145226. /**
  145227. * Sphere options for the radial explosion.
  145228. */
  145229. sphere: {
  145230. segments: number;
  145231. diameter: number;
  145232. };
  145233. /**
  145234. * Sphere options for the radial explosion.
  145235. */
  145236. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  145237. }
  145238. /**
  145239. * Options fot the updraft event
  145240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145241. */
  145242. export class PhysicsUpdraftEventOptions {
  145243. /**
  145244. * The radius of the cylinder for the vortex
  145245. */
  145246. radius: number;
  145247. /**
  145248. * The strenth of the updraft.
  145249. */
  145250. strength: number;
  145251. /**
  145252. * The height of the cylinder for the updraft.
  145253. */
  145254. height: number;
  145255. /**
  145256. * The mode for the the updraft.
  145257. */
  145258. updraftMode: PhysicsUpdraftMode;
  145259. }
  145260. /**
  145261. * Options fot the vortex event
  145262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145263. */
  145264. export class PhysicsVortexEventOptions {
  145265. /**
  145266. * The radius of the cylinder for the vortex
  145267. */
  145268. radius: number;
  145269. /**
  145270. * The strenth of the vortex.
  145271. */
  145272. strength: number;
  145273. /**
  145274. * The height of the cylinder for the vortex.
  145275. */
  145276. height: number;
  145277. /**
  145278. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  145279. */
  145280. centripetalForceThreshold: number;
  145281. /**
  145282. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  145283. */
  145284. centripetalForceMultiplier: number;
  145285. /**
  145286. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  145287. */
  145288. centrifugalForceMultiplier: number;
  145289. /**
  145290. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  145291. */
  145292. updraftForceMultiplier: number;
  145293. }
  145294. /**
  145295. * The strenght of the force in correspondence to the distance of the affected object
  145296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145297. */
  145298. export enum PhysicsRadialImpulseFalloff {
  145299. /** Defines that impulse is constant in strength across it's whole radius */
  145300. Constant = 0,
  145301. /** Defines that impulse gets weaker if it's further from the origin */
  145302. Linear = 1
  145303. }
  145304. /**
  145305. * The strength of the force in correspondence to the distance of the affected object
  145306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145307. */
  145308. export enum PhysicsUpdraftMode {
  145309. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  145310. Center = 0,
  145311. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  145312. Perpendicular = 1
  145313. }
  145314. /**
  145315. * Interface for a physics hit data
  145316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145317. */
  145318. export interface PhysicsHitData {
  145319. /**
  145320. * The force applied at the contact point
  145321. */
  145322. force: Vector3;
  145323. /**
  145324. * The contact point
  145325. */
  145326. contactPoint: Vector3;
  145327. /**
  145328. * The distance from the origin to the contact point
  145329. */
  145330. distanceFromOrigin: number;
  145331. }
  145332. /**
  145333. * Interface for radial explosion event data
  145334. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145335. */
  145336. export interface PhysicsRadialExplosionEventData {
  145337. /**
  145338. * A sphere used for the radial explosion event
  145339. */
  145340. sphere: Mesh;
  145341. }
  145342. /**
  145343. * Interface for gravitational field event data
  145344. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145345. */
  145346. export interface PhysicsGravitationalFieldEventData {
  145347. /**
  145348. * A sphere mesh used for the gravitational field event
  145349. */
  145350. sphere: Mesh;
  145351. }
  145352. /**
  145353. * Interface for updraft event data
  145354. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145355. */
  145356. export interface PhysicsUpdraftEventData {
  145357. /**
  145358. * A cylinder used for the updraft event
  145359. */
  145360. cylinder: Mesh;
  145361. }
  145362. /**
  145363. * Interface for vortex event data
  145364. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145365. */
  145366. export interface PhysicsVortexEventData {
  145367. /**
  145368. * A cylinder used for the vortex event
  145369. */
  145370. cylinder: Mesh;
  145371. }
  145372. /**
  145373. * Interface for an affected physics impostor
  145374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145375. */
  145376. export interface PhysicsAffectedImpostorWithData {
  145377. /**
  145378. * The impostor affected by the effect
  145379. */
  145380. impostor: PhysicsImpostor;
  145381. /**
  145382. * The data about the hit/horce from the explosion
  145383. */
  145384. hitData: PhysicsHitData;
  145385. }
  145386. }
  145387. declare module BABYLON {
  145388. /** @hidden */
  145389. export var blackAndWhitePixelShader: {
  145390. name: string;
  145391. shader: string;
  145392. };
  145393. }
  145394. declare module BABYLON {
  145395. /**
  145396. * Post process used to render in black and white
  145397. */
  145398. export class BlackAndWhitePostProcess extends PostProcess {
  145399. /**
  145400. * Linear about to convert he result to black and white (default: 1)
  145401. */
  145402. degree: number;
  145403. /**
  145404. * Creates a black and white post process
  145405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  145406. * @param name The name of the effect.
  145407. * @param options The required width/height ratio to downsize to before computing the render pass.
  145408. * @param camera The camera to apply the render pass to.
  145409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145410. * @param engine The engine which the post process will be applied. (default: current engine)
  145411. * @param reusable If the post process can be reused on the same frame. (default: false)
  145412. */
  145413. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145414. }
  145415. }
  145416. declare module BABYLON {
  145417. /**
  145418. * This represents a set of one or more post processes in Babylon.
  145419. * A post process can be used to apply a shader to a texture after it is rendered.
  145420. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  145421. */
  145422. export class PostProcessRenderEffect {
  145423. private _postProcesses;
  145424. private _getPostProcesses;
  145425. private _singleInstance;
  145426. private _cameras;
  145427. private _indicesForCamera;
  145428. /**
  145429. * Name of the effect
  145430. * @hidden
  145431. */
  145432. _name: string;
  145433. /**
  145434. * Instantiates a post process render effect.
  145435. * A post process can be used to apply a shader to a texture after it is rendered.
  145436. * @param engine The engine the effect is tied to
  145437. * @param name The name of the effect
  145438. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  145439. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  145440. */
  145441. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  145442. /**
  145443. * Checks if all the post processes in the effect are supported.
  145444. */
  145445. get isSupported(): boolean;
  145446. /**
  145447. * Updates the current state of the effect
  145448. * @hidden
  145449. */
  145450. _update(): void;
  145451. /**
  145452. * Attaches the effect on cameras
  145453. * @param cameras The camera to attach to.
  145454. * @hidden
  145455. */
  145456. _attachCameras(cameras: Camera): void;
  145457. /**
  145458. * Attaches the effect on cameras
  145459. * @param cameras The camera to attach to.
  145460. * @hidden
  145461. */
  145462. _attachCameras(cameras: Camera[]): void;
  145463. /**
  145464. * Detaches the effect on cameras
  145465. * @param cameras The camera to detatch from.
  145466. * @hidden
  145467. */
  145468. _detachCameras(cameras: Camera): void;
  145469. /**
  145470. * Detatches the effect on cameras
  145471. * @param cameras The camera to detatch from.
  145472. * @hidden
  145473. */
  145474. _detachCameras(cameras: Camera[]): void;
  145475. /**
  145476. * Enables the effect on given cameras
  145477. * @param cameras The camera to enable.
  145478. * @hidden
  145479. */
  145480. _enable(cameras: Camera): void;
  145481. /**
  145482. * Enables the effect on given cameras
  145483. * @param cameras The camera to enable.
  145484. * @hidden
  145485. */
  145486. _enable(cameras: Nullable<Camera[]>): void;
  145487. /**
  145488. * Disables the effect on the given cameras
  145489. * @param cameras The camera to disable.
  145490. * @hidden
  145491. */
  145492. _disable(cameras: Camera): void;
  145493. /**
  145494. * Disables the effect on the given cameras
  145495. * @param cameras The camera to disable.
  145496. * @hidden
  145497. */
  145498. _disable(cameras: Nullable<Camera[]>): void;
  145499. /**
  145500. * Gets a list of the post processes contained in the effect.
  145501. * @param camera The camera to get the post processes on.
  145502. * @returns The list of the post processes in the effect.
  145503. */
  145504. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  145505. }
  145506. }
  145507. declare module BABYLON {
  145508. /** @hidden */
  145509. export var extractHighlightsPixelShader: {
  145510. name: string;
  145511. shader: string;
  145512. };
  145513. }
  145514. declare module BABYLON {
  145515. /**
  145516. * 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.
  145517. */
  145518. export class ExtractHighlightsPostProcess extends PostProcess {
  145519. /**
  145520. * The luminance threshold, pixels below this value will be set to black.
  145521. */
  145522. threshold: number;
  145523. /** @hidden */
  145524. _exposure: number;
  145525. /**
  145526. * Post process which has the input texture to be used when performing highlight extraction
  145527. * @hidden
  145528. */
  145529. _inputPostProcess: Nullable<PostProcess>;
  145530. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145531. }
  145532. }
  145533. declare module BABYLON {
  145534. /** @hidden */
  145535. export var bloomMergePixelShader: {
  145536. name: string;
  145537. shader: string;
  145538. };
  145539. }
  145540. declare module BABYLON {
  145541. /**
  145542. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145543. */
  145544. export class BloomMergePostProcess extends PostProcess {
  145545. /** Weight of the bloom to be added to the original input. */
  145546. weight: number;
  145547. /**
  145548. * Creates a new instance of @see BloomMergePostProcess
  145549. * @param name The name of the effect.
  145550. * @param originalFromInput Post process which's input will be used for the merge.
  145551. * @param blurred Blurred highlights post process which's output will be used.
  145552. * @param weight Weight of the bloom to be added to the original input.
  145553. * @param options The required width/height ratio to downsize to before computing the render pass.
  145554. * @param camera The camera to apply the render pass to.
  145555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145556. * @param engine The engine which the post process will be applied. (default: current engine)
  145557. * @param reusable If the post process can be reused on the same frame. (default: false)
  145558. * @param textureType Type of textures used when performing the post process. (default: 0)
  145559. * @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)
  145560. */
  145561. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  145562. /** Weight of the bloom to be added to the original input. */
  145563. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145564. }
  145565. }
  145566. declare module BABYLON {
  145567. /**
  145568. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  145569. */
  145570. export class BloomEffect extends PostProcessRenderEffect {
  145571. private bloomScale;
  145572. /**
  145573. * @hidden Internal
  145574. */
  145575. _effects: Array<PostProcess>;
  145576. /**
  145577. * @hidden Internal
  145578. */
  145579. _downscale: ExtractHighlightsPostProcess;
  145580. private _blurX;
  145581. private _blurY;
  145582. private _merge;
  145583. /**
  145584. * The luminance threshold to find bright areas of the image to bloom.
  145585. */
  145586. get threshold(): number;
  145587. set threshold(value: number);
  145588. /**
  145589. * The strength of the bloom.
  145590. */
  145591. get weight(): number;
  145592. set weight(value: number);
  145593. /**
  145594. * Specifies the size of the bloom blur kernel, relative to the final output size
  145595. */
  145596. get kernel(): number;
  145597. set kernel(value: number);
  145598. /**
  145599. * Creates a new instance of @see BloomEffect
  145600. * @param scene The scene the effect belongs to.
  145601. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  145602. * @param bloomKernel The size of the kernel to be used when applying the blur.
  145603. * @param bloomWeight The the strength of bloom.
  145604. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145605. * @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)
  145606. */
  145607. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  145608. /**
  145609. * Disposes each of the internal effects for a given camera.
  145610. * @param camera The camera to dispose the effect on.
  145611. */
  145612. disposeEffects(camera: Camera): void;
  145613. /**
  145614. * @hidden Internal
  145615. */
  145616. _updateEffects(): void;
  145617. /**
  145618. * Internal
  145619. * @returns if all the contained post processes are ready.
  145620. * @hidden
  145621. */
  145622. _isReady(): boolean;
  145623. }
  145624. }
  145625. declare module BABYLON {
  145626. /** @hidden */
  145627. export var chromaticAberrationPixelShader: {
  145628. name: string;
  145629. shader: string;
  145630. };
  145631. }
  145632. declare module BABYLON {
  145633. /**
  145634. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  145635. */
  145636. export class ChromaticAberrationPostProcess extends PostProcess {
  145637. /**
  145638. * The amount of seperation of rgb channels (default: 30)
  145639. */
  145640. aberrationAmount: number;
  145641. /**
  145642. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  145643. */
  145644. radialIntensity: number;
  145645. /**
  145646. * 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))
  145647. */
  145648. direction: Vector2;
  145649. /**
  145650. * 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))
  145651. */
  145652. centerPosition: Vector2;
  145653. /**
  145654. * Creates a new instance ChromaticAberrationPostProcess
  145655. * @param name The name of the effect.
  145656. * @param screenWidth The width of the screen to apply the effect on.
  145657. * @param screenHeight The height of the screen to apply the effect on.
  145658. * @param options The required width/height ratio to downsize to before computing the render pass.
  145659. * @param camera The camera to apply the render pass to.
  145660. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145661. * @param engine The engine which the post process will be applied. (default: current engine)
  145662. * @param reusable If the post process can be reused on the same frame. (default: false)
  145663. * @param textureType Type of textures used when performing the post process. (default: 0)
  145664. * @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)
  145665. */
  145666. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145667. }
  145668. }
  145669. declare module BABYLON {
  145670. /** @hidden */
  145671. export var circleOfConfusionPixelShader: {
  145672. name: string;
  145673. shader: string;
  145674. };
  145675. }
  145676. declare module BABYLON {
  145677. /**
  145678. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  145679. */
  145680. export class CircleOfConfusionPostProcess extends PostProcess {
  145681. /**
  145682. * 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.
  145683. */
  145684. lensSize: number;
  145685. /**
  145686. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145687. */
  145688. fStop: number;
  145689. /**
  145690. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145691. */
  145692. focusDistance: number;
  145693. /**
  145694. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  145695. */
  145696. focalLength: number;
  145697. private _depthTexture;
  145698. /**
  145699. * Creates a new instance CircleOfConfusionPostProcess
  145700. * @param name The name of the effect.
  145701. * @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.
  145702. * @param options The required width/height ratio to downsize to before computing the render pass.
  145703. * @param camera The camera to apply the render pass to.
  145704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145705. * @param engine The engine which the post process will be applied. (default: current engine)
  145706. * @param reusable If the post process can be reused on the same frame. (default: false)
  145707. * @param textureType Type of textures used when performing the post process. (default: 0)
  145708. * @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)
  145709. */
  145710. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  145711. /**
  145712. * 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.
  145713. */
  145714. set depthTexture(value: RenderTargetTexture);
  145715. }
  145716. }
  145717. declare module BABYLON {
  145718. /** @hidden */
  145719. export var colorCorrectionPixelShader: {
  145720. name: string;
  145721. shader: string;
  145722. };
  145723. }
  145724. declare module BABYLON {
  145725. /**
  145726. *
  145727. * This post-process allows the modification of rendered colors by using
  145728. * a 'look-up table' (LUT). This effect is also called Color Grading.
  145729. *
  145730. * The object needs to be provided an url to a texture containing the color
  145731. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  145732. * Use an image editing software to tweak the LUT to match your needs.
  145733. *
  145734. * For an example of a color LUT, see here:
  145735. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  145736. * For explanations on color grading, see here:
  145737. * @see http://udn.epicgames.com/Three/ColorGrading.html
  145738. *
  145739. */
  145740. export class ColorCorrectionPostProcess extends PostProcess {
  145741. private _colorTableTexture;
  145742. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  145743. }
  145744. }
  145745. declare module BABYLON {
  145746. /** @hidden */
  145747. export var convolutionPixelShader: {
  145748. name: string;
  145749. shader: string;
  145750. };
  145751. }
  145752. declare module BABYLON {
  145753. /**
  145754. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  145755. * input texture to perform effects such as edge detection or sharpening
  145756. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  145757. */
  145758. export class ConvolutionPostProcess extends PostProcess {
  145759. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  145760. kernel: number[];
  145761. /**
  145762. * Creates a new instance ConvolutionPostProcess
  145763. * @param name The name of the effect.
  145764. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  145765. * @param options The required width/height ratio to downsize to before computing the render pass.
  145766. * @param camera The camera to apply the render pass to.
  145767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145768. * @param engine The engine which the post process will be applied. (default: current engine)
  145769. * @param reusable If the post process can be reused on the same frame. (default: false)
  145770. * @param textureType Type of textures used when performing the post process. (default: 0)
  145771. */
  145772. constructor(name: string,
  145773. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  145774. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  145775. /**
  145776. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145777. */
  145778. static EdgeDetect0Kernel: number[];
  145779. /**
  145780. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145781. */
  145782. static EdgeDetect1Kernel: number[];
  145783. /**
  145784. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145785. */
  145786. static EdgeDetect2Kernel: number[];
  145787. /**
  145788. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145789. */
  145790. static SharpenKernel: number[];
  145791. /**
  145792. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145793. */
  145794. static EmbossKernel: number[];
  145795. /**
  145796. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  145797. */
  145798. static GaussianKernel: number[];
  145799. }
  145800. }
  145801. declare module BABYLON {
  145802. /**
  145803. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  145804. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  145805. * based on samples that have a large difference in distance than the center pixel.
  145806. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  145807. */
  145808. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  145809. direction: Vector2;
  145810. /**
  145811. * Creates a new instance CircleOfConfusionPostProcess
  145812. * @param name The name of the effect.
  145813. * @param scene The scene the effect belongs to.
  145814. * @param direction The direction the blur should be applied.
  145815. * @param kernel The size of the kernel used to blur.
  145816. * @param options The required width/height ratio to downsize to before computing the render pass.
  145817. * @param camera The camera to apply the render pass to.
  145818. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  145819. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  145820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145821. * @param engine The engine which the post process will be applied. (default: current engine)
  145822. * @param reusable If the post process can be reused on the same frame. (default: false)
  145823. * @param textureType Type of textures used when performing the post process. (default: 0)
  145824. * @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)
  145825. */
  145826. 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);
  145827. }
  145828. }
  145829. declare module BABYLON {
  145830. /** @hidden */
  145831. export var depthOfFieldMergePixelShader: {
  145832. name: string;
  145833. shader: string;
  145834. };
  145835. }
  145836. declare module BABYLON {
  145837. /**
  145838. * Options to be set when merging outputs from the default pipeline.
  145839. */
  145840. export class DepthOfFieldMergePostProcessOptions {
  145841. /**
  145842. * The original image to merge on top of
  145843. */
  145844. originalFromInput: PostProcess;
  145845. /**
  145846. * Parameters to perform the merge of the depth of field effect
  145847. */
  145848. depthOfField?: {
  145849. circleOfConfusion: PostProcess;
  145850. blurSteps: Array<PostProcess>;
  145851. };
  145852. /**
  145853. * Parameters to perform the merge of bloom effect
  145854. */
  145855. bloom?: {
  145856. blurred: PostProcess;
  145857. weight: number;
  145858. };
  145859. }
  145860. /**
  145861. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  145862. */
  145863. export class DepthOfFieldMergePostProcess extends PostProcess {
  145864. private blurSteps;
  145865. /**
  145866. * Creates a new instance of DepthOfFieldMergePostProcess
  145867. * @param name The name of the effect.
  145868. * @param originalFromInput Post process which's input will be used for the merge.
  145869. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  145870. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  145871. * @param options The required width/height ratio to downsize to before computing the render pass.
  145872. * @param camera The camera to apply the render pass to.
  145873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145874. * @param engine The engine which the post process will be applied. (default: current engine)
  145875. * @param reusable If the post process can be reused on the same frame. (default: false)
  145876. * @param textureType Type of textures used when performing the post process. (default: 0)
  145877. * @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)
  145878. */
  145879. 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);
  145880. /**
  145881. * Updates the effect with the current post process compile time values and recompiles the shader.
  145882. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  145883. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  145884. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  145885. * @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
  145886. * @param onCompiled Called when the shader has been compiled.
  145887. * @param onError Called if there is an error when compiling a shader.
  145888. */
  145889. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  145890. }
  145891. }
  145892. declare module BABYLON {
  145893. /**
  145894. * Specifies the level of max blur that should be applied when using the depth of field effect
  145895. */
  145896. export enum DepthOfFieldEffectBlurLevel {
  145897. /**
  145898. * Subtle blur
  145899. */
  145900. Low = 0,
  145901. /**
  145902. * Medium blur
  145903. */
  145904. Medium = 1,
  145905. /**
  145906. * Large blur
  145907. */
  145908. High = 2
  145909. }
  145910. /**
  145911. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  145912. */
  145913. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  145914. private _circleOfConfusion;
  145915. /**
  145916. * @hidden Internal, blurs from high to low
  145917. */
  145918. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  145919. private _depthOfFieldBlurY;
  145920. private _dofMerge;
  145921. /**
  145922. * @hidden Internal post processes in depth of field effect
  145923. */
  145924. _effects: Array<PostProcess>;
  145925. /**
  145926. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  145927. */
  145928. set focalLength(value: number);
  145929. get focalLength(): number;
  145930. /**
  145931. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  145932. */
  145933. set fStop(value: number);
  145934. get fStop(): number;
  145935. /**
  145936. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  145937. */
  145938. set focusDistance(value: number);
  145939. get focusDistance(): number;
  145940. /**
  145941. * 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.
  145942. */
  145943. set lensSize(value: number);
  145944. get lensSize(): number;
  145945. /**
  145946. * Creates a new instance DepthOfFieldEffect
  145947. * @param scene The scene the effect belongs to.
  145948. * @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.
  145949. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  145950. * @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)
  145951. */
  145952. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  145953. /**
  145954. * Get the current class name of the current effet
  145955. * @returns "DepthOfFieldEffect"
  145956. */
  145957. getClassName(): string;
  145958. /**
  145959. * 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.
  145960. */
  145961. set depthTexture(value: RenderTargetTexture);
  145962. /**
  145963. * Disposes each of the internal effects for a given camera.
  145964. * @param camera The camera to dispose the effect on.
  145965. */
  145966. disposeEffects(camera: Camera): void;
  145967. /**
  145968. * @hidden Internal
  145969. */
  145970. _updateEffects(): void;
  145971. /**
  145972. * Internal
  145973. * @returns if all the contained post processes are ready.
  145974. * @hidden
  145975. */
  145976. _isReady(): boolean;
  145977. }
  145978. }
  145979. declare module BABYLON {
  145980. /** @hidden */
  145981. export var displayPassPixelShader: {
  145982. name: string;
  145983. shader: string;
  145984. };
  145985. }
  145986. declare module BABYLON {
  145987. /**
  145988. * DisplayPassPostProcess which produces an output the same as it's input
  145989. */
  145990. export class DisplayPassPostProcess extends PostProcess {
  145991. /**
  145992. * Creates the DisplayPassPostProcess
  145993. * @param name The name of the effect.
  145994. * @param options The required width/height ratio to downsize to before computing the render pass.
  145995. * @param camera The camera to apply the render pass to.
  145996. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  145997. * @param engine The engine which the post process will be applied. (default: current engine)
  145998. * @param reusable If the post process can be reused on the same frame. (default: false)
  145999. */
  146000. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146001. }
  146002. }
  146003. declare module BABYLON {
  146004. /** @hidden */
  146005. export var filterPixelShader: {
  146006. name: string;
  146007. shader: string;
  146008. };
  146009. }
  146010. declare module BABYLON {
  146011. /**
  146012. * Applies a kernel filter to the image
  146013. */
  146014. export class FilterPostProcess extends PostProcess {
  146015. /** The matrix to be applied to the image */
  146016. kernelMatrix: Matrix;
  146017. /**
  146018. *
  146019. * @param name The name of the effect.
  146020. * @param kernelMatrix The matrix to be applied to the image
  146021. * @param options The required width/height ratio to downsize to before computing the render pass.
  146022. * @param camera The camera to apply the render pass to.
  146023. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146024. * @param engine The engine which the post process will be applied. (default: current engine)
  146025. * @param reusable If the post process can be reused on the same frame. (default: false)
  146026. */
  146027. constructor(name: string,
  146028. /** The matrix to be applied to the image */
  146029. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146030. }
  146031. }
  146032. declare module BABYLON {
  146033. /** @hidden */
  146034. export var fxaaPixelShader: {
  146035. name: string;
  146036. shader: string;
  146037. };
  146038. }
  146039. declare module BABYLON {
  146040. /** @hidden */
  146041. export var fxaaVertexShader: {
  146042. name: string;
  146043. shader: string;
  146044. };
  146045. }
  146046. declare module BABYLON {
  146047. /**
  146048. * Fxaa post process
  146049. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146050. */
  146051. export class FxaaPostProcess extends PostProcess {
  146052. /** @hidden */
  146053. texelWidth: number;
  146054. /** @hidden */
  146055. texelHeight: number;
  146056. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146057. private _getDefines;
  146058. }
  146059. }
  146060. declare module BABYLON {
  146061. /** @hidden */
  146062. export var grainPixelShader: {
  146063. name: string;
  146064. shader: string;
  146065. };
  146066. }
  146067. declare module BABYLON {
  146068. /**
  146069. * The GrainPostProcess adds noise to the image at mid luminance levels
  146070. */
  146071. export class GrainPostProcess extends PostProcess {
  146072. /**
  146073. * The intensity of the grain added (default: 30)
  146074. */
  146075. intensity: number;
  146076. /**
  146077. * If the grain should be randomized on every frame
  146078. */
  146079. animated: boolean;
  146080. /**
  146081. * Creates a new instance of @see GrainPostProcess
  146082. * @param name The name of the effect.
  146083. * @param options The required width/height ratio to downsize to before computing the render pass.
  146084. * @param camera The camera to apply the render pass to.
  146085. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146086. * @param engine The engine which the post process will be applied. (default: current engine)
  146087. * @param reusable If the post process can be reused on the same frame. (default: false)
  146088. * @param textureType Type of textures used when performing the post process. (default: 0)
  146089. * @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)
  146090. */
  146091. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146092. }
  146093. }
  146094. declare module BABYLON {
  146095. /** @hidden */
  146096. export var highlightsPixelShader: {
  146097. name: string;
  146098. shader: string;
  146099. };
  146100. }
  146101. declare module BABYLON {
  146102. /**
  146103. * Extracts highlights from the image
  146104. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146105. */
  146106. export class HighlightsPostProcess extends PostProcess {
  146107. /**
  146108. * Extracts highlights from the image
  146109. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  146110. * @param name The name of the effect.
  146111. * @param options The required width/height ratio to downsize to before computing the render pass.
  146112. * @param camera The camera to apply the render pass to.
  146113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146114. * @param engine The engine which the post process will be applied. (default: current engine)
  146115. * @param reusable If the post process can be reused on the same frame. (default: false)
  146116. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  146117. */
  146118. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146119. }
  146120. }
  146121. declare module BABYLON {
  146122. /** @hidden */
  146123. export var mrtFragmentDeclaration: {
  146124. name: string;
  146125. shader: string;
  146126. };
  146127. }
  146128. declare module BABYLON {
  146129. /** @hidden */
  146130. export var geometryPixelShader: {
  146131. name: string;
  146132. shader: string;
  146133. };
  146134. }
  146135. declare module BABYLON {
  146136. /** @hidden */
  146137. export var geometryVertexShader: {
  146138. name: string;
  146139. shader: string;
  146140. };
  146141. }
  146142. declare module BABYLON {
  146143. /** @hidden */
  146144. interface ISavedTransformationMatrix {
  146145. world: Matrix;
  146146. viewProjection: Matrix;
  146147. }
  146148. /**
  146149. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  146150. */
  146151. export class GeometryBufferRenderer {
  146152. /**
  146153. * Constant used to retrieve the position texture index in the G-Buffer textures array
  146154. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  146155. */
  146156. static readonly POSITION_TEXTURE_TYPE: number;
  146157. /**
  146158. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  146159. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  146160. */
  146161. static readonly VELOCITY_TEXTURE_TYPE: number;
  146162. /**
  146163. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  146164. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  146165. */
  146166. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  146167. /**
  146168. * Dictionary used to store the previous transformation matrices of each rendered mesh
  146169. * in order to compute objects velocities when enableVelocity is set to "true"
  146170. * @hidden
  146171. */
  146172. _previousTransformationMatrices: {
  146173. [index: number]: ISavedTransformationMatrix;
  146174. };
  146175. /**
  146176. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  146177. * in order to compute objects velocities when enableVelocity is set to "true"
  146178. * @hidden
  146179. */
  146180. _previousBonesTransformationMatrices: {
  146181. [index: number]: Float32Array;
  146182. };
  146183. /**
  146184. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  146185. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  146186. */
  146187. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  146188. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  146189. renderTransparentMeshes: boolean;
  146190. private _scene;
  146191. private _multiRenderTarget;
  146192. private _ratio;
  146193. private _enablePosition;
  146194. private _enableVelocity;
  146195. private _enableReflectivity;
  146196. private _positionIndex;
  146197. private _velocityIndex;
  146198. private _reflectivityIndex;
  146199. protected _effect: Effect;
  146200. protected _cachedDefines: string;
  146201. /**
  146202. * Set the render list (meshes to be rendered) used in the G buffer.
  146203. */
  146204. set renderList(meshes: Mesh[]);
  146205. /**
  146206. * Gets wether or not G buffer are supported by the running hardware.
  146207. * This requires draw buffer supports
  146208. */
  146209. get isSupported(): boolean;
  146210. /**
  146211. * Returns the index of the given texture type in the G-Buffer textures array
  146212. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  146213. * @returns the index of the given texture type in the G-Buffer textures array
  146214. */
  146215. getTextureIndex(textureType: number): number;
  146216. /**
  146217. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  146218. */
  146219. get enablePosition(): boolean;
  146220. /**
  146221. * Sets whether or not objects positions are enabled for the G buffer.
  146222. */
  146223. set enablePosition(enable: boolean);
  146224. /**
  146225. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  146226. */
  146227. get enableVelocity(): boolean;
  146228. /**
  146229. * Sets wether or not objects velocities are enabled for the G buffer.
  146230. */
  146231. set enableVelocity(enable: boolean);
  146232. /**
  146233. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  146234. */
  146235. get enableReflectivity(): boolean;
  146236. /**
  146237. * Sets wether or not objects roughness are enabled for the G buffer.
  146238. */
  146239. set enableReflectivity(enable: boolean);
  146240. /**
  146241. * Gets the scene associated with the buffer.
  146242. */
  146243. get scene(): Scene;
  146244. /**
  146245. * Gets the ratio used by the buffer during its creation.
  146246. * How big is the buffer related to the main canvas.
  146247. */
  146248. get ratio(): number;
  146249. /** @hidden */
  146250. static _SceneComponentInitialization: (scene: Scene) => void;
  146251. /**
  146252. * Creates a new G Buffer for the scene
  146253. * @param scene The scene the buffer belongs to
  146254. * @param ratio How big is the buffer related to the main canvas.
  146255. */
  146256. constructor(scene: Scene, ratio?: number);
  146257. /**
  146258. * Checks wether everything is ready to render a submesh to the G buffer.
  146259. * @param subMesh the submesh to check readiness for
  146260. * @param useInstances is the mesh drawn using instance or not
  146261. * @returns true if ready otherwise false
  146262. */
  146263. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  146264. /**
  146265. * Gets the current underlying G Buffer.
  146266. * @returns the buffer
  146267. */
  146268. getGBuffer(): MultiRenderTarget;
  146269. /**
  146270. * Gets the number of samples used to render the buffer (anti aliasing).
  146271. */
  146272. get samples(): number;
  146273. /**
  146274. * Sets the number of samples used to render the buffer (anti aliasing).
  146275. */
  146276. set samples(value: number);
  146277. /**
  146278. * Disposes the renderer and frees up associated resources.
  146279. */
  146280. dispose(): void;
  146281. protected _createRenderTargets(): void;
  146282. private _copyBonesTransformationMatrices;
  146283. }
  146284. }
  146285. declare module BABYLON {
  146286. interface Scene {
  146287. /** @hidden (Backing field) */
  146288. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  146289. /**
  146290. * Gets or Sets the current geometry buffer associated to the scene.
  146291. */
  146292. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  146293. /**
  146294. * Enables a GeometryBufferRender and associates it with the scene
  146295. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  146296. * @returns the GeometryBufferRenderer
  146297. */
  146298. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  146299. /**
  146300. * Disables the GeometryBufferRender associated with the scene
  146301. */
  146302. disableGeometryBufferRenderer(): void;
  146303. }
  146304. /**
  146305. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  146306. * in several rendering techniques.
  146307. */
  146308. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  146309. /**
  146310. * The component name helpful to identify the component in the list of scene components.
  146311. */
  146312. readonly name: string;
  146313. /**
  146314. * The scene the component belongs to.
  146315. */
  146316. scene: Scene;
  146317. /**
  146318. * Creates a new instance of the component for the given scene
  146319. * @param scene Defines the scene to register the component in
  146320. */
  146321. constructor(scene: Scene);
  146322. /**
  146323. * Registers the component in a given scene
  146324. */
  146325. register(): void;
  146326. /**
  146327. * Rebuilds the elements related to this component in case of
  146328. * context lost for instance.
  146329. */
  146330. rebuild(): void;
  146331. /**
  146332. * Disposes the component and the associated ressources
  146333. */
  146334. dispose(): void;
  146335. private _gatherRenderTargets;
  146336. }
  146337. }
  146338. declare module BABYLON {
  146339. /** @hidden */
  146340. export var motionBlurPixelShader: {
  146341. name: string;
  146342. shader: string;
  146343. };
  146344. }
  146345. declare module BABYLON {
  146346. /**
  146347. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  146348. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  146349. * As an example, all you have to do is to create the post-process:
  146350. * var mb = new BABYLON.MotionBlurPostProcess(
  146351. * 'mb', // The name of the effect.
  146352. * scene, // The scene containing the objects to blur according to their velocity.
  146353. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  146354. * camera // The camera to apply the render pass to.
  146355. * );
  146356. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  146357. */
  146358. export class MotionBlurPostProcess extends PostProcess {
  146359. /**
  146360. * Defines how much the image is blurred by the movement. Default value is equal to 1
  146361. */
  146362. motionStrength: number;
  146363. /**
  146364. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  146365. */
  146366. get motionBlurSamples(): number;
  146367. /**
  146368. * Sets the number of iterations to be used for motion blur quality
  146369. */
  146370. set motionBlurSamples(samples: number);
  146371. private _motionBlurSamples;
  146372. private _geometryBufferRenderer;
  146373. /**
  146374. * Creates a new instance MotionBlurPostProcess
  146375. * @param name The name of the effect.
  146376. * @param scene The scene containing the objects to blur according to their velocity.
  146377. * @param options The required width/height ratio to downsize to before computing the render pass.
  146378. * @param camera The camera to apply the render pass to.
  146379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146380. * @param engine The engine which the post process will be applied. (default: current engine)
  146381. * @param reusable If the post process can be reused on the same frame. (default: false)
  146382. * @param textureType Type of textures used when performing the post process. (default: 0)
  146383. * @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)
  146384. */
  146385. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146386. /**
  146387. * Excludes the given skinned mesh from computing bones velocities.
  146388. * 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.
  146389. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  146390. */
  146391. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146392. /**
  146393. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  146394. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  146395. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  146396. */
  146397. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  146398. /**
  146399. * Disposes the post process.
  146400. * @param camera The camera to dispose the post process on.
  146401. */
  146402. dispose(camera?: Camera): void;
  146403. }
  146404. }
  146405. declare module BABYLON {
  146406. /** @hidden */
  146407. export var refractionPixelShader: {
  146408. name: string;
  146409. shader: string;
  146410. };
  146411. }
  146412. declare module BABYLON {
  146413. /**
  146414. * Post process which applies a refractin texture
  146415. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146416. */
  146417. export class RefractionPostProcess extends PostProcess {
  146418. /** the base color of the refraction (used to taint the rendering) */
  146419. color: Color3;
  146420. /** simulated refraction depth */
  146421. depth: number;
  146422. /** the coefficient of the base color (0 to remove base color tainting) */
  146423. colorLevel: number;
  146424. private _refTexture;
  146425. private _ownRefractionTexture;
  146426. /**
  146427. * Gets or sets the refraction texture
  146428. * Please note that you are responsible for disposing the texture if you set it manually
  146429. */
  146430. get refractionTexture(): Texture;
  146431. set refractionTexture(value: Texture);
  146432. /**
  146433. * Initializes the RefractionPostProcess
  146434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  146435. * @param name The name of the effect.
  146436. * @param refractionTextureUrl Url of the refraction texture to use
  146437. * @param color the base color of the refraction (used to taint the rendering)
  146438. * @param depth simulated refraction depth
  146439. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  146440. * @param camera The camera to apply the render pass to.
  146441. * @param options The required width/height ratio to downsize to before computing the render pass.
  146442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146443. * @param engine The engine which the post process will be applied. (default: current engine)
  146444. * @param reusable If the post process can be reused on the same frame. (default: false)
  146445. */
  146446. constructor(name: string, refractionTextureUrl: string,
  146447. /** the base color of the refraction (used to taint the rendering) */
  146448. color: Color3,
  146449. /** simulated refraction depth */
  146450. depth: number,
  146451. /** the coefficient of the base color (0 to remove base color tainting) */
  146452. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146453. /**
  146454. * Disposes of the post process
  146455. * @param camera Camera to dispose post process on
  146456. */
  146457. dispose(camera: Camera): void;
  146458. }
  146459. }
  146460. declare module BABYLON {
  146461. /** @hidden */
  146462. export var sharpenPixelShader: {
  146463. name: string;
  146464. shader: string;
  146465. };
  146466. }
  146467. declare module BABYLON {
  146468. /**
  146469. * The SharpenPostProcess applies a sharpen kernel to every pixel
  146470. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146471. */
  146472. export class SharpenPostProcess extends PostProcess {
  146473. /**
  146474. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  146475. */
  146476. colorAmount: number;
  146477. /**
  146478. * How much sharpness should be applied (default: 0.3)
  146479. */
  146480. edgeAmount: number;
  146481. /**
  146482. * Creates a new instance ConvolutionPostProcess
  146483. * @param name The name of the effect.
  146484. * @param options The required width/height ratio to downsize to before computing the render pass.
  146485. * @param camera The camera to apply the render pass to.
  146486. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146487. * @param engine The engine which the post process will be applied. (default: current engine)
  146488. * @param reusable If the post process can be reused on the same frame. (default: false)
  146489. * @param textureType Type of textures used when performing the post process. (default: 0)
  146490. * @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)
  146491. */
  146492. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146493. }
  146494. }
  146495. declare module BABYLON {
  146496. /**
  146497. * PostProcessRenderPipeline
  146498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146499. */
  146500. export class PostProcessRenderPipeline {
  146501. private engine;
  146502. private _renderEffects;
  146503. private _renderEffectsForIsolatedPass;
  146504. /**
  146505. * List of inspectable custom properties (used by the Inspector)
  146506. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  146507. */
  146508. inspectableCustomProperties: IInspectable[];
  146509. /**
  146510. * @hidden
  146511. */
  146512. protected _cameras: Camera[];
  146513. /** @hidden */
  146514. _name: string;
  146515. /**
  146516. * Gets pipeline name
  146517. */
  146518. get name(): string;
  146519. /** Gets the list of attached cameras */
  146520. get cameras(): Camera[];
  146521. /**
  146522. * Initializes a PostProcessRenderPipeline
  146523. * @param engine engine to add the pipeline to
  146524. * @param name name of the pipeline
  146525. */
  146526. constructor(engine: Engine, name: string);
  146527. /**
  146528. * Gets the class name
  146529. * @returns "PostProcessRenderPipeline"
  146530. */
  146531. getClassName(): string;
  146532. /**
  146533. * If all the render effects in the pipeline are supported
  146534. */
  146535. get isSupported(): boolean;
  146536. /**
  146537. * Adds an effect to the pipeline
  146538. * @param renderEffect the effect to add
  146539. */
  146540. addEffect(renderEffect: PostProcessRenderEffect): void;
  146541. /** @hidden */
  146542. _rebuild(): void;
  146543. /** @hidden */
  146544. _enableEffect(renderEffectName: string, cameras: Camera): void;
  146545. /** @hidden */
  146546. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  146547. /** @hidden */
  146548. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146549. /** @hidden */
  146550. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  146551. /** @hidden */
  146552. _attachCameras(cameras: Camera, unique: boolean): void;
  146553. /** @hidden */
  146554. _attachCameras(cameras: Camera[], unique: boolean): void;
  146555. /** @hidden */
  146556. _detachCameras(cameras: Camera): void;
  146557. /** @hidden */
  146558. _detachCameras(cameras: Nullable<Camera[]>): void;
  146559. /** @hidden */
  146560. _update(): void;
  146561. /** @hidden */
  146562. _reset(): void;
  146563. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  146564. /**
  146565. * Disposes of the pipeline
  146566. */
  146567. dispose(): void;
  146568. }
  146569. }
  146570. declare module BABYLON {
  146571. /**
  146572. * PostProcessRenderPipelineManager class
  146573. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146574. */
  146575. export class PostProcessRenderPipelineManager {
  146576. private _renderPipelines;
  146577. /**
  146578. * Initializes a PostProcessRenderPipelineManager
  146579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146580. */
  146581. constructor();
  146582. /**
  146583. * Gets the list of supported render pipelines
  146584. */
  146585. get supportedPipelines(): PostProcessRenderPipeline[];
  146586. /**
  146587. * Adds a pipeline to the manager
  146588. * @param renderPipeline The pipeline to add
  146589. */
  146590. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  146591. /**
  146592. * Attaches a camera to the pipeline
  146593. * @param renderPipelineName The name of the pipeline to attach to
  146594. * @param cameras the camera to attach
  146595. * @param unique if the camera can be attached multiple times to the pipeline
  146596. */
  146597. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  146598. /**
  146599. * Detaches a camera from the pipeline
  146600. * @param renderPipelineName The name of the pipeline to detach from
  146601. * @param cameras the camera to detach
  146602. */
  146603. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  146604. /**
  146605. * Enables an effect by name on a pipeline
  146606. * @param renderPipelineName the name of the pipeline to enable the effect in
  146607. * @param renderEffectName the name of the effect to enable
  146608. * @param cameras the cameras that the effect should be enabled on
  146609. */
  146610. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146611. /**
  146612. * Disables an effect by name on a pipeline
  146613. * @param renderPipelineName the name of the pipeline to disable the effect in
  146614. * @param renderEffectName the name of the effect to disable
  146615. * @param cameras the cameras that the effect should be disabled on
  146616. */
  146617. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  146618. /**
  146619. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  146620. */
  146621. update(): void;
  146622. /** @hidden */
  146623. _rebuild(): void;
  146624. /**
  146625. * Disposes of the manager and pipelines
  146626. */
  146627. dispose(): void;
  146628. }
  146629. }
  146630. declare module BABYLON {
  146631. interface Scene {
  146632. /** @hidden (Backing field) */
  146633. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146634. /**
  146635. * Gets the postprocess render pipeline manager
  146636. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146637. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146638. */
  146639. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  146640. }
  146641. /**
  146642. * Defines the Render Pipeline scene component responsible to rendering pipelines
  146643. */
  146644. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  146645. /**
  146646. * The component name helpfull to identify the component in the list of scene components.
  146647. */
  146648. readonly name: string;
  146649. /**
  146650. * The scene the component belongs to.
  146651. */
  146652. scene: Scene;
  146653. /**
  146654. * Creates a new instance of the component for the given scene
  146655. * @param scene Defines the scene to register the component in
  146656. */
  146657. constructor(scene: Scene);
  146658. /**
  146659. * Registers the component in a given scene
  146660. */
  146661. register(): void;
  146662. /**
  146663. * Rebuilds the elements related to this component in case of
  146664. * context lost for instance.
  146665. */
  146666. rebuild(): void;
  146667. /**
  146668. * Disposes the component and the associated ressources
  146669. */
  146670. dispose(): void;
  146671. private _gatherRenderTargets;
  146672. }
  146673. }
  146674. declare module BABYLON {
  146675. /**
  146676. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  146677. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  146678. */
  146679. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  146680. private _scene;
  146681. private _camerasToBeAttached;
  146682. /**
  146683. * ID of the sharpen post process,
  146684. */
  146685. private readonly SharpenPostProcessId;
  146686. /**
  146687. * @ignore
  146688. * ID of the image processing post process;
  146689. */
  146690. readonly ImageProcessingPostProcessId: string;
  146691. /**
  146692. * @ignore
  146693. * ID of the Fast Approximate Anti-Aliasing post process;
  146694. */
  146695. readonly FxaaPostProcessId: string;
  146696. /**
  146697. * ID of the chromatic aberration post process,
  146698. */
  146699. private readonly ChromaticAberrationPostProcessId;
  146700. /**
  146701. * ID of the grain post process
  146702. */
  146703. private readonly GrainPostProcessId;
  146704. /**
  146705. * Sharpen post process which will apply a sharpen convolution to enhance edges
  146706. */
  146707. sharpen: SharpenPostProcess;
  146708. private _sharpenEffect;
  146709. private bloom;
  146710. /**
  146711. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  146712. */
  146713. depthOfField: DepthOfFieldEffect;
  146714. /**
  146715. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  146716. */
  146717. fxaa: FxaaPostProcess;
  146718. /**
  146719. * Image post processing pass used to perform operations such as tone mapping or color grading.
  146720. */
  146721. imageProcessing: ImageProcessingPostProcess;
  146722. /**
  146723. * Chromatic aberration post process which will shift rgb colors in the image
  146724. */
  146725. chromaticAberration: ChromaticAberrationPostProcess;
  146726. private _chromaticAberrationEffect;
  146727. /**
  146728. * Grain post process which add noise to the image
  146729. */
  146730. grain: GrainPostProcess;
  146731. private _grainEffect;
  146732. /**
  146733. * Glow post process which adds a glow to emissive areas of the image
  146734. */
  146735. private _glowLayer;
  146736. /**
  146737. * Animations which can be used to tweak settings over a period of time
  146738. */
  146739. animations: Animation[];
  146740. private _imageProcessingConfigurationObserver;
  146741. private _sharpenEnabled;
  146742. private _bloomEnabled;
  146743. private _depthOfFieldEnabled;
  146744. private _depthOfFieldBlurLevel;
  146745. private _fxaaEnabled;
  146746. private _imageProcessingEnabled;
  146747. private _defaultPipelineTextureType;
  146748. private _bloomScale;
  146749. private _chromaticAberrationEnabled;
  146750. private _grainEnabled;
  146751. private _buildAllowed;
  146752. /**
  146753. * Gets active scene
  146754. */
  146755. get scene(): Scene;
  146756. /**
  146757. * Enable or disable the sharpen process from the pipeline
  146758. */
  146759. set sharpenEnabled(enabled: boolean);
  146760. get sharpenEnabled(): boolean;
  146761. private _resizeObserver;
  146762. private _hardwareScaleLevel;
  146763. private _bloomKernel;
  146764. /**
  146765. * Specifies the size of the bloom blur kernel, relative to the final output size
  146766. */
  146767. get bloomKernel(): number;
  146768. set bloomKernel(value: number);
  146769. /**
  146770. * Specifies the weight of the bloom in the final rendering
  146771. */
  146772. private _bloomWeight;
  146773. /**
  146774. * Specifies the luma threshold for the area that will be blurred by the bloom
  146775. */
  146776. private _bloomThreshold;
  146777. private _hdr;
  146778. /**
  146779. * The strength of the bloom.
  146780. */
  146781. set bloomWeight(value: number);
  146782. get bloomWeight(): number;
  146783. /**
  146784. * The strength of the bloom.
  146785. */
  146786. set bloomThreshold(value: number);
  146787. get bloomThreshold(): number;
  146788. /**
  146789. * The scale of the bloom, lower value will provide better performance.
  146790. */
  146791. set bloomScale(value: number);
  146792. get bloomScale(): number;
  146793. /**
  146794. * Enable or disable the bloom from the pipeline
  146795. */
  146796. set bloomEnabled(enabled: boolean);
  146797. get bloomEnabled(): boolean;
  146798. private _rebuildBloom;
  146799. /**
  146800. * If the depth of field is enabled.
  146801. */
  146802. get depthOfFieldEnabled(): boolean;
  146803. set depthOfFieldEnabled(enabled: boolean);
  146804. /**
  146805. * Blur level of the depth of field effect. (Higher blur will effect performance)
  146806. */
  146807. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  146808. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  146809. /**
  146810. * If the anti aliasing is enabled.
  146811. */
  146812. set fxaaEnabled(enabled: boolean);
  146813. get fxaaEnabled(): boolean;
  146814. private _samples;
  146815. /**
  146816. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  146817. */
  146818. set samples(sampleCount: number);
  146819. get samples(): number;
  146820. /**
  146821. * If image processing is enabled.
  146822. */
  146823. set imageProcessingEnabled(enabled: boolean);
  146824. get imageProcessingEnabled(): boolean;
  146825. /**
  146826. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  146827. */
  146828. set glowLayerEnabled(enabled: boolean);
  146829. get glowLayerEnabled(): boolean;
  146830. /**
  146831. * Gets the glow layer (or null if not defined)
  146832. */
  146833. get glowLayer(): Nullable<GlowLayer>;
  146834. /**
  146835. * Enable or disable the chromaticAberration process from the pipeline
  146836. */
  146837. set chromaticAberrationEnabled(enabled: boolean);
  146838. get chromaticAberrationEnabled(): boolean;
  146839. /**
  146840. * Enable or disable the grain process from the pipeline
  146841. */
  146842. set grainEnabled(enabled: boolean);
  146843. get grainEnabled(): boolean;
  146844. /**
  146845. * @constructor
  146846. * @param name - The rendering pipeline name (default: "")
  146847. * @param hdr - If high dynamic range textures should be used (default: true)
  146848. * @param scene - The scene linked to this pipeline (default: the last created scene)
  146849. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  146850. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  146851. */
  146852. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  146853. /**
  146854. * Get the class name
  146855. * @returns "DefaultRenderingPipeline"
  146856. */
  146857. getClassName(): string;
  146858. /**
  146859. * Force the compilation of the entire pipeline.
  146860. */
  146861. prepare(): void;
  146862. private _hasCleared;
  146863. private _prevPostProcess;
  146864. private _prevPrevPostProcess;
  146865. private _setAutoClearAndTextureSharing;
  146866. private _depthOfFieldSceneObserver;
  146867. private _buildPipeline;
  146868. private _disposePostProcesses;
  146869. /**
  146870. * Adds a camera to the pipeline
  146871. * @param camera the camera to be added
  146872. */
  146873. addCamera(camera: Camera): void;
  146874. /**
  146875. * Removes a camera from the pipeline
  146876. * @param camera the camera to remove
  146877. */
  146878. removeCamera(camera: Camera): void;
  146879. /**
  146880. * Dispose of the pipeline and stop all post processes
  146881. */
  146882. dispose(): void;
  146883. /**
  146884. * Serialize the rendering pipeline (Used when exporting)
  146885. * @returns the serialized object
  146886. */
  146887. serialize(): any;
  146888. /**
  146889. * Parse the serialized pipeline
  146890. * @param source Source pipeline.
  146891. * @param scene The scene to load the pipeline to.
  146892. * @param rootUrl The URL of the serialized pipeline.
  146893. * @returns An instantiated pipeline from the serialized object.
  146894. */
  146895. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  146896. }
  146897. }
  146898. declare module BABYLON {
  146899. /** @hidden */
  146900. export var lensHighlightsPixelShader: {
  146901. name: string;
  146902. shader: string;
  146903. };
  146904. }
  146905. declare module BABYLON {
  146906. /** @hidden */
  146907. export var depthOfFieldPixelShader: {
  146908. name: string;
  146909. shader: string;
  146910. };
  146911. }
  146912. declare module BABYLON {
  146913. /**
  146914. * BABYLON.JS Chromatic Aberration GLSL Shader
  146915. * Author: Olivier Guyot
  146916. * Separates very slightly R, G and B colors on the edges of the screen
  146917. * Inspired by Francois Tarlier & Martins Upitis
  146918. */
  146919. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  146920. /**
  146921. * @ignore
  146922. * The chromatic aberration PostProcess id in the pipeline
  146923. */
  146924. LensChromaticAberrationEffect: string;
  146925. /**
  146926. * @ignore
  146927. * The highlights enhancing PostProcess id in the pipeline
  146928. */
  146929. HighlightsEnhancingEffect: string;
  146930. /**
  146931. * @ignore
  146932. * The depth-of-field PostProcess id in the pipeline
  146933. */
  146934. LensDepthOfFieldEffect: string;
  146935. private _scene;
  146936. private _depthTexture;
  146937. private _grainTexture;
  146938. private _chromaticAberrationPostProcess;
  146939. private _highlightsPostProcess;
  146940. private _depthOfFieldPostProcess;
  146941. private _edgeBlur;
  146942. private _grainAmount;
  146943. private _chromaticAberration;
  146944. private _distortion;
  146945. private _highlightsGain;
  146946. private _highlightsThreshold;
  146947. private _dofDistance;
  146948. private _dofAperture;
  146949. private _dofDarken;
  146950. private _dofPentagon;
  146951. private _blurNoise;
  146952. /**
  146953. * @constructor
  146954. *
  146955. * Effect parameters are as follow:
  146956. * {
  146957. * chromatic_aberration: number; // from 0 to x (1 for realism)
  146958. * edge_blur: number; // from 0 to x (1 for realism)
  146959. * distortion: number; // from 0 to x (1 for realism)
  146960. * grain_amount: number; // from 0 to 1
  146961. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  146962. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  146963. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  146964. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  146965. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  146966. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  146967. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  146968. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  146969. * }
  146970. * Note: if an effect parameter is unset, effect is disabled
  146971. *
  146972. * @param name The rendering pipeline name
  146973. * @param parameters - An object containing all parameters (see above)
  146974. * @param scene The scene linked to this pipeline
  146975. * @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)
  146976. * @param cameras The array of cameras that the rendering pipeline will be attached to
  146977. */
  146978. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  146979. /**
  146980. * Get the class name
  146981. * @returns "LensRenderingPipeline"
  146982. */
  146983. getClassName(): string;
  146984. /**
  146985. * Gets associated scene
  146986. */
  146987. get scene(): Scene;
  146988. /**
  146989. * Gets or sets the edge blur
  146990. */
  146991. get edgeBlur(): number;
  146992. set edgeBlur(value: number);
  146993. /**
  146994. * Gets or sets the grain amount
  146995. */
  146996. get grainAmount(): number;
  146997. set grainAmount(value: number);
  146998. /**
  146999. * Gets or sets the chromatic aberration amount
  147000. */
  147001. get chromaticAberration(): number;
  147002. set chromaticAberration(value: number);
  147003. /**
  147004. * Gets or sets the depth of field aperture
  147005. */
  147006. get dofAperture(): number;
  147007. set dofAperture(value: number);
  147008. /**
  147009. * Gets or sets the edge distortion
  147010. */
  147011. get edgeDistortion(): number;
  147012. set edgeDistortion(value: number);
  147013. /**
  147014. * Gets or sets the depth of field distortion
  147015. */
  147016. get dofDistortion(): number;
  147017. set dofDistortion(value: number);
  147018. /**
  147019. * Gets or sets the darken out of focus amount
  147020. */
  147021. get darkenOutOfFocus(): number;
  147022. set darkenOutOfFocus(value: number);
  147023. /**
  147024. * Gets or sets a boolean indicating if blur noise is enabled
  147025. */
  147026. get blurNoise(): boolean;
  147027. set blurNoise(value: boolean);
  147028. /**
  147029. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147030. */
  147031. get pentagonBokeh(): boolean;
  147032. set pentagonBokeh(value: boolean);
  147033. /**
  147034. * Gets or sets the highlight grain amount
  147035. */
  147036. get highlightsGain(): number;
  147037. set highlightsGain(value: number);
  147038. /**
  147039. * Gets or sets the highlight threshold
  147040. */
  147041. get highlightsThreshold(): number;
  147042. set highlightsThreshold(value: number);
  147043. /**
  147044. * Sets the amount of blur at the edges
  147045. * @param amount blur amount
  147046. */
  147047. setEdgeBlur(amount: number): void;
  147048. /**
  147049. * Sets edge blur to 0
  147050. */
  147051. disableEdgeBlur(): void;
  147052. /**
  147053. * Sets the amout of grain
  147054. * @param amount Amount of grain
  147055. */
  147056. setGrainAmount(amount: number): void;
  147057. /**
  147058. * Set grain amount to 0
  147059. */
  147060. disableGrain(): void;
  147061. /**
  147062. * Sets the chromatic aberration amount
  147063. * @param amount amount of chromatic aberration
  147064. */
  147065. setChromaticAberration(amount: number): void;
  147066. /**
  147067. * Sets chromatic aberration amount to 0
  147068. */
  147069. disableChromaticAberration(): void;
  147070. /**
  147071. * Sets the EdgeDistortion amount
  147072. * @param amount amount of EdgeDistortion
  147073. */
  147074. setEdgeDistortion(amount: number): void;
  147075. /**
  147076. * Sets edge distortion to 0
  147077. */
  147078. disableEdgeDistortion(): void;
  147079. /**
  147080. * Sets the FocusDistance amount
  147081. * @param amount amount of FocusDistance
  147082. */
  147083. setFocusDistance(amount: number): void;
  147084. /**
  147085. * Disables depth of field
  147086. */
  147087. disableDepthOfField(): void;
  147088. /**
  147089. * Sets the Aperture amount
  147090. * @param amount amount of Aperture
  147091. */
  147092. setAperture(amount: number): void;
  147093. /**
  147094. * Sets the DarkenOutOfFocus amount
  147095. * @param amount amount of DarkenOutOfFocus
  147096. */
  147097. setDarkenOutOfFocus(amount: number): void;
  147098. private _pentagonBokehIsEnabled;
  147099. /**
  147100. * Creates a pentagon bokeh effect
  147101. */
  147102. enablePentagonBokeh(): void;
  147103. /**
  147104. * Disables the pentagon bokeh effect
  147105. */
  147106. disablePentagonBokeh(): void;
  147107. /**
  147108. * Enables noise blur
  147109. */
  147110. enableNoiseBlur(): void;
  147111. /**
  147112. * Disables noise blur
  147113. */
  147114. disableNoiseBlur(): void;
  147115. /**
  147116. * Sets the HighlightsGain amount
  147117. * @param amount amount of HighlightsGain
  147118. */
  147119. setHighlightsGain(amount: number): void;
  147120. /**
  147121. * Sets the HighlightsThreshold amount
  147122. * @param amount amount of HighlightsThreshold
  147123. */
  147124. setHighlightsThreshold(amount: number): void;
  147125. /**
  147126. * Disables highlights
  147127. */
  147128. disableHighlights(): void;
  147129. /**
  147130. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  147131. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  147132. */
  147133. dispose(disableDepthRender?: boolean): void;
  147134. private _createChromaticAberrationPostProcess;
  147135. private _createHighlightsPostProcess;
  147136. private _createDepthOfFieldPostProcess;
  147137. private _createGrainTexture;
  147138. }
  147139. }
  147140. declare module BABYLON {
  147141. /** @hidden */
  147142. export var ssao2PixelShader: {
  147143. name: string;
  147144. shader: string;
  147145. };
  147146. }
  147147. declare module BABYLON {
  147148. /** @hidden */
  147149. export var ssaoCombinePixelShader: {
  147150. name: string;
  147151. shader: string;
  147152. };
  147153. }
  147154. declare module BABYLON {
  147155. /**
  147156. * Render pipeline to produce ssao effect
  147157. */
  147158. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  147159. /**
  147160. * @ignore
  147161. * The PassPostProcess id in the pipeline that contains the original scene color
  147162. */
  147163. SSAOOriginalSceneColorEffect: string;
  147164. /**
  147165. * @ignore
  147166. * The SSAO PostProcess id in the pipeline
  147167. */
  147168. SSAORenderEffect: string;
  147169. /**
  147170. * @ignore
  147171. * The horizontal blur PostProcess id in the pipeline
  147172. */
  147173. SSAOBlurHRenderEffect: string;
  147174. /**
  147175. * @ignore
  147176. * The vertical blur PostProcess id in the pipeline
  147177. */
  147178. SSAOBlurVRenderEffect: string;
  147179. /**
  147180. * @ignore
  147181. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147182. */
  147183. SSAOCombineRenderEffect: string;
  147184. /**
  147185. * The output strength of the SSAO post-process. Default value is 1.0.
  147186. */
  147187. totalStrength: number;
  147188. /**
  147189. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  147190. */
  147191. maxZ: number;
  147192. /**
  147193. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  147194. */
  147195. minZAspect: number;
  147196. private _samples;
  147197. /**
  147198. * Number of samples used for the SSAO calculations. Default value is 8
  147199. */
  147200. set samples(n: number);
  147201. get samples(): number;
  147202. private _textureSamples;
  147203. /**
  147204. * Number of samples to use for antialiasing
  147205. */
  147206. set textureSamples(n: number);
  147207. get textureSamples(): number;
  147208. /**
  147209. * Ratio object used for SSAO ratio and blur ratio
  147210. */
  147211. private _ratio;
  147212. /**
  147213. * Dynamically generated sphere sampler.
  147214. */
  147215. private _sampleSphere;
  147216. /**
  147217. * Blur filter offsets
  147218. */
  147219. private _samplerOffsets;
  147220. private _expensiveBlur;
  147221. /**
  147222. * If bilateral blur should be used
  147223. */
  147224. set expensiveBlur(b: boolean);
  147225. get expensiveBlur(): boolean;
  147226. /**
  147227. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  147228. */
  147229. radius: number;
  147230. /**
  147231. * The base color of the SSAO post-process
  147232. * The final result is "base + ssao" between [0, 1]
  147233. */
  147234. base: number;
  147235. /**
  147236. * Support test.
  147237. */
  147238. static get IsSupported(): boolean;
  147239. private _scene;
  147240. private _depthTexture;
  147241. private _normalTexture;
  147242. private _randomTexture;
  147243. private _originalColorPostProcess;
  147244. private _ssaoPostProcess;
  147245. private _blurHPostProcess;
  147246. private _blurVPostProcess;
  147247. private _ssaoCombinePostProcess;
  147248. /**
  147249. * Gets active scene
  147250. */
  147251. get scene(): Scene;
  147252. /**
  147253. * @constructor
  147254. * @param name The rendering pipeline name
  147255. * @param scene The scene linked to this pipeline
  147256. * @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 }
  147257. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147258. */
  147259. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147260. /**
  147261. * Get the class name
  147262. * @returns "SSAO2RenderingPipeline"
  147263. */
  147264. getClassName(): string;
  147265. /**
  147266. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147267. */
  147268. dispose(disableGeometryBufferRenderer?: boolean): void;
  147269. private _createBlurPostProcess;
  147270. /** @hidden */
  147271. _rebuild(): void;
  147272. private _bits;
  147273. private _radicalInverse_VdC;
  147274. private _hammersley;
  147275. private _hemisphereSample_uniform;
  147276. private _generateHemisphere;
  147277. private _createSSAOPostProcess;
  147278. private _createSSAOCombinePostProcess;
  147279. private _createRandomTexture;
  147280. /**
  147281. * Serialize the rendering pipeline (Used when exporting)
  147282. * @returns the serialized object
  147283. */
  147284. serialize(): any;
  147285. /**
  147286. * Parse the serialized pipeline
  147287. * @param source Source pipeline.
  147288. * @param scene The scene to load the pipeline to.
  147289. * @param rootUrl The URL of the serialized pipeline.
  147290. * @returns An instantiated pipeline from the serialized object.
  147291. */
  147292. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  147293. }
  147294. }
  147295. declare module BABYLON {
  147296. /** @hidden */
  147297. export var ssaoPixelShader: {
  147298. name: string;
  147299. shader: string;
  147300. };
  147301. }
  147302. declare module BABYLON {
  147303. /**
  147304. * Render pipeline to produce ssao effect
  147305. */
  147306. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  147307. /**
  147308. * @ignore
  147309. * The PassPostProcess id in the pipeline that contains the original scene color
  147310. */
  147311. SSAOOriginalSceneColorEffect: string;
  147312. /**
  147313. * @ignore
  147314. * The SSAO PostProcess id in the pipeline
  147315. */
  147316. SSAORenderEffect: string;
  147317. /**
  147318. * @ignore
  147319. * The horizontal blur PostProcess id in the pipeline
  147320. */
  147321. SSAOBlurHRenderEffect: string;
  147322. /**
  147323. * @ignore
  147324. * The vertical blur PostProcess id in the pipeline
  147325. */
  147326. SSAOBlurVRenderEffect: string;
  147327. /**
  147328. * @ignore
  147329. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  147330. */
  147331. SSAOCombineRenderEffect: string;
  147332. /**
  147333. * The output strength of the SSAO post-process. Default value is 1.0.
  147334. */
  147335. totalStrength: number;
  147336. /**
  147337. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  147338. */
  147339. radius: number;
  147340. /**
  147341. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  147342. * Must not be equal to fallOff and superior to fallOff.
  147343. * Default value is 0.0075
  147344. */
  147345. area: number;
  147346. /**
  147347. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  147348. * Must not be equal to area and inferior to area.
  147349. * Default value is 0.000001
  147350. */
  147351. fallOff: number;
  147352. /**
  147353. * The base color of the SSAO post-process
  147354. * The final result is "base + ssao" between [0, 1]
  147355. */
  147356. base: number;
  147357. private _scene;
  147358. private _depthTexture;
  147359. private _randomTexture;
  147360. private _originalColorPostProcess;
  147361. private _ssaoPostProcess;
  147362. private _blurHPostProcess;
  147363. private _blurVPostProcess;
  147364. private _ssaoCombinePostProcess;
  147365. private _firstUpdate;
  147366. /**
  147367. * Gets active scene
  147368. */
  147369. get scene(): Scene;
  147370. /**
  147371. * @constructor
  147372. * @param name - The rendering pipeline name
  147373. * @param scene - The scene linked to this pipeline
  147374. * @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 }
  147375. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  147376. */
  147377. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  147378. /**
  147379. * Get the class name
  147380. * @returns "SSAORenderingPipeline"
  147381. */
  147382. getClassName(): string;
  147383. /**
  147384. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  147385. */
  147386. dispose(disableDepthRender?: boolean): void;
  147387. private _createBlurPostProcess;
  147388. /** @hidden */
  147389. _rebuild(): void;
  147390. private _createSSAOPostProcess;
  147391. private _createSSAOCombinePostProcess;
  147392. private _createRandomTexture;
  147393. }
  147394. }
  147395. declare module BABYLON {
  147396. /** @hidden */
  147397. export var screenSpaceReflectionPixelShader: {
  147398. name: string;
  147399. shader: string;
  147400. };
  147401. }
  147402. declare module BABYLON {
  147403. /**
  147404. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  147405. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  147406. */
  147407. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  147408. /**
  147409. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  147410. */
  147411. threshold: number;
  147412. /**
  147413. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  147414. */
  147415. strength: number;
  147416. /**
  147417. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  147418. */
  147419. reflectionSpecularFalloffExponent: number;
  147420. /**
  147421. * 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]
  147422. */
  147423. step: number;
  147424. /**
  147425. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  147426. */
  147427. roughnessFactor: number;
  147428. private _geometryBufferRenderer;
  147429. private _enableSmoothReflections;
  147430. private _reflectionSamples;
  147431. private _smoothSteps;
  147432. /**
  147433. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  147434. * @param name The name of the effect.
  147435. * @param scene The scene containing the objects to calculate reflections.
  147436. * @param options The required width/height ratio to downsize to before computing the render pass.
  147437. * @param camera The camera to apply the render pass to.
  147438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147439. * @param engine The engine which the post process will be applied. (default: current engine)
  147440. * @param reusable If the post process can be reused on the same frame. (default: false)
  147441. * @param textureType Type of textures used when performing the post process. (default: 0)
  147442. * @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)
  147443. */
  147444. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147445. /**
  147446. * Gets wether or not smoothing reflections is enabled.
  147447. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147448. */
  147449. get enableSmoothReflections(): boolean;
  147450. /**
  147451. * Sets wether or not smoothing reflections is enabled.
  147452. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  147453. */
  147454. set enableSmoothReflections(enabled: boolean);
  147455. /**
  147456. * Gets the number of samples taken while computing reflections. More samples count is high,
  147457. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147458. */
  147459. get reflectionSamples(): number;
  147460. /**
  147461. * Sets the number of samples taken while computing reflections. More samples count is high,
  147462. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  147463. */
  147464. set reflectionSamples(samples: number);
  147465. /**
  147466. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  147467. * more the post-process will require GPU power and can generate a drop in FPS.
  147468. * Default value (5.0) work pretty well in all cases but can be adjusted.
  147469. */
  147470. get smoothSteps(): number;
  147471. set smoothSteps(steps: number);
  147472. private _updateEffectDefines;
  147473. }
  147474. }
  147475. declare module BABYLON {
  147476. /** @hidden */
  147477. export var standardPixelShader: {
  147478. name: string;
  147479. shader: string;
  147480. };
  147481. }
  147482. declare module BABYLON {
  147483. /**
  147484. * Standard rendering pipeline
  147485. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147486. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  147487. */
  147488. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147489. /**
  147490. * Public members
  147491. */
  147492. /**
  147493. * Post-process which contains the original scene color before the pipeline applies all the effects
  147494. */
  147495. originalPostProcess: Nullable<PostProcess>;
  147496. /**
  147497. * Post-process used to down scale an image x4
  147498. */
  147499. downSampleX4PostProcess: Nullable<PostProcess>;
  147500. /**
  147501. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  147502. */
  147503. brightPassPostProcess: Nullable<PostProcess>;
  147504. /**
  147505. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  147506. */
  147507. blurHPostProcesses: PostProcess[];
  147508. /**
  147509. * Post-process array storing all the vertical blur post-processes used by the pipeline
  147510. */
  147511. blurVPostProcesses: PostProcess[];
  147512. /**
  147513. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  147514. */
  147515. textureAdderPostProcess: Nullable<PostProcess>;
  147516. /**
  147517. * Post-process used to create volumetric lighting effect
  147518. */
  147519. volumetricLightPostProcess: Nullable<PostProcess>;
  147520. /**
  147521. * Post-process used to smooth the previous volumetric light post-process on the X axis
  147522. */
  147523. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  147524. /**
  147525. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  147526. */
  147527. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  147528. /**
  147529. * Post-process used to merge the volumetric light effect and the real scene color
  147530. */
  147531. volumetricLightMergePostProces: Nullable<PostProcess>;
  147532. /**
  147533. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  147534. */
  147535. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  147536. /**
  147537. * Base post-process used to calculate the average luminance of the final image for HDR
  147538. */
  147539. luminancePostProcess: Nullable<PostProcess>;
  147540. /**
  147541. * Post-processes used to create down sample post-processes in order to get
  147542. * the average luminance of the final image for HDR
  147543. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  147544. */
  147545. luminanceDownSamplePostProcesses: PostProcess[];
  147546. /**
  147547. * Post-process used to create a HDR effect (light adaptation)
  147548. */
  147549. hdrPostProcess: Nullable<PostProcess>;
  147550. /**
  147551. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  147552. */
  147553. textureAdderFinalPostProcess: Nullable<PostProcess>;
  147554. /**
  147555. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  147556. */
  147557. lensFlareFinalPostProcess: Nullable<PostProcess>;
  147558. /**
  147559. * Post-process used to merge the final HDR post-process and the real scene color
  147560. */
  147561. hdrFinalPostProcess: Nullable<PostProcess>;
  147562. /**
  147563. * Post-process used to create a lens flare effect
  147564. */
  147565. lensFlarePostProcess: Nullable<PostProcess>;
  147566. /**
  147567. * Post-process that merges the result of the lens flare post-process and the real scene color
  147568. */
  147569. lensFlareComposePostProcess: Nullable<PostProcess>;
  147570. /**
  147571. * Post-process used to create a motion blur effect
  147572. */
  147573. motionBlurPostProcess: Nullable<PostProcess>;
  147574. /**
  147575. * Post-process used to create a depth of field effect
  147576. */
  147577. depthOfFieldPostProcess: Nullable<PostProcess>;
  147578. /**
  147579. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147580. */
  147581. fxaaPostProcess: Nullable<FxaaPostProcess>;
  147582. /**
  147583. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  147584. */
  147585. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  147586. /**
  147587. * Represents the brightness threshold in order to configure the illuminated surfaces
  147588. */
  147589. brightThreshold: number;
  147590. /**
  147591. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  147592. */
  147593. blurWidth: number;
  147594. /**
  147595. * Sets if the blur for highlighted surfaces must be only horizontal
  147596. */
  147597. horizontalBlur: boolean;
  147598. /**
  147599. * Gets the overall exposure used by the pipeline
  147600. */
  147601. get exposure(): number;
  147602. /**
  147603. * Sets the overall exposure used by the pipeline
  147604. */
  147605. set exposure(value: number);
  147606. /**
  147607. * Texture used typically to simulate "dirty" on camera lens
  147608. */
  147609. lensTexture: Nullable<Texture>;
  147610. /**
  147611. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  147612. */
  147613. volumetricLightCoefficient: number;
  147614. /**
  147615. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  147616. */
  147617. volumetricLightPower: number;
  147618. /**
  147619. * Used the set the blur intensity to smooth the volumetric lights
  147620. */
  147621. volumetricLightBlurScale: number;
  147622. /**
  147623. * Light (spot or directional) used to generate the volumetric lights rays
  147624. * The source light must have a shadow generate so the pipeline can get its
  147625. * depth map
  147626. */
  147627. sourceLight: Nullable<SpotLight | DirectionalLight>;
  147628. /**
  147629. * For eye adaptation, represents the minimum luminance the eye can see
  147630. */
  147631. hdrMinimumLuminance: number;
  147632. /**
  147633. * For eye adaptation, represents the decrease luminance speed
  147634. */
  147635. hdrDecreaseRate: number;
  147636. /**
  147637. * For eye adaptation, represents the increase luminance speed
  147638. */
  147639. hdrIncreaseRate: number;
  147640. /**
  147641. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147642. */
  147643. get hdrAutoExposure(): boolean;
  147644. /**
  147645. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  147646. */
  147647. set hdrAutoExposure(value: boolean);
  147648. /**
  147649. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  147650. */
  147651. lensColorTexture: Nullable<Texture>;
  147652. /**
  147653. * The overall strengh for the lens flare effect
  147654. */
  147655. lensFlareStrength: number;
  147656. /**
  147657. * Dispersion coefficient for lens flare ghosts
  147658. */
  147659. lensFlareGhostDispersal: number;
  147660. /**
  147661. * Main lens flare halo width
  147662. */
  147663. lensFlareHaloWidth: number;
  147664. /**
  147665. * Based on the lens distortion effect, defines how much the lens flare result
  147666. * is distorted
  147667. */
  147668. lensFlareDistortionStrength: number;
  147669. /**
  147670. * Configures the blur intensity used for for lens flare (halo)
  147671. */
  147672. lensFlareBlurWidth: number;
  147673. /**
  147674. * Lens star texture must be used to simulate rays on the flares and is available
  147675. * in the documentation
  147676. */
  147677. lensStarTexture: Nullable<Texture>;
  147678. /**
  147679. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  147680. * flare effect by taking account of the dirt texture
  147681. */
  147682. lensFlareDirtTexture: Nullable<Texture>;
  147683. /**
  147684. * Represents the focal length for the depth of field effect
  147685. */
  147686. depthOfFieldDistance: number;
  147687. /**
  147688. * Represents the blur intensity for the blurred part of the depth of field effect
  147689. */
  147690. depthOfFieldBlurWidth: number;
  147691. /**
  147692. * Gets how much the image is blurred by the movement while using the motion blur post-process
  147693. */
  147694. get motionStrength(): number;
  147695. /**
  147696. * Sets how much the image is blurred by the movement while using the motion blur post-process
  147697. */
  147698. set motionStrength(strength: number);
  147699. /**
  147700. * Gets wether or not the motion blur post-process is object based or screen based.
  147701. */
  147702. get objectBasedMotionBlur(): boolean;
  147703. /**
  147704. * Sets wether or not the motion blur post-process should be object based or screen based
  147705. */
  147706. set objectBasedMotionBlur(value: boolean);
  147707. /**
  147708. * List of animations for the pipeline (IAnimatable implementation)
  147709. */
  147710. animations: Animation[];
  147711. /**
  147712. * Private members
  147713. */
  147714. private _scene;
  147715. private _currentDepthOfFieldSource;
  147716. private _basePostProcess;
  147717. private _fixedExposure;
  147718. private _currentExposure;
  147719. private _hdrAutoExposure;
  147720. private _hdrCurrentLuminance;
  147721. private _motionStrength;
  147722. private _isObjectBasedMotionBlur;
  147723. private _floatTextureType;
  147724. private _camerasToBeAttached;
  147725. private _ratio;
  147726. private _bloomEnabled;
  147727. private _depthOfFieldEnabled;
  147728. private _vlsEnabled;
  147729. private _lensFlareEnabled;
  147730. private _hdrEnabled;
  147731. private _motionBlurEnabled;
  147732. private _fxaaEnabled;
  147733. private _screenSpaceReflectionsEnabled;
  147734. private _motionBlurSamples;
  147735. private _volumetricLightStepsCount;
  147736. private _samples;
  147737. /**
  147738. * @ignore
  147739. * Specifies if the bloom pipeline is enabled
  147740. */
  147741. get BloomEnabled(): boolean;
  147742. set BloomEnabled(enabled: boolean);
  147743. /**
  147744. * @ignore
  147745. * Specifies if the depth of field pipeline is enabed
  147746. */
  147747. get DepthOfFieldEnabled(): boolean;
  147748. set DepthOfFieldEnabled(enabled: boolean);
  147749. /**
  147750. * @ignore
  147751. * Specifies if the lens flare pipeline is enabed
  147752. */
  147753. get LensFlareEnabled(): boolean;
  147754. set LensFlareEnabled(enabled: boolean);
  147755. /**
  147756. * @ignore
  147757. * Specifies if the HDR pipeline is enabled
  147758. */
  147759. get HDREnabled(): boolean;
  147760. set HDREnabled(enabled: boolean);
  147761. /**
  147762. * @ignore
  147763. * Specifies if the volumetric lights scattering effect is enabled
  147764. */
  147765. get VLSEnabled(): boolean;
  147766. set VLSEnabled(enabled: boolean);
  147767. /**
  147768. * @ignore
  147769. * Specifies if the motion blur effect is enabled
  147770. */
  147771. get MotionBlurEnabled(): boolean;
  147772. set MotionBlurEnabled(enabled: boolean);
  147773. /**
  147774. * Specifies if anti-aliasing is enabled
  147775. */
  147776. get fxaaEnabled(): boolean;
  147777. set fxaaEnabled(enabled: boolean);
  147778. /**
  147779. * Specifies if screen space reflections are enabled.
  147780. */
  147781. get screenSpaceReflectionsEnabled(): boolean;
  147782. set screenSpaceReflectionsEnabled(enabled: boolean);
  147783. /**
  147784. * Specifies the number of steps used to calculate the volumetric lights
  147785. * Typically in interval [50, 200]
  147786. */
  147787. get volumetricLightStepsCount(): number;
  147788. set volumetricLightStepsCount(count: number);
  147789. /**
  147790. * Specifies the number of samples used for the motion blur effect
  147791. * Typically in interval [16, 64]
  147792. */
  147793. get motionBlurSamples(): number;
  147794. set motionBlurSamples(samples: number);
  147795. /**
  147796. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147797. */
  147798. get samples(): number;
  147799. set samples(sampleCount: number);
  147800. /**
  147801. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  147802. * @constructor
  147803. * @param name The rendering pipeline name
  147804. * @param scene The scene linked to this pipeline
  147805. * @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)
  147806. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  147807. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147808. */
  147809. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  147810. private _buildPipeline;
  147811. private _createDownSampleX4PostProcess;
  147812. private _createBrightPassPostProcess;
  147813. private _createBlurPostProcesses;
  147814. private _createTextureAdderPostProcess;
  147815. private _createVolumetricLightPostProcess;
  147816. private _createLuminancePostProcesses;
  147817. private _createHdrPostProcess;
  147818. private _createLensFlarePostProcess;
  147819. private _createDepthOfFieldPostProcess;
  147820. private _createMotionBlurPostProcess;
  147821. private _getDepthTexture;
  147822. private _disposePostProcesses;
  147823. /**
  147824. * Dispose of the pipeline and stop all post processes
  147825. */
  147826. dispose(): void;
  147827. /**
  147828. * Serialize the rendering pipeline (Used when exporting)
  147829. * @returns the serialized object
  147830. */
  147831. serialize(): any;
  147832. /**
  147833. * Parse the serialized pipeline
  147834. * @param source Source pipeline.
  147835. * @param scene The scene to load the pipeline to.
  147836. * @param rootUrl The URL of the serialized pipeline.
  147837. * @returns An instantiated pipeline from the serialized object.
  147838. */
  147839. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  147840. /**
  147841. * Luminance steps
  147842. */
  147843. static LuminanceSteps: number;
  147844. }
  147845. }
  147846. declare module BABYLON {
  147847. /** @hidden */
  147848. export var stereoscopicInterlacePixelShader: {
  147849. name: string;
  147850. shader: string;
  147851. };
  147852. }
  147853. declare module BABYLON {
  147854. /**
  147855. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  147856. */
  147857. export class StereoscopicInterlacePostProcessI extends PostProcess {
  147858. private _stepSize;
  147859. private _passedProcess;
  147860. /**
  147861. * Initializes a StereoscopicInterlacePostProcessI
  147862. * @param name The name of the effect.
  147863. * @param rigCameras The rig cameras to be appled to the post process
  147864. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  147865. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  147866. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147867. * @param engine The engine which the post process will be applied. (default: current engine)
  147868. * @param reusable If the post process can be reused on the same frame. (default: false)
  147869. */
  147870. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147871. }
  147872. /**
  147873. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  147874. */
  147875. export class StereoscopicInterlacePostProcess extends PostProcess {
  147876. private _stepSize;
  147877. private _passedProcess;
  147878. /**
  147879. * Initializes a StereoscopicInterlacePostProcess
  147880. * @param name The name of the effect.
  147881. * @param rigCameras The rig cameras to be appled to the post process
  147882. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  147883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147884. * @param engine The engine which the post process will be applied. (default: current engine)
  147885. * @param reusable If the post process can be reused on the same frame. (default: false)
  147886. */
  147887. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147888. }
  147889. }
  147890. declare module BABYLON {
  147891. /** @hidden */
  147892. export var tonemapPixelShader: {
  147893. name: string;
  147894. shader: string;
  147895. };
  147896. }
  147897. declare module BABYLON {
  147898. /** Defines operator used for tonemapping */
  147899. export enum TonemappingOperator {
  147900. /** Hable */
  147901. Hable = 0,
  147902. /** Reinhard */
  147903. Reinhard = 1,
  147904. /** HejiDawson */
  147905. HejiDawson = 2,
  147906. /** Photographic */
  147907. Photographic = 3
  147908. }
  147909. /**
  147910. * Defines a post process to apply tone mapping
  147911. */
  147912. export class TonemapPostProcess extends PostProcess {
  147913. private _operator;
  147914. /** Defines the required exposure adjustement */
  147915. exposureAdjustment: number;
  147916. /**
  147917. * Creates a new TonemapPostProcess
  147918. * @param name defines the name of the postprocess
  147919. * @param _operator defines the operator to use
  147920. * @param exposureAdjustment defines the required exposure adjustement
  147921. * @param camera defines the camera to use (can be null)
  147922. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  147923. * @param engine defines the hosting engine (can be ignore if camera is set)
  147924. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  147925. */
  147926. constructor(name: string, _operator: TonemappingOperator,
  147927. /** Defines the required exposure adjustement */
  147928. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  147929. }
  147930. }
  147931. declare module BABYLON {
  147932. /** @hidden */
  147933. export var volumetricLightScatteringPixelShader: {
  147934. name: string;
  147935. shader: string;
  147936. };
  147937. }
  147938. declare module BABYLON {
  147939. /** @hidden */
  147940. export var volumetricLightScatteringPassVertexShader: {
  147941. name: string;
  147942. shader: string;
  147943. };
  147944. }
  147945. declare module BABYLON {
  147946. /** @hidden */
  147947. export var volumetricLightScatteringPassPixelShader: {
  147948. name: string;
  147949. shader: string;
  147950. };
  147951. }
  147952. declare module BABYLON {
  147953. /**
  147954. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  147955. */
  147956. export class VolumetricLightScatteringPostProcess extends PostProcess {
  147957. private _volumetricLightScatteringPass;
  147958. private _volumetricLightScatteringRTT;
  147959. private _viewPort;
  147960. private _screenCoordinates;
  147961. private _cachedDefines;
  147962. /**
  147963. * If not undefined, the mesh position is computed from the attached node position
  147964. */
  147965. attachedNode: {
  147966. position: Vector3;
  147967. };
  147968. /**
  147969. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  147970. */
  147971. customMeshPosition: Vector3;
  147972. /**
  147973. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  147974. */
  147975. useCustomMeshPosition: boolean;
  147976. /**
  147977. * If the post-process should inverse the light scattering direction
  147978. */
  147979. invert: boolean;
  147980. /**
  147981. * The internal mesh used by the post-process
  147982. */
  147983. mesh: Mesh;
  147984. /**
  147985. * @hidden
  147986. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  147987. */
  147988. get useDiffuseColor(): boolean;
  147989. set useDiffuseColor(useDiffuseColor: boolean);
  147990. /**
  147991. * Array containing the excluded meshes not rendered in the internal pass
  147992. */
  147993. excludedMeshes: AbstractMesh[];
  147994. /**
  147995. * Controls the overall intensity of the post-process
  147996. */
  147997. exposure: number;
  147998. /**
  147999. * Dissipates each sample's contribution in range [0, 1]
  148000. */
  148001. decay: number;
  148002. /**
  148003. * Controls the overall intensity of each sample
  148004. */
  148005. weight: number;
  148006. /**
  148007. * Controls the density of each sample
  148008. */
  148009. density: number;
  148010. /**
  148011. * @constructor
  148012. * @param name The post-process name
  148013. * @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)
  148014. * @param camera The camera that the post-process will be attached to
  148015. * @param mesh The mesh used to create the light scattering
  148016. * @param samples The post-process quality, default 100
  148017. * @param samplingModeThe post-process filtering mode
  148018. * @param engine The babylon engine
  148019. * @param reusable If the post-process is reusable
  148020. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  148021. */
  148022. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  148023. /**
  148024. * Returns the string "VolumetricLightScatteringPostProcess"
  148025. * @returns "VolumetricLightScatteringPostProcess"
  148026. */
  148027. getClassName(): string;
  148028. private _isReady;
  148029. /**
  148030. * Sets the new light position for light scattering effect
  148031. * @param position The new custom light position
  148032. */
  148033. setCustomMeshPosition(position: Vector3): void;
  148034. /**
  148035. * Returns the light position for light scattering effect
  148036. * @return Vector3 The custom light position
  148037. */
  148038. getCustomMeshPosition(): Vector3;
  148039. /**
  148040. * Disposes the internal assets and detaches the post-process from the camera
  148041. */
  148042. dispose(camera: Camera): void;
  148043. /**
  148044. * Returns the render target texture used by the post-process
  148045. * @return the render target texture used by the post-process
  148046. */
  148047. getPass(): RenderTargetTexture;
  148048. private _meshExcluded;
  148049. private _createPass;
  148050. private _updateMeshScreenCoordinates;
  148051. /**
  148052. * Creates a default mesh for the Volumeric Light Scattering post-process
  148053. * @param name The mesh name
  148054. * @param scene The scene where to create the mesh
  148055. * @return the default mesh
  148056. */
  148057. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  148058. }
  148059. }
  148060. declare module BABYLON {
  148061. interface Scene {
  148062. /** @hidden (Backing field) */
  148063. _boundingBoxRenderer: BoundingBoxRenderer;
  148064. /** @hidden (Backing field) */
  148065. _forceShowBoundingBoxes: boolean;
  148066. /**
  148067. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  148068. */
  148069. forceShowBoundingBoxes: boolean;
  148070. /**
  148071. * Gets the bounding box renderer associated with the scene
  148072. * @returns a BoundingBoxRenderer
  148073. */
  148074. getBoundingBoxRenderer(): BoundingBoxRenderer;
  148075. }
  148076. interface AbstractMesh {
  148077. /** @hidden (Backing field) */
  148078. _showBoundingBox: boolean;
  148079. /**
  148080. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  148081. */
  148082. showBoundingBox: boolean;
  148083. }
  148084. /**
  148085. * Component responsible of rendering the bounding box of the meshes in a scene.
  148086. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  148087. */
  148088. export class BoundingBoxRenderer implements ISceneComponent {
  148089. /**
  148090. * The component name helpfull to identify the component in the list of scene components.
  148091. */
  148092. readonly name: string;
  148093. /**
  148094. * The scene the component belongs to.
  148095. */
  148096. scene: Scene;
  148097. /**
  148098. * Color of the bounding box lines placed in front of an object
  148099. */
  148100. frontColor: Color3;
  148101. /**
  148102. * Color of the bounding box lines placed behind an object
  148103. */
  148104. backColor: Color3;
  148105. /**
  148106. * Defines if the renderer should show the back lines or not
  148107. */
  148108. showBackLines: boolean;
  148109. /**
  148110. * Observable raised before rendering a bounding box
  148111. */
  148112. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  148113. /**
  148114. * Observable raised after rendering a bounding box
  148115. */
  148116. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  148117. /**
  148118. * @hidden
  148119. */
  148120. renderList: SmartArray<BoundingBox>;
  148121. private _colorShader;
  148122. private _vertexBuffers;
  148123. private _indexBuffer;
  148124. private _fillIndexBuffer;
  148125. private _fillIndexData;
  148126. /**
  148127. * Instantiates a new bounding box renderer in a scene.
  148128. * @param scene the scene the renderer renders in
  148129. */
  148130. constructor(scene: Scene);
  148131. /**
  148132. * Registers the component in a given scene
  148133. */
  148134. register(): void;
  148135. private _evaluateSubMesh;
  148136. private _activeMesh;
  148137. private _prepareRessources;
  148138. private _createIndexBuffer;
  148139. /**
  148140. * Rebuilds the elements related to this component in case of
  148141. * context lost for instance.
  148142. */
  148143. rebuild(): void;
  148144. /**
  148145. * @hidden
  148146. */
  148147. reset(): void;
  148148. /**
  148149. * Render the bounding boxes of a specific rendering group
  148150. * @param renderingGroupId defines the rendering group to render
  148151. */
  148152. render(renderingGroupId: number): void;
  148153. /**
  148154. * In case of occlusion queries, we can render the occlusion bounding box through this method
  148155. * @param mesh Define the mesh to render the occlusion bounding box for
  148156. */
  148157. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  148158. /**
  148159. * Dispose and release the resources attached to this renderer.
  148160. */
  148161. dispose(): void;
  148162. }
  148163. }
  148164. declare module BABYLON {
  148165. interface Scene {
  148166. /** @hidden (Backing field) */
  148167. _depthRenderer: {
  148168. [id: string]: DepthRenderer;
  148169. };
  148170. /**
  148171. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  148172. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  148173. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  148174. * @returns the created depth renderer
  148175. */
  148176. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  148177. /**
  148178. * Disables a depth renderer for a given camera
  148179. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  148180. */
  148181. disableDepthRenderer(camera?: Nullable<Camera>): void;
  148182. }
  148183. /**
  148184. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  148185. * in several rendering techniques.
  148186. */
  148187. export class DepthRendererSceneComponent implements ISceneComponent {
  148188. /**
  148189. * The component name helpfull to identify the component in the list of scene components.
  148190. */
  148191. readonly name: string;
  148192. /**
  148193. * The scene the component belongs to.
  148194. */
  148195. scene: Scene;
  148196. /**
  148197. * Creates a new instance of the component for the given scene
  148198. * @param scene Defines the scene to register the component in
  148199. */
  148200. constructor(scene: Scene);
  148201. /**
  148202. * Registers the component in a given scene
  148203. */
  148204. register(): void;
  148205. /**
  148206. * Rebuilds the elements related to this component in case of
  148207. * context lost for instance.
  148208. */
  148209. rebuild(): void;
  148210. /**
  148211. * Disposes the component and the associated ressources
  148212. */
  148213. dispose(): void;
  148214. private _gatherRenderTargets;
  148215. private _gatherActiveCameraRenderTargets;
  148216. }
  148217. }
  148218. declare module BABYLON {
  148219. /** @hidden */
  148220. export var outlinePixelShader: {
  148221. name: string;
  148222. shader: string;
  148223. };
  148224. }
  148225. declare module BABYLON {
  148226. /** @hidden */
  148227. export var outlineVertexShader: {
  148228. name: string;
  148229. shader: string;
  148230. };
  148231. }
  148232. declare module BABYLON {
  148233. interface Scene {
  148234. /** @hidden */
  148235. _outlineRenderer: OutlineRenderer;
  148236. /**
  148237. * Gets the outline renderer associated with the scene
  148238. * @returns a OutlineRenderer
  148239. */
  148240. getOutlineRenderer(): OutlineRenderer;
  148241. }
  148242. interface AbstractMesh {
  148243. /** @hidden (Backing field) */
  148244. _renderOutline: boolean;
  148245. /**
  148246. * Gets or sets a boolean indicating if the outline must be rendered as well
  148247. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  148248. */
  148249. renderOutline: boolean;
  148250. /** @hidden (Backing field) */
  148251. _renderOverlay: boolean;
  148252. /**
  148253. * Gets or sets a boolean indicating if the overlay must be rendered as well
  148254. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  148255. */
  148256. renderOverlay: boolean;
  148257. }
  148258. /**
  148259. * This class is responsible to draw bothe outline/overlay of meshes.
  148260. * It should not be used directly but through the available method on mesh.
  148261. */
  148262. export class OutlineRenderer implements ISceneComponent {
  148263. /**
  148264. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  148265. */
  148266. private static _StencilReference;
  148267. /**
  148268. * The name of the component. Each component must have a unique name.
  148269. */
  148270. name: string;
  148271. /**
  148272. * The scene the component belongs to.
  148273. */
  148274. scene: Scene;
  148275. /**
  148276. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  148277. */
  148278. zOffset: number;
  148279. private _engine;
  148280. private _effect;
  148281. private _cachedDefines;
  148282. private _savedDepthWrite;
  148283. /**
  148284. * Instantiates a new outline renderer. (There could be only one per scene).
  148285. * @param scene Defines the scene it belongs to
  148286. */
  148287. constructor(scene: Scene);
  148288. /**
  148289. * Register the component to one instance of a scene.
  148290. */
  148291. register(): void;
  148292. /**
  148293. * Rebuilds the elements related to this component in case of
  148294. * context lost for instance.
  148295. */
  148296. rebuild(): void;
  148297. /**
  148298. * Disposes the component and the associated ressources.
  148299. */
  148300. dispose(): void;
  148301. /**
  148302. * Renders the outline in the canvas.
  148303. * @param subMesh Defines the sumesh to render
  148304. * @param batch Defines the batch of meshes in case of instances
  148305. * @param useOverlay Defines if the rendering is for the overlay or the outline
  148306. */
  148307. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  148308. /**
  148309. * Returns whether or not the outline renderer is ready for a given submesh.
  148310. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  148311. * @param subMesh Defines the submesh to check readyness for
  148312. * @param useInstances Defines wheter wee are trying to render instances or not
  148313. * @returns true if ready otherwise false
  148314. */
  148315. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  148316. private _beforeRenderingMesh;
  148317. private _afterRenderingMesh;
  148318. }
  148319. }
  148320. declare module BABYLON {
  148321. /**
  148322. * Defines the basic options interface of a Sprite Frame Source Size.
  148323. */
  148324. export interface ISpriteJSONSpriteSourceSize {
  148325. /**
  148326. * number of the original width of the Frame
  148327. */
  148328. w: number;
  148329. /**
  148330. * number of the original height of the Frame
  148331. */
  148332. h: number;
  148333. }
  148334. /**
  148335. * Defines the basic options interface of a Sprite Frame Data.
  148336. */
  148337. export interface ISpriteJSONSpriteFrameData {
  148338. /**
  148339. * number of the x offset of the Frame
  148340. */
  148341. x: number;
  148342. /**
  148343. * number of the y offset of the Frame
  148344. */
  148345. y: number;
  148346. /**
  148347. * number of the width of the Frame
  148348. */
  148349. w: number;
  148350. /**
  148351. * number of the height of the Frame
  148352. */
  148353. h: number;
  148354. }
  148355. /**
  148356. * Defines the basic options interface of a JSON Sprite.
  148357. */
  148358. export interface ISpriteJSONSprite {
  148359. /**
  148360. * string name of the Frame
  148361. */
  148362. filename: string;
  148363. /**
  148364. * ISpriteJSONSpriteFrame basic object of the frame data
  148365. */
  148366. frame: ISpriteJSONSpriteFrameData;
  148367. /**
  148368. * boolean to flag is the frame was rotated.
  148369. */
  148370. rotated: boolean;
  148371. /**
  148372. * boolean to flag is the frame was trimmed.
  148373. */
  148374. trimmed: boolean;
  148375. /**
  148376. * ISpriteJSONSpriteFrame basic object of the source data
  148377. */
  148378. spriteSourceSize: ISpriteJSONSpriteFrameData;
  148379. /**
  148380. * ISpriteJSONSpriteFrame basic object of the source data
  148381. */
  148382. sourceSize: ISpriteJSONSpriteSourceSize;
  148383. }
  148384. /**
  148385. * Defines the basic options interface of a JSON atlas.
  148386. */
  148387. export interface ISpriteJSONAtlas {
  148388. /**
  148389. * Array of objects that contain the frame data.
  148390. */
  148391. frames: Array<ISpriteJSONSprite>;
  148392. /**
  148393. * object basic object containing the sprite meta data.
  148394. */
  148395. meta?: object;
  148396. }
  148397. }
  148398. declare module BABYLON {
  148399. /** @hidden */
  148400. export var spriteMapPixelShader: {
  148401. name: string;
  148402. shader: string;
  148403. };
  148404. }
  148405. declare module BABYLON {
  148406. /** @hidden */
  148407. export var spriteMapVertexShader: {
  148408. name: string;
  148409. shader: string;
  148410. };
  148411. }
  148412. declare module BABYLON {
  148413. /**
  148414. * Defines the basic options interface of a SpriteMap
  148415. */
  148416. export interface ISpriteMapOptions {
  148417. /**
  148418. * Vector2 of the number of cells in the grid.
  148419. */
  148420. stageSize?: Vector2;
  148421. /**
  148422. * Vector2 of the size of the output plane in World Units.
  148423. */
  148424. outputSize?: Vector2;
  148425. /**
  148426. * Vector3 of the position of the output plane in World Units.
  148427. */
  148428. outputPosition?: Vector3;
  148429. /**
  148430. * Vector3 of the rotation of the output plane.
  148431. */
  148432. outputRotation?: Vector3;
  148433. /**
  148434. * number of layers that the system will reserve in resources.
  148435. */
  148436. layerCount?: number;
  148437. /**
  148438. * number of max animation frames a single cell will reserve in resources.
  148439. */
  148440. maxAnimationFrames?: number;
  148441. /**
  148442. * number cell index of the base tile when the system compiles.
  148443. */
  148444. baseTile?: number;
  148445. /**
  148446. * boolean flip the sprite after its been repositioned by the framing data.
  148447. */
  148448. flipU?: boolean;
  148449. /**
  148450. * Vector3 scalar of the global RGB values of the SpriteMap.
  148451. */
  148452. colorMultiply?: Vector3;
  148453. }
  148454. /**
  148455. * Defines the IDisposable interface in order to be cleanable from resources.
  148456. */
  148457. export interface ISpriteMap extends IDisposable {
  148458. /**
  148459. * String name of the SpriteMap.
  148460. */
  148461. name: string;
  148462. /**
  148463. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  148464. */
  148465. atlasJSON: ISpriteJSONAtlas;
  148466. /**
  148467. * Texture of the SpriteMap.
  148468. */
  148469. spriteSheet: Texture;
  148470. /**
  148471. * The parameters to initialize the SpriteMap with.
  148472. */
  148473. options: ISpriteMapOptions;
  148474. }
  148475. /**
  148476. * Class used to manage a grid restricted sprite deployment on an Output plane.
  148477. */
  148478. export class SpriteMap implements ISpriteMap {
  148479. /** The Name of the spriteMap */
  148480. name: string;
  148481. /** The JSON file with the frame and meta data */
  148482. atlasJSON: ISpriteJSONAtlas;
  148483. /** The systems Sprite Sheet Texture */
  148484. spriteSheet: Texture;
  148485. /** Arguments passed with the Constructor */
  148486. options: ISpriteMapOptions;
  148487. /** Public Sprite Storage array, parsed from atlasJSON */
  148488. sprites: Array<ISpriteJSONSprite>;
  148489. /** Returns the Number of Sprites in the System */
  148490. get spriteCount(): number;
  148491. /** Returns the Position of Output Plane*/
  148492. get position(): Vector3;
  148493. /** Returns the Position of Output Plane*/
  148494. set position(v: Vector3);
  148495. /** Returns the Rotation of Output Plane*/
  148496. get rotation(): Vector3;
  148497. /** Returns the Rotation of Output Plane*/
  148498. set rotation(v: Vector3);
  148499. /** Sets the AnimationMap*/
  148500. get animationMap(): RawTexture;
  148501. /** Sets the AnimationMap*/
  148502. set animationMap(v: RawTexture);
  148503. /** Scene that the SpriteMap was created in */
  148504. private _scene;
  148505. /** Texture Buffer of Float32 that holds tile frame data*/
  148506. private _frameMap;
  148507. /** Texture Buffers of Float32 that holds tileMap data*/
  148508. private _tileMaps;
  148509. /** Texture Buffer of Float32 that holds Animation Data*/
  148510. private _animationMap;
  148511. /** Custom ShaderMaterial Central to the System*/
  148512. private _material;
  148513. /** Custom ShaderMaterial Central to the System*/
  148514. private _output;
  148515. /** Systems Time Ticker*/
  148516. private _time;
  148517. /**
  148518. * Creates a new SpriteMap
  148519. * @param name defines the SpriteMaps Name
  148520. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  148521. * @param spriteSheet is the Texture that the Sprites are on.
  148522. * @param options a basic deployment configuration
  148523. * @param scene The Scene that the map is deployed on
  148524. */
  148525. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  148526. /**
  148527. * Returns tileID location
  148528. * @returns Vector2 the cell position ID
  148529. */
  148530. getTileID(): Vector2;
  148531. /**
  148532. * Gets the UV location of the mouse over the SpriteMap.
  148533. * @returns Vector2 the UV position of the mouse interaction
  148534. */
  148535. getMousePosition(): Vector2;
  148536. /**
  148537. * Creates the "frame" texture Buffer
  148538. * -------------------------------------
  148539. * Structure of frames
  148540. * "filename": "Falling-Water-2.png",
  148541. * "frame": {"x":69,"y":103,"w":24,"h":32},
  148542. * "rotated": true,
  148543. * "trimmed": true,
  148544. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  148545. * "sourceSize": {"w":32,"h":32}
  148546. * @returns RawTexture of the frameMap
  148547. */
  148548. private _createFrameBuffer;
  148549. /**
  148550. * Creates the tileMap texture Buffer
  148551. * @param buffer normally and array of numbers, or a false to generate from scratch
  148552. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  148553. * @returns RawTexture of the tileMap
  148554. */
  148555. private _createTileBuffer;
  148556. /**
  148557. * Modifies the data of the tileMaps
  148558. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  148559. * @param pos is the iVector2 Coordinates of the Tile
  148560. * @param tile The SpriteIndex of the new Tile
  148561. */
  148562. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  148563. /**
  148564. * Creates the animationMap texture Buffer
  148565. * @param buffer normally and array of numbers, or a false to generate from scratch
  148566. * @returns RawTexture of the animationMap
  148567. */
  148568. private _createTileAnimationBuffer;
  148569. /**
  148570. * Modifies the data of the animationMap
  148571. * @param cellID is the Index of the Sprite
  148572. * @param _frame is the target Animation frame
  148573. * @param toCell is the Target Index of the next frame of the animation
  148574. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  148575. * @param speed is a global scalar of the time variable on the map.
  148576. */
  148577. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  148578. /**
  148579. * Exports the .tilemaps file
  148580. */
  148581. saveTileMaps(): void;
  148582. /**
  148583. * Imports the .tilemaps file
  148584. * @param url of the .tilemaps file
  148585. */
  148586. loadTileMaps(url: string): void;
  148587. /**
  148588. * Release associated resources
  148589. */
  148590. dispose(): void;
  148591. }
  148592. }
  148593. declare module BABYLON {
  148594. /**
  148595. * Class used to manage multiple sprites of different sizes on the same spritesheet
  148596. * @see http://doc.babylonjs.com/babylon101/sprites
  148597. */
  148598. export class SpritePackedManager extends SpriteManager {
  148599. /** defines the packed manager's name */
  148600. name: string;
  148601. /**
  148602. * Creates a new sprite manager from a packed sprite sheet
  148603. * @param name defines the manager's name
  148604. * @param imgUrl defines the sprite sheet url
  148605. * @param capacity defines the maximum allowed number of sprites
  148606. * @param scene defines the hosting scene
  148607. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  148608. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  148609. * @param samplingMode defines the smapling mode to use with spritesheet
  148610. * @param fromPacked set to true; do not alter
  148611. */
  148612. constructor(
  148613. /** defines the packed manager's name */
  148614. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  148615. }
  148616. }
  148617. declare module BABYLON {
  148618. /**
  148619. * Defines the list of states available for a task inside a AssetsManager
  148620. */
  148621. export enum AssetTaskState {
  148622. /**
  148623. * Initialization
  148624. */
  148625. INIT = 0,
  148626. /**
  148627. * Running
  148628. */
  148629. RUNNING = 1,
  148630. /**
  148631. * Done
  148632. */
  148633. DONE = 2,
  148634. /**
  148635. * Error
  148636. */
  148637. ERROR = 3
  148638. }
  148639. /**
  148640. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  148641. */
  148642. export abstract class AbstractAssetTask {
  148643. /**
  148644. * Task name
  148645. */ name: string;
  148646. /**
  148647. * Callback called when the task is successful
  148648. */
  148649. onSuccess: (task: any) => void;
  148650. /**
  148651. * Callback called when the task is not successful
  148652. */
  148653. onError: (task: any, message?: string, exception?: any) => void;
  148654. /**
  148655. * Creates a new AssetsManager
  148656. * @param name defines the name of the task
  148657. */
  148658. constructor(
  148659. /**
  148660. * Task name
  148661. */ name: string);
  148662. private _isCompleted;
  148663. private _taskState;
  148664. private _errorObject;
  148665. /**
  148666. * Get if the task is completed
  148667. */
  148668. get isCompleted(): boolean;
  148669. /**
  148670. * Gets the current state of the task
  148671. */
  148672. get taskState(): AssetTaskState;
  148673. /**
  148674. * Gets the current error object (if task is in error)
  148675. */
  148676. get errorObject(): {
  148677. message?: string;
  148678. exception?: any;
  148679. };
  148680. /**
  148681. * Internal only
  148682. * @hidden
  148683. */
  148684. _setErrorObject(message?: string, exception?: any): void;
  148685. /**
  148686. * Execute the current task
  148687. * @param scene defines the scene where you want your assets to be loaded
  148688. * @param onSuccess is a callback called when the task is successfully executed
  148689. * @param onError is a callback called if an error occurs
  148690. */
  148691. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148692. /**
  148693. * Execute the current task
  148694. * @param scene defines the scene where you want your assets to be loaded
  148695. * @param onSuccess is a callback called when the task is successfully executed
  148696. * @param onError is a callback called if an error occurs
  148697. */
  148698. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148699. /**
  148700. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  148701. * This can be used with failed tasks that have the reason for failure fixed.
  148702. */
  148703. reset(): void;
  148704. private onErrorCallback;
  148705. private onDoneCallback;
  148706. }
  148707. /**
  148708. * Define the interface used by progress events raised during assets loading
  148709. */
  148710. export interface IAssetsProgressEvent {
  148711. /**
  148712. * Defines the number of remaining tasks to process
  148713. */
  148714. remainingCount: number;
  148715. /**
  148716. * Defines the total number of tasks
  148717. */
  148718. totalCount: number;
  148719. /**
  148720. * Defines the task that was just processed
  148721. */
  148722. task: AbstractAssetTask;
  148723. }
  148724. /**
  148725. * Class used to share progress information about assets loading
  148726. */
  148727. export class AssetsProgressEvent implements IAssetsProgressEvent {
  148728. /**
  148729. * Defines the number of remaining tasks to process
  148730. */
  148731. remainingCount: number;
  148732. /**
  148733. * Defines the total number of tasks
  148734. */
  148735. totalCount: number;
  148736. /**
  148737. * Defines the task that was just processed
  148738. */
  148739. task: AbstractAssetTask;
  148740. /**
  148741. * Creates a AssetsProgressEvent
  148742. * @param remainingCount defines the number of remaining tasks to process
  148743. * @param totalCount defines the total number of tasks
  148744. * @param task defines the task that was just processed
  148745. */
  148746. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  148747. }
  148748. /**
  148749. * Define a task used by AssetsManager to load meshes
  148750. */
  148751. export class MeshAssetTask extends AbstractAssetTask {
  148752. /**
  148753. * Defines the name of the task
  148754. */
  148755. name: string;
  148756. /**
  148757. * Defines the list of mesh's names you want to load
  148758. */
  148759. meshesNames: any;
  148760. /**
  148761. * Defines the root url to use as a base to load your meshes and associated resources
  148762. */
  148763. rootUrl: string;
  148764. /**
  148765. * Defines the filename or File of the scene to load from
  148766. */
  148767. sceneFilename: string | File;
  148768. /**
  148769. * Gets the list of loaded meshes
  148770. */
  148771. loadedMeshes: Array<AbstractMesh>;
  148772. /**
  148773. * Gets the list of loaded particle systems
  148774. */
  148775. loadedParticleSystems: Array<IParticleSystem>;
  148776. /**
  148777. * Gets the list of loaded skeletons
  148778. */
  148779. loadedSkeletons: Array<Skeleton>;
  148780. /**
  148781. * Gets the list of loaded animation groups
  148782. */
  148783. loadedAnimationGroups: Array<AnimationGroup>;
  148784. /**
  148785. * Callback called when the task is successful
  148786. */
  148787. onSuccess: (task: MeshAssetTask) => void;
  148788. /**
  148789. * Callback called when the task is successful
  148790. */
  148791. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  148792. /**
  148793. * Creates a new MeshAssetTask
  148794. * @param name defines the name of the task
  148795. * @param meshesNames defines the list of mesh's names you want to load
  148796. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  148797. * @param sceneFilename defines the filename or File of the scene to load from
  148798. */
  148799. constructor(
  148800. /**
  148801. * Defines the name of the task
  148802. */
  148803. name: string,
  148804. /**
  148805. * Defines the list of mesh's names you want to load
  148806. */
  148807. meshesNames: any,
  148808. /**
  148809. * Defines the root url to use as a base to load your meshes and associated resources
  148810. */
  148811. rootUrl: string,
  148812. /**
  148813. * Defines the filename or File of the scene to load from
  148814. */
  148815. sceneFilename: string | File);
  148816. /**
  148817. * Execute the current task
  148818. * @param scene defines the scene where you want your assets to be loaded
  148819. * @param onSuccess is a callback called when the task is successfully executed
  148820. * @param onError is a callback called if an error occurs
  148821. */
  148822. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148823. }
  148824. /**
  148825. * Define a task used by AssetsManager to load text content
  148826. */
  148827. export class TextFileAssetTask extends AbstractAssetTask {
  148828. /**
  148829. * Defines the name of the task
  148830. */
  148831. name: string;
  148832. /**
  148833. * Defines the location of the file to load
  148834. */
  148835. url: string;
  148836. /**
  148837. * Gets the loaded text string
  148838. */
  148839. text: string;
  148840. /**
  148841. * Callback called when the task is successful
  148842. */
  148843. onSuccess: (task: TextFileAssetTask) => void;
  148844. /**
  148845. * Callback called when the task is successful
  148846. */
  148847. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  148848. /**
  148849. * Creates a new TextFileAssetTask object
  148850. * @param name defines the name of the task
  148851. * @param url defines the location of the file to load
  148852. */
  148853. constructor(
  148854. /**
  148855. * Defines the name of the task
  148856. */
  148857. name: string,
  148858. /**
  148859. * Defines the location of the file to load
  148860. */
  148861. url: string);
  148862. /**
  148863. * Execute the current task
  148864. * @param scene defines the scene where you want your assets to be loaded
  148865. * @param onSuccess is a callback called when the task is successfully executed
  148866. * @param onError is a callback called if an error occurs
  148867. */
  148868. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148869. }
  148870. /**
  148871. * Define a task used by AssetsManager to load binary data
  148872. */
  148873. export class BinaryFileAssetTask extends AbstractAssetTask {
  148874. /**
  148875. * Defines the name of the task
  148876. */
  148877. name: string;
  148878. /**
  148879. * Defines the location of the file to load
  148880. */
  148881. url: string;
  148882. /**
  148883. * Gets the lodaded data (as an array buffer)
  148884. */
  148885. data: ArrayBuffer;
  148886. /**
  148887. * Callback called when the task is successful
  148888. */
  148889. onSuccess: (task: BinaryFileAssetTask) => void;
  148890. /**
  148891. * Callback called when the task is successful
  148892. */
  148893. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  148894. /**
  148895. * Creates a new BinaryFileAssetTask object
  148896. * @param name defines the name of the new task
  148897. * @param url defines the location of the file to load
  148898. */
  148899. constructor(
  148900. /**
  148901. * Defines the name of the task
  148902. */
  148903. name: string,
  148904. /**
  148905. * Defines the location of the file to load
  148906. */
  148907. url: string);
  148908. /**
  148909. * Execute the current task
  148910. * @param scene defines the scene where you want your assets to be loaded
  148911. * @param onSuccess is a callback called when the task is successfully executed
  148912. * @param onError is a callback called if an error occurs
  148913. */
  148914. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148915. }
  148916. /**
  148917. * Define a task used by AssetsManager to load images
  148918. */
  148919. export class ImageAssetTask extends AbstractAssetTask {
  148920. /**
  148921. * Defines the name of the task
  148922. */
  148923. name: string;
  148924. /**
  148925. * Defines the location of the image to load
  148926. */
  148927. url: string;
  148928. /**
  148929. * Gets the loaded images
  148930. */
  148931. image: HTMLImageElement;
  148932. /**
  148933. * Callback called when the task is successful
  148934. */
  148935. onSuccess: (task: ImageAssetTask) => void;
  148936. /**
  148937. * Callback called when the task is successful
  148938. */
  148939. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  148940. /**
  148941. * Creates a new ImageAssetTask
  148942. * @param name defines the name of the task
  148943. * @param url defines the location of the image to load
  148944. */
  148945. constructor(
  148946. /**
  148947. * Defines the name of the task
  148948. */
  148949. name: string,
  148950. /**
  148951. * Defines the location of the image to load
  148952. */
  148953. url: string);
  148954. /**
  148955. * Execute the current task
  148956. * @param scene defines the scene where you want your assets to be loaded
  148957. * @param onSuccess is a callback called when the task is successfully executed
  148958. * @param onError is a callback called if an error occurs
  148959. */
  148960. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  148961. }
  148962. /**
  148963. * Defines the interface used by texture loading tasks
  148964. */
  148965. export interface ITextureAssetTask<TEX extends BaseTexture> {
  148966. /**
  148967. * Gets the loaded texture
  148968. */
  148969. texture: TEX;
  148970. }
  148971. /**
  148972. * Define a task used by AssetsManager to load 2D textures
  148973. */
  148974. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  148975. /**
  148976. * Defines the name of the task
  148977. */
  148978. name: string;
  148979. /**
  148980. * Defines the location of the file to load
  148981. */
  148982. url: string;
  148983. /**
  148984. * Defines if mipmap should not be generated (default is false)
  148985. */
  148986. noMipmap?: boolean | undefined;
  148987. /**
  148988. * Defines if texture must be inverted on Y axis (default is true)
  148989. */
  148990. invertY: boolean;
  148991. /**
  148992. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  148993. */
  148994. samplingMode: number;
  148995. /**
  148996. * Gets the loaded texture
  148997. */
  148998. texture: Texture;
  148999. /**
  149000. * Callback called when the task is successful
  149001. */
  149002. onSuccess: (task: TextureAssetTask) => void;
  149003. /**
  149004. * Callback called when the task is successful
  149005. */
  149006. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  149007. /**
  149008. * Creates a new TextureAssetTask object
  149009. * @param name defines the name of the task
  149010. * @param url defines the location of the file to load
  149011. * @param noMipmap defines if mipmap should not be generated (default is false)
  149012. * @param invertY defines if texture must be inverted on Y axis (default is true)
  149013. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149014. */
  149015. constructor(
  149016. /**
  149017. * Defines the name of the task
  149018. */
  149019. name: string,
  149020. /**
  149021. * Defines the location of the file to load
  149022. */
  149023. url: string,
  149024. /**
  149025. * Defines if mipmap should not be generated (default is false)
  149026. */
  149027. noMipmap?: boolean | undefined,
  149028. /**
  149029. * Defines if texture must be inverted on Y axis (default is true)
  149030. */
  149031. invertY?: boolean,
  149032. /**
  149033. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  149034. */
  149035. samplingMode?: number);
  149036. /**
  149037. * Execute the current task
  149038. * @param scene defines the scene where you want your assets to be loaded
  149039. * @param onSuccess is a callback called when the task is successfully executed
  149040. * @param onError is a callback called if an error occurs
  149041. */
  149042. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149043. }
  149044. /**
  149045. * Define a task used by AssetsManager to load cube textures
  149046. */
  149047. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  149048. /**
  149049. * Defines the name of the task
  149050. */
  149051. name: string;
  149052. /**
  149053. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149054. */
  149055. url: string;
  149056. /**
  149057. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149058. */
  149059. extensions?: string[] | undefined;
  149060. /**
  149061. * Defines if mipmaps should not be generated (default is false)
  149062. */
  149063. noMipmap?: boolean | undefined;
  149064. /**
  149065. * Defines the explicit list of files (undefined by default)
  149066. */
  149067. files?: string[] | undefined;
  149068. /**
  149069. * Gets the loaded texture
  149070. */
  149071. texture: CubeTexture;
  149072. /**
  149073. * Callback called when the task is successful
  149074. */
  149075. onSuccess: (task: CubeTextureAssetTask) => void;
  149076. /**
  149077. * Callback called when the task is successful
  149078. */
  149079. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  149080. /**
  149081. * Creates a new CubeTextureAssetTask
  149082. * @param name defines the name of the task
  149083. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149084. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149085. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149086. * @param files defines the explicit list of files (undefined by default)
  149087. */
  149088. constructor(
  149089. /**
  149090. * Defines the name of the task
  149091. */
  149092. name: string,
  149093. /**
  149094. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  149095. */
  149096. url: string,
  149097. /**
  149098. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  149099. */
  149100. extensions?: string[] | undefined,
  149101. /**
  149102. * Defines if mipmaps should not be generated (default is false)
  149103. */
  149104. noMipmap?: boolean | undefined,
  149105. /**
  149106. * Defines the explicit list of files (undefined by default)
  149107. */
  149108. files?: string[] | undefined);
  149109. /**
  149110. * Execute the current task
  149111. * @param scene defines the scene where you want your assets to be loaded
  149112. * @param onSuccess is a callback called when the task is successfully executed
  149113. * @param onError is a callback called if an error occurs
  149114. */
  149115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149116. }
  149117. /**
  149118. * Define a task used by AssetsManager to load HDR cube textures
  149119. */
  149120. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  149121. /**
  149122. * Defines the name of the task
  149123. */
  149124. name: string;
  149125. /**
  149126. * Defines the location of the file to load
  149127. */
  149128. url: string;
  149129. /**
  149130. * Defines the desired size (the more it increases the longer the generation will be)
  149131. */
  149132. size: number;
  149133. /**
  149134. * Defines if mipmaps should not be generated (default is false)
  149135. */
  149136. noMipmap: boolean;
  149137. /**
  149138. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149139. */
  149140. generateHarmonics: boolean;
  149141. /**
  149142. * 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)
  149143. */
  149144. gammaSpace: boolean;
  149145. /**
  149146. * Internal Use Only
  149147. */
  149148. reserved: boolean;
  149149. /**
  149150. * Gets the loaded texture
  149151. */
  149152. texture: HDRCubeTexture;
  149153. /**
  149154. * Callback called when the task is successful
  149155. */
  149156. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  149157. /**
  149158. * Callback called when the task is successful
  149159. */
  149160. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  149161. /**
  149162. * Creates a new HDRCubeTextureAssetTask object
  149163. * @param name defines the name of the task
  149164. * @param url defines the location of the file to load
  149165. * @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.
  149166. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149167. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149168. * @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)
  149169. * @param reserved Internal use only
  149170. */
  149171. constructor(
  149172. /**
  149173. * Defines the name of the task
  149174. */
  149175. name: string,
  149176. /**
  149177. * Defines the location of the file to load
  149178. */
  149179. url: string,
  149180. /**
  149181. * Defines the desired size (the more it increases the longer the generation will be)
  149182. */
  149183. size: number,
  149184. /**
  149185. * Defines if mipmaps should not be generated (default is false)
  149186. */
  149187. noMipmap?: boolean,
  149188. /**
  149189. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  149190. */
  149191. generateHarmonics?: boolean,
  149192. /**
  149193. * 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)
  149194. */
  149195. gammaSpace?: boolean,
  149196. /**
  149197. * Internal Use Only
  149198. */
  149199. reserved?: boolean);
  149200. /**
  149201. * Execute the current task
  149202. * @param scene defines the scene where you want your assets to be loaded
  149203. * @param onSuccess is a callback called when the task is successfully executed
  149204. * @param onError is a callback called if an error occurs
  149205. */
  149206. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149207. }
  149208. /**
  149209. * Define a task used by AssetsManager to load Equirectangular cube textures
  149210. */
  149211. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  149212. /**
  149213. * Defines the name of the task
  149214. */
  149215. name: string;
  149216. /**
  149217. * Defines the location of the file to load
  149218. */
  149219. url: string;
  149220. /**
  149221. * Defines the desired size (the more it increases the longer the generation will be)
  149222. */
  149223. size: number;
  149224. /**
  149225. * Defines if mipmaps should not be generated (default is false)
  149226. */
  149227. noMipmap: boolean;
  149228. /**
  149229. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  149230. * but the standard material would require them in Gamma space) (default is true)
  149231. */
  149232. gammaSpace: boolean;
  149233. /**
  149234. * Gets the loaded texture
  149235. */
  149236. texture: EquiRectangularCubeTexture;
  149237. /**
  149238. * Callback called when the task is successful
  149239. */
  149240. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  149241. /**
  149242. * Callback called when the task is successful
  149243. */
  149244. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  149245. /**
  149246. * Creates a new EquiRectangularCubeTextureAssetTask object
  149247. * @param name defines the name of the task
  149248. * @param url defines the location of the file to load
  149249. * @param size defines the desired size (the more it increases the longer the generation will be)
  149250. * If the size is omitted this implies you are using a preprocessed cubemap.
  149251. * @param noMipmap defines if mipmaps should not be generated (default is false)
  149252. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  149253. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  149254. * (default is true)
  149255. */
  149256. constructor(
  149257. /**
  149258. * Defines the name of the task
  149259. */
  149260. name: string,
  149261. /**
  149262. * Defines the location of the file to load
  149263. */
  149264. url: string,
  149265. /**
  149266. * Defines the desired size (the more it increases the longer the generation will be)
  149267. */
  149268. size: number,
  149269. /**
  149270. * Defines if mipmaps should not be generated (default is false)
  149271. */
  149272. noMipmap?: boolean,
  149273. /**
  149274. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  149275. * but the standard material would require them in Gamma space) (default is true)
  149276. */
  149277. gammaSpace?: boolean);
  149278. /**
  149279. * Execute the current task
  149280. * @param scene defines the scene where you want your assets to be loaded
  149281. * @param onSuccess is a callback called when the task is successfully executed
  149282. * @param onError is a callback called if an error occurs
  149283. */
  149284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149285. }
  149286. /**
  149287. * This class can be used to easily import assets into a scene
  149288. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  149289. */
  149290. export class AssetsManager {
  149291. private _scene;
  149292. private _isLoading;
  149293. protected _tasks: AbstractAssetTask[];
  149294. protected _waitingTasksCount: number;
  149295. protected _totalTasksCount: number;
  149296. /**
  149297. * Callback called when all tasks are processed
  149298. */
  149299. onFinish: (tasks: AbstractAssetTask[]) => void;
  149300. /**
  149301. * Callback called when a task is successful
  149302. */
  149303. onTaskSuccess: (task: AbstractAssetTask) => void;
  149304. /**
  149305. * Callback called when a task had an error
  149306. */
  149307. onTaskError: (task: AbstractAssetTask) => void;
  149308. /**
  149309. * Callback called when a task is done (whatever the result is)
  149310. */
  149311. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  149312. /**
  149313. * Observable called when all tasks are processed
  149314. */
  149315. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  149316. /**
  149317. * Observable called when a task had an error
  149318. */
  149319. onTaskErrorObservable: Observable<AbstractAssetTask>;
  149320. /**
  149321. * Observable called when all tasks were executed
  149322. */
  149323. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  149324. /**
  149325. * Observable called when a task is done (whatever the result is)
  149326. */
  149327. onProgressObservable: Observable<IAssetsProgressEvent>;
  149328. /**
  149329. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  149330. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  149331. */
  149332. useDefaultLoadingScreen: boolean;
  149333. /**
  149334. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  149335. * when all assets have been downloaded.
  149336. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  149337. */
  149338. autoHideLoadingUI: boolean;
  149339. /**
  149340. * Creates a new AssetsManager
  149341. * @param scene defines the scene to work on
  149342. */
  149343. constructor(scene: Scene);
  149344. /**
  149345. * Add a MeshAssetTask to the list of active tasks
  149346. * @param taskName defines the name of the new task
  149347. * @param meshesNames defines the name of meshes to load
  149348. * @param rootUrl defines the root url to use to locate files
  149349. * @param sceneFilename defines the filename of the scene file
  149350. * @returns a new MeshAssetTask object
  149351. */
  149352. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  149353. /**
  149354. * Add a TextFileAssetTask to the list of active tasks
  149355. * @param taskName defines the name of the new task
  149356. * @param url defines the url of the file to load
  149357. * @returns a new TextFileAssetTask object
  149358. */
  149359. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  149360. /**
  149361. * Add a BinaryFileAssetTask to the list of active tasks
  149362. * @param taskName defines the name of the new task
  149363. * @param url defines the url of the file to load
  149364. * @returns a new BinaryFileAssetTask object
  149365. */
  149366. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  149367. /**
  149368. * Add a ImageAssetTask to the list of active tasks
  149369. * @param taskName defines the name of the new task
  149370. * @param url defines the url of the file to load
  149371. * @returns a new ImageAssetTask object
  149372. */
  149373. addImageTask(taskName: string, url: string): ImageAssetTask;
  149374. /**
  149375. * Add a TextureAssetTask to the list of active tasks
  149376. * @param taskName defines the name of the new task
  149377. * @param url defines the url of the file to load
  149378. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149379. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  149380. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  149381. * @returns a new TextureAssetTask object
  149382. */
  149383. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  149384. /**
  149385. * Add a CubeTextureAssetTask to the list of active tasks
  149386. * @param taskName defines the name of the new task
  149387. * @param url defines the url of the file to load
  149388. * @param extensions defines the extension to use to load the cube map (can be null)
  149389. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149390. * @param files defines the list of files to load (can be null)
  149391. * @returns a new CubeTextureAssetTask object
  149392. */
  149393. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  149394. /**
  149395. *
  149396. * Add a HDRCubeTextureAssetTask to the list of active tasks
  149397. * @param taskName defines the name of the new task
  149398. * @param url defines the url of the file to load
  149399. * @param size defines the size you want for the cubemap (can be null)
  149400. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149401. * @param generateHarmonics defines if you want to automatically generate (true by default)
  149402. * @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)
  149403. * @param reserved Internal use only
  149404. * @returns a new HDRCubeTextureAssetTask object
  149405. */
  149406. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  149407. /**
  149408. *
  149409. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  149410. * @param taskName defines the name of the new task
  149411. * @param url defines the url of the file to load
  149412. * @param size defines the size you want for the cubemap (can be null)
  149413. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  149414. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  149415. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  149416. * @returns a new EquiRectangularCubeTextureAssetTask object
  149417. */
  149418. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  149419. /**
  149420. * Remove a task from the assets manager.
  149421. * @param task the task to remove
  149422. */
  149423. removeTask(task: AbstractAssetTask): void;
  149424. private _decreaseWaitingTasksCount;
  149425. private _runTask;
  149426. /**
  149427. * Reset the AssetsManager and remove all tasks
  149428. * @return the current instance of the AssetsManager
  149429. */
  149430. reset(): AssetsManager;
  149431. /**
  149432. * Start the loading process
  149433. * @return the current instance of the AssetsManager
  149434. */
  149435. load(): AssetsManager;
  149436. /**
  149437. * Start the loading process as an async operation
  149438. * @return a promise returning the list of failed tasks
  149439. */
  149440. loadAsync(): Promise<void>;
  149441. }
  149442. }
  149443. declare module BABYLON {
  149444. /**
  149445. * Wrapper class for promise with external resolve and reject.
  149446. */
  149447. export class Deferred<T> {
  149448. /**
  149449. * The promise associated with this deferred object.
  149450. */
  149451. readonly promise: Promise<T>;
  149452. private _resolve;
  149453. private _reject;
  149454. /**
  149455. * The resolve method of the promise associated with this deferred object.
  149456. */
  149457. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  149458. /**
  149459. * The reject method of the promise associated with this deferred object.
  149460. */
  149461. get reject(): (reason?: any) => void;
  149462. /**
  149463. * Constructor for this deferred object.
  149464. */
  149465. constructor();
  149466. }
  149467. }
  149468. declare module BABYLON {
  149469. /**
  149470. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  149471. */
  149472. export class MeshExploder {
  149473. private _centerMesh;
  149474. private _meshes;
  149475. private _meshesOrigins;
  149476. private _toCenterVectors;
  149477. private _scaledDirection;
  149478. private _newPosition;
  149479. private _centerPosition;
  149480. /**
  149481. * Explodes meshes from a center mesh.
  149482. * @param meshes The meshes to explode.
  149483. * @param centerMesh The mesh to be center of explosion.
  149484. */
  149485. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  149486. private _setCenterMesh;
  149487. /**
  149488. * Get class name
  149489. * @returns "MeshExploder"
  149490. */
  149491. getClassName(): string;
  149492. /**
  149493. * "Exploded meshes"
  149494. * @returns Array of meshes with the centerMesh at index 0.
  149495. */
  149496. getMeshes(): Array<Mesh>;
  149497. /**
  149498. * Explodes meshes giving a specific direction
  149499. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  149500. */
  149501. explode(direction?: number): void;
  149502. }
  149503. }
  149504. declare module BABYLON {
  149505. /**
  149506. * Class used to help managing file picking and drag'n'drop
  149507. */
  149508. export class FilesInput {
  149509. /**
  149510. * List of files ready to be loaded
  149511. */
  149512. static get FilesToLoad(): {
  149513. [key: string]: File;
  149514. };
  149515. /**
  149516. * Callback called when a file is processed
  149517. */
  149518. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  149519. private _engine;
  149520. private _currentScene;
  149521. private _sceneLoadedCallback;
  149522. private _progressCallback;
  149523. private _additionalRenderLoopLogicCallback;
  149524. private _textureLoadingCallback;
  149525. private _startingProcessingFilesCallback;
  149526. private _onReloadCallback;
  149527. private _errorCallback;
  149528. private _elementToMonitor;
  149529. private _sceneFileToLoad;
  149530. private _filesToLoad;
  149531. /**
  149532. * Creates a new FilesInput
  149533. * @param engine defines the rendering engine
  149534. * @param scene defines the hosting scene
  149535. * @param sceneLoadedCallback callback called when scene is loaded
  149536. * @param progressCallback callback called to track progress
  149537. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  149538. * @param textureLoadingCallback callback called when a texture is loading
  149539. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  149540. * @param onReloadCallback callback called when a reload is requested
  149541. * @param errorCallback callback call if an error occurs
  149542. */
  149543. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: ISceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  149544. private _dragEnterHandler;
  149545. private _dragOverHandler;
  149546. private _dropHandler;
  149547. /**
  149548. * Calls this function to listen to drag'n'drop events on a specific DOM element
  149549. * @param elementToMonitor defines the DOM element to track
  149550. */
  149551. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  149552. /**
  149553. * Release all associated resources
  149554. */
  149555. dispose(): void;
  149556. private renderFunction;
  149557. private drag;
  149558. private drop;
  149559. private _traverseFolder;
  149560. private _processFiles;
  149561. /**
  149562. * Load files from a drop event
  149563. * @param event defines the drop event to use as source
  149564. */
  149565. loadFiles(event: any): void;
  149566. private _processReload;
  149567. /**
  149568. * Reload the current scene from the loaded files
  149569. */
  149570. reload(): void;
  149571. }
  149572. }
  149573. declare module BABYLON {
  149574. /**
  149575. * Defines the root class used to create scene optimization to use with SceneOptimizer
  149576. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149577. */
  149578. export class SceneOptimization {
  149579. /**
  149580. * Defines the priority of this optimization (0 by default which means first in the list)
  149581. */
  149582. priority: number;
  149583. /**
  149584. * Gets a string describing the action executed by the current optimization
  149585. * @returns description string
  149586. */
  149587. getDescription(): string;
  149588. /**
  149589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149590. * @param scene defines the current scene where to apply this optimization
  149591. * @param optimizer defines the current optimizer
  149592. * @returns true if everything that can be done was applied
  149593. */
  149594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149595. /**
  149596. * Creates the SceneOptimization object
  149597. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149598. * @param desc defines the description associated with the optimization
  149599. */
  149600. constructor(
  149601. /**
  149602. * Defines the priority of this optimization (0 by default which means first in the list)
  149603. */
  149604. priority?: number);
  149605. }
  149606. /**
  149607. * Defines an optimization used to reduce the size of render target textures
  149608. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149609. */
  149610. export class TextureOptimization extends SceneOptimization {
  149611. /**
  149612. * Defines the priority of this optimization (0 by default which means first in the list)
  149613. */
  149614. priority: number;
  149615. /**
  149616. * 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
  149617. */
  149618. maximumSize: number;
  149619. /**
  149620. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149621. */
  149622. step: number;
  149623. /**
  149624. * Gets a string describing the action executed by the current optimization
  149625. * @returns description string
  149626. */
  149627. getDescription(): string;
  149628. /**
  149629. * Creates the TextureOptimization object
  149630. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149631. * @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
  149632. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149633. */
  149634. constructor(
  149635. /**
  149636. * Defines the priority of this optimization (0 by default which means first in the list)
  149637. */
  149638. priority?: number,
  149639. /**
  149640. * 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
  149641. */
  149642. maximumSize?: number,
  149643. /**
  149644. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  149645. */
  149646. step?: number);
  149647. /**
  149648. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149649. * @param scene defines the current scene where to apply this optimization
  149650. * @param optimizer defines the current optimizer
  149651. * @returns true if everything that can be done was applied
  149652. */
  149653. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149654. }
  149655. /**
  149656. * Defines an optimization used to increase or decrease the rendering resolution
  149657. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149658. */
  149659. export class HardwareScalingOptimization extends SceneOptimization {
  149660. /**
  149661. * Defines the priority of this optimization (0 by default which means first in the list)
  149662. */
  149663. priority: number;
  149664. /**
  149665. * Defines the maximum scale to use (2 by default)
  149666. */
  149667. maximumScale: number;
  149668. /**
  149669. * Defines the step to use between two passes (0.5 by default)
  149670. */
  149671. step: number;
  149672. private _currentScale;
  149673. private _directionOffset;
  149674. /**
  149675. * Gets a string describing the action executed by the current optimization
  149676. * @return description string
  149677. */
  149678. getDescription(): string;
  149679. /**
  149680. * Creates the HardwareScalingOptimization object
  149681. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149682. * @param maximumScale defines the maximum scale to use (2 by default)
  149683. * @param step defines the step to use between two passes (0.5 by default)
  149684. */
  149685. constructor(
  149686. /**
  149687. * Defines the priority of this optimization (0 by default which means first in the list)
  149688. */
  149689. priority?: number,
  149690. /**
  149691. * Defines the maximum scale to use (2 by default)
  149692. */
  149693. maximumScale?: number,
  149694. /**
  149695. * Defines the step to use between two passes (0.5 by default)
  149696. */
  149697. step?: number);
  149698. /**
  149699. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149700. * @param scene defines the current scene where to apply this optimization
  149701. * @param optimizer defines the current optimizer
  149702. * @returns true if everything that can be done was applied
  149703. */
  149704. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149705. }
  149706. /**
  149707. * Defines an optimization used to remove shadows
  149708. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149709. */
  149710. export class ShadowsOptimization extends SceneOptimization {
  149711. /**
  149712. * Gets a string describing the action executed by the current optimization
  149713. * @return description string
  149714. */
  149715. getDescription(): string;
  149716. /**
  149717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149718. * @param scene defines the current scene where to apply this optimization
  149719. * @param optimizer defines the current optimizer
  149720. * @returns true if everything that can be done was applied
  149721. */
  149722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149723. }
  149724. /**
  149725. * Defines an optimization used to turn post-processes off
  149726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149727. */
  149728. export class PostProcessesOptimization extends SceneOptimization {
  149729. /**
  149730. * Gets a string describing the action executed by the current optimization
  149731. * @return description string
  149732. */
  149733. getDescription(): string;
  149734. /**
  149735. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149736. * @param scene defines the current scene where to apply this optimization
  149737. * @param optimizer defines the current optimizer
  149738. * @returns true if everything that can be done was applied
  149739. */
  149740. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149741. }
  149742. /**
  149743. * Defines an optimization used to turn lens flares off
  149744. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149745. */
  149746. export class LensFlaresOptimization extends SceneOptimization {
  149747. /**
  149748. * Gets a string describing the action executed by the current optimization
  149749. * @return description string
  149750. */
  149751. getDescription(): string;
  149752. /**
  149753. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149754. * @param scene defines the current scene where to apply this optimization
  149755. * @param optimizer defines the current optimizer
  149756. * @returns true if everything that can be done was applied
  149757. */
  149758. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149759. }
  149760. /**
  149761. * Defines an optimization based on user defined callback.
  149762. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149763. */
  149764. export class CustomOptimization extends SceneOptimization {
  149765. /**
  149766. * Callback called to apply the custom optimization.
  149767. */
  149768. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  149769. /**
  149770. * Callback called to get custom description
  149771. */
  149772. onGetDescription: () => string;
  149773. /**
  149774. * Gets a string describing the action executed by the current optimization
  149775. * @returns description string
  149776. */
  149777. getDescription(): string;
  149778. /**
  149779. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149780. * @param scene defines the current scene where to apply this optimization
  149781. * @param optimizer defines the current optimizer
  149782. * @returns true if everything that can be done was applied
  149783. */
  149784. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149785. }
  149786. /**
  149787. * Defines an optimization used to turn particles off
  149788. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149789. */
  149790. export class ParticlesOptimization extends SceneOptimization {
  149791. /**
  149792. * Gets a string describing the action executed by the current optimization
  149793. * @return description string
  149794. */
  149795. getDescription(): string;
  149796. /**
  149797. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149798. * @param scene defines the current scene where to apply this optimization
  149799. * @param optimizer defines the current optimizer
  149800. * @returns true if everything that can be done was applied
  149801. */
  149802. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149803. }
  149804. /**
  149805. * Defines an optimization used to turn render targets off
  149806. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149807. */
  149808. export class RenderTargetsOptimization extends SceneOptimization {
  149809. /**
  149810. * Gets a string describing the action executed by the current optimization
  149811. * @return description string
  149812. */
  149813. getDescription(): string;
  149814. /**
  149815. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149816. * @param scene defines the current scene where to apply this optimization
  149817. * @param optimizer defines the current optimizer
  149818. * @returns true if everything that can be done was applied
  149819. */
  149820. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  149821. }
  149822. /**
  149823. * Defines an optimization used to merge meshes with compatible materials
  149824. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149825. */
  149826. export class MergeMeshesOptimization extends SceneOptimization {
  149827. private static _UpdateSelectionTree;
  149828. /**
  149829. * Gets or sets a boolean which defines if optimization octree has to be updated
  149830. */
  149831. static get UpdateSelectionTree(): boolean;
  149832. /**
  149833. * Gets or sets a boolean which defines if optimization octree has to be updated
  149834. */
  149835. static set UpdateSelectionTree(value: boolean);
  149836. /**
  149837. * Gets a string describing the action executed by the current optimization
  149838. * @return description string
  149839. */
  149840. getDescription(): string;
  149841. private _canBeMerged;
  149842. /**
  149843. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  149844. * @param scene defines the current scene where to apply this optimization
  149845. * @param optimizer defines the current optimizer
  149846. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  149847. * @returns true if everything that can be done was applied
  149848. */
  149849. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  149850. }
  149851. /**
  149852. * Defines a list of options used by SceneOptimizer
  149853. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149854. */
  149855. export class SceneOptimizerOptions {
  149856. /**
  149857. * Defines the target frame rate to reach (60 by default)
  149858. */
  149859. targetFrameRate: number;
  149860. /**
  149861. * Defines the interval between two checkes (2000ms by default)
  149862. */
  149863. trackerDuration: number;
  149864. /**
  149865. * Gets the list of optimizations to apply
  149866. */
  149867. optimizations: SceneOptimization[];
  149868. /**
  149869. * Creates a new list of options used by SceneOptimizer
  149870. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  149871. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  149872. */
  149873. constructor(
  149874. /**
  149875. * Defines the target frame rate to reach (60 by default)
  149876. */
  149877. targetFrameRate?: number,
  149878. /**
  149879. * Defines the interval between two checkes (2000ms by default)
  149880. */
  149881. trackerDuration?: number);
  149882. /**
  149883. * Add a new optimization
  149884. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  149885. * @returns the current SceneOptimizerOptions
  149886. */
  149887. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  149888. /**
  149889. * Add a new custom optimization
  149890. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  149891. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  149892. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  149893. * @returns the current SceneOptimizerOptions
  149894. */
  149895. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  149896. /**
  149897. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  149898. * @param targetFrameRate defines the target frame rate (60 by default)
  149899. * @returns a SceneOptimizerOptions object
  149900. */
  149901. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149902. /**
  149903. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  149904. * @param targetFrameRate defines the target frame rate (60 by default)
  149905. * @returns a SceneOptimizerOptions object
  149906. */
  149907. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149908. /**
  149909. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  149910. * @param targetFrameRate defines the target frame rate (60 by default)
  149911. * @returns a SceneOptimizerOptions object
  149912. */
  149913. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  149914. }
  149915. /**
  149916. * Class used to run optimizations in order to reach a target frame rate
  149917. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  149918. */
  149919. export class SceneOptimizer implements IDisposable {
  149920. private _isRunning;
  149921. private _options;
  149922. private _scene;
  149923. private _currentPriorityLevel;
  149924. private _targetFrameRate;
  149925. private _trackerDuration;
  149926. private _currentFrameRate;
  149927. private _sceneDisposeObserver;
  149928. private _improvementMode;
  149929. /**
  149930. * Defines an observable called when the optimizer reaches the target frame rate
  149931. */
  149932. onSuccessObservable: Observable<SceneOptimizer>;
  149933. /**
  149934. * Defines an observable called when the optimizer enables an optimization
  149935. */
  149936. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  149937. /**
  149938. * Defines an observable called when the optimizer is not able to reach the target frame rate
  149939. */
  149940. onFailureObservable: Observable<SceneOptimizer>;
  149941. /**
  149942. * Gets a boolean indicating if the optimizer is in improvement mode
  149943. */
  149944. get isInImprovementMode(): boolean;
  149945. /**
  149946. * Gets the current priority level (0 at start)
  149947. */
  149948. get currentPriorityLevel(): number;
  149949. /**
  149950. * Gets the current frame rate checked by the SceneOptimizer
  149951. */
  149952. get currentFrameRate(): number;
  149953. /**
  149954. * Gets or sets the current target frame rate (60 by default)
  149955. */
  149956. get targetFrameRate(): number;
  149957. /**
  149958. * Gets or sets the current target frame rate (60 by default)
  149959. */
  149960. set targetFrameRate(value: number);
  149961. /**
  149962. * Gets or sets the current interval between two checks (every 2000ms by default)
  149963. */
  149964. get trackerDuration(): number;
  149965. /**
  149966. * Gets or sets the current interval between two checks (every 2000ms by default)
  149967. */
  149968. set trackerDuration(value: number);
  149969. /**
  149970. * Gets the list of active optimizations
  149971. */
  149972. get optimizations(): SceneOptimization[];
  149973. /**
  149974. * Creates a new SceneOptimizer
  149975. * @param scene defines the scene to work on
  149976. * @param options defines the options to use with the SceneOptimizer
  149977. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  149978. * @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)
  149979. */
  149980. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  149981. /**
  149982. * Stops the current optimizer
  149983. */
  149984. stop(): void;
  149985. /**
  149986. * Reset the optimizer to initial step (current priority level = 0)
  149987. */
  149988. reset(): void;
  149989. /**
  149990. * Start the optimizer. By default it will try to reach a specific framerate
  149991. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  149992. */
  149993. start(): void;
  149994. private _checkCurrentState;
  149995. /**
  149996. * Release all resources
  149997. */
  149998. dispose(): void;
  149999. /**
  150000. * Helper function to create a SceneOptimizer with one single line of code
  150001. * @param scene defines the scene to work on
  150002. * @param options defines the options to use with the SceneOptimizer
  150003. * @param onSuccess defines a callback to call on success
  150004. * @param onFailure defines a callback to call on failure
  150005. * @returns the new SceneOptimizer object
  150006. */
  150007. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  150008. }
  150009. }
  150010. declare module BABYLON {
  150011. /**
  150012. * Class used to serialize a scene into a string
  150013. */
  150014. export class SceneSerializer {
  150015. /**
  150016. * Clear cache used by a previous serialization
  150017. */
  150018. static ClearCache(): void;
  150019. /**
  150020. * Serialize a scene into a JSON compatible object
  150021. * @param scene defines the scene to serialize
  150022. * @returns a JSON compatible object
  150023. */
  150024. static Serialize(scene: Scene): any;
  150025. /**
  150026. * Serialize a mesh into a JSON compatible object
  150027. * @param toSerialize defines the mesh to serialize
  150028. * @param withParents defines if parents must be serialized as well
  150029. * @param withChildren defines if children must be serialized as well
  150030. * @returns a JSON compatible object
  150031. */
  150032. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  150033. }
  150034. }
  150035. declare module BABYLON {
  150036. /**
  150037. * Class used to host texture specific utilities
  150038. */
  150039. export class TextureTools {
  150040. /**
  150041. * Uses the GPU to create a copy texture rescaled at a given size
  150042. * @param texture Texture to copy from
  150043. * @param width defines the desired width
  150044. * @param height defines the desired height
  150045. * @param useBilinearMode defines if bilinear mode has to be used
  150046. * @return the generated texture
  150047. */
  150048. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  150049. }
  150050. }
  150051. declare module BABYLON {
  150052. /**
  150053. * This represents the different options available for the video capture.
  150054. */
  150055. export interface VideoRecorderOptions {
  150056. /** Defines the mime type of the video. */
  150057. mimeType: string;
  150058. /** Defines the FPS the video should be recorded at. */
  150059. fps: number;
  150060. /** Defines the chunk size for the recording data. */
  150061. recordChunckSize: number;
  150062. /** The audio tracks to attach to the recording. */
  150063. audioTracks?: MediaStreamTrack[];
  150064. }
  150065. /**
  150066. * This can help with recording videos from BabylonJS.
  150067. * This is based on the available WebRTC functionalities of the browser.
  150068. *
  150069. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  150070. */
  150071. export class VideoRecorder {
  150072. private static readonly _defaultOptions;
  150073. /**
  150074. * Returns whether or not the VideoRecorder is available in your browser.
  150075. * @param engine Defines the Babylon Engine.
  150076. * @returns true if supported otherwise false.
  150077. */
  150078. static IsSupported(engine: Engine): boolean;
  150079. private readonly _options;
  150080. private _canvas;
  150081. private _mediaRecorder;
  150082. private _recordedChunks;
  150083. private _fileName;
  150084. private _resolve;
  150085. private _reject;
  150086. /**
  150087. * True when a recording is already in progress.
  150088. */
  150089. get isRecording(): boolean;
  150090. /**
  150091. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  150092. * @param engine Defines the BabylonJS Engine you wish to record.
  150093. * @param options Defines options that can be used to customize the capture.
  150094. */
  150095. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  150096. /**
  150097. * Stops the current recording before the default capture timeout passed in the startRecording function.
  150098. */
  150099. stopRecording(): void;
  150100. /**
  150101. * Starts recording the canvas for a max duration specified in parameters.
  150102. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  150103. * If null no automatic download will start and you can rely on the promise to get the data back.
  150104. * @param maxDuration Defines the maximum recording time in seconds.
  150105. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  150106. * @return A promise callback at the end of the recording with the video data in Blob.
  150107. */
  150108. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  150109. /**
  150110. * Releases internal resources used during the recording.
  150111. */
  150112. dispose(): void;
  150113. private _handleDataAvailable;
  150114. private _handleError;
  150115. private _handleStop;
  150116. }
  150117. }
  150118. declare module BABYLON {
  150119. /**
  150120. * Class containing a set of static utilities functions for screenshots
  150121. */
  150122. export class ScreenshotTools {
  150123. /**
  150124. * Captures a screenshot of the current rendering
  150125. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150126. * @param engine defines the rendering engine
  150127. * @param camera defines the source camera
  150128. * @param size This parameter can be set to a single number or to an object with the
  150129. * following (optional) properties: precision, width, height. If a single number is passed,
  150130. * it will be used for both width and height. If an object is passed, the screenshot size
  150131. * will be derived from the parameters. The precision property is a multiplier allowing
  150132. * rendering at a higher or lower resolution
  150133. * @param successCallback defines the callback receives a single parameter which contains the
  150134. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  150135. * src parameter of an <img> to display it
  150136. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  150137. * Check your browser for supported MIME types
  150138. */
  150139. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  150140. /**
  150141. * Captures a screenshot of the current rendering
  150142. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150143. * @param engine defines the rendering engine
  150144. * @param camera defines the source camera
  150145. * @param size This parameter can be set to a single number or to an object with the
  150146. * following (optional) properties: precision, width, height. If a single number is passed,
  150147. * it will be used for both width and height. If an object is passed, the screenshot size
  150148. * will be derived from the parameters. The precision property is a multiplier allowing
  150149. * rendering at a higher or lower resolution
  150150. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  150151. * Check your browser for supported MIME types
  150152. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  150153. * to the src parameter of an <img> to display it
  150154. */
  150155. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  150156. /**
  150157. * Generates an image screenshot from the specified camera.
  150158. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150159. * @param engine The engine to use for rendering
  150160. * @param camera The camera to use for rendering
  150161. * @param size This parameter can be set to a single number or to an object with the
  150162. * following (optional) properties: precision, width, height. If a single number is passed,
  150163. * it will be used for both width and height. If an object is passed, the screenshot size
  150164. * will be derived from the parameters. The precision property is a multiplier allowing
  150165. * rendering at a higher or lower resolution
  150166. * @param successCallback The callback receives a single parameter which contains the
  150167. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  150168. * src parameter of an <img> to display it
  150169. * @param mimeType The MIME type of the screenshot image (default: image/png).
  150170. * Check your browser for supported MIME types
  150171. * @param samples Texture samples (default: 1)
  150172. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  150173. * @param fileName A name for for the downloaded file.
  150174. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  150175. */
  150176. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  150177. /**
  150178. * Generates an image screenshot from the specified camera.
  150179. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  150180. * @param engine The engine to use for rendering
  150181. * @param camera The camera to use for rendering
  150182. * @param size This parameter can be set to a single number or to an object with the
  150183. * following (optional) properties: precision, width, height. If a single number is passed,
  150184. * it will be used for both width and height. If an object is passed, the screenshot size
  150185. * will be derived from the parameters. The precision property is a multiplier allowing
  150186. * rendering at a higher or lower resolution
  150187. * @param mimeType The MIME type of the screenshot image (default: image/png).
  150188. * Check your browser for supported MIME types
  150189. * @param samples Texture samples (default: 1)
  150190. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  150191. * @param fileName A name for for the downloaded file.
  150192. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  150193. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  150194. * to the src parameter of an <img> to display it
  150195. */
  150196. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  150197. /**
  150198. * Gets height and width for screenshot size
  150199. * @private
  150200. */
  150201. private static _getScreenshotSize;
  150202. }
  150203. }
  150204. declare module BABYLON {
  150205. /**
  150206. * Interface for a data buffer
  150207. */
  150208. export interface IDataBuffer {
  150209. /**
  150210. * Reads bytes from the data buffer.
  150211. * @param byteOffset The byte offset to read
  150212. * @param byteLength The byte length to read
  150213. * @returns A promise that resolves when the bytes are read
  150214. */
  150215. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  150216. /**
  150217. * The byte length of the buffer.
  150218. */
  150219. readonly byteLength: number;
  150220. }
  150221. /**
  150222. * Utility class for reading from a data buffer
  150223. */
  150224. export class DataReader {
  150225. /**
  150226. * The data buffer associated with this data reader.
  150227. */
  150228. readonly buffer: IDataBuffer;
  150229. /**
  150230. * The current byte offset from the beginning of the data buffer.
  150231. */
  150232. byteOffset: number;
  150233. private _dataView;
  150234. private _dataByteOffset;
  150235. /**
  150236. * Constructor
  150237. * @param buffer The buffer to read
  150238. */
  150239. constructor(buffer: IDataBuffer);
  150240. /**
  150241. * Loads the given byte length.
  150242. * @param byteLength The byte length to load
  150243. * @returns A promise that resolves when the load is complete
  150244. */
  150245. loadAsync(byteLength: number): Promise<void>;
  150246. /**
  150247. * Read a unsigned 32-bit integer from the currently loaded data range.
  150248. * @returns The 32-bit integer read
  150249. */
  150250. readUint32(): number;
  150251. /**
  150252. * Read a byte array from the currently loaded data range.
  150253. * @param byteLength The byte length to read
  150254. * @returns The byte array read
  150255. */
  150256. readUint8Array(byteLength: number): Uint8Array;
  150257. /**
  150258. * Read a string from the currently loaded data range.
  150259. * @param byteLength The byte length to read
  150260. * @returns The string read
  150261. */
  150262. readString(byteLength: number): string;
  150263. /**
  150264. * Skips the given byte length the currently loaded data range.
  150265. * @param byteLength The byte length to skip
  150266. */
  150267. skipBytes(byteLength: number): void;
  150268. }
  150269. }
  150270. declare module BABYLON {
  150271. /**
  150272. * Class for storing data to local storage if available or in-memory storage otherwise
  150273. */
  150274. export class DataStorage {
  150275. private static _Storage;
  150276. private static _GetStorage;
  150277. /**
  150278. * Reads a string from the data storage
  150279. * @param key The key to read
  150280. * @param defaultValue The value if the key doesn't exist
  150281. * @returns The string value
  150282. */
  150283. static ReadString(key: string, defaultValue: string): string;
  150284. /**
  150285. * Writes a string to the data storage
  150286. * @param key The key to write
  150287. * @param value The value to write
  150288. */
  150289. static WriteString(key: string, value: string): void;
  150290. /**
  150291. * Reads a boolean from the data storage
  150292. * @param key The key to read
  150293. * @param defaultValue The value if the key doesn't exist
  150294. * @returns The boolean value
  150295. */
  150296. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  150297. /**
  150298. * Writes a boolean to the data storage
  150299. * @param key The key to write
  150300. * @param value The value to write
  150301. */
  150302. static WriteBoolean(key: string, value: boolean): void;
  150303. /**
  150304. * Reads a number from the data storage
  150305. * @param key The key to read
  150306. * @param defaultValue The value if the key doesn't exist
  150307. * @returns The number value
  150308. */
  150309. static ReadNumber(key: string, defaultValue: number): number;
  150310. /**
  150311. * Writes a number to the data storage
  150312. * @param key The key to write
  150313. * @param value The value to write
  150314. */
  150315. static WriteNumber(key: string, value: number): void;
  150316. }
  150317. }
  150318. declare module BABYLON {
  150319. /**
  150320. * An interface for all Hit test features
  150321. */
  150322. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  150323. /**
  150324. * Triggered when new babylon (transformed) hit test results are available
  150325. */
  150326. onHitTestResultObservable: Observable<T[]>;
  150327. }
  150328. /**
  150329. * Options used for hit testing
  150330. */
  150331. export interface IWebXRLegacyHitTestOptions {
  150332. /**
  150333. * Only test when user interacted with the scene. Default - hit test every frame
  150334. */
  150335. testOnPointerDownOnly?: boolean;
  150336. /**
  150337. * The node to use to transform the local results to world coordinates
  150338. */
  150339. worldParentNode?: TransformNode;
  150340. }
  150341. /**
  150342. * Interface defining the babylon result of raycasting/hit-test
  150343. */
  150344. export interface IWebXRLegacyHitResult {
  150345. /**
  150346. * Transformation matrix that can be applied to a node that will put it in the hit point location
  150347. */
  150348. transformationMatrix: Matrix;
  150349. /**
  150350. * The native hit test result
  150351. */
  150352. xrHitResult: XRHitResult | XRHitTestResult;
  150353. }
  150354. /**
  150355. * The currently-working hit-test module.
  150356. * Hit test (or Ray-casting) is used to interact with the real world.
  150357. * For further information read here - https://github.com/immersive-web/hit-test
  150358. */
  150359. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  150360. /**
  150361. * options to use when constructing this feature
  150362. */
  150363. readonly options: IWebXRLegacyHitTestOptions;
  150364. private _direction;
  150365. private _mat;
  150366. private _onSelectEnabled;
  150367. private _origin;
  150368. /**
  150369. * The module's name
  150370. */
  150371. static readonly Name: string;
  150372. /**
  150373. * The (Babylon) version of this module.
  150374. * This is an integer representing the implementation version.
  150375. * This number does not correspond to the WebXR specs version
  150376. */
  150377. static readonly Version: number;
  150378. /**
  150379. * Populated with the last native XR Hit Results
  150380. */
  150381. lastNativeXRHitResults: XRHitResult[];
  150382. /**
  150383. * Triggered when new babylon (transformed) hit test results are available
  150384. */
  150385. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  150386. /**
  150387. * Creates a new instance of the (legacy version) hit test feature
  150388. * @param _xrSessionManager an instance of WebXRSessionManager
  150389. * @param options options to use when constructing this feature
  150390. */
  150391. constructor(_xrSessionManager: WebXRSessionManager,
  150392. /**
  150393. * options to use when constructing this feature
  150394. */
  150395. options?: IWebXRLegacyHitTestOptions);
  150396. /**
  150397. * execute a hit test with an XR Ray
  150398. *
  150399. * @param xrSession a native xrSession that will execute this hit test
  150400. * @param xrRay the ray (position and direction) to use for ray-casting
  150401. * @param referenceSpace native XR reference space to use for the hit-test
  150402. * @param filter filter function that will filter the results
  150403. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150404. */
  150405. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  150406. /**
  150407. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  150408. * @param event the (select) event to use to select with
  150409. * @param referenceSpace the reference space to use for this hit test
  150410. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  150411. */
  150412. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  150413. /**
  150414. * attach this feature
  150415. * Will usually be called by the features manager
  150416. *
  150417. * @returns true if successful.
  150418. */
  150419. attach(): boolean;
  150420. /**
  150421. * detach this feature.
  150422. * Will usually be called by the features manager
  150423. *
  150424. * @returns true if successful.
  150425. */
  150426. detach(): boolean;
  150427. /**
  150428. * Dispose this feature and all of the resources attached
  150429. */
  150430. dispose(): void;
  150431. protected _onXRFrame(frame: XRFrame): void;
  150432. private _onHitTestResults;
  150433. private _onSelect;
  150434. }
  150435. }
  150436. declare module BABYLON {
  150437. /**
  150438. * Options used for hit testing (version 2)
  150439. */
  150440. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  150441. /**
  150442. * Do not create a permanent hit test. Will usually be used when only
  150443. * transient inputs are needed.
  150444. */
  150445. disablePermanentHitTest?: boolean;
  150446. /**
  150447. * Enable transient (for example touch-based) hit test inspections
  150448. */
  150449. enableTransientHitTest?: boolean;
  150450. /**
  150451. * Offset ray for the permanent hit test
  150452. */
  150453. offsetRay?: Vector3;
  150454. /**
  150455. * Offset ray for the transient hit test
  150456. */
  150457. transientOffsetRay?: Vector3;
  150458. /**
  150459. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  150460. */
  150461. useReferenceSpace?: boolean;
  150462. }
  150463. /**
  150464. * Interface defining the babylon result of hit-test
  150465. */
  150466. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  150467. /**
  150468. * The input source that generated this hit test (if transient)
  150469. */
  150470. inputSource?: XRInputSource;
  150471. /**
  150472. * Is this a transient hit test
  150473. */
  150474. isTransient?: boolean;
  150475. /**
  150476. * Position of the hit test result
  150477. */
  150478. position: Vector3;
  150479. /**
  150480. * Rotation of the hit test result
  150481. */
  150482. rotationQuaternion: Quaternion;
  150483. /**
  150484. * The native hit test result
  150485. */
  150486. xrHitResult: XRHitTestResult;
  150487. }
  150488. /**
  150489. * The currently-working hit-test module.
  150490. * Hit test (or Ray-casting) is used to interact with the real world.
  150491. * For further information read here - https://github.com/immersive-web/hit-test
  150492. *
  150493. * Tested on chrome (mobile) 80.
  150494. */
  150495. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  150496. /**
  150497. * options to use when constructing this feature
  150498. */
  150499. readonly options: IWebXRHitTestOptions;
  150500. private _tmpMat;
  150501. private _tmpPos;
  150502. private _tmpQuat;
  150503. private _transientXrHitTestSource;
  150504. private _xrHitTestSource;
  150505. private initHitTestSource;
  150506. /**
  150507. * The module's name
  150508. */
  150509. static readonly Name: string;
  150510. /**
  150511. * The (Babylon) version of this module.
  150512. * This is an integer representing the implementation version.
  150513. * This number does not correspond to the WebXR specs version
  150514. */
  150515. static readonly Version: number;
  150516. /**
  150517. * When set to true, each hit test will have its own position/rotation objects
  150518. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  150519. * the developers will clone them or copy them as they see fit.
  150520. */
  150521. autoCloneTransformation: boolean;
  150522. /**
  150523. * Triggered when new babylon (transformed) hit test results are available
  150524. */
  150525. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  150526. /**
  150527. * Use this to temporarily pause hit test checks.
  150528. */
  150529. paused: boolean;
  150530. /**
  150531. * Creates a new instance of the hit test feature
  150532. * @param _xrSessionManager an instance of WebXRSessionManager
  150533. * @param options options to use when constructing this feature
  150534. */
  150535. constructor(_xrSessionManager: WebXRSessionManager,
  150536. /**
  150537. * options to use when constructing this feature
  150538. */
  150539. options?: IWebXRHitTestOptions);
  150540. /**
  150541. * attach this feature
  150542. * Will usually be called by the features manager
  150543. *
  150544. * @returns true if successful.
  150545. */
  150546. attach(): boolean;
  150547. /**
  150548. * detach this feature.
  150549. * Will usually be called by the features manager
  150550. *
  150551. * @returns true if successful.
  150552. */
  150553. detach(): boolean;
  150554. /**
  150555. * Dispose this feature and all of the resources attached
  150556. */
  150557. dispose(): void;
  150558. protected _onXRFrame(frame: XRFrame): void;
  150559. private _processWebXRHitTestResult;
  150560. }
  150561. }
  150562. declare module BABYLON {
  150563. /**
  150564. * Configuration options of the anchor system
  150565. */
  150566. export interface IWebXRAnchorSystemOptions {
  150567. /**
  150568. * a node that will be used to convert local to world coordinates
  150569. */
  150570. worldParentNode?: TransformNode;
  150571. /**
  150572. * If set to true a reference of the created anchors will be kept until the next session starts
  150573. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  150574. */
  150575. doNotRemoveAnchorsOnSessionEnded?: boolean;
  150576. }
  150577. /**
  150578. * A babylon container for an XR Anchor
  150579. */
  150580. export interface IWebXRAnchor {
  150581. /**
  150582. * A babylon-assigned ID for this anchor
  150583. */
  150584. id: number;
  150585. /**
  150586. * Transformation matrix to apply to an object attached to this anchor
  150587. */
  150588. transformationMatrix: Matrix;
  150589. /**
  150590. * The native anchor object
  150591. */
  150592. xrAnchor: XRAnchor;
  150593. /**
  150594. * if defined, this object will be constantly updated by the anchor's position and rotation
  150595. */
  150596. attachedNode?: TransformNode;
  150597. }
  150598. /**
  150599. * An implementation of the anchor system for WebXR.
  150600. * For further information see https://github.com/immersive-web/anchors/
  150601. */
  150602. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  150603. private _options;
  150604. private _lastFrameDetected;
  150605. private _trackedAnchors;
  150606. private _referenceSpaceForFrameAnchors;
  150607. private _futureAnchors;
  150608. /**
  150609. * The module's name
  150610. */
  150611. static readonly Name: string;
  150612. /**
  150613. * The (Babylon) version of this module.
  150614. * This is an integer representing the implementation version.
  150615. * This number does not correspond to the WebXR specs version
  150616. */
  150617. static readonly Version: number;
  150618. /**
  150619. * Observers registered here will be executed when a new anchor was added to the session
  150620. */
  150621. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  150622. /**
  150623. * Observers registered here will be executed when an anchor was removed from the session
  150624. */
  150625. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  150626. /**
  150627. * Observers registered here will be executed when an existing anchor updates
  150628. * This can execute N times every frame
  150629. */
  150630. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  150631. /**
  150632. * Set the reference space to use for anchor creation, when not using a hit test.
  150633. * Will default to the session's reference space if not defined
  150634. */
  150635. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  150636. /**
  150637. * constructs a new anchor system
  150638. * @param _xrSessionManager an instance of WebXRSessionManager
  150639. * @param _options configuration object for this feature
  150640. */
  150641. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  150642. private _tmpVector;
  150643. private _tmpQuaternion;
  150644. private _populateTmpTransformation;
  150645. /**
  150646. * Create a new anchor point using a hit test result at a specific point in the scene
  150647. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150648. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150649. *
  150650. * @param hitTestResult The hit test result to use for this anchor creation
  150651. * @param position an optional position offset for this anchor
  150652. * @param rotationQuaternion an optional rotation offset for this anchor
  150653. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150654. */
  150655. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  150656. /**
  150657. * Add a new anchor at a specific position and rotation
  150658. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  150659. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  150660. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  150661. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  150662. *
  150663. * @param position the position in which to add an anchor
  150664. * @param rotationQuaternion an optional rotation for the anchor transformation
  150665. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  150666. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  150667. */
  150668. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  150669. /**
  150670. * detach this feature.
  150671. * Will usually be called by the features manager
  150672. *
  150673. * @returns true if successful.
  150674. */
  150675. detach(): boolean;
  150676. /**
  150677. * Dispose this feature and all of the resources attached
  150678. */
  150679. dispose(): void;
  150680. protected _onXRFrame(frame: XRFrame): void;
  150681. /**
  150682. * avoiding using Array.find for global support.
  150683. * @param xrAnchor the plane to find in the array
  150684. */
  150685. private _findIndexInAnchorArray;
  150686. private _updateAnchorWithXRFrame;
  150687. private _createAnchorAtTransformation;
  150688. }
  150689. }
  150690. declare module BABYLON {
  150691. /**
  150692. * Options used in the plane detector module
  150693. */
  150694. export interface IWebXRPlaneDetectorOptions {
  150695. /**
  150696. * The node to use to transform the local results to world coordinates
  150697. */
  150698. worldParentNode?: TransformNode;
  150699. /**
  150700. * If set to true a reference of the created planes will be kept until the next session starts
  150701. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  150702. */
  150703. doNotRemovePlanesOnSessionEnded?: boolean;
  150704. }
  150705. /**
  150706. * A babylon interface for a WebXR plane.
  150707. * A Plane is actually a polygon, built from N points in space
  150708. *
  150709. * Supported in chrome 79, not supported in canary 81 ATM
  150710. */
  150711. export interface IWebXRPlane {
  150712. /**
  150713. * a babylon-assigned ID for this polygon
  150714. */
  150715. id: number;
  150716. /**
  150717. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  150718. */
  150719. polygonDefinition: Array<Vector3>;
  150720. /**
  150721. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  150722. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  150723. */
  150724. transformationMatrix: Matrix;
  150725. /**
  150726. * the native xr-plane object
  150727. */
  150728. xrPlane: XRPlane;
  150729. }
  150730. /**
  150731. * The plane detector is used to detect planes in the real world when in AR
  150732. * For more information see https://github.com/immersive-web/real-world-geometry/
  150733. */
  150734. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  150735. private _options;
  150736. private _detectedPlanes;
  150737. private _enabled;
  150738. private _lastFrameDetected;
  150739. /**
  150740. * The module's name
  150741. */
  150742. static readonly Name: string;
  150743. /**
  150744. * The (Babylon) version of this module.
  150745. * This is an integer representing the implementation version.
  150746. * This number does not correspond to the WebXR specs version
  150747. */
  150748. static readonly Version: number;
  150749. /**
  150750. * Observers registered here will be executed when a new plane was added to the session
  150751. */
  150752. onPlaneAddedObservable: Observable<IWebXRPlane>;
  150753. /**
  150754. * Observers registered here will be executed when a plane is no longer detected in the session
  150755. */
  150756. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  150757. /**
  150758. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  150759. * This can execute N times every frame
  150760. */
  150761. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  150762. /**
  150763. * construct a new Plane Detector
  150764. * @param _xrSessionManager an instance of xr Session manager
  150765. * @param _options configuration to use when constructing this feature
  150766. */
  150767. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  150768. /**
  150769. * detach this feature.
  150770. * Will usually be called by the features manager
  150771. *
  150772. * @returns true if successful.
  150773. */
  150774. detach(): boolean;
  150775. /**
  150776. * Dispose this feature and all of the resources attached
  150777. */
  150778. dispose(): void;
  150779. protected _onXRFrame(frame: XRFrame): void;
  150780. private _init;
  150781. private _updatePlaneWithXRPlane;
  150782. /**
  150783. * avoiding using Array.find for global support.
  150784. * @param xrPlane the plane to find in the array
  150785. */
  150786. private findIndexInPlaneArray;
  150787. }
  150788. }
  150789. declare module BABYLON {
  150790. /**
  150791. * Options interface for the background remover plugin
  150792. */
  150793. export interface IWebXRBackgroundRemoverOptions {
  150794. /**
  150795. * Further background meshes to disable when entering AR
  150796. */
  150797. backgroundMeshes?: AbstractMesh[];
  150798. /**
  150799. * flags to configure the removal of the environment helper.
  150800. * If not set, the entire background will be removed. If set, flags should be set as well.
  150801. */
  150802. environmentHelperRemovalFlags?: {
  150803. /**
  150804. * Should the skybox be removed (default false)
  150805. */
  150806. skyBox?: boolean;
  150807. /**
  150808. * Should the ground be removed (default false)
  150809. */
  150810. ground?: boolean;
  150811. };
  150812. /**
  150813. * don't disable the environment helper
  150814. */
  150815. ignoreEnvironmentHelper?: boolean;
  150816. }
  150817. /**
  150818. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  150819. */
  150820. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  150821. /**
  150822. * read-only options to be used in this module
  150823. */
  150824. readonly options: IWebXRBackgroundRemoverOptions;
  150825. /**
  150826. * The module's name
  150827. */
  150828. static readonly Name: string;
  150829. /**
  150830. * The (Babylon) version of this module.
  150831. * This is an integer representing the implementation version.
  150832. * This number does not correspond to the WebXR specs version
  150833. */
  150834. static readonly Version: number;
  150835. /**
  150836. * registered observers will be triggered when the background state changes
  150837. */
  150838. onBackgroundStateChangedObservable: Observable<boolean>;
  150839. /**
  150840. * constructs a new background remover module
  150841. * @param _xrSessionManager the session manager for this module
  150842. * @param options read-only options to be used in this module
  150843. */
  150844. constructor(_xrSessionManager: WebXRSessionManager,
  150845. /**
  150846. * read-only options to be used in this module
  150847. */
  150848. options?: IWebXRBackgroundRemoverOptions);
  150849. /**
  150850. * attach this feature
  150851. * Will usually be called by the features manager
  150852. *
  150853. * @returns true if successful.
  150854. */
  150855. attach(): boolean;
  150856. /**
  150857. * detach this feature.
  150858. * Will usually be called by the features manager
  150859. *
  150860. * @returns true if successful.
  150861. */
  150862. detach(): boolean;
  150863. /**
  150864. * Dispose this feature and all of the resources attached
  150865. */
  150866. dispose(): void;
  150867. protected _onXRFrame(_xrFrame: XRFrame): void;
  150868. private _setBackgroundState;
  150869. }
  150870. }
  150871. declare module BABYLON {
  150872. /**
  150873. * Options for the controller physics feature
  150874. */
  150875. export class IWebXRControllerPhysicsOptions {
  150876. /**
  150877. * Should the headset get its own impostor
  150878. */
  150879. enableHeadsetImpostor?: boolean;
  150880. /**
  150881. * Optional parameters for the headset impostor
  150882. */
  150883. headsetImpostorParams?: {
  150884. /**
  150885. * The type of impostor to create. Default is sphere
  150886. */
  150887. impostorType: number;
  150888. /**
  150889. * the size of the impostor. Defaults to 10cm
  150890. */
  150891. impostorSize?: number | {
  150892. width: number;
  150893. height: number;
  150894. depth: number;
  150895. };
  150896. /**
  150897. * Friction definitions
  150898. */
  150899. friction?: number;
  150900. /**
  150901. * Restitution
  150902. */
  150903. restitution?: number;
  150904. };
  150905. /**
  150906. * The physics properties of the future impostors
  150907. */
  150908. physicsProperties?: {
  150909. /**
  150910. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  150911. * Note that this requires a physics engine that supports mesh impostors!
  150912. */
  150913. useControllerMesh?: boolean;
  150914. /**
  150915. * The type of impostor to create. Default is sphere
  150916. */
  150917. impostorType?: number;
  150918. /**
  150919. * the size of the impostor. Defaults to 10cm
  150920. */
  150921. impostorSize?: number | {
  150922. width: number;
  150923. height: number;
  150924. depth: number;
  150925. };
  150926. /**
  150927. * Friction definitions
  150928. */
  150929. friction?: number;
  150930. /**
  150931. * Restitution
  150932. */
  150933. restitution?: number;
  150934. };
  150935. /**
  150936. * the xr input to use with this pointer selection
  150937. */
  150938. xrInput: WebXRInput;
  150939. }
  150940. /**
  150941. * Add physics impostor to your webxr controllers,
  150942. * including naive calculation of their linear and angular velocity
  150943. */
  150944. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  150945. private readonly _options;
  150946. private _attachController;
  150947. private _controllers;
  150948. private _debugMode;
  150949. private _delta;
  150950. private _headsetImpostor?;
  150951. private _headsetMesh?;
  150952. private _lastTimestamp;
  150953. private _tmpQuaternion;
  150954. private _tmpVector;
  150955. /**
  150956. * The module's name
  150957. */
  150958. static readonly Name: string;
  150959. /**
  150960. * The (Babylon) version of this module.
  150961. * This is an integer representing the implementation version.
  150962. * This number does not correspond to the webxr specs version
  150963. */
  150964. static readonly Version: number;
  150965. /**
  150966. * Construct a new Controller Physics Feature
  150967. * @param _xrSessionManager the corresponding xr session manager
  150968. * @param _options options to create this feature with
  150969. */
  150970. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  150971. /**
  150972. * @hidden
  150973. * enable debugging - will show console outputs and the impostor mesh
  150974. */
  150975. _enablePhysicsDebug(): void;
  150976. /**
  150977. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  150978. * @param xrController the controller to add
  150979. */
  150980. addController(xrController: WebXRInputSource): void;
  150981. /**
  150982. * attach this feature
  150983. * Will usually be called by the features manager
  150984. *
  150985. * @returns true if successful.
  150986. */
  150987. attach(): boolean;
  150988. /**
  150989. * detach this feature.
  150990. * Will usually be called by the features manager
  150991. *
  150992. * @returns true if successful.
  150993. */
  150994. detach(): boolean;
  150995. /**
  150996. * Get the headset impostor, if enabled
  150997. * @returns the impostor
  150998. */
  150999. getHeadsetImpostor(): PhysicsImpostor | undefined;
  151000. /**
  151001. * Get the physics impostor of a specific controller.
  151002. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  151003. * @param controller the controller or the controller id of which to get the impostor
  151004. * @returns the impostor or null
  151005. */
  151006. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  151007. /**
  151008. * Update the physics properties provided in the constructor
  151009. * @param newProperties the new properties object
  151010. */
  151011. setPhysicsProperties(newProperties: {
  151012. impostorType?: number;
  151013. impostorSize?: number | {
  151014. width: number;
  151015. height: number;
  151016. depth: number;
  151017. };
  151018. friction?: number;
  151019. restitution?: number;
  151020. }): void;
  151021. protected _onXRFrame(_xrFrame: any): void;
  151022. private _detachController;
  151023. }
  151024. }
  151025. declare module BABYLON {
  151026. /**
  151027. * The motion controller class for all microsoft mixed reality controllers
  151028. */
  151029. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  151030. protected readonly _mapping: {
  151031. defaultButton: {
  151032. valueNodeName: string;
  151033. unpressedNodeName: string;
  151034. pressedNodeName: string;
  151035. };
  151036. defaultAxis: {
  151037. valueNodeName: string;
  151038. minNodeName: string;
  151039. maxNodeName: string;
  151040. };
  151041. buttons: {
  151042. "xr-standard-trigger": {
  151043. rootNodeName: string;
  151044. componentProperty: string;
  151045. states: string[];
  151046. };
  151047. "xr-standard-squeeze": {
  151048. rootNodeName: string;
  151049. componentProperty: string;
  151050. states: string[];
  151051. };
  151052. "xr-standard-touchpad": {
  151053. rootNodeName: string;
  151054. labelAnchorNodeName: string;
  151055. touchPointNodeName: string;
  151056. };
  151057. "xr-standard-thumbstick": {
  151058. rootNodeName: string;
  151059. componentProperty: string;
  151060. states: string[];
  151061. };
  151062. };
  151063. axes: {
  151064. "xr-standard-touchpad": {
  151065. "x-axis": {
  151066. rootNodeName: string;
  151067. };
  151068. "y-axis": {
  151069. rootNodeName: string;
  151070. };
  151071. };
  151072. "xr-standard-thumbstick": {
  151073. "x-axis": {
  151074. rootNodeName: string;
  151075. };
  151076. "y-axis": {
  151077. rootNodeName: string;
  151078. };
  151079. };
  151080. };
  151081. };
  151082. /**
  151083. * The base url used to load the left and right controller models
  151084. */
  151085. static MODEL_BASE_URL: string;
  151086. /**
  151087. * The name of the left controller model file
  151088. */
  151089. static MODEL_LEFT_FILENAME: string;
  151090. /**
  151091. * The name of the right controller model file
  151092. */
  151093. static MODEL_RIGHT_FILENAME: string;
  151094. profileId: string;
  151095. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  151096. protected _getFilenameAndPath(): {
  151097. filename: string;
  151098. path: string;
  151099. };
  151100. protected _getModelLoadingConstraints(): boolean;
  151101. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151102. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151103. protected _updateModel(): void;
  151104. }
  151105. }
  151106. declare module BABYLON {
  151107. /**
  151108. * The motion controller class for oculus touch (quest, rift).
  151109. * This class supports legacy mapping as well the standard xr mapping
  151110. */
  151111. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  151112. private _forceLegacyControllers;
  151113. private _modelRootNode;
  151114. /**
  151115. * The base url used to load the left and right controller models
  151116. */
  151117. static MODEL_BASE_URL: string;
  151118. /**
  151119. * The name of the left controller model file
  151120. */
  151121. static MODEL_LEFT_FILENAME: string;
  151122. /**
  151123. * The name of the right controller model file
  151124. */
  151125. static MODEL_RIGHT_FILENAME: string;
  151126. /**
  151127. * Base Url for the Quest controller model.
  151128. */
  151129. static QUEST_MODEL_BASE_URL: string;
  151130. profileId: string;
  151131. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  151132. protected _getFilenameAndPath(): {
  151133. filename: string;
  151134. path: string;
  151135. };
  151136. protected _getModelLoadingConstraints(): boolean;
  151137. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151138. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151139. protected _updateModel(): void;
  151140. /**
  151141. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  151142. * between the touch and touch 2.
  151143. */
  151144. private _isQuest;
  151145. }
  151146. }
  151147. declare module BABYLON {
  151148. /**
  151149. * The motion controller class for the standard HTC-Vive controllers
  151150. */
  151151. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  151152. private _modelRootNode;
  151153. /**
  151154. * The base url used to load the left and right controller models
  151155. */
  151156. static MODEL_BASE_URL: string;
  151157. /**
  151158. * File name for the controller model.
  151159. */
  151160. static MODEL_FILENAME: string;
  151161. profileId: string;
  151162. /**
  151163. * Create a new Vive motion controller object
  151164. * @param scene the scene to use to create this controller
  151165. * @param gamepadObject the corresponding gamepad object
  151166. * @param handedness the handedness of the controller
  151167. */
  151168. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  151169. protected _getFilenameAndPath(): {
  151170. filename: string;
  151171. path: string;
  151172. };
  151173. protected _getModelLoadingConstraints(): boolean;
  151174. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  151175. protected _setRootMesh(meshes: AbstractMesh[]): void;
  151176. protected _updateModel(): void;
  151177. }
  151178. }
  151179. declare module BABYLON {
  151180. /**
  151181. * A cursor which tracks a point on a path
  151182. */
  151183. export class PathCursor {
  151184. private path;
  151185. /**
  151186. * Stores path cursor callbacks for when an onchange event is triggered
  151187. */
  151188. private _onchange;
  151189. /**
  151190. * The value of the path cursor
  151191. */
  151192. value: number;
  151193. /**
  151194. * The animation array of the path cursor
  151195. */
  151196. animations: Animation[];
  151197. /**
  151198. * Initializes the path cursor
  151199. * @param path The path to track
  151200. */
  151201. constructor(path: Path2);
  151202. /**
  151203. * Gets the cursor point on the path
  151204. * @returns A point on the path cursor at the cursor location
  151205. */
  151206. getPoint(): Vector3;
  151207. /**
  151208. * Moves the cursor ahead by the step amount
  151209. * @param step The amount to move the cursor forward
  151210. * @returns This path cursor
  151211. */
  151212. moveAhead(step?: number): PathCursor;
  151213. /**
  151214. * Moves the cursor behind by the step amount
  151215. * @param step The amount to move the cursor back
  151216. * @returns This path cursor
  151217. */
  151218. moveBack(step?: number): PathCursor;
  151219. /**
  151220. * Moves the cursor by the step amount
  151221. * If the step amount is greater than one, an exception is thrown
  151222. * @param step The amount to move the cursor
  151223. * @returns This path cursor
  151224. */
  151225. move(step: number): PathCursor;
  151226. /**
  151227. * Ensures that the value is limited between zero and one
  151228. * @returns This path cursor
  151229. */
  151230. private ensureLimits;
  151231. /**
  151232. * Runs onchange callbacks on change (used by the animation engine)
  151233. * @returns This path cursor
  151234. */
  151235. private raiseOnChange;
  151236. /**
  151237. * Executes a function on change
  151238. * @param f A path cursor onchange callback
  151239. * @returns This path cursor
  151240. */
  151241. onchange(f: (cursor: PathCursor) => void): PathCursor;
  151242. }
  151243. }
  151244. declare module BABYLON {
  151245. /** @hidden */
  151246. export var blurPixelShader: {
  151247. name: string;
  151248. shader: string;
  151249. };
  151250. }
  151251. declare module BABYLON {
  151252. /** @hidden */
  151253. export var pointCloudVertexDeclaration: {
  151254. name: string;
  151255. shader: string;
  151256. };
  151257. }
  151258. // Mixins
  151259. interface Window {
  151260. mozIndexedDB: IDBFactory;
  151261. webkitIndexedDB: IDBFactory;
  151262. msIndexedDB: IDBFactory;
  151263. webkitURL: typeof URL;
  151264. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  151265. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  151266. WebGLRenderingContext: WebGLRenderingContext;
  151267. MSGesture: MSGesture;
  151268. CANNON: any;
  151269. AudioContext: AudioContext;
  151270. webkitAudioContext: AudioContext;
  151271. PointerEvent: any;
  151272. Math: Math;
  151273. Uint8Array: Uint8ArrayConstructor;
  151274. Float32Array: Float32ArrayConstructor;
  151275. mozURL: typeof URL;
  151276. msURL: typeof URL;
  151277. VRFrameData: any; // WebVR, from specs 1.1
  151278. DracoDecoderModule: any;
  151279. setImmediate(handler: (...args: any[]) => void): number;
  151280. }
  151281. interface HTMLCanvasElement {
  151282. requestPointerLock(): void;
  151283. msRequestPointerLock?(): void;
  151284. mozRequestPointerLock?(): void;
  151285. webkitRequestPointerLock?(): void;
  151286. /** Track wether a record is in progress */
  151287. isRecording: boolean;
  151288. /** Capture Stream method defined by some browsers */
  151289. captureStream(fps?: number): MediaStream;
  151290. }
  151291. interface CanvasRenderingContext2D {
  151292. msImageSmoothingEnabled: boolean;
  151293. }
  151294. interface MouseEvent {
  151295. mozMovementX: number;
  151296. mozMovementY: number;
  151297. webkitMovementX: number;
  151298. webkitMovementY: number;
  151299. msMovementX: number;
  151300. msMovementY: number;
  151301. }
  151302. interface Navigator {
  151303. mozGetVRDevices: (any: any) => any;
  151304. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151305. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151306. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  151307. webkitGetGamepads(): Gamepad[];
  151308. msGetGamepads(): Gamepad[];
  151309. webkitGamepads(): Gamepad[];
  151310. }
  151311. interface HTMLVideoElement {
  151312. mozSrcObject: any;
  151313. }
  151314. interface Math {
  151315. fround(x: number): number;
  151316. imul(a: number, b: number): number;
  151317. }
  151318. interface WebGLRenderingContext {
  151319. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  151320. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  151321. vertexAttribDivisor(index: number, divisor: number): void;
  151322. createVertexArray(): any;
  151323. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  151324. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  151325. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  151326. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  151327. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  151328. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  151329. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  151330. // Queries
  151331. createQuery(): WebGLQuery;
  151332. deleteQuery(query: WebGLQuery): void;
  151333. beginQuery(target: number, query: WebGLQuery): void;
  151334. endQuery(target: number): void;
  151335. getQueryParameter(query: WebGLQuery, pname: number): any;
  151336. getQuery(target: number, pname: number): any;
  151337. MAX_SAMPLES: number;
  151338. RGBA8: number;
  151339. READ_FRAMEBUFFER: number;
  151340. DRAW_FRAMEBUFFER: number;
  151341. UNIFORM_BUFFER: number;
  151342. HALF_FLOAT_OES: number;
  151343. RGBA16F: number;
  151344. RGBA32F: number;
  151345. R32F: number;
  151346. RG32F: number;
  151347. RGB32F: number;
  151348. R16F: number;
  151349. RG16F: number;
  151350. RGB16F: number;
  151351. RED: number;
  151352. RG: number;
  151353. R8: number;
  151354. RG8: number;
  151355. UNSIGNED_INT_24_8: number;
  151356. DEPTH24_STENCIL8: number;
  151357. MIN: number;
  151358. MAX: number;
  151359. /* Multiple Render Targets */
  151360. drawBuffers(buffers: number[]): void;
  151361. readBuffer(src: number): void;
  151362. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  151363. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  151364. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  151365. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  151366. // Occlusion Query
  151367. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  151368. ANY_SAMPLES_PASSED: number;
  151369. QUERY_RESULT_AVAILABLE: number;
  151370. QUERY_RESULT: number;
  151371. }
  151372. interface WebGLProgram {
  151373. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  151374. }
  151375. interface EXT_disjoint_timer_query {
  151376. QUERY_COUNTER_BITS_EXT: number;
  151377. TIME_ELAPSED_EXT: number;
  151378. TIMESTAMP_EXT: number;
  151379. GPU_DISJOINT_EXT: number;
  151380. QUERY_RESULT_EXT: number;
  151381. QUERY_RESULT_AVAILABLE_EXT: number;
  151382. queryCounterEXT(query: WebGLQuery, target: number): void;
  151383. createQueryEXT(): WebGLQuery;
  151384. beginQueryEXT(target: number, query: WebGLQuery): void;
  151385. endQueryEXT(target: number): void;
  151386. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  151387. deleteQueryEXT(query: WebGLQuery): void;
  151388. }
  151389. interface WebGLUniformLocation {
  151390. _currentState: any;
  151391. }
  151392. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  151393. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  151394. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  151395. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151396. interface WebGLRenderingContext {
  151397. readonly RASTERIZER_DISCARD: number;
  151398. readonly DEPTH_COMPONENT24: number;
  151399. readonly TEXTURE_3D: number;
  151400. readonly TEXTURE_2D_ARRAY: number;
  151401. readonly TEXTURE_COMPARE_FUNC: number;
  151402. readonly TEXTURE_COMPARE_MODE: number;
  151403. readonly COMPARE_REF_TO_TEXTURE: number;
  151404. readonly TEXTURE_WRAP_R: number;
  151405. readonly HALF_FLOAT: number;
  151406. readonly RGB8: number;
  151407. readonly RED_INTEGER: number;
  151408. readonly RG_INTEGER: number;
  151409. readonly RGB_INTEGER: number;
  151410. readonly RGBA_INTEGER: number;
  151411. readonly R8_SNORM: number;
  151412. readonly RG8_SNORM: number;
  151413. readonly RGB8_SNORM: number;
  151414. readonly RGBA8_SNORM: number;
  151415. readonly R8I: number;
  151416. readonly RG8I: number;
  151417. readonly RGB8I: number;
  151418. readonly RGBA8I: number;
  151419. readonly R8UI: number;
  151420. readonly RG8UI: number;
  151421. readonly RGB8UI: number;
  151422. readonly RGBA8UI: number;
  151423. readonly R16I: number;
  151424. readonly RG16I: number;
  151425. readonly RGB16I: number;
  151426. readonly RGBA16I: number;
  151427. readonly R16UI: number;
  151428. readonly RG16UI: number;
  151429. readonly RGB16UI: number;
  151430. readonly RGBA16UI: number;
  151431. readonly R32I: number;
  151432. readonly RG32I: number;
  151433. readonly RGB32I: number;
  151434. readonly RGBA32I: number;
  151435. readonly R32UI: number;
  151436. readonly RG32UI: number;
  151437. readonly RGB32UI: number;
  151438. readonly RGBA32UI: number;
  151439. readonly RGB10_A2UI: number;
  151440. readonly R11F_G11F_B10F: number;
  151441. readonly RGB9_E5: number;
  151442. readonly RGB10_A2: number;
  151443. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  151444. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  151445. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  151446. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  151447. readonly DEPTH_COMPONENT32F: number;
  151448. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  151449. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  151450. 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;
  151451. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  151452. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  151453. readonly TRANSFORM_FEEDBACK: number;
  151454. readonly INTERLEAVED_ATTRIBS: number;
  151455. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  151456. createTransformFeedback(): WebGLTransformFeedback;
  151457. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  151458. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  151459. beginTransformFeedback(primitiveMode: number): void;
  151460. endTransformFeedback(): void;
  151461. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  151462. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151463. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151464. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  151465. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  151466. }
  151467. interface ImageBitmap {
  151468. readonly width: number;
  151469. readonly height: number;
  151470. close(): void;
  151471. }
  151472. interface WebGLQuery extends WebGLObject {
  151473. }
  151474. declare var WebGLQuery: {
  151475. prototype: WebGLQuery;
  151476. new(): WebGLQuery;
  151477. };
  151478. interface WebGLSampler extends WebGLObject {
  151479. }
  151480. declare var WebGLSampler: {
  151481. prototype: WebGLSampler;
  151482. new(): WebGLSampler;
  151483. };
  151484. interface WebGLSync extends WebGLObject {
  151485. }
  151486. declare var WebGLSync: {
  151487. prototype: WebGLSync;
  151488. new(): WebGLSync;
  151489. };
  151490. interface WebGLTransformFeedback extends WebGLObject {
  151491. }
  151492. declare var WebGLTransformFeedback: {
  151493. prototype: WebGLTransformFeedback;
  151494. new(): WebGLTransformFeedback;
  151495. };
  151496. interface WebGLVertexArrayObject extends WebGLObject {
  151497. }
  151498. declare var WebGLVertexArrayObject: {
  151499. prototype: WebGLVertexArrayObject;
  151500. new(): WebGLVertexArrayObject;
  151501. };
  151502. // Type definitions for WebVR API
  151503. // Project: https://w3c.github.io/webvr/
  151504. // Definitions by: six a <https://github.com/lostfictions>
  151505. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  151506. interface VRDisplay extends EventTarget {
  151507. /**
  151508. * Dictionary of capabilities describing the VRDisplay.
  151509. */
  151510. readonly capabilities: VRDisplayCapabilities;
  151511. /**
  151512. * z-depth defining the far plane of the eye view frustum
  151513. * enables mapping of values in the render target depth
  151514. * attachment to scene coordinates. Initially set to 10000.0.
  151515. */
  151516. depthFar: number;
  151517. /**
  151518. * z-depth defining the near plane of the eye view frustum
  151519. * enables mapping of values in the render target depth
  151520. * attachment to scene coordinates. Initially set to 0.01.
  151521. */
  151522. depthNear: number;
  151523. /**
  151524. * An identifier for this distinct VRDisplay. Used as an
  151525. * association point in the Gamepad API.
  151526. */
  151527. readonly displayId: number;
  151528. /**
  151529. * A display name, a user-readable name identifying it.
  151530. */
  151531. readonly displayName: string;
  151532. readonly isConnected: boolean;
  151533. readonly isPresenting: boolean;
  151534. /**
  151535. * If this VRDisplay supports room-scale experiences, the optional
  151536. * stage attribute contains details on the room-scale parameters.
  151537. */
  151538. readonly stageParameters: VRStageParameters | null;
  151539. /**
  151540. * Passing the value returned by `requestAnimationFrame` to
  151541. * `cancelAnimationFrame` will unregister the callback.
  151542. * @param handle Define the hanle of the request to cancel
  151543. */
  151544. cancelAnimationFrame(handle: number): void;
  151545. /**
  151546. * Stops presenting to the VRDisplay.
  151547. * @returns a promise to know when it stopped
  151548. */
  151549. exitPresent(): Promise<void>;
  151550. /**
  151551. * Return the current VREyeParameters for the given eye.
  151552. * @param whichEye Define the eye we want the parameter for
  151553. * @returns the eye parameters
  151554. */
  151555. getEyeParameters(whichEye: string): VREyeParameters;
  151556. /**
  151557. * Populates the passed VRFrameData with the information required to render
  151558. * the current frame.
  151559. * @param frameData Define the data structure to populate
  151560. * @returns true if ok otherwise false
  151561. */
  151562. getFrameData(frameData: VRFrameData): boolean;
  151563. /**
  151564. * Get the layers currently being presented.
  151565. * @returns the list of VR layers
  151566. */
  151567. getLayers(): VRLayer[];
  151568. /**
  151569. * Return a VRPose containing the future predicted pose of the VRDisplay
  151570. * when the current frame will be presented. The value returned will not
  151571. * change until JavaScript has returned control to the browser.
  151572. *
  151573. * The VRPose will contain the position, orientation, velocity,
  151574. * and acceleration of each of these properties.
  151575. * @returns the pose object
  151576. */
  151577. getPose(): VRPose;
  151578. /**
  151579. * Return the current instantaneous pose of the VRDisplay, with no
  151580. * prediction applied.
  151581. * @returns the current instantaneous pose
  151582. */
  151583. getImmediatePose(): VRPose;
  151584. /**
  151585. * The callback passed to `requestAnimationFrame` will be called
  151586. * any time a new frame should be rendered. When the VRDisplay is
  151587. * presenting the callback will be called at the native refresh
  151588. * rate of the HMD. When not presenting this function acts
  151589. * identically to how window.requestAnimationFrame acts. Content should
  151590. * make no assumptions of frame rate or vsync behavior as the HMD runs
  151591. * asynchronously from other displays and at differing refresh rates.
  151592. * @param callback Define the eaction to run next frame
  151593. * @returns the request handle it
  151594. */
  151595. requestAnimationFrame(callback: FrameRequestCallback): number;
  151596. /**
  151597. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  151598. * Repeat calls while already presenting will update the VRLayers being displayed.
  151599. * @param layers Define the list of layer to present
  151600. * @returns a promise to know when the request has been fulfilled
  151601. */
  151602. requestPresent(layers: VRLayer[]): Promise<void>;
  151603. /**
  151604. * Reset the pose for this display, treating its current position and
  151605. * orientation as the "origin/zero" values. VRPose.position,
  151606. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  151607. * updated when calling resetPose(). This should be called in only
  151608. * sitting-space experiences.
  151609. */
  151610. resetPose(): void;
  151611. /**
  151612. * The VRLayer provided to the VRDisplay will be captured and presented
  151613. * in the HMD. Calling this function has the same effect on the source
  151614. * canvas as any other operation that uses its source image, and canvases
  151615. * created without preserveDrawingBuffer set to true will be cleared.
  151616. * @param pose Define the pose to submit
  151617. */
  151618. submitFrame(pose?: VRPose): void;
  151619. }
  151620. declare var VRDisplay: {
  151621. prototype: VRDisplay;
  151622. new(): VRDisplay;
  151623. };
  151624. interface VRLayer {
  151625. leftBounds?: number[] | Float32Array | null;
  151626. rightBounds?: number[] | Float32Array | null;
  151627. source?: HTMLCanvasElement | null;
  151628. }
  151629. interface VRDisplayCapabilities {
  151630. readonly canPresent: boolean;
  151631. readonly hasExternalDisplay: boolean;
  151632. readonly hasOrientation: boolean;
  151633. readonly hasPosition: boolean;
  151634. readonly maxLayers: number;
  151635. }
  151636. interface VREyeParameters {
  151637. /** @deprecated */
  151638. readonly fieldOfView: VRFieldOfView;
  151639. readonly offset: Float32Array;
  151640. readonly renderHeight: number;
  151641. readonly renderWidth: number;
  151642. }
  151643. interface VRFieldOfView {
  151644. readonly downDegrees: number;
  151645. readonly leftDegrees: number;
  151646. readonly rightDegrees: number;
  151647. readonly upDegrees: number;
  151648. }
  151649. interface VRFrameData {
  151650. readonly leftProjectionMatrix: Float32Array;
  151651. readonly leftViewMatrix: Float32Array;
  151652. readonly pose: VRPose;
  151653. readonly rightProjectionMatrix: Float32Array;
  151654. readonly rightViewMatrix: Float32Array;
  151655. readonly timestamp: number;
  151656. }
  151657. interface VRPose {
  151658. readonly angularAcceleration: Float32Array | null;
  151659. readonly angularVelocity: Float32Array | null;
  151660. readonly linearAcceleration: Float32Array | null;
  151661. readonly linearVelocity: Float32Array | null;
  151662. readonly orientation: Float32Array | null;
  151663. readonly position: Float32Array | null;
  151664. readonly timestamp: number;
  151665. }
  151666. interface VRStageParameters {
  151667. sittingToStandingTransform?: Float32Array;
  151668. sizeX?: number;
  151669. sizeY?: number;
  151670. }
  151671. interface Navigator {
  151672. getVRDisplays(): Promise<VRDisplay[]>;
  151673. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  151674. }
  151675. interface Window {
  151676. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  151677. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  151678. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  151679. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151680. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  151681. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  151682. }
  151683. interface Gamepad {
  151684. readonly displayId: number;
  151685. }
  151686. type XRSessionMode =
  151687. | "inline"
  151688. | "immersive-vr"
  151689. | "immersive-ar";
  151690. type XRReferenceSpaceType =
  151691. | "viewer"
  151692. | "local"
  151693. | "local-floor"
  151694. | "bounded-floor"
  151695. | "unbounded";
  151696. type XREnvironmentBlendMode =
  151697. | "opaque"
  151698. | "additive"
  151699. | "alpha-blend";
  151700. type XRVisibilityState =
  151701. | "visible"
  151702. | "visible-blurred"
  151703. | "hidden";
  151704. type XRHandedness =
  151705. | "none"
  151706. | "left"
  151707. | "right";
  151708. type XRTargetRayMode =
  151709. | "gaze"
  151710. | "tracked-pointer"
  151711. | "screen";
  151712. type XREye =
  151713. | "none"
  151714. | "left"
  151715. | "right";
  151716. type XREventType =
  151717. | "devicechange"
  151718. | "visibilitychange"
  151719. | "end"
  151720. | "inputsourceschange"
  151721. | "select"
  151722. | "selectstart"
  151723. | "selectend"
  151724. | "squeeze"
  151725. | "squeezestart"
  151726. | "squeezeend"
  151727. | "reset";
  151728. interface XRSpace extends EventTarget {
  151729. }
  151730. interface XRRenderState {
  151731. depthNear?: number;
  151732. depthFar?: number;
  151733. inlineVerticalFieldOfView?: number;
  151734. baseLayer?: XRWebGLLayer;
  151735. }
  151736. interface XRInputSource {
  151737. handedness: XRHandedness;
  151738. targetRayMode: XRTargetRayMode;
  151739. targetRaySpace: XRSpace;
  151740. gripSpace: XRSpace | undefined;
  151741. gamepad: Gamepad | undefined;
  151742. profiles: Array<string>;
  151743. }
  151744. interface XRSessionInit {
  151745. optionalFeatures?: string[];
  151746. requiredFeatures?: string[];
  151747. }
  151748. interface XRSession {
  151749. addEventListener: Function;
  151750. removeEventListener: Function;
  151751. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  151752. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  151753. requestAnimationFrame: Function;
  151754. end(): Promise<void>;
  151755. renderState: XRRenderState;
  151756. inputSources: Array<XRInputSource>;
  151757. // hit test
  151758. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  151759. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  151760. // legacy AR hit test
  151761. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151762. // legacy plane detection
  151763. updateWorldTrackingState(options: {
  151764. planeDetectionState?: { enabled: boolean; }
  151765. }): void;
  151766. }
  151767. interface XRReferenceSpace extends XRSpace {
  151768. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  151769. onreset: any;
  151770. }
  151771. type XRPlaneSet = Set<XRPlane>;
  151772. type XRAnchorSet = Set<XRAnchor>;
  151773. interface XRFrame {
  151774. session: XRSession;
  151775. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  151776. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  151777. // AR
  151778. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  151779. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  151780. // Anchors
  151781. trackedAnchors?: XRAnchorSet;
  151782. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  151783. // Planes
  151784. worldInformation: {
  151785. detectedPlanes?: XRPlaneSet;
  151786. };
  151787. }
  151788. interface XRViewerPose extends XRPose {
  151789. views: Array<XRView>;
  151790. }
  151791. interface XRPose {
  151792. transform: XRRigidTransform;
  151793. emulatedPosition: boolean;
  151794. }
  151795. interface XRWebGLLayerOptions {
  151796. antialias?: boolean;
  151797. depth?: boolean;
  151798. stencil?: boolean;
  151799. alpha?: boolean;
  151800. multiview?: boolean;
  151801. framebufferScaleFactor?: number;
  151802. }
  151803. declare var XRWebGLLayer: {
  151804. prototype: XRWebGLLayer;
  151805. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  151806. };
  151807. interface XRWebGLLayer {
  151808. framebuffer: WebGLFramebuffer;
  151809. framebufferWidth: number;
  151810. framebufferHeight: number;
  151811. getViewport: Function;
  151812. }
  151813. declare class XRRigidTransform {
  151814. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  151815. position: DOMPointReadOnly;
  151816. orientation: DOMPointReadOnly;
  151817. matrix: Float32Array;
  151818. inverse: XRRigidTransform;
  151819. }
  151820. interface XRView {
  151821. eye: XREye;
  151822. projectionMatrix: Float32Array;
  151823. transform: XRRigidTransform;
  151824. }
  151825. interface XRInputSourceChangeEvent {
  151826. session: XRSession;
  151827. removed: Array<XRInputSource>;
  151828. added: Array<XRInputSource>;
  151829. }
  151830. interface XRInputSourceEvent extends Event {
  151831. readonly frame: XRFrame;
  151832. readonly inputSource: XRInputSource;
  151833. }
  151834. // Experimental(er) features
  151835. declare class XRRay {
  151836. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  151837. origin: DOMPointReadOnly;
  151838. direction: DOMPointReadOnly;
  151839. matrix: Float32Array;
  151840. }
  151841. declare enum XRHitTestTrackableType {
  151842. "point",
  151843. "plane"
  151844. }
  151845. interface XRHitResult {
  151846. hitMatrix: Float32Array;
  151847. }
  151848. interface XRTransientInputHitTestResult {
  151849. readonly inputSource: XRInputSource;
  151850. readonly results: Array<XRHitTestResult>;
  151851. }
  151852. interface XRHitTestResult {
  151853. getPose(baseSpace: XRSpace): XRPose | undefined;
  151854. // When anchor system is enabled
  151855. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  151856. }
  151857. interface XRHitTestSource {
  151858. cancel(): void;
  151859. }
  151860. interface XRTransientInputHitTestSource {
  151861. cancel(): void;
  151862. }
  151863. interface XRHitTestOptionsInit {
  151864. space: XRSpace;
  151865. entityTypes?: Array<XRHitTestTrackableType>;
  151866. offsetRay?: XRRay;
  151867. }
  151868. interface XRTransientInputHitTestOptionsInit {
  151869. profile: string;
  151870. entityTypes?: Array<XRHitTestTrackableType>;
  151871. offsetRay?: XRRay;
  151872. }
  151873. interface XRAnchor {
  151874. anchorSpace: XRSpace;
  151875. delete(): void;
  151876. }
  151877. interface XRPlane {
  151878. orientation: "Horizontal" | "Vertical";
  151879. planeSpace: XRSpace;
  151880. polygon: Array<DOMPointReadOnly>;
  151881. lastChangedTime: number;
  151882. }